carbon-design-system / carbon-charts

:bar_chart: :chart_with_upwards_trend:⠀Robust dataviz framework implemented using D3 & typescript
https://charts.carbondesignsystem.com
Apache License 2.0
876 stars 182 forks source link

[Enhancement]: Allow repeating name in different categories in Alluvial charts #1822

Open gmanrique-cb opened 1 month ago

gmanrique-cb commented 1 month ago

Summary

The current implementation doesn't allow repeated names across categories in Alluvial charts. If I do that I get a "circular link" error thrown by the d3-sankey lib. I dig a bit in the code and I think it's because the name is being used as the nodeId but I'm providing repeated names in different nodes, which causes ids not to be unique.

Justification

Let's say we asked some users to sort a list of three colors by their preference, and we want to represent that as flows using an Alluvial chart. Something like this:

image

Note: totally made up numbers that don't make any sense

I was able to make it work by including the category names (First, Second, Third) as part of the node names to make them unique.

Sandbox