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>
<h2>"Area tab toggle chart display"</h2>
<div id="wrapper">
<div id="pivotContainer"></div>
<div id="highchartsContainer"></div>
</div>
CSS
#wrapper {
height: 500px;
position: relative;
}
#highchartsContainer {
top: 80px;
bottom: 0;
right: 0;
left: 0;
z-index: 10;
display: none;
position: absolute;
}
JavaScript
let highchartsContainer = document.getElementById("highchartsContainer");
var pivot = new Flexmonster({
container: "pivotContainer",
componentFolder: "https://cdn.flexmonster.com/",
licenseFilePath: "https://cdn.flexmonster.com/jsfiddle.charts.key",
toolbar: true,
width: "100%",
height: "100%",
report: "https://cdn.flexmonster.com/reports/report.json"
});
flexmonster.on("reportcomplete", () => {
pivot.off("reportcomplete");
areaChart();
});
flexmonster.on("beforetoolbarcreated", (toolbar) => {
var tabs = toolbar.getTabs();
toolbar.getTabs = () => {
tabs.splice(7, 0, {
id: "open-area-chart",
title: "Area",
icon: tabs[6].icon,
handler: toggleChart
});
tabs[tabs.length - 1].handler = toggleFullscreen;
return tabs;
};
function toggleFullscreen() {
if (document.fullscreenElement) document.exitFullscreen();
else document.getElementById("wrapper").requestFullscreen();
}
function toggleChart() {
if (!highchartsContainer.style.display || highchartsContainer.style.display == "none")
highchartsContainer.style.display = "block";
else highchartsContainer.style.display = "none";
window.dispatchEvent(new Event('resize'));
}
});
function areaChart() {
pivot.highcharts.getData({
type: "area"
},
function(chartConfig) {
Highcharts.chart('highchartsContainer', chartConfig);
},
function(chartConfig) {
Highcharts.chart('highchartsContainer', chartConfig);
}
);
}