tooltip set up for chart - Javascript highcharts

Javascript examples for highcharts:Chart Tooltip

Description

tooltip set up for chart

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 () {/*from w  w  w .j a va 2s .com*/
    var chart;
    $(document).ready(function () {
        var chartType = 2;
        chart = new Highcharts.Chart({
            chart: {
                renderTo: 'container',
                type: 'scatter'
            },
            tooltip: {
                valueSuffix: '',
                pointFormat: (chartType == 1 ? '{series.name}: {point.y}' : null),
                shared: (chartType == 1 ? true : false),
                formatter: (chartType == 1 ? null : function () {
                    if (chartType == 2) {
                        return '' + this.point.tooltip + ': ' + (chartType == 2 ? this.y.toFixed(1) : this.y.toFixed(0));
                    } else {
                        return false;
                    }
                })
            },
            series: [{
                name: 'Female',
                color: 'rgba(223, 83, 83, .5)',
                data: [
                    [161.2, 51.6],
                    [167.5, 59.0],
                    [159.5, 49.2]
                ]
            }]
        });
    });
});

      </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>  
   </body>
</html>

Related Tutorials