如何使用rCharts动态地将点添加到高图中的系列

时间:2015-10-22 10:54:15

标签: r highcharts rcharts

我正在尝试在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数据帧转换为向量,看看是否有效,但无济于事。

0 个答案:

没有答案