【问题标题】:How do I set hover parameters on rCharts Rickshaw charts?如何在 rCharts 人力车图表上设置悬停参数?
【发布时间】:2013-10-25 13:22:26
【问题描述】:

这是我的代码:

#Start up rickshaw charts
library(rCharts)
df.plot <- Rickshaw$new()

#Set chart parameters
df.plot$layer(
  y ~ x,
  data = df.aggregate2,
  type = "area",
  groups = "var2",
  colors= c("#E1CA4C","#74D2E3","#B70002","#987989","#9A9A9A","#ACD759","#5FCC5C","#4C6676"),
  height = 500,
  width = 800
)
df.plot$set(
  hoverDetail = TRUE,
  yAxis = TRUE,
  xAxis = TRUE,
  shelving = FALSE,
  legend = TRUE,
  slider = TRUE,
  highlight = TRUE,
  unstack = TRUE,    
)

df.plot$xAxis( tickFormat=
                  "#!function(d) {
                  return d3.time.format('%Y-%m-%d')(new Date( d * 86400000 ));
                  }
                  !#" )
#Plot
df.plot$print('Performance', include_assets = TRUE, cdn = TRUE)

我的悬停看起来像这样:

格林威治标准时间 2013 年 9 月 23 日星期一 00:00:00 变量 1045.00

我希望它看起来像这样: 2013 年 9 月 23 日,星期一 变量 1045 *没有时间&没有小数点。

【问题讨论】:

    标签: r rickshaw rcharts


    【解决方案1】:

    您可以使用hoverDetail 方法并将其传递给格式化程序函数。您需要编写一个 javascript 函数来输出所需的字符串。

    moods.plot$hoverDetail(formatter = "#! function(series, x, y){
    
    } !#")
    

    查看this page的源码可以看到formatter函数的示例

    【讨论】:

      猜你喜欢
      • 2016-09-05
      • 2013-11-17
      • 1970-01-01
      • 1970-01-01
      • 2023-03-05
      • 2012-05-16
      • 2013-09-03
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多