问题
I need to get offline export from highchart in Shiny. Parameter fallbackToExportServer does not work.
highcharter 0.7.0 R Version: "R version 3.5.1 (2018-07-02)"
output$hc <- renderHighchart({
highchart() %>%
hc_chart(type = "line" ) %>%
hc_xAxis(cars$speed) %>%
hc_add_series(cars$dist) %>%
hc_exporting(enabled = T, fallbackToExportServer = F) })
回答1:
Parameter fallbackToExportServer does not work because it does not force the offline exporting. To enforce offline exporting I defined my own buttons, i.e. exporting menu.
export <- list(
list(text="PNG",
onclick=JS("function () {
this.exportChartLocal(); }")),
list(text="JPEG",
onclick=JS("function () {
this.exportChartLocal({ type: 'image/jpeg' }); }"))
)
output$hc <- renderHighchart({
highchart() %>%
hc_chart(type = "line" ) %>%
hc_xAxis(cars$speed) %>%
hc_add_series(cars$dist) %>%
hc_exporting(enabled = T, fallbackToExportServer = F,
menuItems = export) })
It is generally good to get to know the Highcharts API and how to use it with highcharter. The exporting options are here https://api.highcharts.com/highcharts/exporting And info on client side export: https://www.highcharts.com/docs/export-module/client-side-export
The other exporting menuItems are then defined in "export", and how to do that is described in the API.
So to conclude, you now will enforce client side exporting. The fallbackToExportServer = F specification says "If client side exporting fails, do NOT fall back on exporting.highcharts.com server".
Hope this helps.
来源:https://stackoverflow.com/questions/56255026/highchart-export-offline