feat(plot): an x axis caption drawn as chrome, not as an annotation
A host that re-anchors its x labels on a grid has to name the anchor somewhere, and an `Annotation` cannot serve: its anchor is a data coordinate, so the caption crawls across the plot under a pan and drifts under a zoom. `Plot::set_x_note()` takes the host's own string -- the host is the only one that knows how much precision the sum of a label and its caption needs -- and `Renderer::draw_x_note()` places it in the axes' bottom-left corner in pixels, on the legend's own backplate. It is measured in the renderer rather than in `Plot::layout()` because it reserves no space and nothing can be picked on it, and a caption explaining the x labels must not be able to move the layout those labels were measured into. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
1 parent
03c41adbec
commit
59c2e45af7
5 files changed
+150
No files matched your search
@@ -342,6 +342,8 @@ void Plot::set_y_axis_origin_from_range(u32 axis, bool on) {
|
||||
y_axes_[axis].origin_follows_range = on;
|
||||
}
|
||||
|
||||
void Plot::set_x_note(std::string text) { x_note_ = std::move(text); }
|
||||
|
||||
f64 Plot::x_axis_origin(u32 axis) const {
|
||||
return axis < x_axes_.size() ? x_axes_[axis].origin : 0.0;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user