https://github.com/alexvpickering/shinydlplot
Add a stylish data download button to a shiny plot(ly)
https://github.com/alexvpickering/shinydlplot
ggplot2 plotly shiny
Last synced: 8 months ago
JSON representation
Add a stylish data download button to a shiny plot(ly)
- Host: GitHub
- URL: https://github.com/alexvpickering/shinydlplot
- Owner: alexvpickering
- License: other
- Created: 2020-04-08T19:07:07.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2022-11-18T17:22:04.000Z (over 3 years ago)
- Last Synced: 2023-10-13T06:34:20.605Z (over 2 years ago)
- Topics: ggplot2, plotly, shiny
- Language: R
- Size: 98.6 KB
- Stars: 8
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# shinydlplot
### Installation
```R
remotes::install_github('alexvpickering/shinydlplot)
```
### Usage
Example that renders a `plotly` with a download button to download the iris dataset:
```R
library(shiny)
library(shinyjs)
library(shinydlplot)
library(plotly)
ui <- fluidPage(
useShinyjs(),
downloadablePlotlyUI(id = 'iris_plotly')
)
server <- function(input, output, session) {
plot <- plot_ly(data = iris, x = ~Sepal.Length, y = ~Petal.Length)
callModule(downloadablePlotly,
id = 'iris_plotly',
plot = plot,
filename = 'iris.csv',
content = function(file) {write.csv(iris, file)})
}
shinyApp(ui, server)
```

Example that renders a `ggplot2` object with a download button to download the iris dataset:
```R
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)})
}
shinyApp(ui, server)
```
