File tree Expand file tree Collapse file tree 1 file changed +5
-12
lines changed Expand file tree Collapse file tree 1 file changed +5
-12
lines changed Original file line number Diff line number Diff line change @@ -425,13 +425,13 @@ impl Plot {
425
425
width : usize ,
426
426
height : usize ,
427
427
scale : f64 ,
428
- ) -> Result < String , Error > {
428
+ ) -> Result < String , String > {
429
429
match format{
430
430
ImageFormat :: JPEG => { } ,
431
431
ImageFormat :: PNG => { } ,
432
432
ImageFormat :: WEBP => { } ,
433
433
_ => {
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 ( ) ) ;
435
435
} ,
436
436
}
437
437
let kaleido = plotly_kaleido:: Kaleido :: new ( ) ;
@@ -444,29 +444,22 @@ impl Plot {
444
444
scale,
445
445
)
446
446
. unwrap_or_else ( |_| panic ! ( "failed to generate b64" ) ) ;
447
- output
447
+ Ok ( output)
448
448
}
449
449
450
450
// similar to write_image, but returns svg contents
451
451
#[ cfg( feature = "kaleido" ) ]
452
452
pub fn to_svg (
453
453
& self ,
454
- format : ImageFormat ,
455
454
width : usize ,
456
455
height : usize ,
457
456
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 {
465
458
let kaleido = plotly_kaleido:: Kaleido :: new ( ) ;
466
459
let output = kaleido
467
460
. get_image_data (
468
461
& serde_json:: to_value ( self ) . unwrap ( ) ,
469
- & format . to_string ( ) ,
462
+ "svg" ,
470
463
width,
471
464
height,
472
465
scale,
You can’t perform that action at this time.
0 commit comments