JSFiddle - React, Tailwind, and code Playground

by HemalathaThanigaivel

HTML

<script src="https://code.highcharts.com/js/highcharts.js"></script>
<script src="https://code.highcharts.com/js/modules/exporting.js"></script>

<div id="container"></div>
<h2>
Exported image below
</h2>
<img id="image"/>

CSS

@import 'https://code.highcharts.com/css/highcharts.css'

JavaScript

var options = {
  chart: {},
  xAxis: {
    categories: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun',
      'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'
    ]
  },
  series: [{
    data: [29.9, 71.5, 106.4, 129.2, 144.0, 176.0, 135.6, 148.5, 216.4, 194.1, 95.6, 54.4],
    type: 'column'
  }]
}

var chart = Highcharts.chart('container', options);

var data = {
    options: JSON.stringify(options),
    resources: {
    	// You can add your CSS styles here
    	css: ".highcharts-background { fill: #efefef; stroke: #a4edba; stroke-width: 2px}"
    },
    width: 100,
    height: 100,
    filename: 'test.png',
    type: 'image/png',
    async: true
};

var exportUrl = 'https://export.highcharts.com/';
$.post(exportUrl, data, function(data) {
    var imageUrl = exportUrl + data;
    console.log(exportUrl, imageUrl)
    var urlCreator = window.URL || window.webkitURL;
    document.querySelector("#image").src = imageUrl;
    fetch(imageUrl).then(response => response.blob()).then(data => {console.log(data)});
});