apache / apache/echarts

[Bug] legend in Sankey

Open
#20,598 3 comments 0 reactions 0 assignees View on GitHub
bug en pending
Dominant language
TypeScript
Stars
67.3k
Forks
19.8k
Avg merge
11d 14h
Merged PRs (30d)
8

Description

### Version

5.2.2

### Link to Minimal Reproduction

https://echarts.apache.org/examples/en/editor.html?code=CYQwLiAEC8kNoChKQN5OZAdiAtgUwC5IByEYgGnWQGNw8BzAewCcBPI4gRmPQF9LkaDFlyESAIwpVItMAxbsS3PgNTTs-DiG6qadJmw4AmHsn7ohGDWNIndM_Qo7Kzqy8msdxO6bPmGSAGZTSHNBdVEOailhPwNFLhDeBABdAG4EPGB6PABnGHgLaVzGAFdmahsyewhmHLAtH2EANxAAG1KxAFZ7OKcSahMVIuES8sqtGIxa-q07aVaOsUDexwDiahdQt2KyiptJGpA6vAaJJoxFzqIADlW5eKih1xGMMf3Jo5Oz4m8p5Cuy3u_gSmySO1Gewm53-kBmp0asMBRE4wMeA2Cw3CkPGBwuyHhP2i9mRkCMaP6Gy2yXSCAQjAADmAAJaMTAFSxtBh4TDAIgoMKQXJ4ZjMvL86RgVgMmy5ECYADWeFYsLaIFYZR-mDZeFhnhIuQVsLwOAZAAsQLlmbl-ZAAGaMailG0kEDAABWIEqmGoKu2dOEoAg9iyOVy9mFXOocmAAFlGMAbDhSm0WQyubDI3ho7a2szMHgAMpSrm26iMNosDjMLLEUL-l7IejMEDm5nUIiIYTuabSmzNsoM2HIUX0M1nABsAAZ7ATGUQZ9IaGbmW1gDXMJ2lxge8ICX3q9mwMO9wAvLnNPBtIgAFlne9yFpltrNeGZY7ORnJkAA7szgGAZpEIE37MEQXQNnuowlmIKD2qu14kAy-ZGpBUEEngAAeYAAMJsnImBnLu6Hnngl6IXe25QbkMG2nI2FRDo9r4YWzKnmInATuQ8FtIhvxqtQqHJOhGCCiJ9G4WydrvraDKMFaLJshw-ZWomdZiehbLUHmglEHapQ-op7IABQMgAlGoInCG0CoFHAtJWRgoZ5AAdA6zAAKJemaxnGZh3HMhZ0AAHyWY5GDMnakB-S5fRsDA0CwFSxAWTZLkMs6PmBRk4WhGZOXhTgrA4RazBgC5wDWgy4DUGaACC0aspgxnEeJB4kGAjD0PQXKFleR4niJQYgAAkryWFEDZ95DeAIAACrtcQzkhI5vD5VRokbcJe4pNI227bwaRAA

### Steps to Reproduce

data = [
{ name: 'a', category: 'Category 1' },
{ name: 'b', category: 'Category 1' },
{ name: 'a1', category: 'Category 2' },
{ name: 'a2', category: 'Category 1' },
{ name: 'b1', category: 'Category 3' },
{ name: 'c', category: 'Category 1' },
];

edges = [
{ source: 'a', target: 'a1', value: 5 },
{ source: 'a', target: 'a2', value: 3 },
{ source: 'b', target: 'b1', value: 8 },
{ source: 'a', target: 'b1', value: 3 },
{ source: 'b1', target: 'a1', value: 1 },
{ source: 'b1', target: 'c', value: 2 },
];

option = {
tooltip: {
trigger: 'item',
triggerOn: 'mousemove',
},
legend: {
show: true,
data: ['Category 1', 'Category 2', 'Category 3'],
selectedMode: 'multiple',
top: 'top',
},
series: [
{
type: 'sankey',
layout: 'none',
data: data,
links: edges,
categories: [
{ name: 'Категория 1', itemStyle: { color: '#5470c6' } },
{ name: 'Категория 2', itemStyle: { color: '#91cc75' } },
{ name: 'Категория 3', itemStyle: { color: '#fac858' } },
],
emphasis: { focus: 'adjacency' },
},
],
};

### Current Behavior

I am using a Sankey diagram. I need to be able to customize the legend so that when clicked, the steps associated with it will disappear

### Expected Behavior

the legend must show

### Environment

```markdown
- OS:
- Browser:
- Framework:
```

### Any additional comments?

_No response_

Contributor guide

Open the contributing guide

Research direction

Start with the linked minimal reproduction and the Sankey configuration, especially the legend data, categories, and selectedMode settings. Trace how Sankey series items are matched to legend entries, then verify that clicking a category hides its associated steps and that the legend displays the intended category names.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
data-visualization
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.