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>
CSS
.highlight {
background-color: lightgreen !important;
}
JavaScript
let pivot = new Flexmonster({
container: "pivot-container",
componentFolder: "https://cdn.flexmonster.com/",
toolbar: true,
customizeCell: customizeCellFunction,
report: {
"dataSource": {
"type": "json",
"filename": "https://cdn.flexmonster.com/data/retail-data.json",
"mapping": {
"Date": [{
"uniqueName": "Week",
"type": "datetime",
"interval": "w",
"format": "d-MMM"
},
{
"uniqueName": "Month",
"type": "datetime",
"interval": "M",
"format": "MMM"
}
],
}
},
slice: {
rows: [{
uniqueName: "Country"
},
{
uniqueName: "Status"
}
],
columns: [
{
uniqueName: "Month"
},
{
uniqueName: "Week"
},
],
measures: [{
uniqueName: "Price"
}],
expands: {
expandAll: true
}
},
options: {
grid: {
"type": "classic",
"showTotals": "columns"
}
}
}
});
function customizeCellFunction(cell, data) {
if (data.type == "value" &&
data.value >= 0 &&
data.isTotal &&
!data.isGrandTotal &&
data.measure != null &&
data.measure.uniqueName == "Price") {
cell.addClass("highlight");
}
}