nextstrain/auspice

Limit x-axis by visible measurements

huddlej opened this issue · 1 comments

@rneher originally noted:

In the measurement panel, some limits on the axis might be useful as well. We currently have -6 to 14 in some views (which is a million fold titer difference)

The following example from the measurements panel paper dataset shows how the x-axis retains its original domain even after filtering to a single reference with a smaller range of measurement values. In this example, the x-axis domain should reflect the minimum and maximum std dev values at the lower and upper bounds.

image

Similarly, the raw measurements display for the same data should use the minimum and maximum measurement value plus/minus some small padding on the lower and upper bounds.

image

This should be straightforward to implement by changing which measurements get used to create the xScale. It currently uses all measurements, but should be straightforward to switch out with filteredMeasurements

const xScale = useMemo(() => createXScale(width, measurements), [width, measurements]);

My initial gut feeling was this may significantly slow down transitions when applying filters to the measurements panel because the xScale is memoized in the svgData and any changes to the svgData will trigger a complete redraw of the SVG. However, I'm remembering that the svgData already gets updated when we change the group-by and that transition is pretty smooth, so I'm not as worried about speed anymore.