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

Creates a new empty Sankey diagram.

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

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

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.

Set and style the title to appear for the legend group

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

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.

Sets the hover label for this trace.

Sets the font for node labels.

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

Sets the orientation of the Sankey diagram.

The nodes of the Sankey diagram.

The links of the Sankey diagram.

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.

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.

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.

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

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

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

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

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

The resulting type after obtaining ownership.

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

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

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.