-
Notifications
You must be signed in to change notification settings - Fork 26
Description
Ticks
The axis configs we pass to VisCanvas may include a flag called isIndexAxis. This property has one goal: to prevent ticks from appearing between axis values - i.e. typically between image pixels on the heatmap:
isIndexAxis: true |
isIndexAxis: false |
|---|---|
![]() |
![]() |
We set isIndexAxis to true when we know the axes show pixel indices, that is:
- on
HeatmapVis, when custom abscissa/ordinate values are not provided - on
LineVis, when custom abscissa values are not provided - on
RgbVis, always for both axes (arguably this should follow the same behaviour asHeatmapVisnow that we support custom axis values)
The assumption here is that when custom axis values are available, the axis is meant to be continuous.
When isIndexAxis is true, the Axis component calls getIntegerTicks instead of the axis' D3 scale's ticks() method, which cannot guarantee the generation of a specific number of ticks (i.e. scale.ticks(3) can actually generate more than 3 ticks...) This works great when dealing with indices ([0 ... cols]), but it doesn't work at all with custom axis values (e.g. getIntegerTicks([0.001, 0.004], 4) returns an empty array and the axis disappears...)
Of course, we can work around this problem easily in the viewer by setting isIndexAxis to false in RgbVis when custom absicssa/ordinate values are provided.
However, this does not prevent misuse of isIndexAxis by consumers of @h5web/lib.
Note also that getIntegerTicks does not prevent ticks from appearing outside of the bounds of the heatmap:
Tooltips
The other way in which the viewer currently supports discrete axes is in the tooltips of HeatmapVis and LineVis. In fact we always consider that the axes are discrete regardless of isIndexAxis: the tooltip's x and y values are always taken either from the axes' indices or from the custom values if provided:
In other words, there is an inconsistency between the way the ticks are generated and the way the tooltip computes the coordinates of the value under the cursor. This is not great.
In Daiquiri, for the tomography visualizations, where isIndexAxis is left as false, the tooltips show continuous x and y values (in mm) as expected:
Question
So the question this issue raises is: should we add proper support for discrete axes? Is this something that would be useful to some scientific fields, either in the viewer (via a toolbar toggle, or always enabled), or in the lib? By proper support, I mean:
- not limited to integer ticks;
- with a consistent behaviour across all relevant UI elements (i.e. ticks and tooltips, but we could also imagine in the future adjusting a zoom or mask selection to exact pixels automatically when discrete axes are enabled);
- enabled with an API that is clear and prevents misuse.
Proper support is not trivial, since, for instance, axes would need more info than just a domain to generate discrete ticks: either the axis values, the number of values (i.e. number of pixels + 1), or the step between the values. Obviously, it would be better if axis values never had to be generated in the viewer, as this is a (minor) performance issue at the moment, so the number of values or the step feel like better solutions.




