TL;DR Question: Can I remove the Legend to be displayed when using the Line Chart option in the RpivotTable package in Rstudio/Shiny?
Hi all,
I am extremely new to Stack Overflow and also R, Rstudio and Shiny a real noob.
I absolutely adore the rpivotTable package!
I am probably being a bit too ambitious but I am hoping to use Shiny, and rpivotTable package to replicate dashboards I had created previously in Excel utilizing multiple pivot tables and connected to slicers...
Unfortunately the data sets/data frames I am using have a large amount of variables, when I construct Line Charts using the rpivotTable package the legend fills the entire screen instead of displaying the Line Chart :(
My rows contain over 1000 different exception codes hence the Legend being too large to be displayed....
Sample Code:
output$pivtbl2 <- renderRpivotTable(rpivotTable(data = DataSet(),
aggregatorName = "Sum",
vals = "Count",
cols = "ExceptionDate",
rows = "ErrorCode",
menuLimit = 1200,
rendererName = "Line Chart"))
Sorry if this question has been answered elsewhere I have spent a bit of time searching, or the answer is really obvious I am very new to R.
Or any other suggestions of packages to use or research to achieve what I am trying to do will be appreciated!
Thanks ^_^
The "Line Chart" in rpivotTable is a C3 chart. You can hide the legend, and provide other options for a C3 chart by passing a named list entry with a c3
key to the rendererOptions
argument of rpivotTable()
. Currently you also need to call provide an extra line of code to get this to work, as outlined in this issue on the rpivotTable GitHub page.
For your case, it would be:
output$pivtbl <- renderRpivotTable({
tbl <- rpivotTable(
data = DataSet(),
aggregatorName = "Sum",
vals = "Count",
cols = "ExceptionDate",
rows = "ErrorCode",
menuLimit = 1200,
rendererName = "Line Chart",
rendererOptions = list(
c3 = list(
legend = list(
show = FALSE
)
)
)
)
tbl$x$params$rendererOptions <- tbl$x$params$rendererOptions[[1]]
tbl #return value
})
The available options to pass to C3 charts are listed here: https://c3js.org/reference.html