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>
<button onclick="showResultsForAllGenders()">
All Genders
</button>
<button onclick="showResultsForFemale()">
Female
</button>
<button onclick="showResultsForMale()">
Male
</button>
<div id="pivot-container"></div>
JavaScript
var pivot = new Flexmonster({
container: "#pivot-container",
componentFolder: "https://cdn.flexmonster.com/",
toolbar: true,
report: {
dataSource: {
data: getData(),
mapping: {
"Gender": {
type: "string",
dimensionUniqueName: "Product"
},
"Category": {
dimensionUniqueName: "Product"
},
"Size": {
type: "string",
dimensionUniqueName: "Product"
},
"Color": {
type: "string",
dimensionUniqueName: "Product"
},
"Destination": {
type: "string",
dimensionUniqueName: "Locations"
},
"Business Type": {
type: "string",
dimensionUniqueName: "Locations"
},
"Country": {
type: "string",
dimensionUniqueName: "Locations"
},
"Price": {
type: "number",
dimensionUniqueName: "Product"
},
"Quantity": {
type: "number",
dimensionUniqueName: "Product"
},
"Discount": {
type: "number",
dimensionUniqueName: "Product"
}
}
},
slice: {
reportFilters: [{
uniqueName: "Gender"
}],
rows: [{
uniqueName: "Category"
},
{
uniqueName: "Color"
}
],
columns: [{
uniqueName: "[Measures]"
}],
measures: [{
uniqueName: "Price",
aggregation: "sum"
},
{
uniqueName: "Quantity",
aggregation: "percentofcolumn",
formats: "myPercentage"
}
],
expands: {
rows: [{
"tuple": [
"category.[accessories]"
]
},
{
"tuple": [
"category.[bikes]"
]
}
]
}
},
options: {
grid: {
type: "classic",
showTotals: "off"
...