【发布时间】:2016-05-22 21:07:30
【问题描述】:
我正在尝试根据 x 轴上的鼠标悬停点将图表顶部的文本设置为自定义值。我以为我正确地关注了 dygraph 网站上的example。有人可以用我下面的例子来解释如何正确地做到这一点吗?
错误:
Error in dygraph(df, { : object 'axes' not found
我的代码:
library(quantmod)
data<-getSymbols("USD/EUR",src="oanda",env=NULL)
df<-as.data.frame(data)
df2<-data.frame(row.names(df))
df2$output<-sample(0:10,length(row.names(df)),replace=T)
library(dygraphs)
#dygraph(df)
dygraph(df, {
axes:{
x:{
valueFormatter: function(dte){
#how to return df2$output with the same date as the date from df that just got passed in?
return(???)
}
}
}
})
获取日期并以标签形式返回正确字符串的函数(在 R 中):
#pass in date to this function
retString<-function(dateFromDygraph){
#returns the data
} #I can write this, I just dont know how to use it in the dygraph code you wrote
【问题讨论】: