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-header.fm-filter-header{
background-color: #4472c4 !important;
color:white !important;
}
.fm-header.fm-header-r.fm-empty{
background-color: #4472c4 !important;
color:white !important;
}
.fm-cols-filter div{
background-color: #4472c4 !important;
color:white !important;
}
JavaScript
var pivot = new Flexmonster({
container: "#pivot-container",
componentFolder: "https://cdn.flexmonster.com/",
report: {
dataSource: {
dataSourceType: "json",
data: getData()
},
options: {
grid: {
type: "classic"
},
showTotals: false
},
slice: {
rows: [{
uniqueName: "HealthSystemName",
caption: "Health System"
}, {
uniqueName: "FacilityName",
caption: "Facility"
}],
columns: [{
uniqueName: "BatchStatus",
sort: "desc"
}, {
uniqueName: "BatchStatusNumber",
caption: "Batch Status"
}, {
uniqueName: "[Measures]"
}],
measures: [{
uniqueName: "formulaCost",
formula: 'if(min("BatchStatusNumber") = 1, sum("Cost"), sum("ChargeCost"))',
individual: true,
caption: "Cost",
grandTotalCaption: "Total of cost"
}],
expands: {
expandAll: true
}
}
},
customizeCell: function(cell, data) {
if (data && data.hierarchy && data.hierarchy.uniqueName === "BatchStatusNumber") {
if (data.label === "1") {
cell.text = "Received"
} else if (data.label === "2") {
cell.text = "Unverified"
} else if (data.label === "3") {
cell.text = "Submitted"
} else if (data.label === "4") {
cell.text = "Shipped"
}
}
},
toolbar: true,
width: "100%",
height: 600
});
function getData() {
return [{
"HealthSystemName": "H1",
"FacilityName": "F1",
"ProgramName": "Amgen Safety Net Foundation",
"ProductName": "Xgeva",
"InvoiceDate": "2013-01-01",
"Cost": 50716.30,
"ChargeCost": 45287.700000,
"BatchStatusName": "Received",
"BatchStatusNumber": 1,
"BatchStatus": "Invoiced"
},
{
"HealthSystemName": "H1",
"FacilityName": "F2",
"ProgramName": "Eisai Patient Assistance Program",
"ProductName":...