Fix up merged PRs: minor gridlines on a logarithmic axis

#666's minor gridlines stepped in value units, but #669 scales a log axis in
exponents of its base; map each minor step back through the base.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Brandon Thomas
2026-10-14 13:53:06 -04:00
co-authored by Claude Opus 5.5
parent 6d1b01b73d
commit bb3627f954
+3 -1
View File
@@ -411,7 +411,9 @@ fn draw_inner(ctx: &mut RenderContext, rctx: &Ctx, c: &Chart, m: Affine, w: f64,
let n = (((max - min) / minor.max(1e-12)).round() as i64).clamp(1, 500);
let mut g = BezPath::new();
for k in (0..=n).filter(|k| k % 5 != 0) {
let pos = to_v(min + k as f64 * minor);
// On a logarithmic axis `min`, `max` and `step` are exponents of the base.
let e = min + k as f64 * minor;
let pos = to_v(log.map_or(e, |(b, _)| b.powf(e)));
if horiz {
g.move_to((pos, plot.y0));
g.line_to((pos, plot.y1));