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
let pivot = new Flexmonster({
container: "pivot-container",
componentFolder: "https://cdn.flexmonster.com/",
toolbar: true,
report: {
dataSource: {
data: getData(),
mapping: {
"DateYear": {
caption: "Year",
type: "date string",
interval: "y",
format: "yyyy"
},
"DateMonth": {
caption: "Month",
type: "date string",
interval: "M",
format: "MMMM yyyy"
},
"DateDay": {
caption: "Day",
type: "date string",
format: "dd MMM yyyy"
}
}
},
slice: {
rows: [{
uniqueName: "DateYear"
},
{
uniqueName: "DateMonth"
},
{
uniqueName: "DateDay"
}
],
columns: [{
uniqueName: "[Measures]"
}],
measures: [{
uniqueName: "Price"
}]
},
}
});
function getData() {
return [{
"DateYear": "2021-05-25",
"DateMonth": "2021-05-25",
"DateDay": "2021-05-25",
"Price": 200
},
{
"DateYear": "2020-01-11",
"DateMonth": "2020-01-11",
"DateDay": "2020-01-11",
"Price": 150
},
{
"DateYear": "2021-03-08",
"DateMonth": "2021-03-08",
"DateDay": "2021-03-08",
"Price": 300
}
];
}