Showing date hierarchy starting from month
Slice configuration
by Flexmonster Pivot Table
HTML
<script src="https://cdn.flexmonster.com/flexmonster.js"></script>
<div id="pivot-container"></div>
CSS
@import url(https://cdn.flexmonster.com/assets/jsfiddle-styles.css);
JavaScript
let pivot = new Flexmonster({
container: "pivot-container",
componentFolder: "https://cdn.flexmonster.com/",
width: "100%",
height: 430,
toolbar: true,
report: {
dataSource: {
data: getData(),
mapping: {
"Date": {
caption: "Flight Date",
type: "year/month/day"
},
"Price": {
caption: "Price",
type: "number"
}
}
},
slice: {
"rows": [{
"uniqueName": "Date",
"levelName": "Date.Month"
}],
"columns": [{
"uniqueName": "[Measures]"
}],
"measures": [{
"uniqueName": "Price",
"aggregation": "sum"
}]
}
}
});
function getData() {
return [{
"Date": "2021-01-11",
"Price": 5477
}, {
"Date": "2020-11-03",
"Price": 2455
}, {
"Date": "2021-03-19",
"Price": 2457
}, {
"Date": "2021-05-09",
"Price": 4367
}];
}