Skip to content

plotly 0.8.1 seems not work with kaleido 0.3.0 #106

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

Closed
m-wim opened this issue Oct 12, 2022 · 9 comments · Fixed by #124
Closed

plotly 0.8.1 seems not work with kaleido 0.3.0 #106

m-wim opened this issue Oct 12, 2022 · 9 comments · Fixed by #124

Comments

@m-wim
Copy link

m-wim commented Oct 12, 2022

Is there anything wrong with this?

Envrionment:
Toolchain: stable-x86_64-pc-windows-msvc
Rust/Cargo: 1.64.0

Steps to reproduce:
cargo init app_name
cd app_name
cargo add plotly
cargo add plotly --features kaleido
cargo check

Output:
....

   Compiling plotly_kaleido v0.3.0
    Checking plotly v0.8.1
error[E0308]: mismatched types
   --> C:\Users\mwim\.cargo\registry\src\github.com-1ecc6299db9ec823\plotly-0.8.1\src\plot.rs:385:17
    |
383 |             .save(
    |              ---- arguments to this function are incorrect
384 |                 filename.as_ref(),
385 |                 &serde_json::to_value(self).unwrap(),
    |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `str`, found enum `Value`
    |
    = note: expected reference `&str`
               found reference `&Value`
note: associated function defined here
   --> C:\Users\mwim\.cargo\registry\src\github.com-1ecc6299db9ec823\plotly_kaleido-0.3.0\src\lib.rs:124:12
    |
124 |     pub fn save(
    |            ^^^^

For more information about this error, try `rustc --explain E0308`.
error: could not compile `plotly` due to previous error
@andrei-ng
Copy link
Collaborator

andrei-ng commented Oct 13, 2022

I can confirm the same behavior. Compling plotly as a dependency in a standalone project gives the above error. Strangely, building any example in master branch works fine.

Minimal example below.

Cargo.toml

[package]
name = "rust-plotting"
version = "0.1.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
plotly = { version = "0.8.1", features = ["kaleido"]}

main.rs

use plotly::common::{AxisSide, Font, Title};
use plotly::layout::{Axis, GridPattern, Layout, LayoutGrid, Legend, RowOrder, TraceOrder};
use plotly::{color::Rgb, Plot, Scatter};

use plotly::ImageFormat;

fn main() {
    let trace1 = Scatter::new(vec![1, 2, 3], vec![4, 5, 6]).name("trace1");
    let trace2 = Scatter::new(vec![20, 30, 40], vec![50, 60, 70])
        .name("trace2")
        .x_axis("x2")
        .y_axis("y2");

    let mut plot = Plot::new();
    plot.add_trace(trace1);
    plot.add_trace(trace2);

    let layout = Layout::new()
        .x_axis(Axis::new().domain(&[0., 0.7]))
        .y_axis2(Axis::new().anchor("x2"))
        .x_axis2(Axis::new().domain(&[0.8, 1.]));
    plot.set_layout(layout);
    plot.show();

    // The following will save the plot in all available formats and show the plot.
    plot.write_image("scatter", ImageFormat::SVG, 1024, 680, 1.0);
    println!("{}", plot.to_inline_html(Some("custom_sized_subplot")));
}

@andrei-ng
Copy link
Collaborator

I am new to rust, but after digging deeper, it seems that the Cargo published version of plotly_kaleido is wrong. Doing a diff between what Cargo downloads in the registry at .cargo/registry/src/github.com-1ecc6299db9ec823/plotly_kaleido-0.3.0 and what is in the github version for tag 0.8.1 shows major differences.

@mfreeborn
Copy link
Contributor

I agree with your findings, @andrei-ng. It looks like I need to bump the version of plotly_kaleido and publish it to crates.io, as well as making the appropriate change to the plotly_kaleido dependency in the main plotly Cargo.toml manifest.

I'll need to ask @igiagkiozis for shared ownership of the plotly_kaleido crate on crates.io and then I can push the changes asap.

@andrei-ng
Copy link
Collaborator

@mfreeborn , I noticed you were hard at work to refactor and close all the PRs :)

Any update on this one since the release of v0.8.2 would likely have the same issue ?

@mfreeborn
Copy link
Contributor

mfreeborn commented Nov 3, 2022 via email

@andrei-ng
Copy link
Collaborator

OK, thank you!

@mfreeborn mfreeborn mentioned this issue Nov 6, 2022
@mfreeborn
Copy link
Contributor

@andrei-ng @m-wim I would expect this to be fixed now in 0.8.3 :)

@andrei-ng
Copy link
Collaborator

I can confirm all works well now. Thank you very much for the effort @mfreeborn !

@mfreeborn
Copy link
Contributor

mfreeborn commented Nov 7, 2022 via email

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

Successfully merging a pull request may close this issue.

3 participants