无法让 Highcharter 绘制时间序列
Cannot get Highcharter to plot time series
尝试用 Highcharter 绘制一些时间序列数据
数据如下:
time <- c("2018-04-23 10:14:39 UTC", "2018-04-23 10:16:41 UTC", "2018-04-23 10:16:42 UTC", "2018-04-23 10:16:51 UTC", "2018-04-23 10:16:54 UTC", "2018-04-23 10:18:23 UTC")
min <- c(0.00020522, 0.00020520, 0.00020517, 0.00020500, 0.00020500, 0.00020522)
max <- c(0.00020527, 0.00020525, 0.00020517, 0.00020550, 0.00020500, 0.00020522)
dff <- data.frame(min, max)
dff$time <- as.POSIXct(time)
tib <- as_tibble(dff)
下面的所有代码变体都会产生 "No data to display" 消息,在 Linux 和 Windows 上也是如此:
hchart(tib, type = "errorbar", hcaes(x = time, ymin = min, ymax = max))
highchart() %>% hc_add_series(tib, "errorbar", hcaes(x = time, ymin = min, ymax = max))
hchart(tib, type = "errorbar", hcaes(x = datetime_to_timestamp(time), ymin = min, ymax = max))
highchart() %>% hc_add_series(tib, "errorbar", hcaes(x = datetime_to_timestamp(time), ymin = min, ymax = max))
更新
能够按照建议 :
通过用 datetime_to_timestamp
转换时间变量来绘制 "line"
highchart() %>% hc_add_series(tib, "line", hcaes(x = datetime_to_timestamp(time), y = min))
hchart(tib, type = "line", hcaes(x = datetime_to_timestamp(time), y = min))
同时错误栏ggplot
代码运行正常:
ggplot() + geom_errorbar(data = tib, aes(x = time, ymin = min, ymax = max))
就是这样:
highchart() %>%
hc_add_series(data = tib, "errorbar", hcaes(x = datetime_to_timestamp(time), low = min, high = max)) %>%
hc_xAxis(type = 'datetime')
尝试用 Highcharter 绘制一些时间序列数据
数据如下:
time <- c("2018-04-23 10:14:39 UTC", "2018-04-23 10:16:41 UTC", "2018-04-23 10:16:42 UTC", "2018-04-23 10:16:51 UTC", "2018-04-23 10:16:54 UTC", "2018-04-23 10:18:23 UTC")
min <- c(0.00020522, 0.00020520, 0.00020517, 0.00020500, 0.00020500, 0.00020522)
max <- c(0.00020527, 0.00020525, 0.00020517, 0.00020550, 0.00020500, 0.00020522)
dff <- data.frame(min, max)
dff$time <- as.POSIXct(time)
tib <- as_tibble(dff)
下面的所有代码变体都会产生 "No data to display" 消息,在 Linux 和 Windows 上也是如此:
hchart(tib, type = "errorbar", hcaes(x = time, ymin = min, ymax = max))
highchart() %>% hc_add_series(tib, "errorbar", hcaes(x = time, ymin = min, ymax = max))
hchart(tib, type = "errorbar", hcaes(x = datetime_to_timestamp(time), ymin = min, ymax = max))
highchart() %>% hc_add_series(tib, "errorbar", hcaes(x = datetime_to_timestamp(time), ymin = min, ymax = max))
更新
能够按照建议
datetime_to_timestamp
转换时间变量来绘制 "line"
highchart() %>% hc_add_series(tib, "line", hcaes(x = datetime_to_timestamp(time), y = min))
hchart(tib, type = "line", hcaes(x = datetime_to_timestamp(time), y = min))
同时错误栏ggplot
代码运行正常:
ggplot() + geom_errorbar(data = tib, aes(x = time, ymin = min, ymax = max))
就是这样:
highchart() %>%
hc_add_series(data = tib, "errorbar", hcaes(x = datetime_to_timestamp(time), low = min, high = max)) %>%
hc_xAxis(type = 'datetime')