Lines 817-825
canned reports and writing custom SQL reports.</p>
Link Here
|
817 |
<script type="text/javascript" src="[% interface %]/lib/d3c3/c3.min.js"></script> |
817 |
<script type="text/javascript" src="[% interface %]/lib/d3c3/c3.min.js"></script> |
818 |
<script type="text/javascript"> |
818 |
<script type="text/javascript"> |
819 |
|
819 |
|
820 |
var headers = [% header_row.json %]; |
|
|
821 |
var results = [% results.json %] |
822 |
|
823 |
function hide_bar_element() { |
820 |
function hide_bar_element() { |
824 |
$('#chart-column-horizontal').hide() |
821 |
$('#chart-column-horizontal').hide() |
825 |
$('.chart-column-group').each(function( index ) { |
822 |
$('.chart-column-group').each(function( index ) { |
Lines 840-869
canned reports and writing custom SQL reports.</p>
Link Here
|
840 |
}); |
837 |
}); |
841 |
} |
838 |
} |
842 |
|
839 |
|
843 |
function removeColumn(id, header_name) { |
840 |
function removeColumn(id) { |
844 |
$('#'+id).remove(); |
841 |
$('#'+id).remove(); |
845 |
|
842 |
|
846 |
var delete_index; |
843 |
if ( $('.chart-column-conf').length == 1 ) { |
847 |
$.each(headers, function(index, value) { |
844 |
$('.chart-column-delete').remove(); |
848 |
if (value.cell == header_name) { |
845 |
} |
849 |
delete_index = index; |
|
|
850 |
} |
851 |
}); |
852 |
headers.splice(delete_index, 1); |
853 |
|
846 |
|
854 |
$.each(results, function(index, value) { |
|
|
855 |
$.each(value.cells, function(i, val) { |
856 |
if (i == delete_index) { |
857 |
results[index].cells.splice(i, 1) |
858 |
} |
859 |
}); |
860 |
}); |
861 |
} |
847 |
} |
862 |
|
848 |
|
863 |
$(document).ready(function(){ |
849 |
$(document).ready(function(){ |
864 |
|
850 |
|
865 |
hide_bar_element(); |
851 |
hide_bar_element(); |
866 |
|
852 |
|
|
|
853 |
if ( $('.chart-column-conf').length == 1 ) { |
854 |
$('.chart-column-delete').remove(); |
855 |
} |
856 |
|
867 |
|
857 |
|
868 |
$('#download-chart').click(function() { |
858 |
$('#download-chart').click(function() { |
869 |
var svg = '<svg>' + $('#chart svg').html() + '</svg>'; |
859 |
var svg = '<svg>' + $('#chart svg').html() + '</svg>'; |
Lines 890-895
canned reports and writing custom SQL reports.</p>
Link Here
|
890 |
var lines = []; |
880 |
var lines = []; |
891 |
var options = {}; |
881 |
var options = {}; |
892 |
|
882 |
|
|
|
883 |
//var headers = [% header_row.json %]; |
884 |
headers = [% header_row.json %]; |
885 |
var results = [% results.json %] |
886 |
|
893 |
$('select[name="y"]').each(function( index ) { |
887 |
$('select[name="y"]').each(function( index ) { |
894 |
y_elements.push( $(this).val() ); |
888 |
y_elements.push( $(this).val() ); |
895 |
}); |
889 |
}); |
Lines 902-913
canned reports and writing custom SQL reports.</p>
Link Here
|
902 |
} |
896 |
} |
903 |
}); |
897 |
}); |
904 |
|
898 |
|
|
|
899 |
// Remove deleted columns from headers and results. |
900 |
var deleted_indexes = []; |
901 |
var kept_headers = []; |
902 |
$.each(headers, function(index, value) { |
903 |
if (value.cell != x_elements && $.inArray(value.cell, y_elements) === -1) { |
904 |
// This header is neither a x element nor in y elements. Don't need it. |
905 |
deleted_indexes.push(index); |
906 |
} |
907 |
else { |
908 |
kept_headers.push({cell: value.cell}); |
909 |
} |
910 |
}); |
911 |
|
912 |
// Remove coresponding cells. |
913 |
var kept_results = []; |
914 |
$.each(results, function(index, value) { |
915 |
var line = {}; |
916 |
line['cells'] = []; |
917 |
$.each(value.cells, function(i, val) { |
918 |
if ($.inArray(i, deleted_indexes) === -1) { |
919 |
line['cells'].push({cell: val.cell}); |
920 |
} |
921 |
}); |
922 |
kept_results.push(line); |
923 |
}); |
924 |
|
905 |
options.type = $('select[name="chart-type"]').val(); |
925 |
options.type = $('select[name="chart-type"]').val(); |
906 |
options.horizontal = $('input[name="column-horizontal"]').prop('checked'); |
926 |
options.horizontal = $('input[name="column-horizontal"]').prop('checked'); |
907 |
options.lines = lines; |
927 |
options.lines = lines; |
908 |
|
928 |
|
909 |
|
929 |
|
910 |
chart = create_chart(headers, results, x_elements, y_elements, groups, options); |
930 |
chart = create_chart(kept_headers, kept_results, x_elements, y_elements, groups, options); |
911 |
$('#chart').prepend('<div style="font-size: 1rem; text-align: center;">[% name %]</div>'); |
931 |
$('#chart').prepend('<div style="font-size: 1rem; text-align: center;">[% name %]</div>'); |
912 |
$('#download-chart').show(); |
932 |
$('#download-chart').show(); |
913 |
}); |
933 |
}); |
914 |
- |
|
|