我正在尝试在highcharts
包中动态添加rCharts
的数据点。我的问题是我无法获得额外的积分。我没有收到任何错误消息。我的数据是通过Google Analytics Real-Time API调用的。
我的代码是
#My initial plot here works fine
a <- hPlot(active.users ~ timestamp, data = realDataFrame,
type = 'spline', title = 'SBK Users per Minute', subtitle = 'Real-Time')
a$global(useUTC = TRUE)
a$xAxis(type='datetime',labels = list(format = '{value:%H:%M}'))
a$yAxis(floor = 0, gridLineColor = '#ffffff')
a
# Attempt to add point with while loop
while(TRUE){
Sys.sleep(3)
print(realDataAdd <- get_realtime(id, metrics = 'rt:activeUsers',
filters = 'rt:pagePath=@www.mybiz.com/url/'))
print(timestamp <-as.numeric(Sys.time())*1000)
print(realDataAdd <- cbind(realDataAdd, timestamp))
print(realDataAdd <- as.vector(realDataAdd, mode = 'numeric' ))
print(a$series(addPoint = realDataAdd ,list(redraw = TRUE, shift = FALSE)))
}
任何帮助都会很棒。我也尝试将realDataAdd
数据帧转换为向量,看看是否有效,但无济于事。