« back to examples

To expand and collapse rows and columns, click on ▶ and ◢ arrows in the table. Scroll down to view the code.


    // This example demonstrates Count (or Sum) As Fraction Of Parent Column aggregators.

    $(function() {
        var dataClass = $.pivotUtilities.SubtotalPivotData;
        var renderers = $.pivotUtilities.subtotal_renderers;
        var aggregators = $.extend($.pivotUtilities.subtotal_aggregators, $.pivotUtilities.aggregators)

        $.getJSON("data/mps.json", function(mps) {
            $("#output").pivotUI(mps, {
                dataClass: dataClass,
                rows: ["Gender", "Province"],
                cols: ["Party", "Age"],
                aggregators: aggregators,
                aggregatorName: "Count As Fraction Of Parent Column",
                // aggregatorName: "Sum As Fraction Of Parent Column",
                vals: ["Age"],
                renderers: renderers,
                rendererName: "Table With Subtotal",
                rendererOptions: {
                    rowSubtotalDisplay: {
                        collapseAt: 0
                    },
                    colSubtotalDisplay: {
                        collapseAt: 0
                    }
                }
            });
        });
    });
    

« back to examples