Type trace axis ids#392
Conversation
7717f12 to
778ee1f
Compare
|
Hi @RedZapdos123, Thank you for the PR. And thank you for the work on the CI fixes. I propose that you make a new PR with the CI fixes to separate it from this PR. Concerning the original issue, the axis IDs, can you give me a bit more context on why you opened an issue in Regarding the fix itself. This crate is trying to follow So I don't think using an Enum here brings much improvement but rather more complexity and I would prefer not to follow this approach. |
b4a4ed9 to
86111f3
Compare
Thank you for the review. I split the CI work out as requested.
I also reworked the #392 to avoid the enum approach. The current version keeps the existing string-based axis ids, but gives them named types:
The trace fields now use those types, and the setters accept I also added regression tests for both paths:
About the 'plotly.py' issue reference. I opened it because the original problem is about the user facing axis-id API feeling unclear from a Plotly user point of view. But I agree that |
Signed-off-by: Mridankan Mandal <xerontitan90@gmail.com>
|
Hi @RedZapdos123, |
|
Hi @andrei-ng. A user writes: Scatter::new(x, y).y_axis("y3") This PR improves is that instead of treating that argument as an unstructured String, the API gives it a named meaning with XAxisId and YAxisId, and the setters consistently accept So, from user (like mine) perspective, the benefit is actually:
An good example is subplot usage like this: let price = Scatter::new(days, prices).y_axis("y");
let volume = Bar::new(days, volumes).y_axis("y2");
let indicator = Scatter::new(days, rsi).y_axis("y3");What this solves for the users like me, is mainly API clarity. The argument now does not look like just any random string. It is easier to understand from the Rust API that values like "y", "y2" and "y3" are axis references. |
Thanks for the reply and for example. I will merge it and see how the community responds to the new usage. |
Description:
Issue plotly/plotly.py#5583 points out that trace
x_axisandy_axissetters are not self-explanatory because users have to discover values like"x2"and"y3"from examples.This PR keeps the existing string-based axis ids, but gives them named types:
XAxisIdYAxisIdThe trace fields now use those named axis-id string types, and the trace setters accept
impl Into<XAxisId>/impl Into<YAxisId>so existing string inputs continue to work without introducing an enum or a hardcoded axis limit.It also adds regression tests for both code paths:
Scatter)Contour)This PR does not include the CI fixes from #397 which have been moved there unlike earlier.
Checklist:
cargo +nightly fmt --all -- --checkandcd examples && cargo +nightly fmt --all -- --check.cargo clippy -p plotly -p plotly_derive -- -D warnings -A deprecated.cargo test -p plotly axis_id --features static_export_chromedriver.cargo test -p plotly --features plotly_ndarray,plotly_image,static_export_chromedriver,debug.The validation screenshots of the tests run, locally: