How to speed up rendering a plotly charts? - r

I am currently preparing a shiny app that shows demographics for my country. I am using the plotly package for data visualization. All the graphs are great, but the problem is that they render very slowly. That is, when I start the application, I have to wait about 30 seconds for the graphs to appear on the screen. Is there any way to speed up the rendering of the graphs and make them appear on the screen much faster? I think the maximum delay can be 2-3 seconds, I wouldn't want more. I have a 8 or 9 graphs per page so honestly, I don't want to believe that the R language and the plotly package that are designed for data visualization work so poorly with such a number of graphs, so I'm considering some mistakes on my own. I found this guide: https://plotly-r.com/performance.html
however, the first way toWebGL () doesn't work at all, and using the second function partial_bundle () I have the impression that the graphs render even slower. So, are there any other ways to speed up the rendering of the graphs? What errors should I watch out for in the code so as not to slow down the rendering of the graphs? I will be grateful for all tips, advice, and in particular for suggestions to solve the problem.
The problem seems general to me, so I do not add my code, but if necessary I will of course add it
Thanks in advance!

Related

How to check if a plot is visible under a tab panel?

I am working on data visualization with R and shiny.
It takes some time to load my visualization and be able to provide plots under tab panels.
Ex. I made 3 tabs for box plot, bar plot, and bean plot
Taking time to visualize the result is understandable, but I am not sure how to check if the plot is visible so that users do not need to wait even though incProcess function reports the program is done.
First, I recorded the time to visualize and tried to delay some time, but it is very subjective to the data input, so I do not think that is a good solution.
Would you be able to provide me solution?
Thank you
I think I need a solution NOT to check if a code is done but the visualization is done.

How to implement interactive graph from plotly in overleaf?

I want to implement interactive graph from plotly in overleaf. However, overleaf removed the communication with plotly in the V2 version. Is it still possible somehow to implement interactive graph in overleaf and therefore in pdf?
I want to hide/unhide line, zoom in and see value of different points when clicking on it.
I saw this question a couple times before, but the answere was only to zoom in or use javascript and implementing different picture on top of eachother.
However, this is not what i am looking for. I am looking for a really interactive in PDF. Does somebody know how this is possible?

R Shiny and highcharter - How to define size and location of 3 plots

I'm new to the R Shiny/ highcharter domain, so any help would be great! I've also poked around the forum and the internet, but I haven't come across anything that directly pertains to my request.
In short, I'm looking to build an R Shiny web app that comes with an interactive UI and 3-4 dynamic graphs/plots that all fits on one page. I have a general sense in how to build the UI portion, but I am confused with how to implement the framework to include 3-4 graphs - specifically, I'd love it if I were able to have a main graph taking up a majority of the space, with 2-3 graphs below and to the right of the main graph, and the interactive UI to the left of the main graph. Any help would be greatly appreciated.

SVGAnnotation to create tool tips for each value in R heatmaps

I'd like to create a heat map in R that I want to use on a website. I stumbled upon the SVGAnnotation package which seems to be very nice to process SVG graphics in R to make them more interactive. First, I was planning to add tool tips for each cell in the heatmap - if the user hovers over the cell, the value of this cell should pop up. However, I am fighting with SVGAnnotation for more than 3 hours now, reading and trying things, and I can't get it to work.
I would appreciate any help on the SVGAnnotation tool tip function. But I would also very much appreciate alternatives to SVGAnnotation to add some activity to my R SVG heatmap.
So, what I have got so far looks like this:
library(SVGAnnotation)
data(mtcars)
cars <- as.matrix(mtcars)
map <- svgPlot(heatmap(cars))
addToolTips(map, ...) # problem
saveXML(map, "cars.svg")
My problem is the addToolTips function itself, I guess. Intuitively, I would simply insert the data matrix, i.e., cars, but this does not work and R gets stuck (it's calculating, but doesn't return anything, I waited 50 minutes)
EDIT:
After some more online research, I found a good example of what I want to achieve: http://online.wsj.com/article/SB125993225142676615.html#articleTabs=interactive
This heat map looks really great, and the interactive features (tool tips) work very well. I am wondering how they did that. To me, it looks like the graphic was done in R using the ggplot package.
I wrote a command line tool that can do exactly that if you are still interested to add tool tips to your heat map. It runs in Windows/Linux/MacOS terminals. All you need as input is the heat map as svg file and the data table/matrix that you used as input to create your heat map as csv or other text file.

Is there a way to replace the legend or axis without redrawing the whole plot?

Sometimes I will place a legend at a particular location on the plot, let's say topright, and then I see that it covers an important part of the plot. Is there a way I can switch it to topleft or some other place without having to run all the other commands first? Sometimes I have the same problem with the axes, I misspell a word and then I have to issue all the commands again.
I eventually place everything in an R script which means this becomes less of a problem, but sometimes I want to quickly test something in console. Please tell me I have overlooked a basic command that does this.
There is no such thing, but you're on the right track - a script is definitely the way to go. I would also recommend R Studio, a free R IDE, which gives you several displays, one for scripts, one for the console, one for your plots - it's great! It makes working with scripts as easy as interacting with the traditional R console.
As Gabriel told you, a script is the best way. However, the following link could help you:
Using Inkscape to Post-edit Labels in R Graphs

Resources