Skip to main content

SankeyPlot

Struct SankeyPlot 

Source
pub struct SankeyPlot {
Show 19 fields pub nodes: Vec<SankeyNode>, pub links: Vec<SankeyLink>, pub alluvia: Vec<SankeyAlluvium>, pub axis_names: Option<Vec<String>>, pub link_color: SankeyLinkColor, pub node_order: SankeyNodeOrder, pub node_coloring: SankeyNodeColoring, pub node_order_seed: u64, pub palette: Option<Vec<String>>, pub left_color_cutoff: f64, pub link_opacity: f64, pub node_width: f64, pub node_gap: f64, pub legend_label: Option<String>, pub flow_labels: bool, pub flow_percent: bool, pub flow_label_format: TickFormat, pub flow_label_unit: Option<String>, pub flow_label_min_height: f64,
}
Expand description

A Sankey diagram: nodes arranged in columns, connected by tapered ribbons.

Fields§

§nodes: Vec<SankeyNode>§links: Vec<SankeyLink>§alluvia: Vec<SankeyAlluvium>§axis_names: Option<Vec<String>>§link_color: SankeyLinkColor§node_order: SankeyNodeOrder§node_coloring: SankeyNodeColoring§node_order_seed: u64§palette: Option<Vec<String>>§left_color_cutoff: f64§link_opacity: f64

Ribbon fill opacity (default 0.5).

§node_width: f64

Node rectangle width in pixels (default 20.0).

§node_gap: f64

Minimum gap between nodes in a column in pixels (default 8.0).

§legend_label: Option<String>

If set, adds one legend entry per node.

§flow_labels: bool

Show the absolute flow value on each ribbon (default false).

§flow_percent: bool

Show each flow as a percentage of its source node’s total outflow (default false). Takes priority over flow_labels when both are set.

§flow_label_format: TickFormat

Number format for absolute flow labels (default Auto).

§flow_label_unit: Option<String>

Optional unit suffix appended to absolute labels, e.g. "reads""1 200 reads".

§flow_label_min_height: f64

Minimum ribbon height in pixels required to render a label. Set to 0.0 to always show labels regardless of ribbon size (default 8.0).

Implementations§

Source§

impl SankeyPlot

Source

pub fn new() -> Self

Source

pub fn with_node<S: Into<String>>(self, label: S) -> Self

Declare a node explicitly (no-op if it already exists).

Source

pub fn with_node_color<S: Into<String>, C: Into<String>>( self, label: S, color: C, ) -> Self

Set the color for a node, creating it if absent.

Source

pub fn with_node_column<S: Into<String>>(self, label: S, col: usize) -> Self

Pin a node to a specific column, creating it if absent.

Add a link, auto-creating nodes by label if needed.

Add a link with an explicit per-link color.

Bulk add links from an iterator of (source_label, target_label, value).

Source

pub fn with_axis_names<S, I>(self, axis_names: I) -> Self
where S: Into<String>, I: IntoIterator<Item = S>,

Set display/canonical names for alluvium axes in input order.

Source

pub fn with_alluvium<S, I>(self, strata: I, value: impl Into<f64>) -> Self
where S: Into<String>, I: IntoIterator<Item = S>,

Add a weighted alluvium spanning multiple ordered axes.

Source

pub fn with_alluvia<S, I, J>(self, alluvia: J) -> Self
where S: Into<String>, I: IntoIterator<Item = S>, J: IntoIterator<Item = (I, f64)>,

Bulk add weighted alluvia from an iterator of (strata, value).

Use gradient ribbons (linearGradient from source to target color).

Use per-link colors (falls back to source color if link.color is None).

Source

pub fn with_node_order(self, order: SankeyNodeOrder) -> Self

Choose how nodes are ordered within each column.

Source

pub fn with_node_coloring(self, coloring: SankeyNodeColoring) -> Self

Choose how node colors are assigned when explicit node colors are absent.

Source

pub fn with_node_order_seed(self, seed: u64) -> Self

Set the RNG seed used by crossing-reduction ordering.

Source

pub fn with_crossing_reduction(self) -> Self

Minimize weighted crossings within columns using a wompwomp-style TSP cycle with Fenwick-scored objective evaluation.

Source

pub fn with_neighbornet(self) -> Self

Use the neighbornet backend for alluvium/Sankey ordering.

Source

pub fn with_left_coloring(self) -> Self

Match wompwomp’s left-to-right color propagation.

Source

pub fn with_palette(self, colors: Vec<String>) -> Self

Override the palette used for fallback Sankey node colors.

Source

pub fn with_left_color_cutoff(self, cutoff: f64) -> Self

Set the parent-share threshold used by left coloring. Default: 0.5.

Source

pub fn with_node_width(self, width: f64) -> Self

Source

pub fn with_node_gap(self, gap: f64) -> Self

Source

pub fn with_legend<S: Into<String>>(self, label: S) -> Self

Source

pub fn with_flow_labels(self) -> Self

Show the absolute flow value on each ribbon. Combine with with_flow_label_format and with_flow_label_unit as needed.

Source

pub fn with_flow_percent(self) -> Self

Show each flow as a percentage of its source node’s total outflow. Takes priority over with_flow_labels when both are set.

Source

pub fn with_flow_label_format(self, fmt: TickFormat) -> Self

Number format for absolute flow labels (default: TickFormat::Auto). Has no effect when with_flow_percent is active.

Source

pub fn with_flow_label_unit<S: Into<String>>(self, unit: S) -> Self

Append a unit string to each absolute flow label, e.g. "reads""1200 reads". Has no effect in percent mode.

Source

pub fn with_flow_label_min_height(self, min_h: f64) -> Self

Minimum ribbon height in pixels required to render a flow label. Set to 0.0 to always show labels regardless of ribbon size (default: 8.0).

Trait Implementations§

Source§

impl Clone for SankeyPlot

Source§

fn clone(&self) -> SankeyPlot

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for SankeyPlot

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for SankeyPlot

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl From<SankeyPlot> for Plot

Source§

fn from(p: SankeyPlot) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> Finish for T

Source§

fn finish(self)

Does nothing but move self, equivalent to drop.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<U, T> ToOwnedObj<U> for T
where U: FromObjRef<T>,

Source§

fn to_owned_obj(&self, data: FontData<'_>) -> U

Convert this type into T, using the provided data to resolve any offsets.
Source§

impl<U, T> ToOwnedTable<U> for T
where U: FromTableRef<T>,

Source§

fn to_owned_table(&self) -> U

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.