Echarts饼图代码

<!DOCTYPE html>
<head>
    <meta charset="utf-8">
    <title>ECharts</title>
</head>
<body>
    <!-- 为ECharts准备一个具备大小(宽高)的Dom -->
    <div id="main" style="height:400px"></div>
    <!-- ECharts单文件引入 -->
    <script src="http://echarts.baidu.com/build/dist/echarts.js"></script>
    <script type="text/javascript">
        // 路径配置
        require.config({
            paths: {
                echarts: 'http://echarts.baidu.com/build/dist'
            }
        });

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

                option = {
                    tooltip : {
                        show: true,
                        formatter: "{a} <br/>{b} : {c} ({d}%)"
                    },
                    legend: {
                        orient : 'vertical',
                        x : 'left',
                        data:['组织生活正常化','凝聚力','战斗力']
                    },
                    toolbox: {
                        show : true
                    },
                    calculable : true,
                    series : [
                    {
                        name:'访问来源',
                        type:'pie',
                        startAngle: 90,
                        center : ['75%', 200],
                        radius : [80, 120],
                        itemStyle : {
                            normal : {
                                label : {
                                    show : true
                                },
                                labelLine : {
                                    show : true
                                }
                            },
                            emphasis : {
                                color: (function (){
                                    var zrColor = require('zrender/tool/color');
                                    return zrColor.getRadialGradient(
                                        650, 200, 80, 650, 200, 120,
                                        [[0, 'rgba(255,255,0,1)'],[1, 'rgba(255,0,0,1)']]
                                        )
                                })(),
                                label : {
                                    show : true,
                                    position : 'center',
                                    formatter : "{d}%",
                                    textStyle : {
                                        color : 'red',
                                        fontSize : '30',
                                        fontFamily : '微软雅黑',
                                        fontWeight : 'bold'
                                    }
                                }
                            }
                        },
                        data:[
                        {value:335, name:'组织生活正常化',
                        itemStyle : {
                            normal : {
                                borderWidth: 4,
                                borderColor: '#ffffff',
                            }
                        }},
                        {
                            value:30,
                            name:'正常化未完成',
                            itemStyle : {
                                normal : {
                                    borderWidth: 0,
                                    label : {
                                        show : false
                                    },
                                    labelLine : {
                                        show : false
                                    },
                                    color:'#2F4F4F'
                                },
                                emphasis : {
                                    label : {
                                        show : true
                                    },
                                    labelLine : {
                                        show : false
                                    },
                                    color:'#2F4F4F'
                                }
                            }
                        },
                        {value:310, name:'凝聚力',
                        itemStyle : {
                            normal : {
                                borderWidth: 4,
                                borderColor: '#ffffff',
                            }
                        }},
                        {
                            value:50,
                            name:'凝聚力未完成',
                            itemStyle : {
                                normal : {
                                    borderWidth: 0,
                                    label : {
                                        show : false
                                    },
                                    labelLine : {
                                        show : false
                                    },
                                    color:'#2F4F4F'
                                },
                                emphasis : {
                                    label : {
                                        show : true
                                    },
                                    labelLine : {
                                        show : false
                                    },
                                    color:'#2F4F4F'
                                }
                            }
                        },
                        {value:234, name:'战斗力',
                        itemStyle : {
                            normal : {
                                borderWidth: 4,
                                borderColor: '#ffffff',
                            }
                        }},
                        {
                            value:40,
                            name:'战斗力未完成',
                            itemStyle : {
                                normal : {
                                    borderWidth: 0,
                                    label : {
                                        show : false
                                    },
                                    labelLine : {
                                        show : false
                                    },
                                    color:'#2F4F4F'
                                },
                                emphasis : {
                                    label : {
                                        show : true
                                    },
                                    labelLine : {
                                        show : false
                                    },
                                    color:'#2F4F4F'
                                }
                            }
                        }
                        ]
                    }
                    ]
                };

                // 为echarts对象加载数据 
                myChart.setOption(option); 
            }
            );
        </script>
    </body>

访问效果如下:

这里写图片描述

专业墙纸贴纸厨房用具装饰出售,本人网店经营

博客对你有用记得访问下哦,增加下访问量,如有需要可以下单购买哦^_^。https://item.taobao.com/item.htm?id=569617707364

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

黄宝康

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值