Skip to content

Commit 0259d0c

Browse files
mchantandrei-ng
authored andcommitted
corrected some errors
1 parent 8fab449 commit 0259d0c

File tree

1 file changed

+5
-12
lines changed

1 file changed

+5
-12
lines changed

plotly/src/plot.rs

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -425,13 +425,13 @@ impl Plot {
425425
width: usize,
426426
height: usize,
427427
scale: f64,
428-
) -> Result<String, Error> {
428+
) -> Result<String, String> {
429429
match format{
430430
ImageFormat::JPEG => {},
431431
ImageFormat::PNG => {},
432432
ImageFormat::WEBP => {},
433433
_ => {
434-
return Err(Error::new("format can only be JPEG, PNG, or WEBP"));
434+
return Err("Format can only be JPEG, PNG, WEBP are allowed".into());
435435
},
436436
}
437437
let kaleido = plotly_kaleido::Kaleido::new();
@@ -444,29 +444,22 @@ impl Plot {
444444
scale,
445445
)
446446
.unwrap_or_else(|_| panic!("failed to generate b64"));
447-
output
447+
Ok(output)
448448
}
449449

450450
// similar to write_image, but returns svg contents
451451
#[cfg(feature = "kaleido")]
452452
pub fn to_svg(
453453
&self,
454-
format: ImageFormat,
455454
width: usize,
456455
height: usize,
457456
scale: f64,
458-
) -> Result<String, Error> {
459-
match format{
460-
ImageFormat::SVG => {},
461-
_ => {
462-
return Err(Error::new("format can only be SVG"));
463-
},
464-
}
457+
) -> String {
465458
let kaleido = plotly_kaleido::Kaleido::new();
466459
let output = kaleido
467460
.get_image_data(
468461
&serde_json::to_value(self).unwrap(),
469-
&format.to_string(),
462+
"svg",
470463
width,
471464
height,
472465
scale,

0 commit comments

Comments
 (0)