JSFiddle - React, Tailwind, and code Playground
by Flexmonster Pivot Table
HTML
<script src="https://cdn.flexmonster.com/flexmonster.js"></script>
<div id="pivot-container"></div>
JavaScript
let pivot = new Flexmonster({
container: "pivot-container",
toolbar: true,
customizeCell: customizeCellFunction,
componentFolder: "https://cdn.flexmonster.com/",
licenseFilePath: "https://cdn.flexmonster.com/jsfiddle.charts.key",
report: {
dataSource: {
data: getJSONData(),
mapping: {
"date": {
type: 'date string',
format: 'MMM-dd',
},
},
},
conditions: [{
formula: "'violationcode' == 1",
format: {
backgroundColor: '#ff0000',
color: '#fff',
},
},
{
formula: "'violationcode' == 3",
format: {
backgroundColor: '#fbd300',
},
},
{
formula: "'violationcode' == 2",
format: {
backgroundColor: '#fff',
},
},
],
slice: {
"rows": [{
"uniqueName": "product",
"sort": "unsorted"
}],
"columns": [{
"uniqueName": "date"
},
{
"uniqueName": "[Measures]"
}
],
"measures": [{
"uniqueName": "value",
"aggregation": "sum",
"grandTotalCaption": "value",
"format": "jatin"
},
/* {
"uniqueName": "actual_data",
"aggregation": "sum",
"grandTotalCaption": "actual_data"
} */
],
expands: {
expandAll: true,
},
},
options: {
grid: {
/* "showGrandTotals": "rows", */
showHierarchyCaptions: false,
"showGrandTotals": "off",
showTotals: "off"
},
"showAggregationLabels": false,
drillThrough: false,
showAggregations: false
},
formats: [{
thousandsSeparator: ' ',
currencySymbol: ' Kg',
positiveCurrencyFormat: '1$',
negativeCurrencyFormat: '-1$',
},
{
name: 'jatin',
decimalPlaces: 2
}
],
}
});
function...