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>
<div id="totals-container"></div>
JavaScript
let pivot = new Flexmonster({
container: "pivot-container",
componentFolder: "https://cdn.flexmonster.com/",
toolbar: true,
height: 400,
report: {
dataSource: {
filename: "data/data.csv",
},
options: {
showGrandTotals: "rows",
},
slice: {
rows: [{
uniqueName: "Country"
},
{
uniqueName: "Color"
}
],
columns: [{
uniqueName: "Business Type"
}, {
uniqueName: "[Measures]"
}],
measures: [{
uniqueName: "Price",
aggregation: "sum",
format: "currency",
}, ]
},
"tableSizes": {
"columns": [{
"idx": 0,
"width": 133
}]
},
"formats": [{
"name": "",
"thousandsSeparator": ",",
"decimalSeparator": ".",
"decimalPlaces": 0,
"nullValue": "-"
},
{
"name": "currency",
"currencySymbol": "$"
}
]
}
});
let totals = new Flexmonster({
container: "totals-container",
componentFolder: "https://cdn.flexmonster.com/",
height: 200,
report: {
dataSource: {
filename: "data/data.csv",
},
options: {
showAggregationLabels: false,
showHeaders: false,
configuratorButton: false,
readOnly: true
},
slice: {
rows: [{
uniqueName: "[Measures]"
}],
columns: [{
uniqueName: "Business Type"
}, ],
measures: [{
uniqueName: "Price",
aggregation: "sum",
format: "currency",
caption: "Sum of Price"
},
{
uniqueName: "Price",
aggregation: "percentofparentcolumntotal",
caption: "% of Total",
}
]
},
"tableSizes": {
"columns": [{
"idx": 0,
"width": 158
},
{
"tuple": [
"business type.[(all member)]"
],
"width": 126
}
]
},
...