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>
JavaScript
new Flexmonster({
container: "#pivot-container",
componentFolder: "https://cdn.flexmonster.com/",
width: "100%",
height: 550,
toolbar: true,
report: {
"dataSource": {
"type": "json",
"data": getData(),
"mapping": {
"Country": {
type: "string"
},
"Volume": {
type: "number"
},
"Price": {
type: "number"
}
}
},
"slice": {
"rows": [{
"uniqueName": "Country",
}],
"columns": [{
"uniqueName": "[Measures]"
}],
"measures": [{
"uniqueName": "Volume",
"aggregation": "sum"
},
{
"uniqueName": "Percent Traded Volume",
"formula": "percentofcolumn(\"Volume\")",
"caption": "Percent Traded Volume",
"format": "Percent Traded Volume"
}
]
},
"formats": [{
"name": "",
"thousandsSeparator": ",",
"decimalSeparator": ".",
"decimalPlaces": 3,
"maxSymbols": 20,
"nullValue": " ",
"infinityValue": "Infinity",
"divideByZeroValue": "Infinity",
"textAlign": "left"
}, {
"name": "Percent Traded Volume",
"currencySymbol": "%",
"positiveCurrencyFormat": "$1",
"negativeCurrencyFormat": "-1$"
}]
}
});
function getData() {
return [{
"Country": "Australia",
"Volume": 109,
"Price": 677
},
{
"Country": "Japan",
"Volume": 98,
"Price": 417
},
{
"Country": "Switzerland",
"Volume": 154,
"Price": 507
},
{
"Country": "Norway",
"Volume": 165,
"Price": 1040
},
{
"Country": "UK",
"Volume": 205,
"Price": 697
},
{
"Country": "Sweden",
"Volume": 109,
"Price": 779
},
{
"Country": "Ukraine",
"Volume": 335,
"Price": 1118
}
]
}