Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature] Set default legend icon for different series types #20339

Open
andyfehrenbach opened this issue Sep 11, 2024 · 3 comments
Open

[Feature] Set default legend icon for different series types #20339

andyfehrenbach opened this issue Sep 11, 2024 · 3 comments
Labels
en This issue is in English support topic: legend

Comments

@andyfehrenbach
Copy link

andyfehrenbach commented Sep 11, 2024

What problem does this feature solve?

I have not been able to figure out a way to do this. I think you should be able to declare a default icon type in the legend for each different series, for example:
bar series: star icon
line series: triangle icon
I know that setting a different symbol on a line series will change the icon in the legend, but there is no way to do this for bar charts

What does the proposed API look like?

bar: {
icon: 'star',
},
line: {
icon: 'triangle',
}

@echarts-bot echarts-bot bot added en This issue is in English pending We are not sure about whether this is a bug/new feature. labels Sep 11, 2024
@Ovilia
Copy link
Contributor

Ovilia commented Sep 12, 2024

The icon in the legend represents that of that series. So it doesn't always make sense to use the same icon for the same series.

@Ovilia Ovilia added support topic: legend waiting-for: author and removed new-feature pending We are not sure about whether this is a bug/new feature. labels Sep 12, 2024
@andyfehrenbach
Copy link
Author

andyfehrenbach commented Sep 12, 2024

I agree that being able to assign different icons to different series of the same chart type, either via series symbols or the legend's data array, is a desired behavior. But I think there is also value in being able to choose the default or fallback icon for a given series type.

The specific problem I'm trying to solve in my app is that the rounded rectangle legend elements don't look good with our design language. I would like them to be normal rectangles or squares. but if I set the icon property to 'rectangle' in the theme file using the legend's icon property, it also changes the icon for all line series, even though I've defined 'emptyCircle' as the default symbol for all line series.

@helgasoft
Copy link

I set the icon property to 'rectangle' in the theme file

please provide code example for your theme problem.

setting a different symbol on a line series will change the icon in the legend, but there is no way to do this for bar charts

setting legend icons is very flexible, even for bars - Demo
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
en This issue is in English support topic: legend
Projects
None yet
Development

No branches or pull requests

3 participants