Вопрос

This is the code I have:

#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)

My hover looks like this:

Mon, 23 September 2013 00:00:00 GMT var 1045.00

And I want it to look like this: Mon, 23 September 2013 var 1045 *without the time & without the decimal points.

Это было полезно?

Решение

You can use the hoverDetail method and pass it a formatter function. You will need to write a javascript function that outputs the required string you want.

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

} !#")

You can see an example of the formatter function by viewing the source of this page

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top