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>
CSS
.fm-custom-cell {
display: flex !important;
align-items: center !important;
font-size: 12px !important;
}
.fm-custom-cell .flag-icon {
width: 21px !important;
height: 16px !important;
margin-left: 0 !important;
margin-right: 2px !important;
}
JavaScript
new Flexmonster({
container: "#pivot-container",
componentFolder: "https://cdn.flexmonster.com/",
width: "100%",
height: 550,
customizeCell: customizeCell,
toolbar: true,
report: {
"dataSource": {
"type": "json",
"filename": "https://cdn.flexmonster.com/data/retail-data.json",
"mapping": {
"Order Date": {
"type": "year/quarter/month/day"
},
"Country": {
"type": "string",
"folder": "Location"
},
"City": {
"type": "string",
"folder": "Location"
},
"CurrencyID": {
"type": "property",
"hierarchy": "Country"
},
"Contact Last Name": {
"type": "string"
},
"Contact First Name": {
"type": "string"
},
"Deal Size": {
"type": "string"
}
}
},
"slice": {
"rows": [{
"uniqueName": "Country"
},
{
"uniqueName": "Status",
}
],
"columns": [{
"uniqueName": "Order Date"
},
{
"uniqueName": "[Measures]"
}
],
"measures": [{
"uniqueName": "Price",
"aggregation": "sum"
}],
}
}
});
function customizeCell(cell, data) {
if (data.hierarchy) {
if (data.type == "header") {
if (data.hierarchy.caption == "Country") {
if (data.member) {
if (data.member.properties) {
var name = data.member.properties.CurrencyID;
cell.addClass('fm-custom-cell');
if (data.expanded) {
var flag = '<i class="fm-icon fm-expanded-icon" title="Click to collapse">' +
"<" + "/i>" + '<img class="flag-icon" src="https://cdn.flexmonster.com/flags/' +
name.toLowerCase() + '.svg">';
} else {
var flag = '<i class="fm-icon fm-collapsed-icon" title="Click to expand">' +
"<" + "/i>"...