echarts: Legend is not displayed when name repeats
Version
5.4.0
Link to Minimal Reproduction
https://codepen.io/Mykhailo-codepen/pen/rNrPbeV
Steps to Reproduce
1)create pie chart with legend 2)add data to legend with elements which has same name.
Current Behavior
If name of legend repeats it will be omitted and only first will be shown
Expected Behavior
All names of legend are displeyed even they repeats
Environment
Problem in all browsers independent of Framework
Any additional comments?

About this issue
- Original URL
- State: open
- Created 4 years ago
- Reactions: 1
- Comments: 17
I agree with @ptulou. In our use case series names are unpredictable, easily repeated, and customizable by the user. It would be nice if the legend could work with the series ID. Currently, the legend breaks when there are duplicate names.
I have a similar case. In my case I’ve got many series on a chart. Some of the series are named line plots. Some of them show the results of analytics on the data using mark areas, and such. We want to be able to toggle the analytics on and off separately from the data through the legend. But, if the user happens to name the data trend the same thing as the analyitic, we get this behavior where the two are treated as one thing. It would be great if we could supply an id value to the legend data so that the id could be used for uniqueness and the name could just be for display. Ideally, that id value could be the id of the series so that we’re linking the two on something more concrete than the user modifyiable name?
I have requirements. I don’t decide by myself
@Mykhaylo12 : Have a better workaround using legend’s formatter. Adding suffix for
name, then using formatter to cut the suffix by delimiterMy previous screenshot only had 2 series. I’m already using the type “scroll” for legend. This helps but it still is just a workaround. We also have that same issue on tooltips:
In order to patch this too we could use the tooltip formater. It feels tacky but allows you to reach the wanted result.
I have a similar issue, in my case I’ve created a chart used to compare data in time. The series names are the same “measureName+deviceName” but in the end they are 2 different series. The only thing that makes them differ is the actual range in which they are visualized but placing that range into that name makes the label too long. I would like to keep the 2 legend items with the same name but different color so the final user can decide to show/hide what he doesn’t want to see in that moment: