Echarts饼状图

本文介绍了一个使用ECharts实现的SIM卡状态饼状图组件。该组件通过AngularJS指令定义,能够展示SIM卡的激活情况,并提供了详细的配置选项,如颜色、标题、图例等。
//sim卡 --- 饼状图
ddpApp.directive('simPieChart', function () {
    return {
        restrict: 'A',
        link: function (scope, ele, attr) {
            attr.$observe('serieData', function () {
                if (attr.serieData.length) {
                    console.log(attr);
                    var myChart = echarts.init(document.getElementById(attr.id));
                    myChart.clear();
                    var option = {
                        title: {
                            text: 'SIM卡总数量' + attr.titleData,
                            textStyle: {
                                color: '#4e4b4e',
                                fontSize: 14,
                                fontWeight: 'normal'
                            },
                            x: 'center',
                            // left:'30%',
                            bottom: 15
                        },
                        legend: {
                            orient: 'vertical',
                            right: 10,
                            bottom: 30,
                            itemWidth: 16,
                            itemHeight: 16,
                            data: JSON.parse(attr.legendData)
                        },
                        // grid: {
                        //     show: true,
                        //     left: '5%',
                        //     right: '5%',
                        //     top: '10%',
                        //     bottom: '5%',
                        //     borderWidth: 1,
                        //     containLabel: true,
                        //     borderColor: '#000',
                        // },
                        color: ['#71b6f9', '#7f8dff', '#fcb247'],
                        series: [
                            {
                                name: '已激活sim卡使用情况',
                                type: 'pie',
                                // selectedMode: 'multiple',
                                // radius: [0, '50%'],
                                radius: '50%',
                                // radius: [0, '60%'],
                                center: ['50%', '45%'],
                                hoverAnimation: false,
                                avoidLabelOverlap: true,
                                selectedOffset: 0,
                                label: {
                                    normal: {
                                        show: true,
                                        position: 'top',//orient
                                        formatter: function (params) {
                                            return params.percent + "%  " + params.value;
                                        },
                                        emphasis: {
                                            show: true
                                        },
                                        textStyle: {
                                            fontSize: 14,
                                            // color: '#535050'
                                        }
                                    }
                                },
                                data: JSON.parse(attr.serieData)
                            }
                        ]
                    };
                    if (option && typeof option === "object") {
                        myChart.setOption(option, true);
                    }
                    $(window).resize(function () {
                        myChart.resize();
                        myChart.setOption(option, true);
                    });
                }
            });
        }
    }
});
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值