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

Return to bug 17282