Highcharter 弃用函数的输出与建议的不同

Highcharter deprecated function's output is different than suggested

我正在使用 Josh Kunst 出色的 highcharter R 库制作时间序列图。

使用此数据:

    > dput(t)
structure(c(2, 2, 267822980, 325286564, 66697091, 239352431, 
94380295, 1, 126621669, 158555699, 32951026, 23, 108000151, 132505189, 
29587564, 120381505, 25106680, 117506099, 22868767, 115940080, 
22878163, 119286731, 22881061), .Dim = c(23L, 1L), index = structure(c(1490990400, 
1490994000, 1490997600, 1491001200, 1491004800, 1491008400, 1491012000, 
1491026400, 1491033600, 1491037200, 1491040800, 1491058800, 1491062400, 
1491066000, 1491069600, 1491073200, 1491076800, 1491109200, 1491112800, 
1491120000, 1491123600, 1491156000, 1491159600), tzone = "US/Mountain", tclass = c("POSIXct", 
"POSIXt")), class = c("xts", "zoo"), .indexCLASS = c("POSIXct", 
"POSIXt"), tclass = c("POSIXct", "POSIXt"), .indexTZ = "US/Mountain", tzone = "US/Mountain", .CLASS = "double", .Dimnames = list(
    NULL, "count"))

我可以画这张图

highcharter::highchart() %>% hc_add_series_xts(t)

但是我收到这个警告:

'hc_add_series_xts' is deprecated.
Use 'hc_add_series' instead.

所以,作为随和的类型,我就是这样做的,而且

highcharter::highchart() %>% hc_add_series(t)  %>% hc_xAxis(type = 'datetime')

我制作了这张图:

问题是我真的很喜欢第一个图底部的 dygraph 风格 window 和滑块,更不用说它在右 y 轴上定位标签了,等等

除了 "please don't deprecate that function",我怎样才能确保第二个输出 - 使用建议的并且很快,似乎只有功能 - 看起来像第一个?

您想要的图形是 'stock' 类型而不是默认的 'chart' 类型(想想 'Highcharts' 与 'Highstock')。

指定类型解决您的问题:

highchart(type = 'stock') %>% 
    hc_add_series(t) %>% 
    hc_xAxis(type = 'datetime')