我试图复制这个工具提示只有在点击点时才会出现的弹琴:
http://jsfiddle.net/2swEQ/2/
这是我对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我很确定问题在于JS部分,它没有被rCharts理解。有什么想法吗?帮助?
谢谢,
卡洛斯
发布于 2017-01-02 14:49:07
代码中很少有错误:
a$chart(list(events =应该是a$chart(events =,其结构与a$xAxis(categories =中的结构相同a$plotOptions(events =需要是a$plotOptions(series = list(events =,或者您可以使用另一个系列类型名称来代替系列,但是系列适用于所有系列类型。{和}作为每个函数的主体。工作代码:
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)
)))
ahttps://stackoverflow.com/questions/37745947
复制相似问题