Printing a chart to show data for all the points - Javascript highcharts

Javascript examples for highcharts:Chart Data

Description

Printing a chart to show data for all the points

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <meta name="viewport" content="width=device-width, initial-scale=1"> 
      <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script> 
      <script type="text/javascript">
$(function () {//w w w  .  jav  a 2s.  com
        $('#container').highcharts({
            chart: {
                type: 'line',
                events:{
                    load:function() {
                        $('.datalabel').hide();
                    }
                }
            },
            title: {
                text: 'Monthly Average Temperature'
            },
            subtitle: {
                text: 'Source: WorldClimate.com'
            },
            xAxis: {
                categories: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
            },
            yAxis: {
                title: {
                    text: 'Temperature (?C)'
                }
            },
            tooltip: {
                enabled: true,
                formatter: function() {
                    return '<b>'+ this.series.name +'</b><br/>'+
                        this.x +': '+ this.y +'?C';
                }
            },
            plotOptions: {
                line: {
                    dataLabels: {
                        enabled: true,
                        useHTML:true,
                        formatter: function() {
                    return '<div class="datalabel">' +this.series.name +'</b><br/>'+
                        this.x +': '+ this.y +'?C</div>';
                        }
                    },
                    enableMouseTracking: true
                }
            },
            series: [{
                name: 'Tokyo',
                data: [7.0, 6.9, 9.5, 14.5, 18.4, 21.5, 25.2, 26.5, 23.3, 18.3, 13.9, 9.6],
                lineWidth: 0
            }]
        });
            $('button').click(function() {
                $('.datalabel').show();
                var chart = $('#container').highcharts();
                chart.print();
                $('.datalabel').hide();
            });
});

      </script> 
   </head> 
   <body> 
      <script src="https://code.highcharts.com/highcharts.js"></script> 
      <script src="https://code.highcharts.com/modules/exporting.js"></script> 
      <div id="container" style="min-width: 400px; height: 400px; margin: 0 auto"></div> 
      <button>print</button> 
   </body>
</html>

Related Tutorials