Skip to content

Commit

Permalink
global options for charts menu
Browse files Browse the repository at this point in the history
  • Loading branch information
pachamaltese committed Aug 12, 2019
1 parent 7ca0d39 commit 1918e16
Show file tree
Hide file tree
Showing 8 changed files with 76 additions and 8 deletions.
17 changes: 17 additions & 0 deletions dashboard/global.R
Expand Up @@ -89,3 +89,20 @@ styles <- list(
skin_color = "blue-light",
css_files = c("css/AdminLTE.min.css", "css/_all-skins.min.css", "css/custom.min.css")
)

# Highcharts --------------------------------------------------------------

hc_export_menu <- list(
list(text="Download PNG image",
onclick=JS("function () {
this.exportChart({ type: 'image/png' }); }")),
list(text="Download JPEG image",
onclick=JS("function () {
this.exportChart({ type: 'image/jpeg' }); }")),
list(text="Download SVG vector image",
onclick=JS("function () {
this.exportChart({ type: 'image/svg+xml' }); }")),
list(text="Download PDF document",
onclick=JS("function () {
this.exportChart({ type: 'application/pdf' }); }"))
)
10 changes: 5 additions & 5 deletions dashboard/server.R
Expand Up @@ -880,7 +880,7 @@ shinyServer(
hchart(d, "column", hcaes(x = `Year`, y = `Trade Value`, group = group)) %>%
hc_colors(c("#4d6fd0", "#bf3251")) %>%
hc_title(text = trade_exchange_bars_title()) %>%
hc_exporting(enabled = TRUE)
hc_exporting(enabled = TRUE, buttons = list(contextButton = list(menuItems = hc_export_menu)))
})

# Exports -----------------------------------------------------------------
Expand Down Expand Up @@ -954,7 +954,7 @@ shinyServer(
hc_add_series(d, name = "Export Value USD", showInLegend = FALSE,
dataLabels = list(verticalAlign = "top", align = "left", style = list(textOutline = FALSE))) %>%
hc_title(text = exports_title_min_year()) %>%
hc_exporting(enabled = TRUE)
hc_exporting(enabled = TRUE, buttons = list(contextButton = list(menuItems = hc_export_menu)))
})

exports_title_max_year <- eventReactive(input$go, {
Expand Down Expand Up @@ -1004,7 +1004,7 @@ shinyServer(
hc_add_series(d, name = "Export Value USD", showInLegend = FALSE,
dataLabels = list(verticalAlign = "top", align = "left", style = list(textOutline = FALSE))) %>%
hc_title(text = exports_title_max_year()) %>%
hc_exporting(enabled = TRUE)
hc_exporting(enabled = TRUE, buttons = list(contextButton = list(menuItems = hc_export_menu)))
})

# Imports -----------------------------------------------------------------
Expand Down Expand Up @@ -1090,7 +1090,7 @@ shinyServer(
align = "left",
style = list(textOutline = FALSE))) %>%
hc_title(text = imports_title_min_year()) %>%
hc_exporting(enabled = TRUE)
hc_exporting(enabled = TRUE, buttons = list(contextButton = list(menuItems = hc_export_menu)))
})

imports_title_max_year <- eventReactive(input$go, {
Expand Down Expand Up @@ -1152,7 +1152,7 @@ shinyServer(
hc_add_series(d, name = "import Value USD", showInLegend = FALSE,
dataLabels = list(verticalAlign = "top", align = "left", style = list(textOutline = FALSE))) %>%
hc_title(text = imports_title_max_year()) %>%
hc_exporting(enabled = TRUE)
hc_exporting(enabled = TRUE, buttons = list(contextButton = list(menuItems = hc_export_menu)))
})

# URL ---------------------------------------------------------------------
Expand Down
17 changes: 17 additions & 0 deletions embed-exports/global.R
Expand Up @@ -50,3 +50,20 @@ reporters_to_display <- tibble(
# Bookmarking -------------------------------------------------------------

enableBookmarking(store = "url")

# Highcharts --------------------------------------------------------------

hc_export_menu <- list(
list(text="Download PNG image",
onclick=JS("function () {
this.exportChart({ type: 'image/png' }); }")),
list(text="Download JPEG image",
onclick=JS("function () {
this.exportChart({ type: 'image/jpeg' }); }")),
list(text="Download SVG vector image",
onclick=JS("function () {
this.exportChart({ type: 'image/svg+xml' }); }")),
list(text="Download PDF document",
onclick=JS("function () {
this.exportChart({ type: 'application/pdf' }); }"))
)
2 changes: 1 addition & 1 deletion embed-exports/server.R
Expand Up @@ -113,7 +113,7 @@ shinyServer(
align = "left",
style = list(textOutline = FALSE))) %>%
hc_title(text = exports_title()) %>%
hc_exporting(enabled = TRUE)
hc_exporting(enabled = TRUE, buttons = list(contextButton = list(menuItems = hc_export_menu)))
})

# Output ------------------------------------------------------------------
Expand Down
17 changes: 17 additions & 0 deletions embed-imports/global.R
Expand Up @@ -50,3 +50,20 @@ reporters_to_display <- tibble(
# Bookmarking -------------------------------------------------------------

enableBookmarking(store = "url")

# Highcharts --------------------------------------------------------------

hc_export_menu <- list(
list(text="Download PNG image",
onclick=JS("function () {
this.exportChart({ type: 'image/png' }); }")),
list(text="Download JPEG image",
onclick=JS("function () {
this.exportChart({ type: 'image/jpeg' }); }")),
list(text="Download SVG vector image",
onclick=JS("function () {
this.exportChart({ type: 'image/svg+xml' }); }")),
list(text="Download PDF document",
onclick=JS("function () {
this.exportChart({ type: 'application/pdf' }); }"))
)
2 changes: 1 addition & 1 deletion embed-imports/server.R
Expand Up @@ -122,7 +122,7 @@ shinyServer(
align = "left",
style = list(textOutline = FALSE))) %>%
hc_title(text = imports_title()) %>%
hc_exporting(enabled = TRUE)
hc_exporting(enabled = TRUE, buttons = list(contextButton = list(menuItems = hc_export_menu)))
})

# Output ------------------------------------------------------------------
Expand Down
17 changes: 17 additions & 0 deletions embed-trade/global.R
Expand Up @@ -51,3 +51,20 @@ reporters_to_display <- tibble(
# Bookmarking -------------------------------------------------------------

enableBookmarking(store = "url")

# Highcharts --------------------------------------------------------------

hc_export_menu <- list(
list(text="Download PNG image",
onclick=JS("function () {
this.exportChart({ type: 'image/png' }); }")),
list(text="Download JPEG image",
onclick=JS("function () {
this.exportChart({ type: 'image/jpeg' }); }")),
list(text="Download SVG vector image",
onclick=JS("function () {
this.exportChart({ type: 'image/svg+xml' }); }")),
list(text="Download PDF document",
onclick=JS("function () {
this.exportChart({ type: 'application/pdf' }); }"))
)
2 changes: 1 addition & 1 deletion embed-trade/server.R
Expand Up @@ -106,7 +106,7 @@ shinyServer(
hchart(d, "column", hcaes(x = `Year`, y = `Trade Value`, group = group)) %>%
hc_colors(c("#4d6fd0", "#bf3251")) %>%
hc_title(text = trade_exchange_bars_title()) %>%
hc_exporting(enabled = TRUE)
hc_exporting(enabled = TRUE, buttons = list(contextButton = list(menuItems = hc_export_menu)))
})

# Output ------------------------------------------------------------------
Expand Down

0 comments on commit 1918e16

Please sign in to comment.