We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 7aecfa7 commit dd57bf6Copy full SHA for dd57bf6
plotly/src/plot.rs
@@ -417,6 +417,28 @@ impl Plot {
417
.unwrap_or_else(|_| panic!("failed to export plot to {:?}", filename.as_ref()));
418
}
419
420
+ // similar to write_image, but returns b64 string
421
+ #[cfg(feature = "kaleido")]
422
+ pub fn get_b64(
423
+ &self,
424
+ format: ImageFormat,
425
+ width: usize,
426
+ height: usize,
427
+ scale: f64,
428
+ ) -> String {
429
+ let kaleido = plotly_kaleido::Kaleido::new();
430
+ let output = kaleido
431
+ .to_b64(
432
+ &serde_json::to_value(self).unwrap(),
433
+ &format.to_string(),
434
+ width,
435
+ height,
436
+ scale,
437
+ )
438
+ .unwrap_or_else(|_| panic!("failed to generate b64"));
439
+ output
440
+ }
441
+
442
fn render(&self) -> String {
443
let tmpl = PlotTemplate {
444
plot: self,
0 commit comments