explorable-viz / fluid

Data-linked visualisations
http://f.luid.org
MIT License
32 stars 1 forks source link

Refresh selection information rather than rebuilding `div` each time #989

Closed rolyp closed 1 month ago

rolyp commented 1 month ago

Every mouse event triggers a re-run of the appropriate analysis (e.g. linked inputs), which causes the d3.js chart to be rebuilt from scratch. This in turn causes mouseenter to be retriggered when the new DOM element appears under the mouse cursor, which causes the analysis to be re-run, the chart to be rebuilt, etc resulting in a loop. Breaking the loop is possible with a flag to drop the handler reentering, but there is also a problem with mouseleave not firing if mouseenter is still active, which I think may be related.

A better approach might be to factor out the code the which sets the visual attributes corresponding to selection information, from the code which constructs the chart, and only run the former when updating the UI. That will stop DOM elements being deleted and re-created under the mouse cursor and mouseenter being repeatedly triggered.

See also: