Skip to content

Sankey layout freezes on dense, heavily branching graphs #7478

Description

@dm-gthb

What is the current behavior?

Rendering a chart can freeze the browser main thread for seconds or minutes during layout, before anything appears on screen.

Starting from relatively small graphs, this is already a problem — not only at “big data” scale. The graph is densely connected: nodes branch heavily and paths merge again, so the number of distinct paths from the first node to the last grows combinatorially even when node/link counts stay small.

With the reproducer below, the dataset has 85 nodes and 112 links, layout on current npm recharts freezes the UI for minutes.

What is the expected behavior?

Layout should complete quickly and feel responsive. Cost should grow with the number of nodes and links, not combinatorially with the number of distinct paths through the graph.

Please provide a demo of the problem in a sandbox

https://codesandbox.io/p/sandbox/recharts-sankey-performance-repro-wjwm4s

Tune SEGMENTS to try different node/link counts. Recommended size: SEGMENTS = 2885 nodes, 112 links. On current recharts from npm, this typically freezes the UI for minutes.

Which versions of Recharts, and which browser / OS are affected by this issue? Did this work in previous versions of Recharts?

  • Recharts: latest on npm (e.g. 2.x / 3.x)
  • Browser: Chromium-based browsers (Chrome, Edge); likely all browsers (CPU-bound JS)
  • OS: any
  • Previous versions: not a regression from a specific release

Note: a related symptom was reported in #5531 (closed as not planned, larger dataset). This issue uses a smaller, more reliable reproduction that isolates the actual cause — layout cost scales with the number of distinct paths through the graph, not with node/link counts. I've opened a fix in #7479

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions