Open
Description
On Windows:
with this in Cargo.toml:
[dependencies]
plotly = { version = "0.12.1", features = ["kaleido", "kaleido_download"] }
rand = "0.8.5"
rand_distr = "0.4.3"
and this code :
use plotly::{
color::{NamedColor},
common::{ Marker },
layout::{Layout, BarMode},
Histogram, Plot, ImageFormat
};
use rand_distr::{Distribution, Normal};
fn sample_normal_distribution(n: usize, mean: f64, std_dev: f64) -> Vec<f64> {
let mut rng = rand::thread_rng();
let dist = Normal::new(mean, std_dev).unwrap();
let mut v = Vec::<f64>::with_capacity(n);
for _idx in 1..n {
v.push(dist.sample(&mut rng));
}
v
}
fn main() {
let samples1 = sample_normal_distribution(500, 0.0, 1.0);
let trace1 = Histogram::new(samples1)
.name("trace 1")
.opacity(0.5)
.marker(Marker::new().color(NamedColor::Green));
let samples2 = sample_normal_distribution(500, 0.0, 1.0);
let trace2 = Histogram::new(samples2)
.name("trace 2")
.opacity(0.6)
.marker(Marker::new().color(NamedColor::Red));
let mut plot = Plot::new();
plot.add_trace(trace1);
plot.add_trace(trace2);
let layout = Layout::new().bar_mode(BarMode::Stack);
plot.set_layout(layout);
plot.write_html("out.html");
plot.write_image("testx", ImageFormat::PNG, 800, 600, 1.0);
}
the file out.html is ok but testx.png is created but empty.
this is the error:
Kaleido failed to generate static image for format: png.
Kaleido stderr output:
[0108/174710.543:WARNING:resource_bundle.cc(405)] locale_file_path.empty() for locale
[0108/174710.605:WARNING:headless_browser_main_parts.cc(83)] Cannot create Pref Service with no user data dir.
is there a way to make this working on windows ?