plotlars_core/components/arrangement.rs
1/// An enumeration representing node arrangement strategies for Sankey diagrams.
2///
3/// The `Arrangement` enum controls how nodes are positioned relative to each other:
4///
5/// * `Snap` — If value is `snap` (the default), the node arrangement is assisted by
6/// automatic snapping of elements to preserve space between nodes specified via `nodepad`.
7/// * `Perpendicular` — Nodes can only move along a line perpendicular to the primary flow.
8/// * `Freeform` — Nodes can freely move anywhere on the plane without automatic constraints.
9/// * `Fixed` — Nodes remain stationary at their specified positions and are not adjusted by the layout algorithm.
10///
11/// # Example
12///
13/// ```rust
14/// use plotlars::{Arrangement, SankeyDiagram, Orientation, Plot, Rgb, Text};
15/// use polars::prelude::*;
16///
17/// let dataset = df![
18/// "source" => &["A1", "A2", "A1", "B1", "B2", "B2"],
19/// "target" => &["B1", "B2", "B2", "C1", "C1", "C2"],
20/// "value" => &[8, 4, 2, 8, 4, 2],
21/// ].unwrap();
22///
23/// SankeyDiagram::builder()
24/// .data(&dataset)
25/// .sources("source")
26/// .targets("target")
27/// .values("value")
28/// .orientation(Orientation::Horizontal)
29/// .arrangement(Arrangement::Freeform)
30/// .node_colors(vec![
31/// Rgb(222, 235, 247),
32/// Rgb(198, 219, 239),
33/// Rgb(158, 202, 225),
34/// Rgb(107, 174, 214),
35/// Rgb( 66, 146, 198),
36/// Rgb( 33, 113, 181),
37/// ])
38/// .link_colors(vec![
39/// Rgb(222, 235, 247),
40/// Rgb(198, 219, 239),
41/// Rgb(158, 202, 225),
42/// Rgb(107, 174, 214),
43/// Rgb( 66, 146, 198),
44/// Rgb( 33, 113, 181),
45/// ])
46/// .build()
47/// .plot();
48/// ```
49///
50/// 
51#[derive(Clone)]
52pub enum Arrangement {
53 Snap,
54 Perpendicular,
55 Freeform,
56 Fixed,
57}