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
var pivot = new Flexmonster({
toolbar: true,
container: "#pivot-container",
componentFolder: "https://cdn.flexmonster.com/",
report: {
dataSource: {
type: "json",
data: getProcessedData()
},
slice: {
rows: [{
"uniqueName": "Row ID"
}],
columns: [{
"uniqueName": "[Measures]"
}],
measures: [{
"uniqueName": "Value",
"aggregation": "sum"
},
{
"uniqueName": "Value",
"aggregation": "differenceofcolumn"
}
]
},
options: {
showEmptyValues: true
}
},
width: "100%",
height: 750
});
function getProcessedData() {
rawData = getRawData();
for (let entry in rawData) {
if ((typeof rawData[entry].Value != 'number') && (rawData[entry].Value == '')) {
rawData[entry].Value = 0;
}
}
return rawData;
}
function getRawData() {
return [{
"Row ID": 1,
"Value": 3500
},
{
"Row ID": 2,
"Value": ""
}, {
"Row ID": 3,
"Value": 70000
}
];
}