statgen / locuszoom

A Javascript/d3 embeddable plugin for interactively visualizing statistical genetic data from customizable sources.
https://statgen.github.io/locuszoom/
MIT License
154 stars 29 forks source link

Deferred Transformations #87

Closed Frencil closed 7 years ago

Frencil commented 7 years ago

Presently transformations are passed along from the fields array to the data source and applied to all elements as data is requested. While sometimes this may be necessary it can be a heavy-handed approach when, for example, just wanting a transformation applied for display (e.g. in a tooltip).

A solution would be to make it so that referencing data fields pretty much anywhere in the library (including retrieving data form sources, parsing tool tip markup, etc) the presence of a transformation is detected and applied as-needed, as opposed to treating the field+transformation as a distinct field that should just exist up front.

Frencil commented 7 years ago

This issue has been effectively addressed in v0.5.5. The new Data Field object allows for gracefully pulling precomputed transformed values from a data object or applying transformations when the field is first requested and then caching values for precomputed retrieval on subsequent passes.

Not all data sources support the new Data Field approach, but the approach has been applied to a few key data layer implementations and the general parseFields method (used any time fields are resolved to values in a display string, such as tooltip HTML or a data label), effectively allowing for deferred transformations universally in parsed display strings.