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,
impl<V> Sankey<V>where V: Serialize + Clone,
sourcepub fn arrangement(self, value: Arrangement) -> Box<Self>
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.
sourcepub fn modify_all_arrangement(value: Arrangement) -> RestyleSankey<V>
pub fn modify_all_arrangement(value: Arrangement) -> RestyleSankey<V>
Apply the same restyling to all the traces
sourcepub fn modify_arrangement(values: Vec<Arrangement>) -> RestyleSankey<V>
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
sourcepub fn domain(self, value: Domain) -> Box<Self>
pub fn domain(self, value: Domain) -> Box<Self>
Sets the domain within which the Sankey diagram will be drawn.
sourcepub fn modify_all_domain(value: Domain) -> RestyleSankey<V>
pub fn modify_all_domain(value: Domain) -> RestyleSankey<V>
Apply the same restyling to all the traces
sourcepub fn modify_domain(values: Vec<Domain>) -> RestyleSankey<V>
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
sourcepub fn ids(self, value: Vec<impl AsRef<str>>) -> Box<Self>
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.
sourcepub fn modify_all_ids(value: Vec<impl AsRef<str>>) -> RestyleSankey<V>
pub fn modify_all_ids(value: Vec<impl AsRef<str>>) -> RestyleSankey<V>
Apply the same restyling to all the traces
sourcepub fn modify_ids(values: Vec<Vec<impl AsRef<str>>>) -> RestyleSankey<V>
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
sourcepub fn hover_info(self, value: HoverInfo) -> Box<Self>
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.
sourcepub fn modify_all_hover_info(value: HoverInfo) -> RestyleSankey<V>
pub fn modify_all_hover_info(value: HoverInfo) -> RestyleSankey<V>
Apply the same restyling to all the traces
sourcepub fn modify_hover_info(values: Vec<HoverInfo>) -> RestyleSankey<V>
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
sourcepub fn hover_label(self, value: Label) -> Box<Self>
pub fn hover_label(self, value: Label) -> Box<Self>
Sets the hover label for this trace.
sourcepub fn modify_all_hover_label(value: Label) -> RestyleSankey<V>
pub fn modify_all_hover_label(value: Label) -> RestyleSankey<V>
Apply the same restyling to all the traces
sourcepub fn modify_hover_label(values: Vec<Label>) -> RestyleSankey<V>
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
sourcepub fn legend_group_title(self, value: LegendGroupTitle) -> Box<Self>
pub fn legend_group_title(self, value: LegendGroupTitle) -> Box<Self>
Set and style the title to appear for the legend group
sourcepub fn modify_all_legend_group_title(
value: LegendGroupTitle
) -> RestyleSankey<V>
pub fn modify_all_legend_group_title( value: LegendGroupTitle ) -> RestyleSankey<V>
Apply the same restyling to all the traces
sourcepub fn modify_legend_group_title(
values: Vec<LegendGroupTitle>
) -> RestyleSankey<V>
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
sourcepub fn legend_rank(self, value: usize) -> Box<Self>
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.
sourcepub fn modify_all_legend_rank(value: usize) -> RestyleSankey<V>
pub fn modify_all_legend_rank(value: usize) -> RestyleSankey<V>
Apply the same restyling to all the traces
sourcepub fn modify_legend_rank(values: Vec<usize>) -> RestyleSankey<V>
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
sourcepub fn modify_all_link(value: Link<V>) -> RestyleSankey<V>
pub fn modify_all_link(value: Link<V>) -> RestyleSankey<V>
Apply the same restyling to all the traces
sourcepub fn modify_link(values: Vec<Link<V>>) -> RestyleSankey<V>
pub fn modify_link(values: Vec<Link<V>>) -> 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
sourcepub fn name(self, value: impl AsRef<str>) -> Box<Self>
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.
sourcepub fn modify_all_name(value: impl AsRef<str>) -> RestyleSankey<V>
pub fn modify_all_name(value: impl AsRef<str>) -> RestyleSankey<V>
Apply the same restyling to all the traces
sourcepub fn modify_name(values: Vec<impl AsRef<str>>) -> RestyleSankey<V>
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
sourcepub fn modify_all_node(value: Node) -> RestyleSankey<V>
pub fn modify_all_node(value: Node) -> RestyleSankey<V>
Apply the same restyling to all the traces
sourcepub fn modify_node(values: Vec<Node>) -> RestyleSankey<V>
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
sourcepub fn orientation(self, value: Orientation) -> Box<Self>
pub fn orientation(self, value: Orientation) -> Box<Self>
Sets the orientation of the Sankey diagram.
sourcepub fn modify_all_orientation(value: Orientation) -> RestyleSankey<V>
pub fn modify_all_orientation(value: Orientation) -> RestyleSankey<V>
Apply the same restyling to all the traces
sourcepub fn modify_orientation(values: Vec<Orientation>) -> RestyleSankey<V>
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
sourcepub fn selected_points(self, value: Vec<usize>) -> Box<Self>
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.
sourcepub fn modify_all_selected_points(value: Vec<usize>) -> RestyleSankey<V>
pub fn modify_all_selected_points(value: Vec<usize>) -> RestyleSankey<V>
Apply the same restyling to all the traces
sourcepub fn modify_selected_points(values: Vec<Vec<usize>>) -> RestyleSankey<V>
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
sourcepub fn modify_all_text_font(value: Font) -> RestyleSankey<V>
pub fn modify_all_text_font(value: Font) -> RestyleSankey<V>
Apply the same restyling to all the traces
sourcepub fn modify_text_font(values: Vec<Font>) -> RestyleSankey<V>
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
sourcepub fn value_format(self, value: impl AsRef<str>) -> Box<Self>
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.
sourcepub fn modify_all_value_format(value: impl AsRef<str>) -> RestyleSankey<V>
pub fn modify_all_value_format(value: impl AsRef<str>) -> RestyleSankey<V>
Apply the same restyling to all the traces
sourcepub fn modify_value_format(values: Vec<impl AsRef<str>>) -> RestyleSankey<V>
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
sourcepub fn value_suffix(self, value: impl AsRef<str>) -> Box<Self>
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.
sourcepub fn modify_all_value_suffix(value: impl AsRef<str>) -> RestyleSankey<V>
pub fn modify_all_value_suffix(value: impl AsRef<str>) -> RestyleSankey<V>
Apply the same restyling to all the traces
sourcepub fn modify_value_suffix(values: Vec<impl AsRef<str>>) -> RestyleSankey<V>
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
sourcepub fn visible(self, value: bool) -> Box<Self>
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).
sourcepub fn modify_all_visible(value: bool) -> RestyleSankey<V>
pub fn modify_all_visible(value: bool) -> RestyleSankey<V>
Apply the same restyling to all the traces
sourcepub fn modify_visible(values: Vec<bool>) -> RestyleSankey<V>
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