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>
<script src="https://cdn.flexmonster.com/lib/flexmonster.googlecharts.js"></script>
<script src="https://www.gstatic.com/charts/loader.js"></script>
<div id="pivot-container"></div>
<br />
<div id="googlechart-container" style="height:250px;"></div>
JavaScript
var pivot = new Flexmonster({
container: "pivot-container",
componentFolder: "https://cdn.flexmonster.com/",
report: {
dataSource: {
data: getJSONData()
},
slice: {
rows: [
{uniqueName: "Category"}
],
columns: [
{uniqueName: "[Measures]"}
],
measures: [
{uniqueName: "Price", format: "currency"},
{uniqueName: "Quantity"},
{uniqueName: "Discount", format: "currency"}
]
},
options: {
grid: {
showHeaders: false
}
},
formats: [
{
name: "currency",
thousandsSeparator: " ",
decimalSeparator: ".",
decimalPlaces: 2,
maxDecimalPlaces: -1,
maxSymbols: 20,
currencySymbol: "$",
currencySymbolAlign: "left",
nullValue: "",
infinityValue: "Infinity",
divideByZeroValue: "Infinity",
textAlign: "right",
isPercent: false
}
]
},
height: 280,
toolbar: true,
reportcomplete: function() {
pivot.off("reportcomplete");
pivotTableReportComplete = true;
createGoogleChart();
}
});
var pivotTableReportComplete = false;
var googleChartsLoaded = false;
google.charts.load('current', {'packages':['corechart']});
google.charts.setOnLoadCallback(onGoogleChartsLoaded);
function onGoogleChartsLoaded() {
googleChartsLoaded = true;
if (pivotTableReportComplete) {
createGoogleChart();
}
}
function createGoogleChart() {
if (googleChartsLoaded) {
pivot.off("reportchange");
pivot.googlecharts.getData(
{
type: "bar",
slice: {
rows: [
{uniqueName: "Category"}
],
columns: [
{uniqueName: "[Measures]"}
],
measures: [
{uniqueName: "Price"}
]
}
},
drawChart,
drawChart
);
pivot.on('reportchange', function () {
createGoogleChart();
});
}
}
function...