Search code examples
rrchartspolychart

rCharts polychart change color of lines


Working with the polychart library in rCharts and creating a bar chart with a line chart overlaid. Basically the bars represent performance of different programs on a single metric, and I am laying a horizontal line where the national average is.

Here's the script I've written, including dummy data:

dummy<-setNames(
  data.frame(c("x1","x2","x3","x4"),
             c(3,4,2,6),
             rep(4,4)),
  c("program","score","national")
)

testplot<-rPlot(score~program,data=dummy,type="bar")
testplot$layer(national~program,data=dummy,type="line")

I'd like the national line to be a different color, like bright red or something (and if you can tell me how to make it thicker, much obliged). I know nothing about javascript, so digging into polycharts programming is a little scary for me. Perhaps the best answer is "go and learn javascript", but please refrain from that answer:)


Solution

  • OK, randomly found my answer:

    testplot$layer(national~program,data=dummy,type="line",color = list(const = 'blue'))