Skip to content

enum

Mark

pub enum Mark {
    Rect { x: f32, y: f32, w: f32, h: f32, r: f32, fill: String, opacity: f32 },
    Line { x1: f32, y1: f32, x2: f32, y2: f32, stroke: String, width: f32, opacity: f32, dash: Option<&'static str> },
    Path { points: Vec<(f32, f32)>, closed: bool, fill: Option<String>, stroke: Option<String>, width: f32, opacity: f32 },
    Arc { cx: f32, cy: f32, r: f32, inner: f32, start: f32, end: f32, fill: String },
    Circle { x: f32, y: f32, r: f32, fill: String, stroke: Option<String>, width: f32 },
    Region { d: String, rings: Vec<Vec<(f32, f32)>>, fill: String },
    Text { x: f32, y: f32, text: String, anchor: &'static str, size: f32, fill: String, opacity: f32, weight: u32 },
}

A shape a chart draws.

Variants

Rect

Rect { x: f32, y: f32, w: f32, h: f32, r: f32, fill: String, opacity: f32 }

A rectangle with rounded corners (r).

Line

Line { x1: f32, y1: f32, x2: f32, y2: f32, stroke: String, width: f32, opacity: f32, dash: Option<&'static str> }

A straight line, solid or dashed.

Path

Path { points: Vec<(f32, f32)>, closed: bool, fill: Option<String>, stroke: Option<String>, width: f32, opacity: f32 }

A line through points, open or closed, stroked or filled.

Arc

Arc { cx: f32, cy: f32, r: f32, inner: f32, start: f32, end: f32, fill: String }

Degrees clockwise from 12 o'clock.

Circle

Circle { x: f32, y: f32, r: f32, fill: String, stroke: Option<String>, width: f32 }

A circle.

Region

Region { d: String, rings: Vec<Vec<(f32, f32)>>, fill: String }

A map region: rings, holes included.

Text

Text { x: f32, y: f32, text: String, anchor: &'static str, size: f32, fill: String, opacity: f32, weight: u32 }

A text label.

Methods

moved

pub fn moved(&mut self, dx: f32, dy: f32)

The mark moved, for a small multiple's place on the page. Map regions stay put: they don't come in small multiples.

center

pub fn center(&self) -> Option<(f32, f32)>

Where a region's middle is, for its tooltip.

to_value

pub fn to_value(&self, dense: bool) -> Value

The record the chart's template reads. Each shape's own flag picks its branch.

Trait implementations