apache / echarts

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

The series.label.formatter function passes in data from the wrong series. #9958

Closed kevinw0123 closed 5 years ago

kevinw0123 commented 5 years ago

General Questions

Issue Type

Issue Details

The series.label.formatter function passes in data from the wrong series.

When I try to access the data passed back from the formatter, the data in the component is from series[dataIndex], rather than series[seriesIndex]. Even though the seriesIndex values and dataIndex values are correct, the data in the component is wrong. Notice how the labels don't match up with the formatted values.

image

image

Expected Behavior

The first digit of data is the series index, and the second digit is the data index. The formatter is supposed to pass in the series[seriesIndex] for the dataset. This should show 11, 12, 13 for the first graph. Instead, it's showing 11, 22, 13, since it's trying to access the wrong series.

Current Behavior

N/A

Online Example

https://codepen.io/kevinw0123/pen/exVGqv

...
series: [
  {
    label: 
      {
        show: 'true', 
        position: 'top', 
        formatter: function (component) {
          console.log(component);
          var i = component.dataIndex+1;
          return component.value[i];
        }
    }
  },
  ...

Topics

Anything Else We Need to Know

Environment

echarts-bot[bot] commented 5 years ago

This issue is not created using issue template so I'm going to close it. 🙊 Sorry for this, but it helps save our maintainers' time so that more developers get helped. Feel free to create another issue using the issue template.

这个 issue 未使用 issue 模板 创建,所以我将关闭此 issue。 为此带来的麻烦我深表歉意,但是请理解这是为了节约社区维护者的时间,以更高效地服务社区的开发者群体。 如果您愿意,可以请使用 issue 模板重新创建 issue。