Sascha
Sascha

Reputation: 239

How to change names of menuItems in R highcharter when exporting

I have the following code within the highchart package for R:

  hc_exporting(enabled = TRUE,
               buttons = list(contextButton = list(menuItems = 
                                                     c("viewFullscreen","separator", "downloadJPEG", "downloadPDF","separator", "downloadCSV"))))

I would like to rename those selected buttons to custom names. So far, they look like this:

enter image description here

I tryed JS, but would prefer a solution without it, as I am not familiar with JS and could not find export functions for csv and the proper function for fullscreen. However, the working solution for pdf would look like this:

  hc_exporting(enabled = TRUE,
           buttons = list(contextButton = 
                            list(menuItems = list(list(text = "als <b> PDF </b> speichern",onclick = JS("function () { \n this.exportChart({\n type: 'application/pdf'\n }); \n }")),

So basically, I am searching a way to rename the menuItems within hihgcharter or for the JS functions for exporting csv and for fullscreen. Thanks!

Upvotes: 2

Views: 202

Answers (1)

Sascha
Sascha

Reputation: 239

So I found the option to rename the menuItems within the global options of r-highcharter (anlog to this solution for highcharts). See:

hcoptslang <- getOption("highcharter.lang")

hcoptslang$contextButtonTitle <-"Optionen"
hcoptslang$downloadCSV <- "als CSV-Datei herunterladen"
hcoptslang$downloadJPEG <- "als JPEG-Datei herunterladen"
hcoptslang$downloadPDF <- "als PDF-Datei herunterladen"
hcoptslang$viewFullscreen <- "im Vollbild betrachten "
hcoptslang$exitFullscreen <- "Vollbild verlassen"

options(highcharter.lang = hcoptslang)

Upvotes: 2

Related Questions