我正在尝试重现此jsfiddle,其中仅在单击该点时才会显示工具提示:
这是我对rCharts的“翻译”:
a <- rCharts::Highcharts$new()
a$xAxis(categories = c("Jan", "Feb", "Mar", "Apr", "May", "Jun",
"Jul", "Aug", "Sep", "Oct", "Nov", "Dec"))
a$tooltip(valueSuffix = " ºC",
enabled = F)
a$chart(list(events = list(load = "#! function()
this.myTooltip = new Highcharts.Tooltip(this, this.options.tooltip) !#")))
a$plotOptions(events = list(click = "#! function(evt)
this.chart.myTooltip.refresh(evt.point, evt) !#",
mouseOut = "#! function()
this.chart.myTooltip.hide() !#"))
a$series(list(
list(name = "Tokyo",
data = c(7.0, 6.9, 9.5, 14.5, 18.2, 21.5,
25.2, 26.5, 23.3, 18.3, 13.9, 9.6))))
a
我很确定问题出在rCharts无法理解的JS部分。有任何想法吗?帮助?
谢谢,
卡洛斯
您的代码中几乎没有错误:
a$chart(list(events =
应该a$chart(events =
与中的结构相同a$xAxis(categories =
a$plotOptions(events =
需要为,a$plotOptions(series = list(events =
或者您可以使用其他系列类型名称代替series,但是series适用于所有系列类型。
这三个函数必须对每个函数的主体使用{
和}
。
工作代码:
a <- rCharts::Highcharts$new()
a$xAxis(categories = c("Jan", "Feb", "Mar", "Apr", "May", "Jun",
"Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
))
a$tooltip(valueSuffix = " ºC",
enabled = F
)
a$chart(events = list(load = "#! function() {
this.myTooltip = new Highcharts.Tooltip(this, this.options.tooltip);
} !#"
))
a$plotOptions(series = list(events = list(click = "#! function(evt) {
this.chart.myTooltip.refresh(evt.point, evt);
} !#",
mouseOut = "#! function() {
this.chart.myTooltip.hide();
} !#"
)))
a$series(list(list(name = "Tokyo",
data = c(7.0, 6.9, 9.5, 14.5, 18.2, 21.5,
25.2, 26.5, 23.3, 18.3, 13.9, 9.6)
)))
a
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句