Highcharts Demo

author(s): Torstein Hønsi

by Michel Penke

HTML

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

<div id="container" style="height: 400px"></div>

CSS

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

.custom-btn  {
   fill: url(#custom-btn-bg);
   color: red;
   font-size: 200px;
   
}

JavaScript

$(function() {
  var chart = new Highcharts.Chart({

    chart: {
      renderTo: 'container'
    },

    defs: {
      custombtnbg: {
        tagName: 'pattern',
        id: 'custom-btn-bg',
        x: 0,
        y: 0,
        width: 24,
        height: 24,
        children: [{
          tagName: 'image',
          width: 24,
          height: 24,
          href: 'https://png.icons8.com/metro/1600/expand.png'
        }]
      }
    },

    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]
    }],

    exporting: {
      buttons: {
        customButton: {
          x: -62,
          id: 'btn',
          onclick: function() {
            alert('Clicked');
          },
          text: 'test',
          className: 'custom-btn',
          theme: {
          	'stroke-width': 0,
            color: 'red',
            fontWeight: 'bold'
          }
        }
      }
    }
  });
});