Shiny app download plot from a renderplot
Note: The app demonstrated here depends on the packages htmltools and sp , in addition of course to ggalluvial and shiny. Please be aware that all of these packages will need to be installed on the server where your Shiny app is running. Enabling hovering over and clicking on strata is straightforward because of their rectangular shape. We only need the minimum and maximum x and y coordinates for each of the rectangles. The rectangles are evenly spaced along the x-axis, centered on positive integers beginning with 1.
The y-coordinates can be determined from the number of rows in the input data multiplied by their weights. Hovering over and clicking on alluvia are more difficult because the shapes of the alluvia are more complex. The default shape of the polygons includes an xspline curve drawn using the grid package.
We need to manually reconstruct the coordinates of the polygons, then use sp::pointInPolygon to detect which, if any, polygons the cursor is over.
Here, we will go over each section of the code in detail. The full code is reproduced at the bottom of this document. Note: This vignette only illustrates how to display output when the user hovers over an element. This will return the location of the mouse cursor in plot coordinates when the user clicks somewhere within the plot panel.
Finally, we call renderPlot to pass the plot to output. Next, we define the tooltip with a renderText expression. Skip to content. Sign in Sign up.
Instantly share code, notes, and snippets. Created Jan 18, Code Revisions 1 Stars 3 Forks 1. Embed What would you like to do? Embed Embed this gist in your website. Thanks for all your help! Show 5 more comments.
Sign up or log in Sign up using Google. Sign up using Facebook. Sign up using Email and Password. Post as a guest Name. Email Required, but never shown. The Overflow Blog. Who owns this outage? Building intelligent escalation chains for modern SRE.
Podcast Who is building clouds for the independent developer? Featured on Meta. These are reactive values, so this expression will re-run whenever they change. The basic parts of a Shiny app. How to get help. App formats and launching apps. Introduction to R Markdown. Introduction to interactive documents. Setting Output args via Render functions. Generating downloadable reports. Shiny Gadgets. Reactivity - An overview.
How to understand reactivity in R. Database basics - dplyr and DBI. Using the pool package basics. Using the pool package advanced. Using dplyr and pool to query a database. Persistent data storage in Shiny apps. Application layout guide. Build a dynamic UI that reacts to user input. Render images in a Shiny app. Displaying and customizing static tables.
How to use DataTables in a Shiny App. Help users download data from your app. Help users upload files to your app.
0コメント