|
Lines 958-1025
canned reports and writing custom SQL reports.</p>
Link Here
|
| 958 |
$('#download-chart').hide(); |
958 |
$('#download-chart').hide(); |
| 959 |
var chart; |
959 |
var chart; |
| 960 |
|
960 |
|
| 961 |
$('#draw-chart').click(function() { |
|
|
| 962 |
var x_elements = $('select[name="x"]').val(); |
| 963 |
var y_elements = []; |
| 964 |
var groups = []; |
| 965 |
var lines = []; |
| 966 |
var options = {}; |
| 967 |
|
| 968 |
//var headers = [% header_row.json %]; |
| 969 |
headers = [% header_row.json %]; |
| 970 |
var results = [% results.json %] |
| 971 |
|
| 972 |
if ($('input[name="chart-exclude-last"]').prop('checked')) { |
| 973 |
results.splice(-1, 1); |
| 974 |
} |
| 975 |
|
961 |
|
| 976 |
$('select[name="y"]').each(function( index ) { |
962 |
[% UNLESS (errors) %] |
| 977 |
y_elements.push( $(this).val() ); |
963 |
$('#draw-chart').click(function() { |
| 978 |
}); |
|
|
| 979 |
$('select[name="group"]').each(function( index ) { |
| 980 |
groups.push( $(this).val() ); |
| 981 |
}); |
| 982 |
$('.column-line').each(function( index ) { |
| 983 |
if ($(this).prop('checked')) { |
| 984 |
lines.push( $(this).attr('name') ); |
| 985 |
} |
| 986 |
}); |
| 987 |
|
964 |
|
| 988 |
// Remove deleted columns from headers and results. |
965 |
var btn_text = $("#draw-chart").html(); |
| 989 |
var deleted_indexes = []; |
966 |
$("#draw-chart").html(_('Loading...')); |
| 990 |
var kept_headers = []; |
967 |
|
| 991 |
$.each(headers, function(index, value) { |
968 |
var x_elements = $('select[name="x"]').val(); |
| 992 |
if (value.cell != x_elements && $.inArray(value.cell, y_elements) === -1) { |
969 |
var y_elements = []; |
| 993 |
// This header is neither a x element nor in y elements. Don't need it. |
970 |
var groups = []; |
| 994 |
deleted_indexes.push(index); |
971 |
var lines = []; |
| 995 |
} |
972 |
var options = {}; |
| 996 |
else { |
973 |
|
| 997 |
kept_headers.push({cell: value.cell}); |
974 |
//var headers = [% header_row.json %]; |
|
|
975 |
headers = [% header_row.json %]; |
| 976 |
var results = [% results.json %] |
| 977 |
|
| 978 |
if ($('input[name="chart-exclude-last"]').prop('checked')) { |
| 979 |
results.splice(-1, 1); |
| 998 |
} |
980 |
} |
| 999 |
}); |
|
|
| 1000 |
|
981 |
|
| 1001 |
// Remove coresponding cells. |
982 |
$('select[name="y"]').each(function( index ) { |
| 1002 |
var kept_results = []; |
983 |
y_elements.push( $(this).val() ); |
| 1003 |
$.each(results, function(index, value) { |
984 |
}); |
| 1004 |
var line = {}; |
985 |
$('select[name="group"]').each(function( index ) { |
| 1005 |
line['cells'] = []; |
986 |
groups.push( $(this).val() ); |
| 1006 |
$.each(value.cells, function(i, val) { |
987 |
}); |
| 1007 |
if ($.inArray(i, deleted_indexes) === -1) { |
988 |
$('.column-line').each(function( index ) { |
| 1008 |
line['cells'].push({cell: val.cell}); |
989 |
if ($(this).prop('checked')) { |
|
|
990 |
lines.push( $(this).attr('name') ); |
| 991 |
} |
| 992 |
}); |
| 993 |
|
| 994 |
// Remove deleted columns from headers and results. |
| 995 |
var deleted_indexes = []; |
| 996 |
var kept_headers = []; |
| 997 |
$.each(headers, function(index, value) { |
| 998 |
if (value.cell != x_elements && $.inArray(value.cell, y_elements) === -1) { |
| 999 |
// This header is neither a x element nor in y elements. Don't need it. |
| 1000 |
deleted_indexes.push(index); |
| 1001 |
} |
| 1002 |
else { |
| 1003 |
kept_headers.push({cell: value.cell}); |
| 1009 |
} |
1004 |
} |
| 1010 |
}); |
1005 |
}); |
| 1011 |
kept_results.push(line); |
|
|
| 1012 |
}); |
| 1013 |
|
1006 |
|
| 1014 |
options.type = $('select[name="chart-type"]').val(); |
1007 |
// Remove coresponding cells. |
| 1015 |
options.horizontal = $('input[name="column-horizontal"]').prop('checked'); |
1008 |
var kept_results = []; |
| 1016 |
options.lines = lines; |
1009 |
$.each(results, function(index, value) { |
|
|
1010 |
var line = {}; |
| 1011 |
line['cells'] = []; |
| 1012 |
$.each(value.cells, function(i, val) { |
| 1013 |
if ($.inArray(i, deleted_indexes) === -1) { |
| 1014 |
line['cells'].push({cell: val.cell}); |
| 1015 |
} |
| 1016 |
}); |
| 1017 |
kept_results.push(line); |
| 1018 |
}); |
| 1017 |
|
1019 |
|
|
|
1020 |
options.type = $('select[name="chart-type"]').val(); |
| 1021 |
options.horizontal = $('input[name="column-horizontal"]').prop('checked'); |
| 1022 |
options.lines = lines; |
| 1018 |
|
1023 |
|
| 1019 |
chart = create_chart(kept_headers, kept_results, x_elements, y_elements, groups, options); |
1024 |
|
| 1020 |
$('#chart').prepend('<div style="font-size: 1rem; text-align: center;">' + "[% name %]" + '</div>'); |
1025 |
chart = create_chart(kept_headers, kept_results, x_elements, y_elements, groups, options); |
| 1021 |
$('#download-chart').show(); |
1026 |
$('#chart').prepend('<div style="font-size: 1rem; text-align: center;">' + "[% name %]" + '</div>'); |
| 1022 |
}); |
1027 |
$('#download-chart').show(); |
|
|
1028 |
$("#draw-chart").html(_(btn_text)); |
| 1029 |
$("html, body").animate({ scrollTop: $(document).height() }, "slow"); |
| 1030 |
}); |
| 1031 |
[% END %] |
| 1023 |
}); |
1032 |
}); |
| 1024 |
</script> |
1033 |
</script> |
| 1025 |
<h1>[% name %]</h1> |
1034 |
<h1>[% name %]</h1> |
| 1026 |
- |
|
|