0

我正在检查这个图表库 highcharts .. 我想知道它如何在这个例子http://jsfiddle.net/wvT85/工具提示选项中的 stackTotal 中显示,是否有可能得到一个差异而不是总数:

    $(function () {
var chart;
$(document).ready(function() {
    chart = new Highcharts.Chart({

        chart: {
            renderTo: 'container',
            type: 'column'
        },

        title: {
            text: 'Total fruit consumtion, grouped by gender'
        },

        xAxis: {
            categories: ['Apples', 'Oranges', 'Pears', 'Grapes', 'Bananas']
        },

        yAxis: {
            allowDecimals: false,
            min: 0,
            title: {
                text: 'Number of fruits'
            }
        },

        tooltip: {
            formatter: function() {
                return '<b>'+ this.x +'</b><br/>'+
                    this.series.name +': '+ this.y +'<br/>'+
                    'Total: '+ this.point.stackTotal;
            }
        },

        plotOptions: {
            column: {
                stacking: 'normal'
            }
        },

        series: [{
            name: 'John',
            data: [5, 3, 4, 7, 2],
            stack: 'male'
        }, {
            name: 'Joe',
            data: [3, 4, 4, 2, 5],
            stack: 'male'
        }, {
            name: 'John',
            data: [2, 5, 6, 2, 1],
            stack: 'male2'
        }, {
            name: 'Joe',
            data: [3, 0, 4, 4, 3],
            stack: 'male2'
        }]
      });
     });

  });
4

1 回答 1

0

stackTotalstackKey是 Highcharts API 在ie的基础上合计值the name of stack given。这些 API 没有记录,也没有出现在官方网站上。

要找到差异,请使用:

'Diff: '+ Math.abs(this.point.stackTotal-this.y);

链接:http: //jsfiddle.net/androdify/wvT85/70/

此外,为了更好地控制工具提示,请参阅共享工具提示格式化程序http://api.highcharts.com/highcharts#tooltip

于 2013-06-26T06:59:05.033 回答