rrcharts

Remove legend from rChart


I am using rCharts library in a Shiny application and want to remove the right side legend.

The tips I found did not work in this case... for example: p1$chart(showLegend = FALSE)

My code is similar to this one:

library(rCharts)

mydata<-data.frame(weekday=c("friday","monday","thursday","tuesday","saturday","sunday","wednesday"),value=rnorm(7,10,2))


p1<-rPlot(value ~ weekday, color = 'weekday', data = mydata, type = 'bar')

  p1$guides(
    color = list(
      numticks = length(unique(mydata$weekday))
    ),
    x = list(title="",
             ticks = c('sunday', 'monday', 'tuesday','wednesday','thursday','friday','saturday'),
             labels ="",
             levels = c('sunday', 'monday', 'tuesday','wednesday','thursday','friday','saturday')
    ),
    y = list(title=""
    )
  )


  p1$chart(showLegend = FALSE)

p1

Solution

  • I solved the problem using the following code line:

      p1$set(legendPosition = "none")