Highcharter弃用功能的输出与建议的不同 [英] Highcharter deprecated function's output is different than suggested

查看:263
本文介绍了Highcharter弃用功能的输出与建议的不同的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在与Josh Kunst的优秀 highcharter 库一起制作时间序列图。

使用这些数据:

 >输入(t)
结构(c(2,2,267822980,325286564,66697091,239352431,
94380295,1,126621669,158555699,32951026,23,108000151,132505189,
29587564, (c)(1490990400,
1490994000,1490997600,1491001200,1491004800,149004800,1491004800,1491004800,1491004800,149004800,1491004800,1491004800, ,1491008400,1491012000,
1491026400,1491033600,1491037200,1491040800,1491058800,1491062400,
1491066000,1491069600,1491073200,1491076800,1491109200,1491112800,
1491120000,1491123600,1491156000,1491159600,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'已被弃用。 
改为使用'hc_add_series'。

所以,做一个随和的类型,
$ b

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

我制作此图:



问题是我真的很喜欢 dygraph 样式的窗口和滑块在底部的第一个图表,更不用说它将标签定向在正确的y轴上等。



除了请不要弃用那个函数我开始确保第二个输出 - 使用建议的和很快的,似乎只有功能 - 看起来像第一个输出?

解决方案

你想要的图表是类型'股票',而不是默认的'图表' (认为​​'Highcharts'vs'Highstock')。



指定类型可以解决您的问题:

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


I am producing a time series plot with Josh Kunst's excellent highcharter library in R.

Using this data:

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

I can make this graph

with

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

But I get this warning:

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

So, being the easy-going type, I do exactly that and with

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

I make this graph:

The problem is I really like that little dygraph-style window and slider at the bottom of the first graph, not to mention that it orients the labels on the right y-axis, etc.

Other than "please don't deprecate that function" how can I go about making sure the second output - using the suggested and soon, it seems, only function - looks like the first?

解决方案

The graph you want is of type 'stock' instead of the default 'chart' (think 'Highcharts' vs 'Highstock').

Specifying the type solve your issue:

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

这篇关于Highcharter弃用功能的输出与建议的不同的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