[英]Change Highcharts tooltip formatter from chart Object , after chart is rendered
I have found that I can change series with setData, and I know I can modify Max values with .setExtremes , but I cannot figure out how to set the tooltip formatter from the chart object. 我发现我可以使用setData更改系列,并且我知道我可以使用.setExtremes修改Max值,但我无法弄清楚如何从图表对象设置工具提示格式化程序。 How do I update that field ?
如何更新该字段? If i have a chart object , how do I update its tooltip formatter property ?
如果我有一个图表对象,如何更新其tooltip格式化程序属性? and How about the plotOptions tooltip formatter?
plotOptions工具提示格式化怎么样?
What I have tried : 我尝试过的:
chart1.tooltip.formatter = function() {return ''+this.series.name +'example: '+ this.y +'example';};
But nothing changed in my tooltips when i added that after the chart definition (for testing). 但是当我在图表定义之后添加(用于测试)时,我的工具提示没有任何改变。 Also, I noted that this
另外,我注意到了这一点
console.log (chart1.tooltip.formatter);
returns undefined, but I don't know why. 返回undefined,但我不知道为什么。
Fiddle so you can try it out. 小提琴让你可以尝试一下。
http://jsfiddle.net/pCuUW/5/ Thanks in advance. http://jsfiddle.net/pCuUW/5/提前致谢。
You can use chart.tooltip.options.formatter
instead, like 您可以使用
chart.tooltip.options.formatter
来代替
chart.tooltip.options.formatter = function() {
var xyArr=[];
$.each(this.points,function(){
xyArr.push('Serie: ' + this.series.name + ', ' +'X: ' + this.x + ', Y: ' +this.y);
});
return xyArr.join('<br/>');
}
Changing tooltip formatter dynamically | 动态更改工具提示格式化程序 Highchart & Highstock @ jsFiddle
Highchart&Highstock @ jsFiddle
UPDATE In new (5.0.0+) versions of highcharts, this can also be done using the chart.update()
method 更新在新的(5.0.0+)版本的highcharts中,这也可以使用
chart.update()
方法完成
chart.update({
tooltip: {
formatter: function() {
var xyArr = [];
$.each(this.points, function() {
xyArr.push('Serie: ' + this.series.name + ', ' + 'X: ' + this.x + ', Y: ' + this.y);
});
return xyArr.join('<br/>');
}
}
});
Changing tooltip formatter dynamically with chart.update | 使用chart.update |动态更改工具提示格式化程序 Highchart & Highstock @ jsFiddle
Highchart&Highstock @ jsFiddle
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.