答案 0 :(得分:1)
您可以通过向library(dygraphs)
james<-mtcars[c("mpg","drat")]
james$date<-seq(from=as.Date("2013-05-16"),to=as.Date("2013-06-16"),by="days")
x <- xts::xts(james$mpg, order.by = james$date)
p <- dygraphs::dygraph(x, main = "mpg over time", xlab = "Date", ylab = "mpg") %>%
dygraphs::dyRangeSelector() %>%
dyOptions(drawPoints = TRUE)
p %>%
dyCallbacks("drawPointCallback" = sprintf(
"
function(g, name, ctx, canvasx, canvasy, color, radius, index) {
var drat = %s;
radius = drat[index];
return Dygraph.Circles.DEFAULT(g, name, ctx, canvasx, canvasy, color, radius)
}
",
jsonlite::toJSON(mtcars$drat)
)
)
多次添加它来执行此操作。或者您可以创建两个listItem和一个自定义适配器,您可以在其中添加逻辑以重复一个接一个。