pub struct SvgBackend { /* private fields */ }Expand description
Accumulates SVG markup for a plot rendered via DrawBackend.
Every number written to an attribute is finite: marks whose geometry is
NaN/±inf are dropped (a polyline keeps its finite vertices), and
non-finite style values fall back to safe defaults. All data-derived
attribute values and text go through [escape].
Implementations§
Source§impl SvgBackend
impl SvgBackend
pub fn new(width: u32, height: u32, plot_area: Rect) -> Self
Sourcepub fn set_root_attrs(&mut self, attrs: Vec<(String, String)>)
pub fn set_root_attrs(&mut self, attrs: Vec<(String, String)>)
Add extra attributes to the root <svg> element (e.g. the
data-domain family from root_data_attrs). Names must be plain
attribute names; values are escaped on output.
Sourcepub fn finish(self) -> String
pub fn finish(self) -> String
Wrap the accumulated elements in a complete <svg> document. The
data-plot attribute records the panel (data) area in viewBox units so a
host can map screen coordinates back to data (e.g. for zoom/crosshair).
Sourcepub fn finish_fragment(self, x: f64, y: f64) -> String
pub fn finish_fragment(self, x: f64, y: f64) -> String
Wrap the accumulated elements in a nested <svg> positioned at
(x, y) in a parent SVG’s user space — no xmlns (it inherits the
parent’s namespace), so the result can be pasted into a larger SVG as-is.
data-plot stays in this fragment’s own viewBox units.
Trait Implementations§
Source§impl DrawBackend for SvgBackend
impl DrawBackend for SvgBackend
fn plot_area(&self) -> Rect
fn total_area(&self) -> Rect
Source§fn set_tooltip(&mut self, tooltip: Option<String>)
fn set_tooltip(&mut self, tooltip: Option<String>)
None.
Backends that produce interactive output (SVG) emit it as a <title>
for a native hover tooltip; others ignore it. Default: no-op.Source§fn set_mark_axis(&mut self, key: Option<String>)
fn set_mark_axis(&mut self, key: Option<String>)
data-x attribute so a host can group marks by x (axis-pointer tooltip).
Default: no-op.Source§fn set_mark_series(&mut self, series: Option<String>)
fn set_mark_series(&mut self, series: Option<String>)
data-series, so a host can highlight or
filter one series without parsing the tooltip. Default: no-op.Source§fn set_mark_value(&mut self, value: Option<String>)
fn set_mark_value(&mut self, value: Option<String>)
data-value. Default: no-op.fn draw_circle( &mut self, (cx, cy): (f64, f64), radius: f64, style: &PointStyle, ) -> Result<(), RenderError>
fn draw_line( &mut self, pts: &[(f64, f64)], style: &LineStyle, ) -> Result<(), RenderError>
fn draw_rect( &mut self, (x0, y0): (f64, f64), (x1, y1): (f64, f64), style: &RectStyle, ) -> Result<(), RenderError>
fn draw_polygon( &mut self, pts: &[(f64, f64)], style: &RectStyle, ) -> Result<(), RenderError>
fn draw_text( &mut self, text: &str, (x, y): (f64, f64), style: &TextStyle, ) -> Result<(), RenderError>
Source§fn draw_shape(
&mut self,
center: (f64, f64),
radius: f64,
style: &PointStyle,
) -> Result<(), RenderError>
fn draw_shape( &mut self, center: (f64, f64), radius: f64, style: &PointStyle, ) -> Result<(), RenderError>
Auto Trait Implementations§
impl Freeze for SvgBackend
impl RefUnwindSafe for SvgBackend
impl Send for SvgBackend
impl Sync for SvgBackend
impl Unpin for SvgBackend
impl UnsafeUnpin for SvgBackend
impl UnwindSafe for SvgBackend
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more