Struct plotly::traces::sankey::Sankey

source ·
pub struct Sankey<V>where
    V: Serialize + Clone,{ /* private fields */ }
Expand description

Construct a Sankey trace.

Examples

use plotly::{
    Sankey,
    common::Orientation,
    sankey::{Line, Link, Node}
};

let line = Line::new().color("#00FF00").width(0.5);

let node = Node::new()
    .line(line)
    .pad(15)
    .thickness(30)
    .label(vec!["A1", "A2", "B1", "B2", "C1", "C2"])
    .color("#0000FF");

let link = Link::new()
    .value(vec![8, 4, 2, 8, 4, 2])
    .source(vec![0, 1, 0, 2, 3, 3])
    .target(vec![2, 3, 3, 4, 4, 5]);

let trace = Sankey::new()
    .node(node)
    .link(link)
    .orientation(Orientation::Horizontal);

let expected = serde_json::json!({
    "type": "sankey",
    "orientation": "h",
    "node": {
        "color": "#0000FF",
        "label": ["A1", "A2", "B1", "B2", "C1", "C2"],
        "thickness": 30,
        "pad": 15,
        "line": {
            "color": "#00FF00",
            "width": 0.5,
        }
    },
    "link": {
        "source": [0, 1, 0, 2, 3, 3],
        "target": [2, 3, 3, 4, 4, 5],
        "value": [8, 4, 2, 8, 4, 2]
    }
});

assert_eq!(serde_json::to_value(trace).unwrap(), expected);

Implementations§

source§

impl<V> Sankey<V>where V: Serialize + Clone,

source

pub fn arrangement(self, value: Arrangement) -> Box<Self>

If value is snap (the default), the node arrangement is assisted by automatic snapping of elements to preserve space between nodes specified via nodepad. If value is perpendicular, the nodes can only move along a line perpendicular to the flow. If value is freeform, the nodes can freely move on the plane. If value is fixed, the nodes are stationary.

source

pub fn modify_all_arrangement(value: Arrangement) -> RestyleSankey<V>

Apply the same restyling to all the traces

source

pub fn modify_arrangement(values: Vec<Arrangement>) -> RestyleSankey<V>

Apply the restyling individually to each trace. Caller is responsible to set the length of the vector to be equal to the number of traces

source

pub fn domain(self, value: Domain) -> Box<Self>

Sets the domain within which the Sankey diagram will be drawn.

source

pub fn modify_all_domain(value: Domain) -> RestyleSankey<V>

Apply the same restyling to all the traces

source

pub fn modify_domain(values: Vec<Domain>) -> RestyleSankey<V>

Apply the restyling individually to each trace. Caller is responsible to set the length of the vector to be equal to the number of traces

source

pub fn ids(self, value: Vec<impl AsRef<str>>) -> Box<Self>

Assigns id labels to each datum. These ids are for object constancy of data points during animation.

source

pub fn modify_all_ids(value: Vec<impl AsRef<str>>) -> RestyleSankey<V>

Apply the same restyling to all the traces

source

pub fn modify_ids(values: Vec<Vec<impl AsRef<str>>>) -> RestyleSankey<V>

Apply the restyling individually to each trace. Caller is responsible to set the length of the vector to be equal to the number of traces

source

pub fn hover_info(self, value: HoverInfo) -> Box<Self>

Determines which trace information appear on hover. If none or skip are set, no information is displayed upon hovering. But, if none is set, click and hover events are still fired. Note that this attribute is superseded by node.hover_info and link.hover_info for nodes and links respectively.

source

pub fn modify_all_hover_info(value: HoverInfo) -> RestyleSankey<V>

Apply the same restyling to all the traces

source

pub fn modify_hover_info(values: Vec<HoverInfo>) -> RestyleSankey<V>

Apply the restyling individually to each trace. Caller is responsible to set the length of the vector to be equal to the number of traces

source

pub fn hover_label(self, value: Label) -> Box<Self>

Sets the hover label for this trace.

source

pub fn modify_all_hover_label(value: Label) -> RestyleSankey<V>

Apply the same restyling to all the traces

source

pub fn modify_hover_label(values: Vec<Label>) -> RestyleSankey<V>

Apply the restyling individually to each trace. Caller is responsible to set the length of the vector to be equal to the number of traces

source

pub fn legend_group_title(self, value: LegendGroupTitle) -> Box<Self>

Set and style the title to appear for the legend group

source

pub fn modify_all_legend_group_title( value: LegendGroupTitle ) -> RestyleSankey<V>

Apply the same restyling to all the traces

source

pub fn modify_legend_group_title( values: Vec<LegendGroupTitle> ) -> RestyleSankey<V>

Apply the restyling individually to each trace. Caller is responsible to set the length of the vector to be equal to the number of traces

source

pub fn legend_rank(self, value: usize) -> Box<Self>

