JSFiddle - React, Tailwind, and code Playground
by Flexmonster Pivot Table
HTML
<script src="https://cdn.flexmonster.com/flexmonster.js"></script>
<div id="pivot-container"></div>
JavaScript
var jsonData = [{
"Department": "ABC",
"Risk Scale": "Inherent Risk",
"Risk Type": "Strategic Risk",
"Value": 1,
},
{
"Department": "ABC",
"Risk Scale": "Inherent Risk",
"Risk Type": "Financial Risk",
"Value": 1,
},
{
"Department": "ABC",
"Risk Scale": "Residual Risk",
"Risk Type": "Financial Risk",
"Value": 2,
},
{
"Department": "ABC",
"Risk Scale": "Residual Risk",
"Risk Type": "Strategic Risk",
"Value": 2,
}
];
var pivot = new Flexmonster({
container: "pivot-container",
componentFolder: "https://cdn.flexmonster.com/",
toolbar: true,
report: {
dataSource: {
data: jsonData
},
slice: {
rows: [{
uniqueName: "Risk Scale"
},
{
uniqueName: "[Measures]"
}
],
columns: [{
uniqueName: "Risk Type"
}],
reportFilters: [{
uniqueName: "Department"
}],
measures: [{
uniqueName: "Value",
aggregation: "max"
}]
},
options: {
grid: {
showTotals: false,
showGrandTotals: false
}
}
}
});
pivot.customizeCell(function(cell, data) {
if (data.type == "value" && !data.isDrillThrough) {
if (data.value == 1) {
cell.text = "Minor";
} else if (data.value == 2) {
cell.text = "High";
}
}
})