set tooltip value suffix - Javascript highcharts

Javascript examples for highcharts:Chart Tooltip

Description

set tooltip value suffix

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <title>when all category series values equal 0</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  av  a 2s.  c om*/
    var data = [{
        name: 'Year 1800',
        data: [0, 0, 0, 0, 0]
    }, {
        name: 'Year 1900',
        data: [0, 156, 947, 408, 6]
    }, {
        name: 'Year 2008',
        data: [0, 914, 4054, 732, 34]
    }];
    data = $.grep(data, function (category) {
        return $.grep(category.data, function (item) {
            return item > 0;
        }).length > 0;
    });
    $('#container').highcharts({
        chart: {
            type: 'bar'
        },
        title: {
            text: 'Historic World Population by Region'
        },
        subtitle: {
            text: 'Source: Wikipedia.org'
        },
        xAxis: {
            categories: ['Africa', 'America', 'Asia', 'Europe', 'Oceania'],
            title: {
                text: null
            }
        },
        yAxis: {
            min: 0,
            title: {
                text: 'Population (millions)',
                align: 'high'
            },
            labels: {
                overflow: 'justify'
            }
        },
        tooltip: {
            valueSuffix: ' millions'
        },
        plotOptions: {
            bar: {
                dataLabels: {
                    enabled: true
                }
            }
        },
        legend: {
            layout: 'vertical',
            align: 'right',
            verticalAlign: 'top',
            x: -100,
            y: 100,
            floating: true,
            borderWidth: 1,
            backgroundColor: '#FFFFFF',
            shadow: true
        },
        credits: {
            enabled: false
        },
        series: data
    });
});

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