feat(plot): the readout marker snaps to the sample it quotes, and the value mode is a choice
The mark was placed at the *pointer's* x with the quoted sample's y, so with the nearest-sample readout it sat off the datum horizontally -- and further off the deeper the zoom. `CrosshairRow` now carries the data `x` the value belongs to and the marker is placed from it, so in `NearestSample` the mark lands on the sample the panel is quoting. `Style::crosshair_marker_px` (9) and `crosshair_marker_width` (1.5) replace the renderer's hard-coded 3 px arm and 1 px stroke: a snapped mark lands among a trace's own sample dots (`marker_px`, 3) and at that size would read as one more sample rather than as the answer to the question the hover asks. `CrosshairValue` makes the previous behaviour reachable rather than deleted. The two modes answer different questions -- `NearestSample` "which datum is under the pointer", `Interpolated` "what is the signal at this instant" -- and only the caller knows which it is asking, so the plot offers both with the sample as the default. `crosshair_interpolate()` is restored for it. `Plot::crosshair_point()` is the lookup with both coordinates, public because a host that draws instruments of its own needs the same snap and a second rule for it would drift from this one; `crosshair_value()` delegates to it.
This commit is contained in:
1 parent
c028f48fa0
commit
c960decaea
9 files changed
+372
-78
No files matched your search
@@ -86,6 +86,21 @@ struct Style {
|
||||
f32 crosshair_width = 0.75f;
|
||||
f32 crosshair_dash_on = 4.0f;
|
||||
f32 crosshair_dash_off = 4.0f;
|
||||
/// The full extent, in logical pixels, of the little cross drawn at each trace's readout
|
||||
/// point (`CrosshairRow::marker`), in that trace's own colour.
|
||||
///
|
||||
/// **Deliberately larger than `marker_px`**, which is what a trace's own samples are dotted
|
||||
/// with at a deep zoom. In the default `CrosshairValue::NearestSample` the readout's mark is
|
||||
/// *snapped to a sample*, so it lands among those dots -- at the same size it would read as
|
||||
/// one more sample instead of as "this is the one the panel is quoting". The lines are chrome
|
||||
/// and recede; this mark is the answer to the question the hover asks, and it is the one
|
||||
/// crosshair element that should not.
|
||||
///
|
||||
/// Its stroke is `crosshair_marker_width`, thicker than the lines' for the same reason. `0`
|
||||
/// across draws no mark at all, which is how a caller that wants the panel without the marks
|
||||
/// says so.
|
||||
f32 crosshair_marker_px = 9.0f;
|
||||
f32 crosshair_marker_width = 1.5f;
|
||||
|
||||
// --- the scale ----------------------------------------------------------
|
||||
|
||||
|
||||
Reference in new issue
Block a user