jQuery Highcharts

advertisements

So I made this pie chart using the jQuery plugin "Highcharts" and what it gives back to me is the percentage of the total fed into it. What I would also like to do is display specifically the number passed to the plugin. Is this possible and how, what I have is blocked through a login in system but this link is to the exact demo I am using:

http://www.highcharts.com/demo/pie-legend

If you view the source you will see this for the plugin:

$(function () {
    var chart;

    $(document).ready(function () {

        // Build the chart
        chart = new Highcharts.Chart({
            chart: {
                renderTo: 'container',
                plotBackgroundColor: null,
                plotBorderWidth: null,
                plotShadow: false
            },
            title: {
                text: 'Browser market shares at a specific website, 2010'
            },
            tooltip: {
                pointFormat: '{series.name}: <b>{point.percentage}%</b>',
                percentageDecimals: 1
            },
            plotOptions: {
                pie: {
                    allowPointSelect: true,
                    cursor: 'pointer',
                    dataLabels: {
                        enabled: false
                    },
                    showInLegend: true
                }
            },
            series: [{
                type: 'pie',
                name: 'Browser share',
                data: [
                    ['Firefox',   45.0],
                    ['IE',       26.8],
                    {
                        name: 'Chrome',
                        y: 12.8,
                        sliced: true,
                        selected: true
                    },
                    ['Safari',    8.5],
                    ['Opera',     6.2],
                    ['Others',   0.7]
                ]
            }]
        });
    });

});

Under "data" there is the series title and then the value. I specifically want to know what syntax to use to display the numbers like "Firefox"'s 45.0. To display the title you use {series.name} so I am guessing its something like {series.number} but there isn't anywhere in the documentation that specifies this so I am not sure if its even possible. Any help would be appreciated!


I actually found the answer but not through Highcharts documentation, if you're wondering in the formatter you can reference the value you pass to the plugin with this:

this.point.y

Overall my code now looks something like this:

       plotOptions: {
            pie: {
                 allowPointSelect: true,
                 cursor: 'pointer',
                 dataLabels: {
                      enabled: true,
                      color: '#000000',
                      connectorColor: '#000000',
                      formatter: function() {
                           return '<b>'+ this.point.name +'</b>: $'+ this.point.y +' '         + Math.round(this.percentage*10)/10 +' %';
                      }
                 }
            }
       },

Customize tooltip and format the number to 2 decimal places of highcharts