Skip to content

Reverse Y Axis in Charts #110

@bocurmach

Description

@bocurmach

Hi, for plotting charts I found that the y axis labels are not ordered like largest number on top, lowest number on bottom. I assumed this was a bug due to the rendering being done top to bottom and the y axis usually runs bottom to top.

In line 395 to 400 in src/components/chart.zig I changed this:

       //_ = plot_height;   //<-
        var result: Writer.Allocating = .init(allocator);
        const writer = &result.writer;

        if (self.y_axis.show_labels) {
            const label = y_ticks.labelForRow(plot_height - 1 - row_index) orelse "";  //<-
  • removed the discard of the plot_height parameter
  • reversed the index for the label row by replacing row_index with plot_height - 1 - row_index

I'm not familiar enough with the codebase to make a PR. But this worked for me. Could you have a look in to this?

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions