JSFiddle - React, Tailwind, and code Playground
by Flexmonster Pivot Table
HTML
<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>
<div id="highcharts-container"></div>
CSS
#fm-fields-view {
top: -70px !important;
height: 360px;
}
#fm-pivot-view #fm-fields-view .fm-popup-content .fm-ui-col-3 {
height: 200px !important;
}
JavaScript
var pivot = new Flexmonster({
container: "pivot-container",
componentFolder: "https://cdn.flexmonster.com/",
licenseFilePath: "https://cdn.flexmonster.com/jsfiddle.charts.key",
toolbar: true,
report: {
dataSource: {
data: getData()
},
slice: {
columns: [{
uniqueName: '[Measures]'
}],
rows: [{
uniqueName: 'Year'
}],
measures: [{
uniqueName: 'Value',
}]
},
options: {
viewType: 'grid',
grid: {
showEmptyValues: true
}
},
},
reportcomplete: function() {
pivot.off("reportcomplete");
createChart();
}
});
function createChart() {
pivot.highcharts.getData({
type: "line",
slice: {
columns: [{
uniqueName: '[Measures]'
}],
rows: [{
uniqueName: 'Year'
}],
measures: [{
uniqueName: 'CalcValue',
formula: "if(!isNaN(sum('Value')) ,sum('Value'),0 )"
}]
},
},
function(chartConfig) {
Highcharts.chart('highcharts-container', chartConfig);
},
function(chartConfig) {
Highcharts.chart('highcharts-container', chartConfig);
}
);
}
function getData() {
return [{
"Year": "2020",
"Value": 20
},
{
"Year": "2021",
"Value": 21
},
{
"Year": "2022"
},
{
"Year": "2023"
},
{
"Year": "2024",
"Value": 26
},
];
}