Closed jfarrin1 closed 5 years ago
You can try legend.formatter
to display any text you want. But the data in legend must be same with series.name
so they can be connected properly
You can try
legend.formatter
to display any text you want. But the data in legend must be same withseries.name
so they can be connected properly
First, thank you for the quick response! Much appreciated :).
Using the formatter still only passes the series.name
value, there is no way to access the data[i].name
values. There must also only be 1 legend label per series - of course that makes sense for the default functionality, but then there is no way to have more labels than series. I don't need the legend labels to be connected toggle a series on/off or have any functionality on click. I just need a custom legend that can be whatever array of names I want. As I understand, this is not possible at the moment.
You may add a series that doesn't contain data, but only to show legend.
You may add a series that doesn't contain data, but only to show legend.
This is interesting and tricky, should mention in docs or support natively.
General Questions
PLEASE MAKE SURE OF ALL THE FOLLOWING OPTIONS IN REQUIRED FIELDS ARE TICKED (with x)! Otherwise, the issue will not be answered. And think before you tick. :) 请确保以下每项都打上勾了!并且确保都做了这些事哦~ 这将大量简化我们的工作流程,使你的问题更快速得到解答。
In this issue, I have provided information with: 在这个 issue 中我提供了以下信息:
Issue Type
Issue Details
I would like to define a custom legend, but
setOptions.legend.data
can only containseries.name
values (most charts) orseries.data[i].name
(pie/funnel charts).Expected Behavior
I have a multi-series graph where I want a legend that includes all
data.name
values from each series. In the demo example, I want a legend that shows: Germany, England, and France with the corresponding color.Current Behavior
Currently, the legend values of a non-pie like chart can only come from the
series.name
and cannot be set to theseries.data.name
values. If the values inlegend.data
do not mach aseries.name
value, then no legend is displayed (as shown in demo).I assume this is an issue because of how the legend interacts with the series - like how clicking on a legend name can toggle displaying of that series.
Online Example
THIS IS REQUIRED FOR ALL BUG REPORTS AND QUESTIONS!!! 如果是提问或报 bug 一定要提供这一项!
http://gallery.echartsjs.com/editor.html?c=xLFLb0Uw7O&v=3
Topics
Anything Else We Need to Know
N/A
Environment
ECharts version;ECharts 版本: 4.2.0
[ ] It happens only on certain browsers or operating systems. 对于特定浏览器或操作系统才会出现的问题,请提供相应环境信息:{BROWSER_VERSION_OR_OS_INFORMATION_HERE}