echart2.0环形图-中间显示进度数据和标题

1.html<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
    <div id="indexChart" class="chart-content" style="height: 200px;"></div>

    <script src="js/jquery-1.9.1.min.js"></script>
    <script src="echarts-2.2.7/build/dist/echarts.js"></script>
    <script src="js/index.js"></script>
</body>
</html>

2.index.js

(function(){
    // 路径配置
    require.config({
        paths: {
            echarts: 'echarts-2.2.7/build/dist'
        }
    });

    require(
        [
            'echarts',
            'echarts/chart/pie'
        ],
        function (ec) {
            // 基于准备好的dom,初始化echarts图表
            var indexChart = ec.init(document.getElementById('indexChart'));

            //当前申请人员统计环形图
            var allValue = 158;
            //标示文字
            var labelTop = {
                normal : {
                    label : {
                        show : false,
                        position : 'center',
                        formatter : '{b}',
                        textStyle: {
                            baseline : 'bottom',  //垂直对齐方式
                            fontSize:12,
                            color:'#666',
                            align : 'center'  //水平对齐方式
                        }
                    },
                    color:'#de4751',
                    labelLine : {  //标示线
                        show : false
                    }
                }
            };
            //百分比设置
            var labelFromatter = {
                normal : {
                    label : {
                        formatter : function (params){
                            return 100 - params.value + '/' + allValue
                        },
                        textStyle: {
                            baseline : 'middle',  //垂直对齐方式
                            fontSize:27,
                            color:'#666',
                            align : 'center'   //水平对齐方式
                        }
                    }
                }
            };
            //数据位置
            var labelBottom = {
                normal : {
                    color: '#ccc',
                    label : {
                        show : true,
                        position : 'center'
                    },
                    labelLine : {
                        show : false
                    }
                },
                emphasis: {
                    color: 'rgba(0,0,0,0)'
                }
            };
            //环形图
            option = {
                title: {
                    text: '待批人员/全部人员',
                    // subtext: '申请明细 >',
                    // sublink: 'http://e.weibo.com/1341556070/AhQXtjbqh',
                    x: 'center',
                    y: '60',
                    itemGap: 50,
                    textStyle : {
                        color : '#666',
                        fontSize : 12,
                        fontWeight : 'normal'
                    },
                    subtextStyle : {
                        color : '#de4751',
                        fontSize : 12
                    }
                },
                series : [
                    {
                        type : 'pie',
                        center : ['50%', '50%'],
                        radius: ['78%', '85%'],
                        // x: '0%', // for funnel
                        itemStyle : labelFromatter,
                        data : [
                            {name:'other', value:30, itemStyle : labelBottom},
                            {name:'人员', value:70,itemStyle : labelTop}
                        ]
                    }
                ]
            };


            // 为echarts对象加载数据
            indexChart.setOption(option);


            // 自适应echarts
            setTimeout(function (){
                $(window).resize(function () {
                    indexChart.resize();
                });
            },200);
        }
    );
})();

附图;

  • 0
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 5
    评论
评论 5
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值