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
#fm-pivot-view .fm-grid-view div.fm-cell.gray{
background-color: #e6e6e6!important;
}
#fm-pivot-view .fm-grid-view div.fm-cell.white{
background-color: #fff!important;
}
JavaScript
var pivot = new Flexmonster({
container: "#pivot-container",
componentFolder: "https://cdn.flexmonster.com/",
report: {
dataSource: {
dataSourceType: "json",
data: getData()
},
options: {
grid: {
type: "compact"
},
showGrandTotals: false,
showAggregationLabels: false
},
slice: {
rows: [{
uniqueName: "HealthSystemName",
caption: "Health System"
}, {
uniqueName: "FacilityName",
caption: "Facility"
}],
columns: [{
uniqueName: "Type"
}, {
uniqueName: "[Measures]"
}],
measures: [{
uniqueName: "ITDValue",
grandTotalCaption: "ITDValue",
aggregation: "sum"
},
{
uniqueName: "YTDValue",
grandTotalCaption: "YTDValue",
aggregation: "sum"
}, {
uniqueName: "priorMonthValue",
grandTotalCaption: "priorMonthValue",
aggregation: "sum"
},
],
expands: {
expandAll: true
},
},
formats: [{
name: "",
currencySymbol: "$ "
}]
},
customizeCell: customizeCellFunction,
toolbar: true,
width: "100%",
height: 600
});
const highlightedMembers = {
"HealthSystemName": ["Alameda Health System", "Appalachian"]
};
const highlightedClasses = {
"Alameda Health System": "white",
"Appalachian": "gray",
}
function customizeCellFunction(cell, data) {
if (data.rows) {
data.rows.forEach(row => {
if (highlightedMembers[row.hierarchyName] &&
highlightedMembers[row.hierarchyName].includes(row.caption)) {
cell.addClass(highlightedClasses[row.caption]);
}
});
}
}
function getData() {
return [{
"HealthSystemName": "Alameda Health System",
"FacilityName": "Alameda Hospital",
"ITDValue": 35733,
"YTDValue": 0,
"priorMonthValue": 0,
"Type": "Savings"
},
{
"HealthSystemName":...