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

echarts的formatter不支持函数 #279

Closed
JoeyCurry opened this issue Dec 4, 2019 · 2 comments
Closed

echarts的formatter不支持函数 #279

JoeyCurry opened this issue Dec 4, 2019 · 2 comments

Comments

@JoeyCurry
Copy link

| Executable | Version |
| node --version | v8.11.1 |
| nodeppt -v | 2.1.8 |

| OS | Version |
| macOS Sierra | 10.15.1 |
| chrome | 78.0|

描述:在echarts中的formatter仅支持字符串模版,如果使用函数则不生效

如下代码

series: [{
            name: '1.0',
            type: 'bar',
            label: {
                show: true,
                formatter: function(params) {
                    if (params.data === 0) {
                        return ''
                    } else {
                        return params.seriesName
                    }
                }
            },
            stack: '版本',
            xAxisIndex: 0,
            yAxisIndex: 0,
            itemStyle: {
                normal: {
                    barBorderRadius: [0, 0, 0, 0],
                    color: '#005dff'
                }

            },
            barWidth: 20,
            data: [0,2,6,0,9,9,0,5,1,1],
            zlevel: 11
        }]

如果使用字符串模版就可以,比如formatter: '{a}'就可以正常显示

但我现在的需求其实是,当数据为0的时候就不显示,如果有数据就显示出name

@ksky521
Copy link
Owner

ksky521 commented Jun 28, 2020

目前的实现,echarts配置里面是不支持function

@ksky521 ksky521 closed this as completed Jun 28, 2020
@Bugatti100Peagle
Copy link

如何让其支持 function ? 换到高版本echart?还是用完全版cdn解析?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants