点对象中的额外数据不适用于工具提示

时间:2013-03-27 19:57:13

标签: highcharts

在Highcharts中,我的数据设置如下:

var data = [{
    x: Date.UTC(2011, 10, 1),
    y: 1.9,
    variance: 2.6
}, {
    x: Date.UTC(2011, 11, 1),
    y: 2.0,
    variance: 2.6
}...];

我想在工具提示中使用方差值。但方差值不会显示在工具提示格式化程序可用的点对象中。我错过了什么?

JSFiddle:http://jsfiddle.net/hofo/um7f6/17/

2 个答案:

答案 0 :(得分:1)

将格式化程序字符串修复为以下内容:

var tooltipString = "Highcharts.dateFormat('%b-%y', this.x) + ' survey<br>Average inflation expectations: ' + this.y + '<br>Variance ' + point.point.variance";

然后您应该将其添加到detailChart数据中。

detailData.push(point.y);更改为detailData.push(point.options);

Demo

答案 1 :(得分:1)

请查看类似示例http://jsfiddle.net/fbMQf/119/

    tooltip:{
    formatter:function(){
        return '<b>' + this.series.name + '</b>' + 
        '<br/><b>X Value:</b> ' + this.x +
        '<br/><b>Y Value:</b> ' + this.y +
        '<br/><b>Other Data:</b> ' + this.point.note;
    }
},