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="pivotContainer"></div>
JavaScript
var pivot = new Flexmonster({
container: "pivotContainer",
componentFolder: "https://cdn.flexmonster.com/",
toolbar: true,
report: {
dataSource: {
data: getData(),
mapping: {
"Color": {
"type": "string"
},
"Month": {
"type": "month"
},
"Week Day": {
"type": "weekday"
},
"Country": {
"type": "string",
"hierarchy": "Geography"
},
"State": {
"type": "string",
"hierarchy": "Geography",
"parent": "Country"
},
"City": {
"type": "string",
"hierarchy": "Geography",
"parent": "State"
},
"Price": {
"type": "number"
},
"Quantity": {
"type": "number"
}
}
},
"slice": {
"rows": [{
"uniqueName": "Week Day"
}],
"columns": [{
"uniqueName": "Month"
},
{
"uniqueName": "[Measures]"
}
],
"measures": [{
"uniqueName": "Price",
"aggregation": "sum"
},
{
"uniqueName": "Price",
"aggregation": "differenceofrow"
}
]
},
"options": {
"grid": {
"showGrandTotals": "off"
}
}
}
});
function getData() {
return [{
"Color": "green",
"Month": "September",
"Week Day": "Wed",
"Country": "Canada",
"State": "Ontario",
"City": "Toronto",
"Price": 174,
"Quantity": 22
},
{
"Color": "red",
"Month": "March",
"Week Day": "Mon",
"Country": "USA",
"State": "California",
"City": "Los Angeles",
"Price": 1664,
"Quantity": 19
},
{
"Color": "red",
"Month": "January",
"Week Day": "Mon",
"Country": "Canada",
"State": "Quebec",
"City": "Montreal",
"Price": 1190,
"Quantity": 292
},
...