JSFiddle - React, Tailwind, and code Playground
by Black Label
HTML
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=11; IE=10; IE=9; IE=8; IE=7; IE=EDGE" />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<script src="https://code.jquery.com/jquery-1.12.4.js"></script>
<script src="https://code.highcharts.com/highcharts.js"></script>
<script src="https://code.highcharts.com/modules/exporting.js"></script>
<script src="https://code.highcharts.com/modules/offline-exporting.js"></script>
<title>Reports</title>
<div id="table">
<div class="caption">
<div id="container" style="height: 350px"></div>
</div>
<div id="buttonrow">
<button id="export2pdf">Export to PDF</button>
</div>
CSS
@import "https://code.highcharts.com/css/highcharts.css";
.highcharts-figure,
.highcharts-data-table table {
min-width: 310px;
max-width: 800px;
margin: 1em auto;
}
.highcharts-data-table table {
font-family: Verdana, sans-serif;
border-collapse: collapse;
border: 1px solid #ebebeb;
margin: 10px auto;
text-align: center;
width: 100%;
max-width: 500px;
}
.highcharts-data-table caption {
padding: 1em 0;
font-size: 1.2em;
color: #555;
}
.highcharts-data-table th {
font-weight: 600;
padding: 0.5em;
}
.highcharts-data-table td,
.highcharts-data-table th,
.highcharts-data-table caption {
padding: 0.5em;
}
.highcharts-data-table thead tr,
.highcharts-data-table tr:nth-child(even) {
background: #f8f8f8;
}
.highcharts-data-table tr:hover {
background: #f1f7ff;
}
.highcharts-yaxis .highcharts-axis-line {
stroke-width: 2px;
}
/* Link the series colors to axis colors */
.highcharts-color-0 {
fill: #7cb5ec;
stroke: #7cb5ec;
}
.highcharts-axis.highcharts-color-0 .highcharts-axis-line {
stroke: #7cb5ec;
}
.highcharts-axis.highcharts-color-0 text {
fill: #7cb5ec;
}
.highcharts-color-1 {
fill: #90ed7d;
stroke: #90ed7d;
}
.highcharts-axis.highcharts-color-1 .highcharts-axis-line {
stroke: #90ed7d;
}
.highcharts-axis.highcharts-color-1 text {
fill: #90ed7d;
}
JavaScript
$(function() {
Highcharts.AST.allowedTags.push('image');
Highcharts.AST.allowedAttributes.push('xlink:href');
Highcharts.getSVG = function(charts, texts, options, callback) {
var svgArr = [],
top = 0,
width = 0,
newLine = false,
txt1;
addSVG = function(svgres, i) {
// Grab width/height from exported chart
var svgWidth = +svgres.match(
/^<svg[^>]*width\s*=\s*\"?(\d+)\"?[^>]*>/
)[1],
svgHeight = +svgres.match(
/^<svg[^>]*height\s*=\s*\"?(\d+)\"?[^>]*>/
)[1],
// Offset the position of this chart in the final SVG
svg;
if (svgWidth > 1100) {
if (i == 5) {
top = 1000;
svg = svgres.replace('<svg', '<g transform="translate(0,' + top + ')"');
} else {
svg = svgres.replace('<svg', '<g transform="translate(' + width + ', 0 )"');
}
top = Math.max(top, svgHeight);
} else {
if (newLine) {
if (i == 4) {
width = 1000;
}
svg = svgres.replace('<svg', '<g transform="translate(' + width + ', ' + top + ')"');
top += svgHeight;
width += svgWidth;
newLine = false;
} else {
newLine = true;
if (i == 5) {
top = 1000;
svg = svgres.replace('<svg', '<g transform="translate(0,' + top + ')" ');
} else {
svg = svgres.replace('<svg', '<g transform="translate(0,' + top + ')" ');
}
top = Math.max(top, svgHeight);
width += svgWidth;
//width = Math.max(width, chart.chartWidth);
}
}
svg = svg.replace('</svg>', '</g>');
svgArr.push(svg);
txt = texts[i];
txt1 = '<svg width="350" height="75" viewBox="0 0 350 75"><rect x="10" y="50" width="300" height="40" style="fill: white;...