Skip to content

Commit b46500a

Browse files
committed
Feat: bump plotly
1 parent 870dfc6 commit b46500a

File tree

3 files changed

+52
-36
lines changed

3 files changed

+52
-36
lines changed

plotly/Cargo.toml

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,7 @@ repository = "https://github.com/igiagkiozis/plotly"
1212
edition = "2018"
1313
keywords = ["plot", "chart", "plotly"]
1414

15-
exclude = [
16-
"target/*"
17-
]
15+
exclude = ["target/*"]
1816

1917
[features]
2018
# Adds plot save functionality to the following formats: png, jpeg, webp, svg, pdf and eps.
@@ -23,17 +21,17 @@ plotly_ndarray = ["ndarray"]
2321

2422
[dependencies]
2523
plotly_kaleido = { version = "0.2.0", path = "../plotly_kaleido", optional = true }
26-
ndarray = { version = ">=0.13.1", optional = true }
27-
serde = { version = "1.0", features = ["derive"] }
28-
serde_json = "1.0"
29-
askama = "0.9.0"
30-
rand = "0.7.3"
31-
rand_distr = "0.2.2"
24+
ndarray = { version = "0.15.1", optional = true }
25+
serde = { version = "1.0.125", features = ["derive"] }
26+
serde_json = "1.0.64"
27+
askama = "0.10.5"
28+
rand = "0.8.3"
29+
rand_distr = "0.4.0"
3230

3331

3432
[dev-dependencies]
3533
plotly_kaleido = { version = "0.2.0", path = "../plotly_kaleido" }
36-
itertools = "0.9.0"
34+
itertools = "0.10.0"
3735
itertools-num = "0.1.3"
38-
csv = "1.1.3"
39-
ndarray = "0.13.1"
36+
csv = "1.1.6"
37+
ndarray = "0.15.1"

plotly/src/plot.rs

Lines changed: 39 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ pub enum ImageFormat {
5454
EPS,
5555
}
5656

57-
5857
/// A struct that implements `Trace` can be serialized to json format that is understood by Plotly.js.
5958
pub trait Trace {
6059
fn serialize(&self) -> String;
@@ -120,7 +119,6 @@ plot.save("filename", ImageFormat::PNG, width, height, scale);
120119
See https://igiagkiozis.github.io/plotly/content/getting_started.html for further details.
121120
"#;
122121

123-
124122
impl Plot {
125123
/// Create a new `Plot`.
126124
pub fn new() -> Plot {
@@ -164,10 +162,13 @@ impl Plot {
164162
let rendered = rendered.as_bytes();
165163
let mut temp = env::temp_dir();
166164

167-
let mut plot_name = rand::thread_rng()
168-
.sample_iter(&rand::distributions::Alphanumeric)
169-
.take(22)
170-
.collect::<String>();
165+
let mut plot_name = String::from_utf8(
166+
thread_rng()
167+
.sample_iter(&Alphanumeric)
168+
.take(22)
169+
.collect::<Vec<u8>>(),
170+
)
171+
.unwrap();
171172
plot_name.push_str(".html");
172173
plot_name = format!("plotly_{}", plot_name);
173174

@@ -191,10 +192,13 @@ impl Plot {
191192
let rendered = rendered.as_bytes();
192193
let mut temp = env::temp_dir();
193194

194-
let mut plot_name = rand::thread_rng()
195-
.sample_iter(&rand::distributions::Alphanumeric)
196-
.take(22)
197-
.collect::<String>();
195+
let mut plot_name = String::from_utf8(
196+
thread_rng()
197+
.sample_iter(&Alphanumeric)
198+
.take(22)
199+
.collect::<Vec<u8>>(),
200+
)
201+
.unwrap();
198202
plot_name.push_str(".html");
199203

200204
temp.push(plot_name);
@@ -217,10 +221,13 @@ impl Plot {
217221
let rendered = rendered.as_bytes();
218222
let mut temp = env::temp_dir();
219223

220-
let mut plot_name = rand::thread_rng()
221-
.sample_iter(&rand::distributions::Alphanumeric)
222-
.take(22)
223-
.collect::<String>();
224+
let mut plot_name: String = String::from_utf8(
225+
thread_rng()
226+
.sample_iter(&Alphanumeric)
227+
.take(22)
228+
.collect::<Vec<u8>>(),
229+
)
230+
.unwrap();
224231
plot_name.push_str(".html");
225232

226233
temp.push(plot_name);
@@ -260,14 +267,26 @@ impl Plot {
260267
match plot_div_id {
261268
Some(id) => self.render_inline(id.as_ref()),
262269
None => {
263-
let rand_id: String = thread_rng().sample_iter(&Alphanumeric).take(20).collect();
270+
let rand_id = String::from_utf8(
271+
thread_rng()
272+
.sample_iter(&Alphanumeric)
273+
.take(20)
274+
.collect::<Vec<u8>>(),
275+
)
276+
.unwrap();
264277
self.render_inline(rand_id.as_str())
265278
}
266279
}
267280
}
268281

269282
fn to_jupyter_notebook_html(&self) -> String {
270-
let plot_div_id: String = thread_rng().sample_iter(&Alphanumeric).take(20).collect();
283+
let plot_div_id = String::from_utf8(
284+
thread_rng()
285+
.sample_iter(&Alphanumeric)
286+
.take(20)
287+
.collect::<Vec<u8>>(),
288+
)
289+
.unwrap();
271290
let plot_data = self.render_plot_data();
272291

273292
let tmpl = JupyterNotebookPlotTemplate {
@@ -280,7 +299,10 @@ impl Plot {
280299
/// Display plot in Jupyter Notebook.
281300
pub fn notebook_display(&self) {
282301
let plot_data = self.to_jupyter_notebook_html();
283-
println!("EVCXR_BEGIN_CONTENT text/html\n{}\nEVCXR_END_CONTENT", plot_data);
302+
println!(
303+
"EVCXR_BEGIN_CONTENT text/html\n{}\nEVCXR_END_CONTENT",
304+
plot_data
305+
);
284306
}
285307

286308
/// Display plot in Jupyter Lab.

plotly_kaleido/Cargo.toml

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,15 @@ repository = "https://github.com/igiagkiozis/plotly"
1212
edition = "2018"
1313
keywords = ["plot", "chart", "plotly", "ndarray"]
1414

15-
exclude = [
16-
"target/*",
17-
"kaleido/*",
18-
"examples/*"
19-
]
15+
exclude = ["target/*", "kaleido/*", "examples/*"]
2016

2117
[dependencies]
2218
serde = { version = "1.0", features = ["derive"] }
2319
serde_json = "1.0"
24-
base64 = "0.12.3"
20+
base64 = "0.13.0"
2521

2622
[dev-dependencies]
2723
zip = "0.5.6"
2824

2925
[build-dependencies]
30-
zip = "0.5.6"
26+
zip = "0.5.6"

0 commit comments

Comments
 (0)