microscopium / microscopium-ui

Microscopium web interface.
2 stars 4 forks source link

Idea - pre-render histograms #67

Open starcalibre opened 9 years ago

starcalibre commented 9 years ago

I was chatting with a mate at MelbJS and we came up with a better way to render the histograms. In the current approach, we need to pull 6k-10k floats from the database and render the histogram client client. This means a) we're waiting for all he floats to come back from the DB, b) the client needs to bin all the floats and render the histogram once the data comes back.

The idea is pre-compute all of the HTML/SVG/JS and save this as string. When a histogram for a feature is called, the string is pulled from the DB, parses this as markup and inserts it into the DOM. This will be much faster because there's no binning to be done, much less data to send in the AJAX request and it'll be nicely compressible because it'll be plain text with lots of redundancy.

The downside to this approach is you lose the data binding, and other information kept in D3 such as the scale that maps the SVG co-ordinate to a data value. We'll need this if we want to make the histogram clickable (see #50). But if we're using a uniform scale for the histogram (see #60) this shouldn't be a problem.

jni commented 9 years ago

Cool idea! Completely separately, @hdashnow and I are making kernel density estimation (KDE) plots and they just look so much better than histograms. So let's compute and save those. And yes, on a single scale. But, by the way, when you say "this shouldn't be a problem", what exactly do you mean? I think it's definitely going to be a problem, LOL.