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-main-container"></div>
<div id="pivot-total-container"></div>
JavaScript
var pivotMain = new Flexmonster({
container: "#pivot-main-container",
componentFolder: "https://cdn.flexmonster.com/",
toolbar: true,
report: {
dataSource: {
type: "json",
data: getData()
},
"slice": {
"columns": [{
"uniqueName": "Color",
"filter": {
"members": [
"color.[green]"
]
}
},
{
"uniqueName": "Business Type"
},
{
"uniqueName": "Category"
},
{
"uniqueName": "[Measures]"
}
],
"rows": [{
"uniqueName": "Country"
}],
"measures": [{
"uniqueName": "Discount",
"aggregation": "sum"
},
{
"uniqueName": "Destination",
"aggregation": "count"
}
],
"expands": {
"columns": [{
"tuple": [
"color.[green]"
]
}]
}
},
"options": {
"grid": {
"type": "classic",
"showTotals": "off",
"showGrandTotals": "columns"
}
}
},
width: "100%",
height: 400
});
pivotMain.on("reportcomplete", () => {
pivotMain.off("reportcomplete");
pivotTotal.setReport({
dataSource: {
type: "json",
data: getData()
},
slice: {
reportFilters: [{
uniqueName: "Color",
filter: {
members: [
"color.[green]"
]
}
}],
rows: [{
uniqueName: "Country"
}],
measures: pivotMain.getAllMeasures()
},
options: {
readOnly: true,
grid: {
type: "classic",
showTotals: "off",
title: "Report Totals"
}
}
})
})
pivotMain.on("reportchange", () => {
let report = pivotMain.getReport();
report.slice.reportFilters = report.slice.columns;
report.slice.columns = [];
report.slice.measures = pivotMain.getAllMeasures();
report.options =...