Type: | Package |
Title: | Add a Download Button to a 'shiny' Plot or 'plotly' |
Version: | 0.1.4 |
Author: | Alex Pickering |
Maintainer: | Alex Pickering <alexvpickering@gmail.com> |
Description: | Add a download button to a 'shiny' plot or 'plotly' that appears when the plot is hovered. A tooltip, styled to resemble 'plotly' buttons, is displayed on hover of the download button. The download button can be used to allow users to download the dataset used for a plot. |
License: | MIT + file LICENSE |
Encoding: | UTF-8 |
RoxygenNote: | 7.2.2 |
Suggests: | ggplot2 (≥ 3.3.2) |
Imports: | shinyBS (≥ 0.61), shiny (≥ 1.4.0), shinyjs (≥ 1.1), plotly (≥ 4.9.2), htmlwidgets (≥ 1.5.1), htmltools (≥ 0.5.0), methods, utils |
NeedsCompilation: | no |
Packaged: | 2022-11-18 17:39:22 UTC; alex |
Repository: | CRAN |
Date/Publication: | 2022-11-18 18:00:02 UTC |
Server-side logic for plot with download data button
Description
Download button appears on hover in top right.
Usage
downloadablePlot(input, output, session, plot, filename, content, ...)
Arguments
input , output , session |
standard |
plot |
A |
filename |
A string of the filename, including extension, that the user's web browser should default to when downloading the file; or a function that returns such a string. (Reactive values and functions may be used from this function.) |
content |
A function that takes a single argument |
... |
additional named arguments passed to |
Value
No return value, called to generate server logic.
See Also
downloadablePlotUI
, renderPlot
.
Examples
library(shiny)
library(shinyjs)
library(shinydlplot)
library(ggplot2)
ui <- fluidPage(
useShinyjs(),
downloadablePlotUI(id = 'iris_plot')
)
server <- function(input, output, session) {
plot <- ggplot(iris, aes(x = Sepal.Length, y = Petal.Length)) + geom_point()
callModule(downloadablePlot,
id = 'iris_plot',
plot = plot,
filename = 'iris.csv',
content = function(file) {write.csv(iris, file)})
}
## Not run: shinyApp(ui, server)
UI for plot with download data button
Description
UI for plot with download data button
Usage
downloadablePlotUI(
id,
title = "Download plot data",
width = "100%",
height = "400px",
zoom = FALSE
)
Arguments
id |
id string that gets namespaced by |
title |
Text to display on hover of download button. |
width , height |
Image width/height. Must be a valid CSS unit (like
|
zoom |
if |
Value
an HTML tag object corresponding to the UI for downloadablePlot
.
See Also
NS
, downloadablePlot
, plotOutput
Server-side logic for plotly with download data button in modebar
Description
Server-side logic for plotly with download data button in modebar
Usage
downloadablePlotly(
input,
output,
session,
plot,
filename,
content,
title = "Download plot data"
)
Arguments
input , output , session |
standard |
plot |
Object of class |
filename |
A string of the filename, including extension, that the user's web browser should default to when downloading the file; or a function that returns such a string. (Reactive values and functions may be used from this function.) |
content |
A function that takes a single argument |
title |
Text for plotly tooltip. |
Value
No return value, called to generate server logic.
See Also
UI for plotly with download data button in modebar
Description
UI for plotly with download data button in modebar
Usage
downloadablePlotlyUI(id, width = "100%", height = "auto", inline = FALSE)
Arguments
id |
id string that gets namespaced by |
width , height |
Must be a valid CSS unit (like |
inline |
use an inline ( |
Value
an HTML tag object corresponding to the UI for downloadablePlotly
.
See Also
Examples
library(shiny)
library(shinyjs)
library(shinydlplot)
library(plotly)
ui <- fluidPage(
useShinyjs(),
downloadablePlotlyUI(id = 'iris')
)
server <- function(input, output, session) {
plot <- plot_ly(data = iris, x = ~Sepal.Length, y = ~Petal.Length)
callModule(downloadablePlotly,
id = 'iris',
plot = plot,
filename = 'iris.csv',
content = function(file) {write.csv(iris, file)})
}
## Not run: shinyApp(ui, server)
Logic for hidden download link
Description
Logic for hidden download link
Usage
hiddenDownload(input, output, session, check, filename, content)
Arguments
, , |
standard |
reactive value to trigger download. | |
A string of the filename, including extension, that the user's web browser should default to when downloading the file; or a function that returns such a string. (Reactive values and functions may be used from this function.) | |
A function that takes a single argument |
Value
No return value, called to generate logic for hidden download link.
See Also
UI for hidden download link
Description
UI for hidden download link
Usage
hiddenDownloadUI(id)
Arguments
id string to be namespaced. |
Value
a shiny.tag used to create a hidden download link.