Titles

Simple title

Titles can be added thanks to the cjsTitle function:

chartjs(mtcars[1:10,], mpg, qsec) %>% 
  cjsBar %>% 
  cjsTitle(title = "mpg and qsec")

Position

chartjs(mtcars[1:10,], mpg, qsec) %>% 
  cjsBar %>% 
  cjsTitle(title = "mpg and qsec", position = "bottom")

Styling

chartjs(mtcars[1:10,], mpg, qsec) %>% 
  cjsBar %>% 
  cjsTitle(title = "mpg and qsec", fontColor = "#FF00FC", fontFamily = "Times", fontSize = 15, fontStyle = "bold", padding = 20)

Legends

Simple legend

Legends can be added thanks to the cjsLegend function:

chartjs(mtcars[1:10,], mpg, qsec) %>% 
  cjsBar %>% 
  cjsLegend

Clicking on a legend box removes this dataset from the plot.

Position

chartjs(mtcars[1:10,], mpg, qsec) %>% 
  cjsBar %>% 
  cjsLegend(position = "bottom")

Styling

chartjs(mtcars[1:10,], mpg, qsec) %>% 
  cjsBar %>% 
  cjsLegend(labels = list(boxWidth = 15, fontColor = "#FF00FC", fontFamily = "Times", fontSize = 15, fontStyle = "bold", padding = 20))