View | Details | Raw Unified | Return to bug 17282
Collapse All | Expand All

(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/chart.inc (-2 / +7 lines)
Lines 30-37 Link Here
30
            [% column = 1 %]
30
            [% column = 1 %]
31
            <div>
31
            <div>
32
                [% FOREACH header IN header_row %]
32
                [% FOREACH header IN header_row %]
33
                    <fieldset id="column_[% column %]" style="display: inline !important;">
33
                    <fieldset class="chart-column-conf" id="column_[% column %]" style="display: inline !important;">
34
                        <legend>Column [% column %] - <a href="#" onclick="removeColumn('column_[% column %]', '[% header.cell %]')">del</a></legend>
34
                        <legend>
35
                            Column [% column %]
36
                            <a class="chart-column-delete" href="#" onclick="removeColumn('column_[% column %]'); return false;">
37
                                <img src="[% interface %]/[% theme %]/img/x.png" alt="Delete" />
38
                            </a>
39
                        </legend>
35
                        <div>
40
                        <div>
36
                            <label for="y_[% column %]">y:</label>
41
                            <label for="y_[% column %]">y:</label>
37
                            <select id="y_[% column %]" name="y">
42
                            <select id="y_[% column %]" name="y">
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/reports/guided_reports_start.tt (-21 / +40 lines)
Lines 898-906 canned reports and writing custom SQL reports.</p> Link Here
898
<script type="text/javascript" src="[% interface %]/lib/d3c3/c3.min.js"></script>
898
<script type="text/javascript" src="[% interface %]/lib/d3c3/c3.min.js"></script>
899
<script type="text/javascript">
899
<script type="text/javascript">
900
900
901
    var headers = [% header_row.json %];
902
    var results = [% results.json %]
903
904
    function hide_bar_element() {
901
    function hide_bar_element() {
905
        $('#chart-column-horizontal').hide()
902
        $('#chart-column-horizontal').hide()
906
        $('.chart-column-group').each(function( index ) {
903
        $('.chart-column-group').each(function( index ) {
Lines 921-950 canned reports and writing custom SQL reports.</p> Link Here
921
        });
918
        });
922
    }
919
    }
923
920
924
    function removeColumn(id, header_name) {
921
    function removeColumn(id) {
925
        $('#'+id).remove();
922
        $('#'+id).remove();
926
923
927
        var delete_index;
924
        if ( $('.chart-column-conf').length == 1 ) {
928
        $.each(headers, function(index, value) {
925
            $('.chart-column-delete').remove();
929
            if (value.cell == header_name) {
926
        }
930
                delete_index = index;
931
            }
932
        });
933
        headers.splice(delete_index, 1);
934
927
935
        $.each(results, function(index, value) {
936
            $.each(value.cells, function(i, val) {
937
                if (i == delete_index) {
938
                    results[index].cells.splice(i, 1)
939
                }
940
            });
941
        });
942
    }
928
    }
943
929
944
    $(document).ready(function(){
930
    $(document).ready(function(){
945
931
946
        hide_bar_element();
932
        hide_bar_element();
947
933
934
        if ( $('.chart-column-conf').length == 1 ) {
935
            $('.chart-column-delete').remove();
936
        }
937
948
938
949
        $('#download-chart').click(function() {
939
        $('#download-chart').click(function() {
950
            var svg = '<svg>' + $('#chart svg').html() + '</svg>';
940
            var svg = '<svg>' + $('#chart svg').html() + '</svg>';
Lines 971-976 canned reports and writing custom SQL reports.</p> Link Here
971
            var lines = [];
961
            var lines = [];
972
            var options = {};
962
            var options = {};
973
963
964
            //var headers = [% header_row.json %];
965
            headers = [% header_row.json %];
966
            var results = [% results.json %]
967
974
            $('select[name="y"]').each(function( index ) {
968
            $('select[name="y"]').each(function( index ) {
975
                y_elements.push( $(this).val() );
969
                y_elements.push( $(this).val() );
976
            });
970
            });
Lines 983-995 canned reports and writing custom SQL reports.</p> Link Here
983
                }
977
                }
984
            });
978
            });
985
979
980
            // Remove deleted columns from headers and results.
981
            var deleted_indexes = [];
982
            var kept_headers = [];
983
            $.each(headers, function(index, value) {
984
                if (value.cell != x_elements && $.inArray(value.cell, y_elements) === -1) {
985
                    // This header is neither a x element nor in y elements. Don't need it.
986
                    deleted_indexes.push(index);
987
                }
988
                else {
989
                    kept_headers.push({cell: value.cell});
990
                }
991
            });
992
993
            // Remove coresponding cells.
994
            var kept_results = [];
995
            $.each(results, function(index, value) {
996
                var line = {};
997
                line['cells'] = [];
998
                $.each(value.cells, function(i, val) {
999
                    if ($.inArray(i, deleted_indexes) === -1) {
1000
                        line['cells'].push({cell: val.cell});
1001
                    }
1002
                });
1003
                kept_results.push(line);
1004
            });
1005
986
            options.type = $('select[name="chart-type"]').val();
1006
            options.type = $('select[name="chart-type"]').val();
987
            options.horizontal = $('input[name="column-horizontal"]').prop('checked');
1007
            options.horizontal = $('input[name="column-horizontal"]').prop('checked');
988
            options.lines = lines;
1008
            options.lines = lines;
989
1009
990
1010
991
            chart = create_chart(headers, results, x_elements, y_elements, groups, options);
1011
            chart = create_chart(kept_headers, kept_results, x_elements, y_elements, groups, options);
992
            $('#chart').prepend('<div style="font-size: 1rem; text-align: center;">[% name %]</div>');
1012
            $('#chart').prepend('<div style="font-size: 1rem; text-align: center;">' + "[% name %]" + '</div>');
993
            $('#download-chart').show();
1013
            $('#download-chart').show();
994
        });
1014
        });
995
    });
1015
    });
996
- 

Return to bug 17282