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,
report: {
dataSource: {
data: getData()
},
options: {
showAggregationLabels: false,
grid: {
showTotals: "off",
showGrandTotals: "off",
type: "classic",
}
},
slice: {
rows: [{
uniqueName: "Category",
}, {
uniqueName: "Color",
}, {
uniqueName: "Size",
}, {
uniqueName: "Product",
}],
measures: [{
uniqueName: "Product",
aggregation: "count",
}],
expands: {
expandAll: true
}
},
tableSizes: {
columns: [{
tuple: [],
measure: {
"uniqueName": "Product",
"aggregation": "count"
},
width: 1
}]
},
}
});
function getData() {
return [{
"Category": "Arts & Crafts",
"Color": "green",
"Size": "8 colors",
"Product": "guashe"
}, {
"Category": "Arts & Crafts",
"Color": "blue",
"Size": "16 colors",
"Product": "watercolor"
},
{
"Category": "Arts & Crafts",
"Color": "blue",
"Size": "8 colors",
"Product": "watercolor"
},
{
"Category": "Clothing",
"Color": "golden",
"Size": "XS",
"Product": "purse"
},
{
"Category": "Clothing",
"Color": "silver",
"Size": "L",
"Product": "boots"
},
{
"Category": "Clothing",
"Color": "nude",
"Size": "M",
"Product": "skirt"
},
{
"Category": "Clothing",
"Color": "nude",
"Product": "dress",
"Size": "XL"
}
]
}