Change color on single-series line chart using rCharts and Highcharts?
Posted
by
Sharon
on Stack Overflow
See other posts from Stack Overflow
or by Sharon
Published on 2014-06-11T21:32:17Z
Indexed on
2014/06/12
15:25 UTC
Read the original article
Hit count: 412
Is it possible to change the color of a line using rCharts and Highcharts so that the line color changes depending on a factor? I've done this with ggplot2 but would like to make an interactive version if possible. I've tried
h1 <- Highcharts$new()
h1$chart(type="line")
h1$series(data=mydf$myvalue, name="", groups = c("myfactor"))
h1$xAxis(tickInterval = 4, categories = mydf$myXaxis)
but that's not working, line stays the same color. Sample data
myvalue <- c(16, 18, 5, 14, 10)
myXaxis <- c(1,2,3,4,5)
myfactor <- c("old", "old", "old", "new", "new")
mydf <- data.frame(myvalue, myXaxis, myfactor)
Thanks for any suggestions.
© Stack Overflow or respective owner