apache / echarts

Apache ECharts is a powerful, interactive charting and data visualization library for browser
https://echarts.apache.org
Apache License 2.0
60.49k stars 19.61k forks source link

[Bug] `layoutIterations` not working as expected on sankey charts #19375

Closed Arch-Storm closed 1 month ago

Arch-Storm commented 10 months ago

Version

5.4.3

Link to Minimal Reproduction

https://echarts.apache.org/examples/en/editor.html?code=PYBwLglsB2AEC8sDeAoAzgUwE4Q2gXLANoqxnKnllgCeIGhARGgIbQDWGNjANJVRgC2IABYs0EAhSpUAZsADGAVymMWAEwBWLBRmgLufGbAC-RmdGDqMAcRYhCAFgAc5qpesB1COrAjCAMwATG7kADYsNMBKYACSYNgskDBSwaFk6kkshCTGZKh55NAsggywjACyAMoASgAKsAAkAIzOAAy8_HkQCYJVtGFlBYXkCsBhwFhMAEZhShidI6bp5GZdVMOFxaVMAEJKYeywdTi6Tc2OHStUPUL9NIOEmyNjE1Pls_OLI2uFv3nPYzbMqMAAqwDALDCsAAwsA0GA0OdmgFvoVbn0BkN1nlXpMmFgMOo0Xl_sYyTJARYSiCAGosHAsWYYWHwxFNABsAFYScYMfdHtIlrA8e9GITiddVlKKRsce4aUwAGIQAAeRNZCKRjRcvJk_KxT3lMlFBKJeqosulxqpCp25ROwFkPVgFQZAHMIHBGkEAOwW8gGh7Y4Ui8b48ruwl6ANkK1xqW2oqK8o1DCQiDQt1YT3ey6x2BBwVJqim8oGNgF-PLHEAXRWYS97CkuQBsDQ0SwuiY1Xq53avFgkJz6b2ByOJwgZxa-Z4sAAblD5oQLm0a4UkO3O93yr2Gi0B3Ph-7R6n0yxM66PV6mrOF0uypd122O0ouyD9odjqcWTOrkOPVPMEIShTV2RaFFB0XOYymaFFn2MTdX3fMcv0nadV0HY8gMdZ0wCvHMbx9f052g5dYD9BDKS3N8d2AyFoThLVkVRI9ALAJh6UZZkwO1bkoIfQhuSojYaJQ8pwQY3iWKw9jlTVDUmPA3VSME2AXBE2B6xxRtoAwAUQ1xcMxSjDRcGgMAA2ULB5z0PApDaAA6LkVitItDOMMtGCjLg9StCJpgwMIjUKLyc2mFgAAo2h4GK4sc30AEoA3kCylRKTMaCYABBRkwhSmAwCqCAAC9YJinEKX-bSTCAA

Steps to Reproduce

  1. Use layoutIterations > 0, where a node with a higher value should be below a lower value.

Current Behavior

image

Expected Behavior

image

Environment

- OS: Windows 11
- Browser: Chrome 119.0.6045.200
- Framework: /

Any additional comments?

Another example of a similar problem, where layoutIterations fixes the ordering but aligns everything to y=0.

This is using layoutIterations: 32 : image

Using layoutIterations: 0: image

Optimal, but currently impossible (to my knowledge) behaviour: image

MatthiasMert commented 10 months ago

where a node with a higher value should be below a lower value

where did you get that information?

Arch-Storm commented 10 months ago

where did you get that information?

I'm not implying that that should be the default behaviour. If you look at the current behaviour, it should be visible that "retail margin" should be below "net profit". But because "retail margin" has a higher value it gets placed above it, also causing a lot of unwanted overlap in the process. This might be good in a lot of cases, but in this one there could be a way to preserve that order, without having everything aligned straight at the top.

MatthiasMert commented 10 months ago

I agree that the algorithm produces some suboptimal results but I dont think this is a bug.

Here is a hack which may lead to preferable results for you.

Arch-Storm commented 10 months ago

Here is a hack which may lead to preferable results for you.

Thank you, this works for the time being. Using the nodegap to space them is quite clever.