Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Klick builder pattern #30

Merged
merged 2 commits into from
Feb 7, 2024

Conversation

qknight
Copy link
Contributor

@qknight qknight commented Nov 21, 2023

Adding item_style support in SankeyNode using builder pattern:

let mut labels: Vec<SankeyNode> = vec![];

let label = "foo";
let my_style = ItemStyle::new().color("red").border_color("black");
let sn = SankeyNode::new(label).item_style(my_style);

labels.push(sn);

This way one can override the echarts sankey colors for nodes and organize the coloring!

let chart = Chart::new().series(
    Sankey::new()
        .layout_iterations(0u64)
        .links(sankey_links)
        .data(labels)
);

Note, this includes #29

This is similar to:

let one = "green";
let two = "#DE3163";
let three = "orange";

option = 
{
  "series": [
    {
      "type": "sankey",

      "layoutIterations": 0,
      lineStyle: {
        color: 'source',
        curveness: 0.4
      },
      "links": [ 
        {
          "source": "Nutzung 2.179",
          "target": "Emission 2.179",
          "value": 2178.4796516480023
        }
      ],
      "data": [
        {
          "name": "Nutzung 2.179",
          itemStyle: {
            color: two,
            borderColor: 'black'
          },
                  },
        {
          "name": "Emission 2.179",
          itemStyle: {
            color: two,
            borderColor: 'black'
          }
        }
      ]
    }
  ]
};

https://echarts.apache.org/examples/en/editor.html?c=sankey-simple&lang=ts&version=5.4.4-dev.20231111&decal=1

@qknight
Copy link
Contributor Author

qknight commented Jan 5, 2024

@ yuankunzhang is there anything I can do to make this being merged?

@yuankunzhang yuankunzhang merged commit 974f8d6 into yuankunzhang:main Feb 7, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants