Home > other >  Change color of the legend and the lines in chartJSRadar
Change color of the legend and the lines in chartJSRadar

Time:10-21

I'm trying to build a radar chart with the chartJSRadar function.

Here is the result : enter image description here

And I would like to change the colors but I did'nt find how.. If someone knows it will be so helpfull for me

Thank you,

Elise

CodePudding user response:

From the docs:

colMatrix: Numeric matrix of rgb colour values. If NULL defaults are used

So try adding a matrix with the desired colors in rgb format to your plotting command. For example the following matrix would produce red, green and blue:

matrix(c(255,0,0,0,255,0,0,0,255), nrow = 3, ncol = 3)

     [,1] [,2] [,3]
[1,]  255    0    0
[2,]    0  255    0
[3,]    0    0  255

Here an example using the generated matrix. You would need 4 vecors in your column. So e.g.

chartJSRadar(..., colMatrix=matrix(c(255,0,0,0,255,0,0,0,255,111,111,111), nrow = 3, ncol = 4))
  • Related