Saturday 15 August 2015

r - rCharts: Change the individual point colors of a time series plot (Highcharts) -



r - rCharts: Change the individual point colors of a time series plot (Highcharts) -

i trying create time-series plot using plotting interface of rcharts highcharts library. trying figure out how can set color of individual point depending on y-value. found way have different colors line , points, group, not info points individually.

here's test code:

library(rcharts) library(rjson) transformdate <- function(x){ as.numeric(as.posixct(x, origin="1970-01-01")) * 1000 } x <- transformdate(c('2013-01-01 11:05:35', '2013-03-03 04:50:35', '2013-05-05 21:09:37', '2013-07-07 12:49:05')) y <- c(1,56,123,1000) w<-transformdate(c('2013-01-10 11:05:35', '2013-03-13 04:50:35', '2013-05-15 21:09:37', '2013-07-17 12:49:05')) z<-c(10, 100, 70, 500) df1 <- data.frame(x = x,y = y) df2 <- data.frame(x = w, y = z) combo <- rcharts:::highcharts$new() combo$series(list(list(data = rcharts::tojsonarray2(df1, json = f, names = f), name = "temp1", marker = list(fillcolor = c('#999'), linewidth=6, linecolor=c('#999'))), list(data = rcharts::tojsonarray2(df2, json = f, names = f), name = "temp2"))) combo$xaxis(type='datetime') combo$chart(type = "scatter") combo$chart(zoomtype="x") combo

i believe can done in polycharts reason why using highcharts plots time-series info nicely , has cool zoom-in functionality.

thanks in advance help & suggestions. jan

here's 1 way command color/size lines/markers separately:

h <- rcharts:::highcharts$new() h$series(list( list(data = rcharts::tojsonarray2(df1, json = false, names = false), name = "big reds", color = '#ff0000', linewidth = 4, marker = list( fillcolor = '#ffa500', radius = 10) ), list(data = rcharts::tojsonarray2(df2, json = false, names = false), name = "small blues", color = '#0000ff', linewidth = 2, marker = list( fillcolor = '#add8e6', radius = 6) ))) h$xaxis(type = 'datetime') h$chart(type = "scatter") h$chart(zoomtype = "x") h

r highcharts rcharts

No comments:

Post a Comment