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
var pivot = new Flexmonster({
container: "#pivot-container",
componentFolder: "https://cdn.flexmonster.com/",
width: "100%",
height: 430,
toolbar: true,
report: {
dataSource: {
filename: "data/sales.csv"
},
options: {
viewType: "charts",
chart: {
type: "bar_h"
}
},
slice: {
columns: [{
uniqueName: "Month"
}, {
uniqueName: "[Measures]"
}],
rows: [{
uniqueName: "Category",
filter: {
members: [
"category.[condiments].[bbq sauce]",
"category.[breakfast cereals].[corn flakes]",
"category.[confectionery]",
"category.[bakery].[chocolate biscuits]",
"category.[fruit preserves].[apple jam]",
"category.[bakery].[apple cake]",
"category.[soups].[tomato soup]"
]
}
}],
measures: [{
"uniqueName": "Revenue",
"aggregation": "sum",
"format": "2sfou03a"
},
{
"uniqueName": "Unit Price",
"aggregation": "sum"
}]
},
formats: [{
name: "2sfou03a",
thousandsSeparator: ",",
decimalSeparator: ".",
decimalPlaces: 2,
currencySymbol: "$",
currencySymbolAlign: "left",
nullValue: "",
textAlign: "right",
isPercent: false
}]
},
beforetoolbarcreated: customizeToolbar
});
function customizeToolbar(toolbar) {
// get all tabs
var tabs = toolbar.getTabs();
toolbar.getTabs = function () {
tabs[6].menu[4].handler = () => pivot.showCharts("pie", false);
return tabs;
}
}