feat(plot): horizontal rulers alongside the vertical cursors

This commit is contained in:
Martino Ferrari committed 2026-09-28 17:18:43 +02:00
1 parent 2d819c4228
commit 63f9655ae1
11 files changed
+514 -29

No files matched your search

+11 -2
View File
@@ -2,15 +2,24 @@
namespace plot {
void Axis::format_value(f64 v, char* buf, usize n) const {
if (format == TickFormat::Time) {
format_time(v, buf, n);
return;
}
format_si(v, buf, n);
}
void Axis::refresh(f32 px, f32 min_px, bool include_minors) {
generate_ticks(range, px, min_px, ticks, include_minors);
if (format != TickFormat::Time) return;
// generate_ticks labels with format_si; a time axis relabels its majors here,
// because the tick generator has no business knowing about a clock.
// because the tick generator has no business knowing about a clock -- through the one
// function that says how a value on this axis is written.
char buf[64];
for (Tick& tick : ticks) {
if (!tick.major) continue;
format_time(tick.value, buf, sizeof buf);
format_value(tick.value, buf, sizeof buf);
tick.label = buf;
}
}