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
let pivot = new Flexmonster({
container: "pivot-container",
componentFolder: "https://cdn.flexmonster.com/",
toolbar: true,
report: {
"dataSource": {
"data": getData()
},
"slice": {
"rows": [
{
"uniqueName": "Price",
"filter": {
"measure": {
"uniqueName": "Price",
"aggregation": "count"
},
"query": {
"top": 5
}
}
}
],
"columns": [
{
"uniqueName": "[Measures]"
}
],
"measures": [
{
"uniqueName": "Price",
"aggregation": "count"
}
],
"sorting": {
"column": {
"type": "desc",
"tuple": [],
"measure": {
"uniqueName": "Price",
"aggregation": "count"
}
}
}
},
}
});
function getData() {
return [{
"Category": "Accessories",
"Country": "Canada",
"Price": 100
},
{
"Category": "Accessories",
"Country": "Canada",
"Price": 100
},
{
"Category": "Accessories",
"Country": "France",
"Price": 74
},
{
"Category": "Bikes",
"Country": "USA",
"Price": 205
},
{
"Category": "Accessories",
"Country": "France",
"Price": 74
},
{
"Category": "Accessories",
"Country": "France",
"Price": 74
},
{
"Category": "Accessories",
"Country": "France",
"Price": 55
},
{
"Category": "Accessories",
"Country": "France",
"Price": 55
},
{
"Category": "Accessories",
"Country": "France",
"Price": 99
},
{
"Category": "Accessories",
...