Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Marker.color_array doesn't support Vec<f64> anymore? #141

Closed
Ionizing opened this issue Mar 10, 2023 · 4 comments
Closed

Marker.color_array doesn't support Vec<f64> anymore? #141

Ionizing opened this issue Mar 10, 2023 · 4 comments

Comments

@Ionizing
Copy link
Contributor

Hi,

I just updated the dependencies of my tiny tool rsgrad, and found there are some breaking change related to color in plotly-rs. The ColorWrapper was removed, and the method impl Color for f64 was also removed. This means I have to transform Vec<f64> to Vec<impl Color> manually, which is rather fussy (I have to write a function to transform f64 to Box<dyn Color> according to each given ColorScalePallete). However, there are still marker.cmin(), marker.cmid() and marker.cmax() methods in API document, the question is do them change anything?

In the latest version of plotly-rs(0.8.3), I have no idea on how to assign the colors for each point in a trace like before (for example, the last fig of ncl bandstructure just used this feature). The examples in plotly-rs book are obsolete, while the large_data_sets in examples/basic_charts/src/main.rs just removes the support of color_array. All these changes just prevented me from adapting the new API of plotly, especially the 'new features' related to color.

So my question is could you please add an example on how to feed marker.color_array() with Vec<f64> or something like that to the documents?

@andrei-ng
Copy link
Collaborator

andrei-ng commented Jun 19, 2024

@Ionizing , does PR #155 made by @tectin0 fix your problem?

@Ionizing
Copy link
Contributor Author

@Ionizing , does PR #155 made by @tectin0 fix your problem?

Hi, thanks for the reply and PR. I'm busy working on other things these weeks. I'll try it next month when I have spare time.

Anyway, thanks for your reply and the PR.

@Ionizing
Copy link
Contributor Author

Migration done

Hi, I just migrated to the latest plotly.rs (v0.9.0) without much effort. Thanks for the job. The implementation of Color trait on String helped a lot, which means I can just simply remove my CustomColor wrapper over the deprecated ColorWrapper and use String directly as color. I really appreciate it.

Other issue

However, after the migration, I find something unexpected:

  1. The height of the graph seems to be fixed to several px instead of 100% of browser window;
  2. The redraw on resize function is broken, I have to refresh the page after the resize to get the graph rendered with new width.

Here are two HTML files: dos.zip

  • the old one is produced by old plotly.rs with plotly.js of v2.2.1;
  • the new one is produced by the latest plotly.rs with plotly.js of v2.12.1.

My machine:

  • macOS 13.5.1 (x86_64)
  • Chrome 127.0.6533.99 Official Build x86_64

Advice

Besides, I have an advice (just an advice, if not feasible, I can just maintain a fork with my own modifications):

The .width method of Bar is Option<usize>, while it is a float number in plotly.js. In some situation, we may need to display bar chart within a curve plot like this:
image
and it's useful to let user specify a proper barwidth to show well. In fact I forked and tried, and everything worked well. I know it may be unreasonable to make this (breaking) change, so this is only my tiny advice.

The original HTML file of the screenshot is enclosed here: tdm_smeared.zip

Thanks again and look forward to you reply!

@andrei-ng
Copy link
Collaborator

@Ionizing , thanks for checking the result of PR #155 . Happy to hear your issues are fixed.
Concerning the other mentioned issues. I propose to make new issues in relation to the things you found broken, I will make them and link to this one (in general I prefer if users don't have to fork 😃 )

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants