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>
<div class="output" id="output">Request output will appear here</div>
CSS
.output {
width: 80%;
height: 250px;
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;
margin-bottom: 20px;
}
JavaScript
let pivot = new Flexmonster({
container: "#pivot-container",
componentFolder: "https://cdn.flexmonster.com/",
width: "100%",
height: 450,
toolbar: true,
report: {
"dataSource": {
"type": "api",
"url": "https://olap.flexmonster.com:9500",
"index": "fm-product-sales",
mapping: {
"Category": {
hierarchy: "Item"
},
"Color": {
hierarchy: "Item",
parent: "Category"
}
}
},
"slice": {
"reportFilters": [
{
"uniqueName": "Country",
},
],
"rows": [{
"uniqueName": "Business Type",
"filter": {
"members": [
"business type.[specialty bike shop]"
]
}
}],
"columns": [{
"uniqueName": "Item",
"levelName": "Category",
"filter": {
"members": [
"item.[accessories]",
"item.[bikes]"
]
}
},
{
"uniqueName": "Size"
},
{
"uniqueName": "[Measures]"
}
],
"measures": [{
"uniqueName": "Price",
"aggregation": "sum"
}]
},
"options": {
"grid": {
"showGrandTotals": "off"
}
},
}
});
pivot.customizeAPIRequest((request) => {
showOutput(JSON.stringify(request, null, 4));
});
function showOutput(content) {
document.getElementById("output").innerText += "\n\nSent request:\n" + content;
}