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>
<script src="https://cdn.flexmonster.com/lib/flexmonster.highcharts.js"></script>
<script src="https://code.highcharts.com/highcharts.js"></script>
<script src="https://code.highcharts.com/highcharts-more.js"></script>
<div id="pivot-container"></div>
<br/>
<div id="highcharts-container"></div>
<div id="highcharts-scatter-container"></div>
JavaScript
var pivot = new Flexmonster({
container: "#pivot-container",
componentFolder: "https://cdn.flexmonster.com/",
licenseFilePath: "https://cdn.flexmonster.com/jsfiddle.charts.key",
toolbar: false,
report: {
dataSource: {
dataSourceType: "json",
data: getData(),
mapping: {
"Username": {
"type": "string"
},
"Time off": {
"type": "string"
},
"Requested Time": {
"type": "time"
}
}
},
slice: {
rows: [{
uniqueName: "Time off"
}],
columns: [{
uniqueName: "[Measures]"
}],
measures: [{
uniqueName: "Username"
},
{
uniqueName: "Requested Time"
}
]
},
options: {
timePattern: "HH:mm"
}
},
height: 250,
reportcomplete: function() {
pivot.off("reportcomplete");
createChart();
}
});
function createChart() {
pivot.highcharts.getData({
type: "column"
},
function(data) {
applyTimeFormatting(data);
Highcharts.chart('highcharts-container', data);
},
function(data) {
applyTimeFormatting(data);
Highcharts.chart('highcharts-container', data);
}
);
}
function applyTimeFormatting(data) {
let measures = pivot.getMeasures();
let timeFormatted = [];
for (let measure of measures)
if (measure.type == 'time')
timeFormatted.push(measure.caption);
for (let axis of data.yAxis)
if (timeFormatted.includes(axis.title.text))
axis.labels = {
formatter: function() {
return formatter(this.value);
}
}
data.tooltip = {
useHTML: true,
formatter: function() {
let value;
if (timeFormatted.includes(this.point.series.name))
value = formatter(this.y);
else value = this.y;
return `${this.point.category}<br>${this.point.series.name}: <b>${value}</b>`;
}
}
return data;
}
function formatter(seconds) {
...