【问题标题】:rCharts NVD3 custom tooltiprCharts NVD3 自定义工具提示
【发布时间】:2023-03-18 03:25:01
【问题描述】:

我想创建movies 数据集的散点图,当用户滚动一个点时,它将显示电影的标题。使用来自rCharts rNVD3 tooltip customisation 的答案,我写了以下内容:

movies <- data(movies)
p1 <- nPlot(length ~ votes,
            group = 'mpaa', 
            data = movies, 
            type = 'scatterChart',
            #the following line seems to have NO EFFECT:
            tooltip = "#!function(item){ return item.title + ' ' + '('+item.year+')'}!#")
#item is not a valid input to the tooltipContent function
p1$chart(tooltipContent = "#! function(key, x, y){ 
            return key + ' '+item.year
            } !#")
p1$print("chart3")
p1

如上面的嵌入式 cmets 中所述,这些自定义工具提示的尝试都不适合我。

【问题讨论】:

    标签: r tooltip rcharts nvd3.js


    【解决方案1】:

    您将polycharts 的工具提示规范与nvd3 混淆。 rCharts 只是一个包装器,可让您访问这些 js 库中的功能,并且由于每个库都有不同的方式让您指定工具提示,因此情况有所不同。以下是如何使其工作

    p1$chart(tooltipContent = "#! function(key, x, y, e){ 
      return key + ' ' + e.point.year
    } !#")
    p1
    

    【讨论】:

      猜你喜欢
      • 2013-07-05
      • 2020-11-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-03-28
      • 2014-09-08
      • 2018-06-08
      • 1970-01-01
      相关资源
      最近更新 更多