MCPcopy Create free account
hub / github.com/alceal/plotlars / save_to_file

Function save_to_file

crates/plotlars-plotters/src/render/mod.rs:120–137  ·  view source on GitHub ↗
(plot: &impl Plot, path: &str)

Source from the content-addressed store, hash-verified

118}
119
120pub fn save_to_file(plot: &impl Plot, path: &str) {
121 let (w, h) = resolve_dimensions(plot.ir_layout());
122
123 if path.ends_with(".svg") {
124 let mut svg = String::new();
125 let dashes;
126 {
127 let root = SVGBackend::with_string(&mut svg, (w, h)).into_drawing_area();
128 dashes = render_to_backend(plot, root);
129 }
130 smooth_svg_lines(&mut svg);
131 apply_svg_dash_patterns(&mut svg, &dashes);
132 std::fs::write(path, svg).unwrap();
133 } else {
134 let root = BitMapBackend::new(path, (w, h)).into_drawing_area();
135 render_to_backend(plot, root);
136 }
137}
138
139pub fn render_to_svg_string(plot: &impl Plot) -> String {
140 let (w, h) = resolve_dimensions(plot.ir_layout());

Callers 2

saveMethod · 0.85
plot_interactiveFunction · 0.85

Calls 5

resolve_dimensionsFunction · 0.85
render_to_backendFunction · 0.85
smooth_svg_linesFunction · 0.85
apply_svg_dash_patternsFunction · 0.85
ir_layoutMethod · 0.45

Tested by

no test coverage detected