所以我有一个有趣的问题 .
这是格式化程序函数在图表配置对象中的位置:
In HighCharts Controller
vm.config = {
options: {
....
chart: {
....
},
navigator: {
....
},
tooltip: {
shared: true,
useHTML: true,
backgroundColor: null,
borderWidth: 0,
shadow: false,
formatter: function(tooltipObj) {
return formatTooltip(tooltipObj, this.points);
}
},
....
我希望能够从我的应用程序中的其他位置调用 formatTooltip
函数 . 但是,1)我该怎么做? 2)如何传入 tooltipObj
?
例如,在我的alertFactory中,我想要当用户将鼠标悬停在plotBand上时发生鼠标悬停事件,以便将更多信息发送到工具提示中:
In AlertsFactory
var formatPlotBand = _.curry((color, alert) => {
return {
color : color,
from : alert.start_epoch * 1000,
to : alert.end_epoch * 1000,
id :'alert-plotband',
events: {
mouseover: function (e) {
/*
Somehow from here call the formatTooltip function
in the highCharts Controller.
*/
},
mouseout: function (e) {
....
1 回答
我不知道
vm
是否是您所调用的图表所以在代码中使用您正在使用的任何变量名称替换chart
.