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

Echart3 自定义仪表盘label不显示 #4143

Closed
lvshui opened this issue Sep 24, 2016 · 1 comment
Closed

Echart3 自定义仪表盘label不显示 #4143

lvshui opened this issue Sep 24, 2016 · 1 comment

Comments

@lvshui
Copy link

lvshui commented Sep 24, 2016

问题简述 (One-line summary)

中文的label:高,中,低等不显示,类似上一个issue。
测试地址:http://echarts.baidu.com/demo.html#gauge

option = {
    tooltip : {
        formatter: "{a} <br/>{b} : {c}%"
    },
    toolbox: {
        feature: {
            restore: {},
            saveAsImage: {}
        }
    },
    series: [
        {
            name: '业务指标',
            type: 'gauge',
            detail: {formatter:'{value}'},
            min:0,
            max:950,
            axisLabel: {           // 坐标轴文本标签,详见axis.axisLabel
                show: true,
                formatter: function(v){
                    switch (v+''){
                        case '100': return '弱';
                        case '300': return '低';
                        case '600': return '中';
                        case '900': return '高';
                        default: return '';
                    }
                },
                textStyle: {       // 其余属性默认使用全局文本样式,详见TEXTSTYLE
                    color: '#333'
                }
            },
            data: [{value: 50, name: '数值'}]
        }
    ]
};

app.timeTicket = setInterval(function () {
    option.series[0].data[0].value = (Math.random() * 950).toFixed(2) - 0;
    myChart.setOption(option, true);
},2000);

版本及环境 (Version & Environment)

  • ECharts 版本 (ECharts version): 3
  • 浏览器类型和版本 (Browser version): baidu,ie,ff等
  • 操作系统类型和版本 (OS Version): xp

重现步骤 (Steps to reproduce)

期望结果 (Expected behaviour)

希望达到的效果:http://echarts.baidu.com/echarts2/doc/example/gauge.html

可能哪里有问题 (What went wrong)

ECharts配置项 (ECharts option)

option = {
 tooltip : {
        formatter: "{a} <br/>{b} : {c}%"
    },
    toolbox: {
        feature: {
            restore: {},
            saveAsImage: {}
        }
    },
    series: [
        {
            name: '业务指标',
            type: 'gauge',
            detail: {formatter:'{value}'},
            min:0,
            max:950,
            axisLabel: {           // 坐标轴文本标签,详见axis.axisLabel
                show: true,
                formatter: function(v){
                    switch (v+''){
                        case '100': return '弱';
                        case '300': return '低';
                        case '600': return '中';
                        case '900': return '高';
                        default: return '';
                    }
                },
                textStyle: {       // 其余属性默认使用全局文本样式,详见TEXTSTYLE
                    color: '#333'
                }
            },
            data: [{value: 50, name: '数值'}]
        }
    ]
}

其他信息 (Other comments)

@100pah
Copy link
Member

100pah commented Sep 24, 2016

formatter: function(v){
    switch (v+''){
        case '100': return '弱';
        case '300': return '低';
        case '600': return '中';
        case '900': return '高';
        default: return '';
    }
}

这里面 v 不一定正好是 100 300 600 900. console.log 打出 v 看看就知道了。

@pissang pissang closed this as completed Sep 30, 2016
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