我已经在highcharts中得到了这个例子的例子,但我很难让它在highstocks中工作。我试图让我的工具提示显示一些关于系列中提供的点的额外信息,但似乎我在系列数据哈希中放置的值没有被正确保存。 X和Y字段设置正常,因为我可以看到图形正确显示,但我的其他“水果”和“名称”字段在工具提示中报告为空。
以下是我的系列数据示例:
{
name: 'food1',
fruit: 'apple',
x: Date.UTC(2010, 0, 1),
y: 216.4
},
{
name: 'food2',
fruit: 'banana',
x: Date.UTC(2010, 0, 4),
y: 116.4
}
这是我的工具提示格式化程序中的循环:
$.each(this.points, function(i, point) {
s += '<br/>Name is = '+ point.name;
s += '<br/>y is = '+point.y;
s += '<br/>Fruit is = ' +point.fruit;
});
工具提示将显示: 名称是:undefined y是:216.4 水果是:未定义
我想要它显示: 名称是:food1 y是:216.4 水果是:苹果
这是jsfiddle链接: http://jsfiddle.net/hYtUj/5/
答案 0 :(得分:1)
您正在以错误的方式访问属性
应该是这样的
$.each(this.points, function(i, point) {
s += '<br/>Name is = '+ point.point.name;
s += '<br/>y is = '+point.y;
s += '<br/>Fruit is = ' +point.point.fruit;
});
更新了你的小提琴here
我希望这会对你有所帮助