get multiple series data in tooltip - Javascript highcharts

Javascript examples for highcharts:Chart Tooltip

Description

get multiple series data in tooltip

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <title>Highcharts Demo</title> 
      <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. j a v a 2  s  .co m
    $('#container').highcharts({
        chart: {
        },
        xAxis: {
            categories: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul',
                                     'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
        },
           tooltip: {
            formatter: function() {
                var s = [];
                $.each(this.points, function(i, point) {
                    s.push('<span style="color:#D31B22;font-weight:bold;">'+ point.series.name +' : '+
                        point.y +'<span>');
                });
                return s.join(' and ');
            },
            shared: true
        },
       series: [{
        showInLegend: false,
                name: 'Total Click',
                 data: [3000,200,50,4000],
                 color: '#9D9D9D'
            }, {
         showInLegend: false,
                 name: 'Total View',
                 data: [100,2000,3000,4000],
                 color: '#D8D8D8'
            }]
    });
});

      </script> 
   </head> 
   <body> 
      <script src="https://code.highcharts.com/highcharts.js"></script> 
      <div id="container" style="height: 400px"></div>  
   </body>
</html>

Related Tutorials