【发布时间】:2016-01-13 15:20:00
【问题描述】:
我正在尝试在我在 R 中创建的 highcharts 图表上获取正确的日期 X 轴。当我将变量用作 Date highcharts 似乎不理解它并且当我将所有 X 标签转换为字符时显示出来了,看起来不太好。使用 rCharts 包中的 NVD3 图表,有一个选项 reduceXticks=TRUE 可以解决这个问题。也许有一个等价物?
例子:
# data
df <- data.frame(x = 1:100, y = rnorm(100), s = 100*rnorm(100), z = 10*rnorm(100),Date=
as.POSIXct(seq(Sys.Date(), by = 1, length.out = 100)))
# chart 1
h1 <- Highcharts$new()
h1$xAxis(categories=df$Date,type = "datetime")
h1$yAxis(list(list(title = list(text = 'x'), opposite = FALSE),
list(title = list(text = 'y'), opposite = TRUE),
list(title = list(text = 's'), opposite = TRUE)))
h1$series(name = 'x', type = 'line', color = '#000099',
data = df$x)
h1$series(name = 'y', type = 'line', color = '#FF0000',
data = df$y, yAxis=1)
h1$series(name = 's', type = 'line', color = '#006600',
data = df$s, yAxis=2)
h1
#-------------------------------------------------------------#
h1 <- Highcharts$new()
h1$xAxis(categories=as.character(df$Date),type = "datetime")
h1$yAxis(list(list(title = list(text = 'x'), opposite = FALSE),
list(title = list(text = 'y'), opposite = TRUE),
list(title = list(text = 's'), opposite = TRUE)))
h1$series(name = 'x', type = 'line', color = '#000099',
data = df$x)
h1$series(name = 'y', type = 'line', color = '#FF0000',
data = df$y, yAxis=1)
h1$series(name = 's', type = 'line', color = '#006600',
data = df$s, yAxis=2)
h1
【问题讨论】:
标签: r highcharts shiny axis