JSFiddle - React, Tailwind, and code Playground
by Flexmonster Pivot Table
HTML
<script src="https://cdn.flexmonster.com/flexmonster.js"></script>
<div id="pivotContainer"></div>
<div class="output" id="output">Output will appear here</div>
CSS
.output {
width: 80%;
height: 300px;
margin-left: auto;
margin-right: auto;
padding: 20px;
background: rgba(242, 242, 242, 1);
font-family: Menlo, Monaco, "Courier New", Courier, monospace;
white-space: pre;
font-size: 16px;
font-weight: 400;
overflow-y: scroll;
margin-top: 20px;
}
JavaScript
var pivot = new Flexmonster({
container: "pivotContainer",
componentFolder: "https://cdn.flexmonster.com/",
licenseFilePath: "https://cdn.flexmonster.com/jsfiddle.charts.key",
height: 320,
toolbar: true,
report: {
dataSource: {
filename: "data/data.csv"
},
"slice": {
"rows": [{
"uniqueName": "Category"
}],
"columns": [{
"uniqueName": "[Measures]"
},
{
"uniqueName": "Business Type"
}
],
"measures": [{
"uniqueName": "Price",
"aggregation": "sum"
}]
},
}
});
let grandTotalRowSlice = {
slice: {
"columns": [{
"uniqueName": "[Measures]"
},
{
"uniqueName": "Business Type"
}
],
"measures": [{
"uniqueName": "Price",
"aggregation": "sum"
}]
}
};
flexmonster.getData(grandTotalRowSlice, function(data) {
//let grandTotal = data.data[0].v0;
showOutput(JSON.stringify(data.data, null, 4));
});
function showOutput(content) {
document.getElementById("output").innerText = content;
}