如何设置高分辨率全局选项IN R [英] How to set highchart global options IN R
问题描述
我在javascript中看到很多例子,但是我无法找到一个例子来做这件事。
下面是api链接: http://api.highcharts.com/highcharts#global我尝试设置timezoneOffset,并尝试了很多不同的方法。
当我在R:highChart $ global(timezoneOffset = -300)
中执行此操作时,我没有收到任何警告或错误信息,但它不起作用。
以下是一段代码:
library(rCharts)
highChart< - Highcharts $ new()
highChart $ global(timezoneOffset = -300)
highChart $ chart(zoomType =xy)
highChart $ exporting(enabled = T)
highChart $ xAxis(type =datetime,list(title = list(text =Time)))
highChart $ yAxis(list
(
list(title = list(text =Variance))
))
highChart $ series (x = 1407795846000,y = 2),c(x = 1407795847000,y = 3)))
highChart
正如您所看到的,当我运行这段代码并且时间仍然显示时,timezoneOffset不起作用在GMT。
highcharter选项s可以被访问,但是它们被设置在列表元素 highcharter.options
下的标准R选项中。它们不是直接给予highchart,而是在 highchart()
内部,有代码行 opts< - getOption(highcharter.options ,list())
。
我不认为除了获取选项之外,还有其他方法可以改变你需要改变的选项然后再添加选项来设置选项。
以下是一个简单的例子:
library(highcharter)
#正常高图
高图(%)>%
hc_add_serie_labels_values(1:901,seq(1,10,0.01))
opts < - getOption(highcharter.options)
opts $ lang $ decimalPoint< - 。
选项(highcharter.options = opts)
#现在用,代替。。 (在工具提示中确认)
highchart()%>%
hc_add_serie_labels_values(1:901,seq(1,10,0.01))
当然对于您的情况,您需要设置 $ global $ timezoneOffset
部分。
I see a lot of examples in javascript but I cannot find an example to do it in R
Here is the api link: http://api.highcharts.com/highcharts#global
I am trying to set "timezoneOffset" and I have tried many different ways. When I do this in R: highChart$global(timezoneOffset=-300) I do not get any warning or error, but it's not working.
Thanks a lot for the help!
Here is a piece of code:
library(rCharts)
highChart <- Highcharts$new()
highChart$global(timezoneOffset=-300)
highChart$chart(zoomType = "xy")
highChart$exporting(enabled = T)
highChart$xAxis(type="datetime",list( title = list(text = "Time")))
highChart$yAxis(list
(
list(title = list(text = "Variance"))
))
highChart$series(data=list(c(x=1407795845000,y=1),c(x=1407795846000,y=2),c(x=1407795847000,y=3)))
highChart
As you can see, the timezoneOffset is not working when I run this piece of code and the time is still displayed in GMT.
The highcharter options can be accessed, but they are set inside the standard R options under the list element highcharter.options
. They are not given directly to the highchart, and inside highchart()
, there is the code line opts <- getOption("highcharter.options", list())
.
I don't think there is another way than just get the options, alter whatever options you need to change and then set the options again with your additions.
The following is a simple illustration:
library(highcharter)
# normal highchart
highchart() %>%
hc_add_serie_labels_values(1:901, seq(1, 10, 0.01))
opts <- getOption("highcharter.options")
opts$lang$decimalPoint <- "."
options(highcharter.options = opts)
# now with "," instead of "." (confirm in tooltip)
highchart() %>%
hc_add_serie_labels_values(1:901, seq(1, 10, 0.01))
Of course in your case, you need to set the $global$timezoneOffset
part.
这篇关于如何设置高分辨率全局选项IN R的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!