JSFiddle - React, Tailwind, and code Playground
Data source
by Flexmonster Pivot Table
HTML
<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(),
},
slice: {
rows: [
{
uniqueName: "Category",
},
{
uniqueName: "Color",
},
],
columns: [
{
uniqueName: "[Measures]",
},
],
measures: [
{
uniqueName: "LT3%",
formula: 'if((sum("Value1") /sum("Value2")*100)>3,1,0)',
individual: true,
},
],
expands: {
expandAll: true,
},
},
},
})
function getData() {
return [
{
Color: "Red",
Category: "Accessories",
Value1: 10,
Value2: 1000,
},
{
Color: "Green",
Category: "Clothing",
Value1: 20,
Value2: 200,
},
{
Color: "Green",
Category: "Accessories",
Value1: 500,
Value2: 1000,
},
{
Color: "Blue",
Category: "Accessories",
Value1: 200,
Value2: 2010,
},
]
}