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