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">The component will appear here</div>
CSS
#fm-pivot-view .fm-charts-view .fm-chart-legend table td {
display: inline-block;
}
JavaScript
let pivot = new Flexmonster({
container: "pivot-container",
componentFolder: "https://cdn.flexmonster.com/",
toolbar: true,
report: {
dataSource: {
filename: "data/flight-etiquette.csv"
},
slice: {
"rows": [{
"uniqueName": "Age",
"filter": {
"exclude": [
"age.[]"
]
}
}],
"columns": [{
"uniqueName": "Location (Census Region)"
},
{
"uniqueName": "[Measures]"
}
],
"measures": [{
"uniqueName": "RespondentID",
"aggregation": "distinctcount"
}]
},
options: {
viewType: "charts",
chart: {
type: "stacked_column",
showFilter: false,
showMeasures: false
}
},
}
});
document.getElementById('sortSelect').addEventListener('change', function() {
customSorting(this.value);
});
function customSorting(age) {
flexmonster.sortingMethod("Age", function(a, b) {
if (a === age) {
return -1;
} else if (b === age) {
return 1;
} else {
return a < b ? -1 : 1;
}
})
}