superset icon indicating copy to clipboard operation
superset copied to clipboard

Sankey can't have same value for source and target

Open xavier-GitHub76 opened this issue 1 month ago • 4 comments

Bug description

Sankey is KO if value are same for source and target

Image

it's OK KO with different value for source and target

Image

Screenshots/recordings

No response

Superset version

master / latest-dev

Python version

3.9

Node version

16

Browser

Chrome

Additional context

No response

Checklist

  • [ ] I have searched Superset docs and Slack and didn't find a solution to my problem.
  • [ ] I have searched the GitHub issue tracker and didn't find a similar bug report.
  • [ ] I have checked Superset's logs for errors and if I found a relevant Python stacktrace, I included it here as text in the "additional context" section.

xavier-GitHub76 avatar Nov 24 '25 15:11 xavier-GitHub76

This is expected behavior: the Sankey chart in Superset cannot render when the source and target are the same (a self-loop) because the underlying ECharts library requires the data to form a Directed Acyclic Graph (DAG). Self-loops or cycles violate this requirement and cause the chart to fail to render. This limitation comes from ECharts, not from Superset itself, and there are currently no built-in workarounds or alternative chart types in Superset for visualizing self-loops or cyclic data in this context. To avoid the error, filter out or transform rows where the source and target are identical before visualizing with a Sankey chart. More details are discussed in this related issue.

To reply, just mention @dosu.


How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other

Chat with Dosu Open in Cursor Join Discord Share on X

dosubot[bot] avatar Nov 24 '25 15:11 dosubot[bot]

@dosu : Source and Target are 2 different columns in the dataset. Just some values of theses columns can be sometimes equals

xavier-GitHub76 avatar Nov 25 '25 07:11 xavier-GitHub76

Superset’s Sankey chart does treat 'source' and 'target' as two separate columns, but if a row has the same value for both, it creates a self-loop. The underlying ECharts library requires the data to form a Directed Acyclic Graph (DAG), so any self-loop (where source equals target) will cause the chart to fail to render—this is a technical limitation from ECharts, not something configurable in Superset itself[^1][^2].

Superset does not automatically filter or handle these cases, so you’ll need to preprocess your data to exclude rows where source and target are equal before visualizing with a Sankey chart. There aren’t any built-in chart types or plugins in Superset that support self-loops or cyclic data for Sankey diagrams. If you need to visualize such relationships, you’d need to consider a custom visualization plugin[^3].

If you want help with a SQL example or a data transformation to filter out self-loops, let me know!

[^1]: Sankey transformProps.ts code [^2]: Sankey chart control panel config [^3]: Custom visualization plugin PR

To reply, just mention @dosu.


How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other

Chat with Dosu Open in Cursor Join Discord Share on X

dosubot[bot] avatar Nov 25 '25 08:11 dosubot[bot]

The bot is right. I understand the data has source: K, target: O and source: O, target: K but that would mean the sankey should draw a loop, which it currently does not support. You're welcome to figure out how to open a PR that allows loop support in this viz component's rendering, but it's more of a feature implementation than a bug fix. Much appreciated if you can figure it out!

rusackas avatar Nov 26 '25 18:11 rusackas