Custom print button and export button - Javascript highcharts

Javascript examples for highcharts:Print

Description

Custom print button and export button

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <title>Highcharts Demo</title> 
      <meta name="viewport" content="width=device-width, initial-scale=1"> 
   </head> 
   <body> 
      <script src="https://code.jquery.com/jquery-3.1.1.min.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/export-data.js"></script> 
      <div id="container" style="min-width: 310px; height: 400px; max-width: 600px; margin: 0 auto"></div> 
      <script type="text/javascript">
// Build the chart
Highcharts.chart('container', {
    chart: {//from www.  j  a  v a 2  s .  c o  m
        plotBackgroundColor: null,
        plotBorderWidth: null,
        plotShadow: false,
        type: 'pie'
    },
    title: '',
    tooltip: {
        pointFormat: '{series.name}: <b>{point.percentage:.1f}%</b>'
    },
    lang: {
       yourKey: "Custom button tooltip text",
       myKey:"Bad Store"
    },
    exporting: {
          buttons: {
            contextButton: {
              enabled: false
            },
            exportButton: {
                text: `Chrome`,
                _titleKey: "yourKey",
                onclick:function(){
                console.log('clicked Chrome');
                },
                x:-410
            },
            printButton: {
                enabled: false,
                text: `IE: `,
                 _titleKey:"myKey",
                onclick: function () {
                    console.log('clicked IE');
                },
                x:-400,
                y:30
            },
          }
        },
    plotOptions: {
        pie: {
            allowPointSelect: true,
            cursor: 'pointer',
            dataLabels: {
                enabled: false
            },
            showInLegend: true
        }
    },
    series: [{
        name: 'Brands',
        colorByPoint: true,
        data: [{
            name: 'Chrome',
            y: 61.41,
            sliced: true,
            selected: true
        }, {
            name: 'Internet Explorer',
            y: 11.84
        }]
    }]
});

      </script>  
   </body>
</html>

Related Tutorials