nicolaskruchten / pivottable

Open-source Javascript Pivot Table (aka Pivot Grid, Pivot Chart, Cross-Tab) implementation with drag'n'drop.
https://pivottable.js.org/
MIT License
4.35k stars 1.08k forks source link

Formatting a single column in a pivot table using pivottable.js #1259

Closed ilitty closed 3 years ago

ilitty commented 3 years ago

Hello! I used this wonderful library, pivottable.js, to create a pivot table as a google web app but unfortunately, I have a problem with the formatting. In my raw data, I have a Utilization column formatted as a percentage but when parsing that data to the pivot table it is converted to a normal number (as shown in the screenshot). Could you please help me if there is any possible way to format the Utilization column as a percent, screenshot bellow.

pivottable - percent column

and here is my code

let drawChart = function (ytdData) {
    $("#output").pivotUI(
        ytdData, {
            rows: ["Name", "Active time", "Unutlized capacity", "Extra Time", "Total available time", "Total Absenteeism", "Utilization"],
            aggregatorName: "Average",
            cols: [],
            vals: [],
            inclusions: {Month:["12"]},
               renderers: $.extend(
                   $.pivotUtilities.renderers,
                   $.pivotUtilities.plotly_renderers,
               )
        });
};