Shiny - How can I tell when graphs are done rendering programmatically? - r

I am an old hand at R, but new to Shiny. (It is very cool!)
I am rendering graphs using ggplot2 in Shiny, and it works great. The only thing is that after my ggplot executes and I issue a renderPlot, there is a delay before the graphs display. I am fine with the delay, but I would like to know in the program after the graphs render. I hit the bottom of my code and the graphs are still rendering in the background.
Any advice is appreciated.
Lou

https://cran.r-project.org/web/packages/shinybusy/vignettes/shinybusy-usage.html
Check this out! You can add a busy spinner and then every time your graph is being rendered, you will be able to understand with the indicator.

Related

Patchwork is squashing my ggplot that has correct aspect when click zoom?

I've tried to make this question clear and I'm sorry that I have not been able to provide an MRE as I wouldn't even know where to begin to make this a MRE, but let me know if you can identify an obvious issue?
In my R script when I run the graph and then click zoom, the following appears: Zoom correct graph
In markdown and also in the bottom right of plots (before clicking zoom), I get the following squashed and misformatted image
Let me know if you can help in any way and I'm sorry if this is not a well worded question.
I guess I want to know in short how to edit my markdown images to appear like they do when I click Zoom function. Sorry I'm pretty new to R and SO.

JavaFX linechart xAxis values looks awful when data series are loaded into chart

The problem:
When I load data series into a JavaFX LineChart, it is displayed like this:
Wrong
If I resize the window, data is instantly placed to the intended position, and X axis data is displayed just like it should. After that, everything displayed fine again no matter what I do.
After panel is resized:
Right
Can anyone tell me what can cause the problem? I don't feel the need to provide to code just yet, because I think this issue is independent from that. But let me know if I'm wrong.

R Leaflet does not show legend when embedded in Shiny Dashboard

The map above renders perfectly fine in the following scenarios:
List item
RStudio Viewer
Shiny app
Shiny app using a minimal Shiny dashboard sceleton
When including the map in an existing, pretty complex Shiny dashboard, the looks as follows:
Obviously, the legend is missing. On top of that, the "reset view" action button has no effect.
Without posting the complete code of the complex shiny dashbboard, I would like make the following comments:
I have disabled all custom JS code and CSS
I use a bare "renderLeaflet" function without additional arguments
I have also tried to display the leaflet in a bare dashboard box without any further arguments
Any obvious culprit anyone could think of causing this issue? Anyone observed similar issues?
I wonder if you solved the issue. I noticed the legend of a raster layer disappears when using the function d3heatmap, for instance d3heatmap(mtcars, scale="column", colors="Blues"). When the line with the heatmap is commented out the dashboard knites just fine -even when the library d3heatmap is loaded. I used the code from this example. Oh I just noticed this has been addressed and solved in other questions, for example here.

googleCharts resets in size in Shiny after second load

So I'm using the googleCharts package in my Shiny app and creating a line chart.
I have a function that creates a different kind of main panel with tabsetpanel depending on the options the user selects. The first load works fine, but when I switch options in my app and it loads the main panel page the second time, the chart shrinks in size unless I specify an exact height and width in options.
The interesting part is if I select the options so the main panel that's created doesn't have a chart, then select one that does, it resets and works fine again. So it's almost like some kind of reactive problem where its saving the wrong page size and not doing a full load.
Any ideas on what I could do? Is there a way for me to force a refresh/reload of the mainPanel?
I actually ended up solving this using invalidateLater, but I would appreciate it if there's a different solution too, since the user can see the chart being redrawn with this solution

uiOutput not displaying with shiny server

I have a shiny app that is working fine locally, whether I open it in a window or the browser, but after putting it onto our shiny server I am getting some unexpected behavior.
I have two plots that get displayed using uiOutput. The first displays after loading a data file, and the second is just a zoomed plot which appears when the user selects a region from the first plot and double clicks. After putting this app on our server and using it in a browser, the first plot appears when the user uploads a file, but the second plot will not display (it is completely blank - no data points, axes or labels).
What is strange is that the data in this second plot can still be interacted with. I have included hover functionality so that when the user hovers over a point in the second plot, information gets displayed about the point in a small text window. Even though the second plot never appears, if I move the mouse over the region where the plot should be, this hover information gets displayed correctly. Depending on the size of the region selecting for zooming (i.e. if it is large), the zoomed image may not fit in the window making scrollbars necessary. If I select a large region for zooming, scrollbars appear as if the image is there, but the plot is as I said blank. I can render the zoomed plot as a pdf and that looks correct, but this isn't what I want.
As I said, everything works fine locally and this only happens after putting the app on our server. The same thing happens in Firefox, Safari and Chrome. This has to be something related to the shiny server but I have no idea what as both plots are being rendered in the same way.
I've managed to figure this out. In server.R when I generate the zoomed plot, I am doing two things. First, I am creating a pdf as follows:
pdf("z_plot.pdf")
plot()
...
dev.off()
The purpose of this is to have a plot that can be downloaded if required. After this, I am issuing the commands to render the plot in my shiny app. This is all being done in the same reactive expression, which for some reason works locally but when run on a shiny server only the pdf gets generated. I just had to separate the plotting commands into two reactive expressions and everything worked fine.

Resources