✊🏿 Black Lives Matter. Please consider donating to Black Girls Code today.
⚾️ It's finally Baseball season! Root for the home team... & Register for our Sports Analytics Webinar!

Best way to serve Plotly graphs on a small searchable web-app? On-demand plotly.js visualization or storing plotly iframe URLs in a database?

Hi, I’m in a molecular biology lab, and I am creating a web app that allows users to search for a certain biological nano-molecule, which will return a plotly generated line graph of the performance of the nano-molecule in various conditions. There are only a few hundred of these graphs, and I am currently working with the data in R/ggplot2.

Method 1
My first thought was to simply export these R graphs to Plotly using the given libraries, and then embed the iframes in my web-app and then use Jquery to make the queried iframe visible upon search, but I thought that would be terrible performance/maintenance wise.

Method 2
I then thought to just use a database (key-pair or document-based like mongodb) to store the urls of the iframes of the R-converted plotly graphs, and then use the database api and ajax to show the requested iframe on search.

Method 3
Another way is how I think most other people do it (although I may be mistaken): storing my biological data into a database like mongodb and then upon search, the web-app would request the data and then use plotly.js library to visualize on-demand.

I believe that Method 2 would be easier than Method 3 to code because I don’t have to worry about how to format/input the data for plotly.js generation, but maybe it’s only marginally so? Or perhaps method 2 is inefficient? I don’t know much about web development so I’m unsure of the best way to do this (in terms of ease of coding, maintenance performance, etc).

If you have any input, I would really appreciate it. Thanks!

Maybe you should consider https://dashboards.ly/

Hi, the dashboards seem interesting, but do you have a best practice in mind for implementing a search function for plot.ly graphs (pre-generating graphs or no)?

For example if I have Molecule 1, and it has a set of data that could generate 2 plot.ly graphs. And then I have Molecule 2 which also has a set of data that could generate 2 graphs. Should I pregenerate the graphs on Plot.ly and then store the URLs of the iframes for search?