jQWidgets Forums

jQuery UI Widgets Forums Grid jqxPivotGrid : access to whole column inside of customAggregationFunctions

This topic contains 1 reply, has 2 voices, and was last updated by  Hristo 7 years, 3 months ago.

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author

  • tiago.decisao
    Participant

    Hi guys.

    I would like to know if there is any way to get the name or the total value of a column within the customAggregationFunctions of jqxPivotGrid.
    Example:

    I’m trying to make the percentage of the entire column and return per line how much it represents from the total

    let pivotDataSource = new jqx.pivot(
    dataAdapter,
    {
    customAggregationFunctions: {
    ‘var’: function (values) {
    if (values.length <= 1)
    return 0;

    // sample’s mean
    var mean = 0;
    for (var i = 0; i < values.length; i++)
    mean += values[i];

    mean /= values.length;

    // calc squared sum
    var ssum = 0;
    for (var i = 0; i < values.length; i++)
    ssum += Math.pow(values[i] – mean, 2)

    // calc the variance
    var variance = ssum / values.length;

    return variance;
    },

    //——————— Exemple ———————
    ‘newAgr’: function (values) {
    // Array column value that i want have access
    var columnSum;
    for (var i = 0; i < columnValue.length; i++){
    columnSum += columnValue[i]
    });
    sumValue
    for (var i = 0; i < values.length; i++) {
    sum += values[i]
    }
    return (sum/columnSum)*100;
    }
    // ——————–End Exemple —————————
    },
    pivotValuesOnRows: false,
    rows: [],
    columns: [],
    filters: [],
    values: []
    }
    );

    return pivotDataSource;
    }

    Have a nice day


    Hristo
    Participant

    Hello tiago.decisao,

    I would like to suggest you look at this forum topic.
    Also, this example that demonstrates how to use methods and methods on items:
    https://www.jseditor.io/?key=jqxpivotgrid-calculation-of-weighted-average

    Best Regards,
    Hristo Hristov

    jQWidgets team
    http://www.jqwidgets.com

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.