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
var month = [];
month[0] = "Jan";
month[1] = "Feb";
month[2] = "Mar";
month[3] = "Apr";
month[4] = "May";
month[5] = "Jun";
month[6] = "Jul";
month[7] = "Aug";
month[8] = "Sep";
month[9] = "Oct";
month[10] = "Nov";
month[11] = "Dec";
var pivot = new Flexmonster({
container: "pivot-container",
componentFolder: "https://cdn.flexmonster.com/",
width: "100%",
height: 430,
toolbar: true,
report: {
dataSource: {
dataSourceType: "json",
data: [{
"date1": {
"type": "date string"
},
"date2": {
"type": "date string"
},
"n": {
"type": "number"
}
}, {
"date1": "2016-04-06T23:59:30",
"date2": "2016-03-25T23:59:30",
"n": 1
}, {
"date1": "2015-05-06T23:59:30",
"date2": "2016-05-11T23:59:30",
"n": 1
}, {
"date1": "2014-02-07T20:33",
"date2": "2016-02-12T23:59:30",
"n": 1
}]
},
options: {
datePattern: "yyyy-MM-dd HH:mm:ss"
},
slice: {
rows: [{
uniqueName: "date1"
}],
columns: [{
uniqueName: "date2"
}, {
uniqueName: "[Measures]"
}],
measures: [{
uniqueName: "n"
}],
}
},
customizeCell: function(cell, data) {
if (data && data.type == "header" && data.hierarchy && data.member) {
if (data.hierarchy.uniqueName == "date1") {
cell.text = data.label.substr(0, 4);
}
if (data.hierarchy.uniqueName == "date2") {
var date = new Date(data.label);
cell.text = date.getDate() + "/" + month[date.getMonth()];
}
}
}
});