7
回答
ECharts 饼图 数据为零时 隐藏lableline 指示线
利用AWS快速构建适用于生产的无服务器应用程序,免费试用12个月>>>   
@ Kener-林峰  请问  饼图  当数值为零时,怎么隐藏它的lableline,只显示数据不为零的lableline?谢谢。
举报

以下是问题补充:

  • @一直在路上123 :另外如果分类很多的话 好多lableline 挤在一起 有什么办法分散开来吗? (3年前)

引用来自“Kener-林峰”的评论

什么版本?上个option?
最新版本2.0.4,

option = {
                title: {
                    text: '停机比例',
                    //  subtext: '纯属虚构',
                    x: 'right'

                },
                tooltip: {
                    trigger: 'item',
                    formatter: "{a} <br/>{b} : {c} ({d}%)"
                },
                legend: {
                    orient: 'vertical',
                    y: 'bottom',
                    x: 'left',

                    data: ['Debug', 'BarcodeIssue', 'QA Quality Issue', 'Hardware Failure', 'Software Failure', 'Crash', 'Maintenance', 'PowerOFF', 'Program END', 'Program Stop','IDLE']
                },
                toolbox: {
                    show: true,
                    orient: 'vertical',
                    y: 'center',
                    feature: {
                        mark: { show: true },
                        dataView: { show: true, readOnly: false },
                        restore: { show: true },
                        saveAsImage: { show: true }
                    }
                },
                calculable: true,
                series: [
        {   minAngle:5,
            name: '停机比例',
            type: 'pie',
            radius: [5, 70],
            center: ['50%', 120],
            roseType: 'radius',
            itemStyle: {
                normal: {
                    label: {
                        show: true,
                        formatter: '{d}%'
                    },
                    labelLine: {
                        show: true
                    }
                },
                emphasis: {
                    label: {
                        show: true
                    },
                    labelLine: {
                        show: true
                    }
                }
            },
            data: [
                { value: msglossrate, name: 'Debug', itemStyle: {
                    normal: {
                        color: '#00EE00',

                        labelLine:{show:true,length: 5}


                    }
                }
                },
                { value: msglossrate, name: 'BarcodeIssue', itemStyle: {
                    normal: {
                        color: '#545454',

                        labelLine: { show: true, length:8 }
                    }
                }
                },
                { value: msglossrate, name: 'QA Quality Issue', itemStyle: {
                    normal: {
                        color: '#7AC5CD',

                        labelLine: { show: true, length: 11 }
                    }
                }
                },
                { value: msglossrate, name: 'Hardware Failure', itemStyle: {
                    normal: {
                        color: '#7A378B',

                        labelLine: { show: true, length: 14 }
                    }
                }
                },
                { value: msglossrate, name: 'Software Failure', itemStyle: {
                    normal: {
                        color: '#9ACD32',

                        labelLine: { show: true, length: 17 }
                    }
                }
                },
                { value: msglossrate, name: 'Crash', itemStyle: {
                    normal: {
                        color: '#C67171',

                        labelLine: { show: true, length: 20 }
                    }
                }
                },
                { value: msglossrate, name: 'Maintenance', itemStyle: {
                    normal: {
                        color: '#191970',

                        labelLine: { show: true, length: 23 }
                    }
                }
                },
                { value: msglossrate, name: 'PowerOFF', itemStyle: {
                    normal: {
                        color: '#CDCD00',

                        labelLine: { show: true, length: 26 }
                    }
                }
                },
                { value: msglossrate, name: 'Program END', itemStyle: {
                    normal: {
                        color: '#FF8C00',

                        labelLine: { show: true, length: 29 }
                    }
                }
                },
                { value: msglossrate, name: 'Program Stop', itemStyle: {
                    normal: {
                        color: '#FF34B3',

                        labelLine: { show: true, length: 32 }
                    }
                }
                },
                { value: msglossrate, name: 'IDLE', itemStyle: {
                    normal: {
                        color: '#FF0000',
                        labelLine: { show: true, length: 3 }
                    }
                }
                }
            ]
        }
    ]
            };

 

 

怎么隐藏那些0.00%的数据?

引用来自“Kener-林峰”的评论

你不都把itemStyle写到data级了吗?判断一下data少于一定值就label:{show:false},见文档。
ok了,thks

引用来自“Kener-林峰”的评论

你不都把itemStyle写到data级了吗?判断一下data少于一定值就label:{show:false},见文档。

引用来自“一直在路上123”的评论

ok了,thks
@Kener-林峰  求判断data的写法,谢谢!急求,谢谢!
--- 共有 1 条评论 ---
@一直在路上123 急求,谢谢! 3年前 回复

引用来自“Kener-林峰”的评论

你不都把itemStyle写到data级了吗?判断一下data少于一定值就label:{show:false},见文档。

引用来自“一直在路上123”的评论

ok了,thks

引用来自“茗”的评论

@Kener-林峰  求判断data的写法,谢谢!急求,谢谢!

{ value: lossrate, name: 'UNPLANED', itemStyle: {
                    normal: {
                        color: '#FF0000',
                        label: { show: function () {
                            if (lossrate == 0.00)
                            { return false; }
                        } ()

                        },
                        labelLine: { show: function () {
                            if (lossrate == 0.00)
                            { return false; }
                        } ()

                        }
                    }
                }
                }

--- 共有 1 条评论 ---
解决了,十分感谢! 3年前 回复
顶部