首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >高级图表(rCharts)点击工具提示

高级图表(rCharts)点击工具提示
EN

Stack Overflow用户
提问于 2016-06-10 10:29:06
回答 1查看 224关注 0票数 2

我试图复制这个工具提示只有在点击点时才会出现的弹琴:

http://jsfiddle.net/2swEQ/2/

这是我对rCharts的“翻译”:

代码语言:javascript
复制
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理解。有什么想法吗?帮助?

谢谢,

卡洛斯

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2017-01-02 14:49:07

代码中很少有错误:

  1. a$chart(list(events =应该是a$chart(events =,其结构与a$xAxis(categories =中的结构相同
  2. a$plotOptions(events =需要是a$plotOptions(series = list(events =,或者您可以使用另一个系列类型名称来代替系列,但是系列适用于所有系列类型。
  3. 这三个函数都必须使用{}作为每个函数的主体。

工作代码:

代码语言:javascript
复制
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
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/37745947

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档