JSFiddle - React, Tailwind, and code Playground
by Flexmonster Pivot Table
HTML
<script src="https://cdn.flexmonster.com/flexmonster.js"></script>
<script src="https://cdn.flexmonster.com/lib/flexmonster.amcharts.js"></script>
<script src="https://www.amcharts.com/lib/4/core.js"></script>
<script src="https://www.amcharts.com/lib/4/charts.js"></script>
<script src="https://www.amcharts.com/lib/4/maps.js"></script>
<script src="https://www.amcharts.com/lib/4/themes/animated.js"></script>
<script src="https://cdn.amcharts.com/lib/4/geodata/worldHigh.js"></script>
<div id="pivot-container"></div>
<div class="demo-box no-text-before no-text-after">
<div class="demo-title"><strong>Feta Interest by Country</strong></div>
<div id="amcharts-map-container" class="chart-container"></div></div>
CSS
body {
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
}
.chart-container {
height: 450px;
}
.demo-box {
background-color: #fafafa;
position: relative;
padding: 40px 30px 30px 30px;
border: 1px solid #e9e9e9;
margin-bottom: 20px;
margin-top: 40px;
}
.demo-title {
font-size: 18px;
margin-bottom: 30px;
white-space: nowrap;
text-overflow: ellipsis;
overflow: hidden;
line-height: 24px;
}
.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;
}
#fm-pivot-view .fm-grid-layout .fm-custom-cell.fm-expanded .fm-expanded-icon::before,
#fm-pivot-view .fm-grid-layout .fm-custom-cell.fm-collapsed .fm-collapsed-icon::before {
top: -2px;
height: 16px;
}
JavaScript
let pivot = new Flexmonster({
container: "pivot-container",
licenseFilePath: "https://cdn.flexmonster.com/jsfiddle.charts.key",
componentFolder: "https://cdn.flexmonster.com/",
height: 440,
customizeCell: customizeCell,
report: {
dataSource: {
data: getData(),
mapping: {
"Date": {
type: "date"
},
"Country": {
type: "string"
},
"id": {
type: "string"
},
"CountryCode": {
type: "property",
hierarchy: "Country"
},
"Feta": {
type: "number"
},
"Mozzarella": {
type: "number"
},
"Parmigiano-Reggiano": {
type: "number"
}
}
},
"slice": {
"rows": [{
"uniqueName": "Date.Month",
"filter": {
"exclude": [
"date.month.[december]",
"date.month.[november]",
"date.month.[october]"
]
}
},
{
"uniqueName": "[Measures]"
}
],
"columns": [{
"uniqueName": "Country"
}],
"measures": [{
"uniqueName": "Feta",
"aggregation": "sum",
"grandTotalCaption": "Feta"
},
{
"uniqueName": "Mozzarella",
"aggregation": "sum",
"grandTotalCaption": "Mozzarella"
},
{
"uniqueName": "Parmigiano-Reggiano",
"aggregation": "sum",
"grandTotalCaption": "Parmigiano-Reggiano"
}
]
},
"options": {
"grid": {
"showHeaders": false,
"showGrandTotals": "rows"
},
"showAggregationLabels": false
}
},
reportcomplete: function() {
pivot.off("reportcomplete");
createMapChart();
}
});
let mapChart;
// Apply amCharts theme
am4core.useTheme(am4themes_animated);
function createMapChart() {
pivot.amcharts.getData({
"slice": {
"rows":...