Skip to content

bug: series.label.formatter callback #10248

@quick-sort

Description

@quick-sort

Version

4.2.1

Steps to reproduce

https://echarts.baidu.com/examples/editor.html?c=dataset-simple1

option = {
legend: {},
tooltip: {},
dataset: {
dimensions: ['product', '2015', '2016', '2017'],
source: [
{product: 'Matcha Latte', '2015': 43.3, '2016': 85.8, '2017': 93.7},
{product: 'Milk Tea', '2015': 83.1, '2016': 73.4, '2017': 55.1},
{product: 'Cheese Cocoa', '2015': 86.4, '2016': 65.2, '2017': 82.5},
{product: 'Walnut Brownie', '2015': 72.4, '2016': 53.9, '2017': 39.1}
]
},
xAxis: {type: 'category'},
yAxis: {},
// Declare several bar series, each will be mapped
// to a column of dataset.source by default.
series: [
{type: 'bar',
encode: {x: 'product', y:'2015'},
label: {
show: true,
formatter: a => JSON.stringify(a.value)
}
}
]
};

猜测问题出在https://github.com/apache/incubator-echarts/blob/master/src/chart/bar/helper.js#L29
参数中缺一个dimIndex的参数,其它图表类型下也存在类似问题,不仅仅是bar
最终参数传递到
https://github.com/apache/incubator-echarts/blob/master/src/model/mixin/dataFormat.js#L87

What is expected?

series.label.formatter = function(params){}
params.value应该是该series对应的列的值

What is actually happening?

params.value获得的是所有列的值的数组

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions