Lines 840-848
canned reports and writing custom SQL reports.</p>
Link Here
|
840 |
<script type="text/javascript" src="[% interface %]/lib/d3c3/c3.min.js"></script> |
840 |
<script type="text/javascript" src="[% interface %]/lib/d3c3/c3.min.js"></script> |
841 |
<script type="text/javascript"> |
841 |
<script type="text/javascript"> |
842 |
|
842 |
|
843 |
var headers = [% header_row.json %]; |
|
|
844 |
var results = [% results.json %] |
845 |
|
846 |
function hide_bar_element() { |
843 |
function hide_bar_element() { |
847 |
$('#chart-column-horizontal').hide() |
844 |
$('#chart-column-horizontal').hide() |
848 |
$('.chart-column-group').each(function( index ) { |
845 |
$('.chart-column-group').each(function( index ) { |
Lines 863-892
canned reports and writing custom SQL reports.</p>
Link Here
|
863 |
}); |
860 |
}); |
864 |
} |
861 |
} |
865 |
|
862 |
|
866 |
function removeColumn(id, header_name) { |
863 |
function removeColumn(id) { |
867 |
$('#'+id).remove(); |
864 |
$('#'+id).remove(); |
868 |
|
865 |
|
869 |
var delete_index; |
866 |
if ( $('.chart-column-conf').length == 1 ) { |
870 |
$.each(headers, function(index, value) { |
867 |
$('.chart-column-delete').remove(); |
871 |
if (value.cell == header_name) { |
868 |
} |
872 |
delete_index = index; |
|
|
873 |
} |
874 |
}); |
875 |
headers.splice(delete_index, 1); |
876 |
|
869 |
|
877 |
$.each(results, function(index, value) { |
|
|
878 |
$.each(value.cells, function(i, val) { |
879 |
if (i == delete_index) { |
880 |
results[index].cells.splice(i, 1) |
881 |
} |
882 |
}); |
883 |
}); |
884 |
} |
870 |
} |
885 |
|
871 |
|
886 |
$(document).ready(function(){ |
872 |
$(document).ready(function(){ |
887 |
|
873 |
|
888 |
hide_bar_element(); |
874 |
hide_bar_element(); |
889 |
|
875 |
|
|
|
876 |
if ( $('.chart-column-conf').length == 1 ) { |
877 |
$('.chart-column-delete').remove(); |
878 |
} |
879 |
|
890 |
|
880 |
|
891 |
$('#download-chart').click(function() { |
881 |
$('#download-chart').click(function() { |
892 |
var svg = '<svg>' + $('#chart svg').html() + '</svg>'; |
882 |
var svg = '<svg>' + $('#chart svg').html() + '</svg>'; |
Lines 913-918
canned reports and writing custom SQL reports.</p>
Link Here
|
913 |
var lines = []; |
903 |
var lines = []; |
914 |
var options = {}; |
904 |
var options = {}; |
915 |
|
905 |
|
|
|
906 |
//var headers = [% header_row.json %]; |
907 |
headers = [% header_row.json %]; |
908 |
var results = [% results.json %] |
909 |
|
916 |
$('select[name="y"]').each(function( index ) { |
910 |
$('select[name="y"]').each(function( index ) { |
917 |
y_elements.push( $(this).val() ); |
911 |
y_elements.push( $(this).val() ); |
918 |
}); |
912 |
}); |
Lines 925-937
canned reports and writing custom SQL reports.</p>
Link Here
|
925 |
} |
919 |
} |
926 |
}); |
920 |
}); |
927 |
|
921 |
|
|
|
922 |
// Remove deleted columns from headers and results. |
923 |
var deleted_indexes = []; |
924 |
var kept_headers = []; |
925 |
$.each(headers, function(index, value) { |
926 |
if (value.cell != x_elements && $.inArray(value.cell, y_elements) === -1) { |
927 |
// This header is neither a x element nor in y elements. Don't need it. |
928 |
deleted_indexes.push(index); |
929 |
} |
930 |
else { |
931 |
kept_headers.push({cell: value.cell}); |
932 |
} |
933 |
}); |
934 |
|
935 |
// Remove coresponding cells. |
936 |
var kept_results = []; |
937 |
$.each(results, function(index, value) { |
938 |
var line = {}; |
939 |
line['cells'] = []; |
940 |
$.each(value.cells, function(i, val) { |
941 |
if ($.inArray(i, deleted_indexes) === -1) { |
942 |
line['cells'].push({cell: val.cell}); |
943 |
} |
944 |
}); |
945 |
kept_results.push(line); |
946 |
}); |
947 |
|
928 |
options.type = $('select[name="chart-type"]').val(); |
948 |
options.type = $('select[name="chart-type"]').val(); |
929 |
options.horizontal = $('input[name="column-horizontal"]').prop('checked'); |
949 |
options.horizontal = $('input[name="column-horizontal"]').prop('checked'); |
930 |
options.lines = lines; |
950 |
options.lines = lines; |
931 |
|
951 |
|
932 |
|
952 |
|
933 |
chart = create_chart(headers, results, x_elements, y_elements, groups, options); |
953 |
chart = create_chart(kept_headers, kept_results, x_elements, y_elements, groups, options); |
934 |
$('#chart').prepend('<div style="font-size: 1rem; text-align: center;">[% name %]</div>'); |
954 |
$('#chart').prepend('<div style="font-size: 1rem; text-align: center;">' + "[% name %]" + '</div>'); |
935 |
$('#download-chart').show(); |
955 |
$('#download-chart').show(); |
936 |
}); |
956 |
}); |
937 |
}); |
957 |
}); |
938 |
- |
|
|