Skip to content

Commit

Permalink
corrected some errors
Browse files Browse the repository at this point in the history
  • Loading branch information
mchant authored and andrei-ng committed Nov 24, 2024
1 parent 90956c1 commit 75cb2d5
Showing 1 changed file with 5 additions and 12 deletions.
17 changes: 5 additions & 12 deletions plotly/src/plot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -425,13 +425,13 @@ impl Plot {
width: usize,
height: usize,
scale: f64,
) -> Result<String, Error> {
) -> Result<String, String> {
match format{
ImageFormat::JPEG => {},
ImageFormat::PNG => {},
ImageFormat::WEBP => {},
_ => {
return Err(Error::new("format can only be JPEG, PNG, or WEBP"));
return Err("Format can only be JPEG, PNG, WEBP are allowed".into());
},
}
let kaleido = plotly_kaleido::Kaleido::new();
Expand All @@ -444,29 +444,22 @@ impl Plot {
scale,
)
.unwrap_or_else(|_| panic!("failed to generate b64"));
output
Ok(output)
}

// similar to write_image, but returns svg contents
#[cfg(feature = "kaleido")]
pub fn to_svg(
&self,
format: ImageFormat,
width: usize,
height: usize,
scale: f64,
) -> Result<String, Error> {
match format{
ImageFormat::SVG => {},
_ => {
return Err(Error::new("format can only be SVG"));
},
}
) -> String {
let kaleido = plotly_kaleido::Kaleido::new();
let output = kaleido
.get_image_data(
&serde_json::to_value(self).unwrap(),
&format.to_string(),
"svg",
width,
height,
scale,
Expand Down

0 comments on commit 75cb2d5

Please sign in to comment.