JSFiddle - React, Tailwind, and code Playground
by Flexmonster Pivot Table
HTML
<link rel="stylesheet" href="https://s3.amazonaws.com/flexmonster/2.3/demo.css">
<script src="https://cdn.flexmonster.com/flexmonster.js"></script>
<div id="pivot-container"></div>
JavaScript
let pivot = new Flexmonster({
container: "pivot-container",
componentFolder: "https://cdn.flexmonster.com/",
toolbar: true,
singleAggregationFormatting: true,
report: {
dataSource: {
data: getData()
},
slice: {
rows: [{
uniqueName: "Category"
}],
columns: [{
uniqueName: "[measures]"
}],
measures: [{
uniqueName: "Quantity",
aggregation: "sum",
format: "currency"
}, {
uniqueName: "Quantity",
aggregation: "count",
format: "currency"
}],
},
formats: [{
name: "currency",
thousandsSeparator: ",",
currencySymbol: "$"
}],
}
});
/* Set property on reportcomplete to ensure that toolbar is loaded */
pivot.on("reportcomplete", () => {
pivot.off("reportcomplete");
pivot.toolbar.singleAggregationFormatting = true;
})
function getData() {
let dataSet = [];
for (let i = 0; i < 1000; i++) {
dataSet.push({
"Category": "Accessories",
"Color": "green",
"Quantity": 1000,
});
}
return dataSet;
}