Skip to content

Non idiomatic method y_axis #5583

Closed
Closed

Description

@inferrna

In Rust, unlike in JavaScript, we are accustomed to using numbers to represent numbers, strings for strings, and Enums for enumerable data. In your code, I see a mix of the correct approach alongside some unidiomatic and incorrect patterns.
Example of the correct approach
The method Layout::bar_mode(self, value: BarMode) is a great example. One can easily navigate to the BarMode type to see all possible values. It is self-explaining, no additional documentation is needed.

Example of the Incorrect Approach
The method y_axis(self, value: AsRef<str>) in the trace structures is problematic. It is not at all obvious what should be passed as the value. It is only through examples that one discovers that "y2" is needed for the second y-axis, "y3" for the third, and so on. In this case, an Enum with variants such as Y1, Y2, Y3, etc., should be used instead.

Activity

  1. camdecoster commented on Apr 24, 2026

    @camdecoster
    Contributor

    Thanks for letting us know! If you'd like to update the types/docs to include this information, we'd be happy to review the PR.

  2. RedZapdos123 commented on Apr 28, 2026

    @RedZapdos123

    I tracked the root cause to the Rust implementation used by the bindings: the derive macro and trace setters were accepting raw strings for axis ids. I’ve implemented a fix in plotly.rs that adds typed XAxisId / YAxisId enums and updates the FieldSetter derive macro so trace x_axis/y_axis setters accept explicit axis-id types while preserving existing JSON serialization. I also added regression tests and ran formatting/linting; focused tests pass.

    PR: plotly/plotly.rs#392

  3. camdecoster commented on Jun 1, 2026

    @camdecoster
    Contributor

    @inferrna with the fix merged in plotly.rs, can this issue be closed?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions