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
new Flexmonster({
container: "#pivot-container",
componentFolder: "https://cdn.flexmonster.com/",
width: "100%",
height: 550,
toolbar: true,
report: {
dataSource: {
type: "json",
data: getData()
},
slice: {
rows: [{
uniqueName: "Category",
}],
measures: [{
uniqueName: "Profit1",
aggregation: "average",
format: "percents",
grandTotalCaption: "Profit 1"
},
{
uniqueName: "Profit2",
aggregation: "average",
format: "percents",
grandTotalCaption: "Profit 2"
},
{
uniqueName: "difference",
formula: "round(round(average('Profit2'))-round(average('Profit1')))",
caption: "Calculated difference",
format: "percents"
}
]
},
formats: [{
name: "percents",
currencySymbol: "%",
positiveCurrencyFormat: "1$",
decimalPlaces: 0
}]
}
});
function getData() {
return [{
Category: "Cars",
Profit1: 55.49,
Profit2: 55.51
}]
}