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="changeTimeFormat()">
Change Time Format
</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()
},
slice: {
rows: [{
uniqueName: "Event"
}],
columns: [{
uniqueName: "[Measures]"
}],
measures: [{
uniqueName: "Time in Second",
aggregation: "sum",
grandTotalCaption: "Total Time in Second"
}]
}
}
});
function changeTimeFormat(){
pivot.setOptions({
timePattern: "d'd' HH'h' mm'min'"
});
pivot.refresh();
}
function getData(){
return [{
"Event": {
type: "string"
},
"Time in Second": {
type: "time"
}
},
{
"Event": "Event 1",
"Time in Second": 120
},
{
"Event": "Event 2",
"Time in Second": 20
},
{
"Event": "Event 2",
"Time in Second": 15600
}
];
}