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
let pivot = new Flexmonster({
container: "#pivot-container",
componentFolder: "https://cdn.flexmonster.com/",
toolbar: true,
height: 370,
report: {
dataSource: {
type: "json",
data: getData()
},
"slice": {
rows: [{
uniqueName: "Area"
},
{
uniqueName: "Vendor"
}
],
columns: [{
uniqueName: "[Measures]"
}],
measures: [{
uniqueName: "Truck",
aggregation: "count"
}],
expands: {
expandAll: true
}
},
options: {
grid: {
type: "classic",
showTotals: "off",
}
}
}
});
function customizeCellFunction(cell, data) {
if (data && data.type == "header" &&
data.member &&
data.member.caption != 'All' &&
data.label == "") {
cell.text = " " + data.member.caption;
}
}
pivot.customizeCell(customizeCellFunction)
function getData() {
return [{
Area: "West Virginia",
Vendor: "Vendor Inc",
Truck: "Volvo FH16 Aero"
},
{
Area: "West Virginia",
Vendor: "Vendor Inc",
Truck: "Freightliner Cascadia"
},
{
Area: "West Virginia",
Vendor: "Vendor Inc",
Truck: "Western Star 5700XE"
},
{
Area: "West Virginia",
Vendor: "Transport Solutions",
Truck: "Kenworth W900"
},
{
Area: "West Virginia",
Vendor: "Transport Solutions",
Truck: "Volvo VNL 860"
},
{
Area: "Northern California",
Vendor: "Transport Solutions",
Truck: "Freightliner Coronado"
},
{
Area: "Northern California",
Vendor: "Vendor Inc",
Truck: "Peterbilt 579"
},
{
Area: "Northern California",
Vendor: "Vendor Inc",
Truck: "Mack Anthem"
},
{
Area: "Northern California",
Vendor: "Freight Express",
Truck: "International LT Series"
},
{
Area: "Northern California",
...