setFormat(format: FormatObject, measureName: String, aggregation: String)
[starting from version: 1.4]
Sets the default number format or a number format for the specified measure.
Learn more about number formatting.
Use the refresh() API call after setting a format to redraw the component and see changes.
Parameter/Type | Description |
---|---|
format FormatObject | Contains the number format parameters. To override the default number format, set the format.name property to an empty string ( "" ). |
measureName String | optional The measure's unique name. Specify this property to apply a format to a specific measure. Must be used with the aggregation parameter unless the measure is calculated. When overriding the default format, skip the measureName . |
aggregation String | optional The measure’s aggregation. Must be used with the measureName. If the measure is calculated, skip the aggregation . |
1) How to override a default number format at runtime:
let format = {
name: "",
decimalPlaces: 0,
thousandsSeparator: ","
};
pivot.setFormat(format);
pivot.refresh();
Try how the sample works on JSFiddle.
2) How to change a currency symbol for a specific measure:
let format = pivot.getFormat("Price", "sum");
format.name = "PriceFormat";
format.currencySymbol = "$";
//format.currencySymbol = "£" // pound sterling
//format.currencySymbol = "€" // euro
//format.currencySymbol = "¥" // yen
pivot.setFormat(format, "Price", "sum");
pivot.refresh();
Open the example on JSFiddle.