From 8370022e952c1bbbb63467c7afef4d6b4f280cad Mon Sep 17 00:00:00 2001 From: Nathan Bourgeois Date: Thu, 28 May 2026 07:40:57 +0200 Subject: [PATCH] fix: invert y-axis label row index to match plot orientation --- src/components/chart.zig | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/chart.zig b/src/components/chart.zig index 90eff91..099c7f4 100644 --- a/src/components/chart.zig +++ b/src/components/chart.zig @@ -392,12 +392,12 @@ pub const Chart = struct { } fn renderPlotRow(self: *const Chart, allocator: std.mem.Allocator, row_index: usize, plot_line: []const u8, plot_height: usize, y_label_width: usize, y_ticks: *const TickSet) ![]const u8 { - _ = plot_height; var result: Writer.Allocating = .init(allocator); const writer = &result.writer; if (self.y_axis.show_labels) { - const label = y_ticks.labelForRow(row_index) orelse ""; + const tick_row = if (plot_height > 0) plot_height - 1 - row_index else row_index; + const label = y_ticks.labelForRow(tick_row) orelse ""; const padded = try renderPaddedLabel(allocator, label, y_label_width, self.y_axis.label_style); defer allocator.free(padded); try writer.writeAll(padded);