Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug: series.label.formatter callback #10248

Closed
quick-sort opened this issue Apr 10, 2019 · 3 comments · Fixed by #10697, OpenTMI/opentmi-default-gui#32 or DeviaVir/zenbot#2011 · May be fixed by dyna-dot/iClient-JavaScript-s#1
Closed

bug: series.label.formatter callback #10248

quick-sort opened this issue Apr 10, 2019 · 3 comments · Fixed by #10697, OpenTMI/opentmi-default-gui#32 or DeviaVir/zenbot#2011 · May be fixed by dyna-dot/iClient-JavaScript-s#1
Labels
Milestone

Comments

@quick-sort
Copy link

quick-sort commented Apr 10, 2019

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获得的是所有列的值的数组

@echarts-bot
Copy link

echarts-bot bot commented Apr 10, 2019

Hi! We've received your issue and please be patient to get responded. 🎉
The average response time is expected to be within one day for weekdays.

In the meanwhile, please make sure that you have posted enough image to demo your request. You may also check out the API and chart option to get the answer.

Have a nice day! 🍵

@echarts-bot echarts-bot bot added bug pending We are not sure about whether this is a bug/new feature. waiting-for-help labels Apr 10, 2019
@deqingli
Copy link
Member

If you want to get the data of a specific dimension, you can use it as follows, with the doc:

series: [
        {
            type: 'bar',
            label: {
                show: true,
                formatter: '{b}: {@2015}'
            }
        }]

@deqingli deqingli removed the bug label Apr 10, 2019
@quick-sort
Copy link
Author

If you want to get the data of a specific dimension, you can use it as follows, with the doc:

series: [
        {
            type: 'bar',
            label: {
                show: true,
                formatter: '{b}: {@2015}'
            }
        }]

I am not only want to get a specific dimension, I want to use a function to transform and calculate it, which is specified in API doc. And it doesn't have the correct behavior.

100pah added a commit that referenced this issue Jun 18, 2019
@Ovilia Ovilia added bug and removed pending We are not sure about whether this is a bug/new feature. waiting-for-help labels Aug 27, 2019
@Ovilia Ovilia changed the title 使用dataset数据时,series.label.formatter使用function(params){},params.value的值为dataset中所有列,而不是该series对应的那一列的数据 bug: series.label.formatter callback Aug 27, 2019
@Ovilia Ovilia added this to the 4.4.0 milestone Aug 27, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment