Continuous graph updating (as opposed to reload every time)

146 views
Skip to first unread message

Blake Arensdorf

unread,
Feb 7, 2014, 1:08:42 PM2/7/14
to shiny-...@googlegroups.com
I've built a Shiny app to play a map based on different checkbox selections by the user.Depending on the checkbox, a different density is plotted on the map and it is reloaded. When the user changes the inputs the graph goes dim, waits a couple of seconds, and then reloads the new version which has lighter or darker colors on the states depending on the data.

My problem with this is that it doesn't create a smooth user experience with the graph. Ideally you'd see a map in front of you and when you change the input, have the states simply update their colors without having to reload the entire map.

Does anyone have experience with this or know a better way to do it? Here is an example of how I'm getting my map (based on a dataset I've dummied as 'percentages'):


states <- map_data("state")
states$percentage <- percentages$a
print(head(states))
map <- ggplot(states, aes(x=long, y=lat)) + 
geom_polygon(aes(group=group, fill=percentage), col=NA,lwd=0) +
borders('state', colour = "grey")
map + scale_fill_gradient(low='white', high='red', limits = c(0,1))



Thanks.

Blake Arensdorf

unread,
Feb 12, 2014, 5:03:20 PM2/12/14
to shiny-...@googlegroups.com
Vincent / Winston,

I've actually realized that this is really a characteristic of Shiny as opposed to R or the map object. When you render a table and update it, Shiny dims the old version, waits for the updated one, and then displays. Is there any way I can tweak some setting or HTML to allow it to simply display the old version and replace as soon as the new one is ready?

Joe Cheng

unread,
Feb 12, 2014, 7:37:44 PM2/12/14
to Blake Arensdorf, shiny-...@googlegroups.com
Add this to your ui.R, like in mainPanel or something:

tags$style(type="text/css",
  ".recalculating { opacity: 1.0; }"
)

If you want to limit it to a specific output, say "myplot1", you could do:

tags$style(type="text/css",
  "#myplot1.recalculating { opacity: 1.0; }"
)



--
You received this message because you are subscribed to the Google Groups "Shiny - Web Framework for R" group.
To unsubscribe from this group and stop receiving emails from it, send an email to shiny-discus...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Vincent

unread,
Feb 12, 2014, 8:28:52 PM2/12/14
to shiny-...@googlegroups.com, Blake Arensdorf
Nice. Thanks Joe.
Reply all
Reply to author
Forward
0 new messages