We are using dplot in rCharts (using the dimple library) to try to create a bubble chart in R Shiny. This is all working well but we are having trouble assigning specific colours to specific bubbles (or "Channel" in the code below). We have managed to specify a set of colours using defaultColors but these are assigned to the Channels randomly, not in the way we've specified!
Can anyone help us get the colo(u)rs mapped correctly?
output$BubbleChart2 <- renderChart2({
Channel <- c('TV','Radio','Press')
Spend <- c(100000,50000,20000)
Revenue <- c(500000,100000,30000)
df <- data.frame(Channel,Spend,Revenue)
df$ROI <- (df$Revenue/df$Spend)
r2 <-dPlot(x="Revenue",y="ROI",type="bubble",groups="Channel",z="Spend",data=df,width=750)
r2$defaultColors("#!d3.scale.ordinal().range(['#C2E588','#FDC382','#FC9A8F']).domain(['TV','Radio','Press'])!#")
r2$xAxis(type = "addMeasureAxis")
r2$yAxis(type = "addMeasureAxis")
r2$zAxis(type = "addMeasureAxis")
r2$legend( x = 200,
y = 7,
width = 400,
height = 20,
horizontalAlign = "center" )
return(r2)