You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
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.
Activity
camdecoster commentedon Apr 24, 2026
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.
RedZapdos123 commentedon Apr 28, 2026
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/YAxisIdenums and updates theFieldSetterderive macro so tracex_axis/y_axissetters 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
camdecoster commentedon Jun 1, 2026
@inferrna with the fix merged in plotly.rs, can this issue be closed?