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="pivotContainer"></div>
JavaScript
let pivot = new Flexmonster({
container: "pivotContainer",
componentFolder: "https://cdn.flexmonster.com/",
toolbar: true,
report: {
dataSource: {
data: getData()
},
"slice": {
"rows": [{
"uniqueName": "Item"
}],
"columns": [{
"uniqueName": "[Measures]"
}],
"measures": [{
"uniqueName": "Price",
"aggregation": "sum"
},
{
"uniqueName": "Quantity",
"aggregation": "sum"
}
]
},
"formats": [{
"name": "",
"decimalPlaces": 2
}]
}
});
flexmonster.customizeCell((cell, data) => {
if (/.*[0-9]+\.00.*/.test(cell.text)) {
cell.text = cell.text.replace(".00", "");
}
});
function getData() {
return [{
"Price": 354.23,
"Quantity": 34563,
"Item": "Item 1"
},
{
"Price": 5446.99,
"Quantity": 24364,
"Item": "Item 2"
},
{
"Price": 345.435,
"Quantity": 25473,
"Item": "Item 3"
}
]
}