JSFiddle - React, Tailwind, and code Playground
by Flexmonster Pivot Table
April 08, 2020
HTML
<link rel="stylesheet" href="https://s3.amazonaws.com/flexmonster/2.3/demo.css">
<script src="https://cdn.flexmonster.com/flexmonster.js"></script>
<div class="title">Try hovering over members of the "GL Code" hierarchy</div>
<div id="pivotContainer"></div>
CSS
.title {
font-family: "Arail", sans-serif;
font-weight: 600;
margin: 10px;
font-size: 18px;
}
JavaScript
var pivot = new Flexmonster({
container: "pivotContainer",
componentFolder: "https://cdn.flexmonster.com/",
toolbar: true,
report: {
dataSource: {
filename: "https://www.flexmonster.com/fm_uploads/2020/04/data-2636-1.json",
mapping: {
"Date": {
"type": "date string"
},
"Feasibility": {
"type": "number"
},
"Forecats": {
"type": "number"
},
"Actual": {
"type": "number"
},
"GL Code": {
"type": "string"
},
"Cost Centre": {
"type": "string"
},
"Note": {
"type": "property",
"hierarchy": "GL Code"
}
}
},
"slice": {
"rows": [{
"uniqueName": "Cost Centre"
},
{
"uniqueName": "GL Code"
},
{
"uniqueName": "Note"
}
],
"columns": [{
"uniqueName": "Date"
},
{
"uniqueName": "[Measures]"
}
],
"measures": [{
"uniqueName": "Feasibility",
"aggregation": "sum"
}],
"expands": {
"expandAll": true
}
},
"formats": [{
"name": "",
"thousandsSeparator": ",",
"decimalPlaces": 2,
"currencySymbol": "$"
}]
}
});
flexmonster.customizeCell((cell, data) => {
if (data.hierarchy && data.type == "header" && data.hierarchy.uniqueName == "GL Code") {
for (let elem of data.rows)
if (elem.hierarchyName == "GL Code") {
cell.attr.title = elem.properties["Note"];
console.log(cell.attr);
}
}
});