I'm using chartJSRadar()
function in the radarchart package from Chart.js. I want to customize the colors but I can't figure out how to pass the RGB values. My data looks like this:
Ncount Strong Exclusive
Define 69 19 6
Align 74 9 1
Refine 84 28 0
Assign 77 12 3
Basically I want a different color for each column. The docs say to pass colors as a matrix of RGB colors in colMatrix
. So I've tried-
chartJSRadar(radarcounts, maxScale = 90, addDots = F, lineAlpha = 0,
colMatrix = matrix(c("FF0000","00FF00","0000FF"))
But this just makes all the polygons gray. I can't find working examples of the colMatrix
parameter. What should the colMatrix
look like?
Finally found a way to format RGB values in a matrix format acceptable to Radarchart. I used grDevices::col2rgb
to do so -
c <- grDevices::col2rgb(c("orange","blue", "black"))
Then I just dropped c
into the argument list -
chartJSRadar(radarcounts, maxScale = 90, addDots = F, lineAlpha = 0, colMatrix = c)
There is probably a better way to do this, but this is what I found.