apache / echarts

Apache ECharts is a powerful, interactive charting and data visualization library for browser
https://echarts.apache.org
Apache License 2.0
60.55k stars 19.61k forks source link

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

Open andyfehrenbach opened 1 month ago

andyfehrenbach commented 1 month ago

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', }

Ovilia commented 1 month ago

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.

andyfehrenbach commented 1 month ago

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 commented 1 month ago

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