|
Lines 900-967
canned reports and writing custom SQL reports.</p>
Link Here
|
| 900 |
$('#download-chart').hide(); |
900 |
$('#download-chart').hide(); |
| 901 |
var chart; |
901 |
var chart; |
| 902 |
|
902 |
|
| 903 |
$('#draw-chart').click(function() { |
|
|
| 904 |
var x_elements = $('select[name="x"]').val(); |
| 905 |
var y_elements = []; |
| 906 |
var groups = []; |
| 907 |
var lines = []; |
| 908 |
var options = {}; |
| 909 |
|
| 910 |
//var headers = [% header_row.json %]; |
| 911 |
headers = [% header_row.json %]; |
| 912 |
var results = [% results.json %] |
| 913 |
|
| 914 |
if ($('input[name="chart-exclude-last"]').prop('checked')) { |
| 915 |
results.splice(-1, 1); |
| 916 |
} |
| 917 |
|
903 |
|
| 918 |
$('select[name="y"]').each(function( index ) { |
904 |
[% UNLESS (errors) %] |
| 919 |
y_elements.push( $(this).val() ); |
905 |
$('#draw-chart').click(function() { |
| 920 |
}); |
|
|
| 921 |
$('select[name="group"]').each(function( index ) { |
| 922 |
groups.push( $(this).val() ); |
| 923 |
}); |
| 924 |
$('.column-line').each(function( index ) { |
| 925 |
if ($(this).prop('checked')) { |
| 926 |
lines.push( $(this).attr('name') ); |
| 927 |
} |
| 928 |
}); |
| 929 |
|
906 |
|
| 930 |
// Remove deleted columns from headers and results. |
907 |
var btn_text = $("#draw-chart").html(); |
| 931 |
var deleted_indexes = []; |
908 |
$("#draw-chart").html(_('Loading...')); |
| 932 |
var kept_headers = []; |
909 |
|
| 933 |
$.each(headers, function(index, value) { |
910 |
var x_elements = $('select[name="x"]').val(); |
| 934 |
if (value.cell != x_elements && $.inArray(value.cell, y_elements) === -1) { |
911 |
var y_elements = []; |
| 935 |
// This header is neither a x element nor in y elements. Don't need it. |
912 |
var groups = []; |
| 936 |
deleted_indexes.push(index); |
913 |
var lines = []; |
| 937 |
} |
914 |
var options = {}; |
| 938 |
else { |
915 |
|
| 939 |
kept_headers.push({cell: value.cell}); |
916 |
//var headers = [% header_row.json %]; |
|
|
917 |
headers = [% header_row.json %]; |
| 918 |
var results = [% results.json %] |
| 919 |
|
| 920 |
if ($('input[name="chart-exclude-last"]').prop('checked')) { |
| 921 |
results.splice(-1, 1); |
| 940 |
} |
922 |
} |
| 941 |
}); |
|
|
| 942 |
|
923 |
|
| 943 |
// Remove coresponding cells. |
924 |
$('select[name="y"]').each(function( index ) { |
| 944 |
var kept_results = []; |
925 |
y_elements.push( $(this).val() ); |
| 945 |
$.each(results, function(index, value) { |
926 |
}); |
| 946 |
var line = {}; |
927 |
$('select[name="group"]').each(function( index ) { |
| 947 |
line['cells'] = []; |
928 |
groups.push( $(this).val() ); |
| 948 |
$.each(value.cells, function(i, val) { |
929 |
}); |
| 949 |
if ($.inArray(i, deleted_indexes) === -1) { |
930 |
$('.column-line').each(function( index ) { |
| 950 |
line['cells'].push({cell: val.cell}); |
931 |
if ($(this).prop('checked')) { |
|
|
932 |
lines.push( $(this).attr('name') ); |
| 933 |
} |
| 934 |
}); |
| 935 |
|
| 936 |
// Remove deleted columns from headers and results. |
| 937 |
var deleted_indexes = []; |
| 938 |
var kept_headers = []; |
| 939 |
$.each(headers, function(index, value) { |
| 940 |
if (value.cell != x_elements && $.inArray(value.cell, y_elements) === -1) { |
| 941 |
// This header is neither a x element nor in y elements. Don't need it. |
| 942 |
deleted_indexes.push(index); |
| 943 |
} |
| 944 |
else { |
| 945 |
kept_headers.push({cell: value.cell}); |
| 951 |
} |
946 |
} |
| 952 |
}); |
947 |
}); |
| 953 |
kept_results.push(line); |
|
|
| 954 |
}); |
| 955 |
|
948 |
|
| 956 |
options.type = $('select[name="chart-type"]').val(); |
949 |
// Remove coresponding cells. |
| 957 |
options.horizontal = $('input[name="column-horizontal"]').prop('checked'); |
950 |
var kept_results = []; |
| 958 |
options.lines = lines; |
951 |
$.each(results, function(index, value) { |
|
|
952 |
var line = {}; |
| 953 |
line['cells'] = []; |
| 954 |
$.each(value.cells, function(i, val) { |
| 955 |
if ($.inArray(i, deleted_indexes) === -1) { |
| 956 |
line['cells'].push({cell: val.cell}); |
| 957 |
} |
| 958 |
}); |
| 959 |
kept_results.push(line); |
| 960 |
}); |
| 959 |
|
961 |
|
|
|
962 |
options.type = $('select[name="chart-type"]').val(); |
| 963 |
options.horizontal = $('input[name="column-horizontal"]').prop('checked'); |
| 964 |
options.lines = lines; |
| 960 |
|
965 |
|
| 961 |
chart = create_chart(kept_headers, kept_results, x_elements, y_elements, groups, options); |
966 |
|
| 962 |
$('#chart').prepend('<div style="font-size: 1rem; text-align: center;">' + "[% name %]" + '</div>'); |
967 |
chart = create_chart(kept_headers, kept_results, x_elements, y_elements, groups, options); |
| 963 |
$('#download-chart').show(); |
968 |
$('#chart').prepend('<div style="font-size: 1rem; text-align: center;">' + "[% name %]" + '</div>'); |
| 964 |
}); |
969 |
$('#download-chart').show(); |
|
|
970 |
$("#draw-chart").html(_(btn_text)); |
| 971 |
$("html, body").animate({ scrollTop: $(document).height() }, "slow"); |
| 972 |
}); |
| 973 |
[% END %] |
| 965 |
}); |
974 |
}); |
| 966 |
</script> |
975 |
</script> |
| 967 |
<h1>[% name %]</h1> |
976 |
<h1>[% name %]</h1> |
| 968 |
- |
|
|