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
sourceimpl<V> Sankey<V>where
V: Serialize + Clone,
impl<V> Sankey<V>where
V: Serialize + Clone,
sourcepub fn name(self, name: &str) -> Box<Self>
pub fn name(self, name: &str) -> Box<Self>
Sets the trace name. The trace name appears as the legend item and on hover.
sourcepub fn visible(self, visible: bool) -> Box<Self>
pub fn visible(self, visible: 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).
sourcepub fn legend_rank(self, legend_rank: usize) -> Box<Self>
pub fn legend_rank(self, legend_rank: 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.
sourcepub fn legend_group_title(
self,
legend_group_title: LegendGroupTitle
) -> Box<Self>
pub fn legend_group_title(
self,
legend_group_title: LegendGroupTitle
) -> Box<Self>
Set and style the title to appear for the legend group
sourcepub fn ids(self, ids: Vec<&str>) -> Box<Self>
pub fn ids(self, ids: Vec<&str>) -> Box<Self>
Assigns id labels to each datum. These ids are for object constancy of data points during animation.
sourcepub fn hover_info(self, hover_info: HoverInfo) -> Box<Self>
pub fn hover_info(self, hover_info: 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.
sourcepub fn hover_label(self, hover_label: Label) -> Box<Self>
pub fn hover_label(self, hover_label: Label) -> Box<Self>
Sets the hover label for this trace.
sourcepub fn domain(self, domain: Domain) -> Box<Self>
pub fn domain(self, domain: Domain) -> Box<Self>
Sets the domain within which the Sankey diagram will be drawn.
sourcepub fn orientation(self, orientation: Orientation) -> Box<Self>
pub fn orientation(self, orientation: Orientation) -> Box<Self>
Sets the orientation of the Sankey diagram.
sourcepub fn selected_points(self, selected_points: Vec<usize>) -> Box<Self>
pub fn selected_points(self, selected_points: 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.
sourcepub fn arrangement(self, arrangement: Arrangement) -> Box<Self>
pub fn arrangement(self, arrangement: 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.
sourcepub fn value_format(self, value_format: &str) -> Box<Self>
pub fn value_format(self, value_format: &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.
sourcepub fn value_suffix(self, value_suffix: &str) -> Box<Self>
pub fn value_suffix(self, value_suffix: &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.
Trait Implementations
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
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more