Sets the legend rank for this trace. Items and groups with smaller ranks are presented on top/left side while with "reversed" legend.trace_order` they are on bottom/right side. The default legendrank is 1000, so that you can use ranks less than 1000 to place certain items before all unranked items, and ranks greater than 1000 to go after all unranked items.

source

pub fn modify_all_legend_rank(value: usize) -> RestyleSankey<V>

Apply the same restyling to all the traces

source

pub fn modify_legend_rank(values: Vec<usize>) -> RestyleSankey<V>

Apply the restyling individually to each trace. Caller is responsible to set the length of the vector to be equal to the number of traces

The links of the Sankey diagram.

Apply the same restyling to all the traces

Apply the restyling individually to each trace. Caller is responsible to set the length of the vector to be equal to the number of traces

source

pub fn name(self, value: impl AsRef<str>) -> Box<Self>

Sets the trace name. The trace name appears as the legend item and on hover.

source

pub fn modify_all_name(value: impl AsRef<str>) -> RestyleSankey<V>

Apply the same restyling to all the traces

source

pub fn modify_name(values: Vec<impl AsRef<str>>) -> RestyleSankey<V>

Apply the restyling individually to each trace. Caller is responsible to set the length of the vector to be equal to the number of traces

source

pub fn node(self, value: Node) -> Box<Self>

The nodes of the Sankey diagram.

source

pub fn modify_all_node(value: Node) -> RestyleSankey<V>

Apply the same restyling to all the traces

source

pub fn modify_node(values: Vec<Node>) -> RestyleSankey<V>

Apply the restyling individually to each trace. Caller is responsible to set the length of the vector to be equal to the number of traces

source

pub fn orientation(self, value: Orientation) -> Box<Self>

Sets the orientation of the Sankey diagram.

source

pub fn modify_all_orientation(value: Orientation) -> RestyleSankey<V>

Apply the same restyling to all the traces

source

pub fn modify_orientation(values: Vec<Orientation>) -> RestyleSankey<V>

Apply the restyling individually to each trace. Caller is responsible to set the length of the vector to be equal to the number of traces

source

pub fn selected_points(self, value: Vec<usize>) -> Box<Self>

Vector containing integer indices of selected points. Has an effect only for traces that support selections. Note that an empty vector means an empty selection where the unselected are turned on for all points.

source

pub fn modify_all_selected_points(value: Vec<usize>) -> RestyleSankey<V>

Apply the same restyling to all the traces

source

pub fn modify_selected_points(values: Vec<Vec<usize>>) -> RestyleSankey<V>

Apply the restyling individually to each trace. Caller is responsible to set the length of the vector to be equal to the number of traces

source

pub fn text_font(self, value: Font) -> Box<Self>

Sets the font for node labels.

source

pub fn modify_all_text_font(value: Font) -> RestyleSankey<V>

Apply the same restyling to all the traces

source

pub fn modify_text_font(values: Vec<Font>) -> RestyleSankey<V>

Apply the restyling individually to each trace. Caller is responsible to set the length of the vector to be equal to the number of traces

source

pub fn value_format(self, value: impl AsRef<str>) -> Box<Self>

Sets the value formatting rule using d3 formatting mini-languages which are very similar to those in Python. For numbers, see: https://github.com/d3/d3-format/tree/v1.4.5#d3-format.

source

pub fn modify_all_value_format(value: impl AsRef<str>) -> RestyleSankey<V>

Apply the same restyling to all the traces

source

pub fn modify_value_format(values: Vec<impl AsRef<str>>) -> RestyleSankey<V>

Apply the restyling individually to each trace. Caller is responsible to set the length of the vector to be equal to the number of traces

source

pub fn value_suffix(self, value: impl AsRef<str>) -> Box<Self>

Adds a unit to follow the value in the hover tooltip. Add a space if a separation is necessary from the value.

source

pub fn modify_all_value_suffix(value: impl AsRef<str>) -> RestyleSankey<V>

Apply the same restyling to all the traces

source

pub fn modify_value_suffix(values: Vec<impl AsRef<str>>) -> RestyleSankey<V>

Apply the restyling individually to each trace. Caller is responsible to set the length of the vector to be equal to the number of traces

source

pub fn visible(self, value: bool) -> Box<Self>

Determines whether or not this trace is visible. If “legendonly”, the trace is not drawn, but can appear as a legend item (provided that the legend itself is visible).

source

pub fn modify_all_visible(value: bool) -> RestyleSankey<V>

Apply the same restyling to all the traces

source

pub fn modify_visible(values: Vec<bool>) -> RestyleSankey<V>

Apply the restyling individually to each trace. Caller is responsible to set the length of the vector to be equal to the number of traces

source§

impl<V> Sankey<V>where V: Serialize + Clone,

source

pub fn new() -> Box<Self>

Creates a new empty Sankey diagram.

Trait Implementations§

source§

impl<V> Clone for Sankey<V>where V: Serialize + Clone + Clone,

source§

fn clone(&self) -> Sankey<V>

Returns a copy of the value. Read more
1.0.0 · source§

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

Performs copy-assignment from source. Read more
source§

impl<V> Default for Sankey<V>where V: Serialize + Clone,

source§

fn default() -> Self

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

impl<V> Serialize for Sankey<V>where V: Serialize + Clone + Serialize,

source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
source§

impl<V> Trace for Sankey<V>where V: Serialize + Clone,

source§

fn to_json(&self) -> String

Auto Trait Implementations§

§

impl<V> !RefUnwindSafe for Sankey<V>

§

impl<V> Send for Sankey<V>where V: Send,

§

impl<V> Sync for Sankey<V>where V: Sync,

§

impl<V> Unpin for Sankey<V>where V: Unpin,

§

impl<V> !UnwindSafe for Sankey<V>

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

source§

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

Mutably borrows from an owned value. Read more
source§

impl<T> DynClone for Twhere T: Clone,

source§

fn __clone_box(&self, _: Private) -> *mut ()

source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere 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> Serialize for Twhere T: Serialize + ?Sized,

source§

fn erased_serialize(&self, serializer: &mut dyn Serializer) -> Result<Ok, Error>

source§

impl<T> ToOwned for Twhere T: Clone,

§

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<T, U> TryFrom<U> for Twhere U: Into<T>,

§

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 Twhere U: TryFrom<T>,

§

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.
§

impl<V, T> VZip<V> for Twhere V: MultiLane<T>,

§

fn vzip(self) -> V