assets/js/pie/jquery.jchart.js
/*
         * Calculate the necessary values for graphing (maxval, percentage value of each segment)
         */
Calculate the necessary values for graphing (maxval, percentage value of each segment)
Calculate the necessary values for graphing ( maxval percentage value of each segment )
calculateDataValues(instance) {
            const values = {
                maxval: 0,
            };
            const data = instance.settings.data;
            for (const segment in data) {
                if (data.hasOwnProperty(segment)) {
                    data[segment] = $.extend(true, {}, instance.settings.placeholder.data, data[segment]);
                    values.maxval += data[segment].value;
                }
            }
            for (const segment in data) {
                if (data.hasOwnProperty(segment)) {
                    if (values.maxval === 0) {
                        data[segment].percentage_raw = 0;
                        data[segment].percentage = 0;
                    } else {
                        data[segment].percentage_raw = data[segment].value / values.maxval;
                        data[segment].percentage = (data[segment].value / values.maxval) * 100;
                    }
                    if (data[segment].order === null) {
                        data[segment].order = data.length;
                    }
                }
            }
            function compare(a, b) {
                if (a['order'] === null) return 1;
                if (b['order'] === null) return -1;
                if (a['order'] < b['order'])
                    return -1;
                if (a['order'] > b['order'])
                    return 1;
                return 0;
            }
            data.sort(compare);
            instance.settings.values = values;
        }
calculateDataValues ( instance ) { const values = { maxval : 0 , } ; const data = instance . settings . data ; for ( const segment in data ) { if ( data . hasOwnProperty ( segment ) ) { data [ segment ] = $ . extend ( true , { } , instance . settings . placeholder . data , data [ segment ] ) ; values . maxval += data [ segment ] . value ; } } for ( const segment in data ) { if ( data . hasOwnProperty ( segment ) ) { if ( values . maxval === 0 ) { data [ segment ] . percentage_raw = 0 ; data [ segment ] . percentage = 0 ; } else { data [ segment ] . percentage_raw = data [ segment ] . value / values . maxval ; data [ segment ] . percentage = ( data [ segment ] . value / values . maxval ) * 100 ; } if ( data [ segment ] . order === null ) { data [ segment ] . order = data . length ; } } } function compare ( a , b ) { if ( a [ 'order' ] === null ) return 1 ; if ( b [ 'order' ] === null ) return - 1 ; if ( a [ 'order' ] < b [ 'order' ] ) return - 1 ; if ( a [ 'order' ] > b [ 'order' ] ) return 1 ; return 0 ; } data . sort ( compare ) ; instance . settings . values = values ; }
Calculate the necessary values for graphing (maxval, percentage value of each segment)
Calculate the necessary values for graphing ( maxval percentage value of each segment )
// calculate the sum data values // calculate the single data values // sort data by their order parameter //instance.settings.data = data;