我已经得到了这个在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 += '
Name is = '+ point.name;
s += '
y is = '+point.y;
s += '
Fruit is = ' +point.fruit;
});
工具提示将显示:名称为:undefined y为:216.4 Fruit is:undefined
我希望它显示:名称是:food1 y是:216.4水果是:苹果
这是jsfiddle链接:http://jsfiddle.net/hYtUj/5/
1 回答
您正在以错误的方式访问属性
它应该是这样的
$.each(this.points, function(i, point) { s += '
Name is = '+ point.point.name; s += '
y is = '+point.y; s += '
Fruit is = ' +point.point.fruit; });
更新你的小提琴here
我希望这能帮到您