占比图

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>ECharts</title>
    <!-- 引入 echarts.js -->
    <script src="echarts-3.js"></script>
</head>
<body>
<!-- 为ECharts准备一个具备大小(宽高)的Dom -->
<div id="main" style="width: 100%;height:400px;"></div>
<script type="text/javascript">
    // 基于准备好的dom,初始化echarts实例
    var myChart = echarts.init(document.getElementById('main'));

    // 指定图表的配置项和数据
var app={}
    app.configParameters = {
        pie1Process: {
            min: 0,
            max: 100
        },
        pie2Process: {
            min: 0,
            max: 100
        },
        pie3Process: {
            min: 0,
            max: 100
        },
    };

    app.config = {
        message: 'dat.gui',
        pie1Process: 25,
        pie2Process: 50,
        pie3Process: 75,
        pie1Color: '#3dd4de',
        pie2Color: '#b697cd',
        pie3Color: '#a6f08f',
        onChange: function() {
            var tempOption = {
                title: {
                    text: parseInt(app.config.pie2Process) + '%',
                    textStyle: {
                        color: app.config.pie2Color,
                    }
                },
                series: [{
                    data: [{
                        value: parseInt(app.config.pie1Process),
                        itemStyle: {
                            normal: {
                                color: app.config.pie1Color,
                                shadowColor: app.config.pie1Color,
                            }
                        },
                        label: {
                            normal: {
                                formatter: '{d}%',
                                position: 'center',
                                show: true,
                                textStyle: {
                                    fontSize: '35',
                                    fontWeight: 'normal',
                                    color: app.config.pie1Color
                                }
                            }
                        },
                    }, {
                        value: 100 - parseInt(app.config.pie1Process),
                        itemStyle: placeHolderStyle,

                    }]
                }, {
                    data: [{
                        value: parseInt(app.config.pie2Process),
                        itemStyle: {
                            normal: {
                                color: app.config.pie2Color,
                                shadowColor: app.config.pie2Color,
                            }
                        }
                    }, {
                        value: 100 - parseInt(app.config.pie2Process),
                        itemStyle: placeHolderStyle,
                    }]
                }, {
                    data: [{
                        value: parseInt(app.config.pie3Process),
                        label: {
                            normal: {
                                formatter: '{d}%',
                                position: 'center',
                                show: true,
                                textStyle: {
                                    fontSize: '35',
                                    fontWeight: 'normal',
                                    color: app.config.pie3Color
                                }
                            }
                        },
                        itemStyle: {
                            normal: {
                                color: app.config.pie3Color,
                                shadowColor: app.config.pie3Color,
                            }
                        }
                    }, {
                        value: 100 - parseInt(app.config.pie3Process),

                        itemStyle: placeHolderStyle,
                    }]
                }]
            }
            myChart.setOption(tempOption);
        }
    };


    // 这里借鉴'5643我'和'小明的小可'两位大神的圆环图格式演示一下效果
    var dataStyle = {
        normal: {
            label: {
                show: false
            },
            labelLine: {
                show: false
            },
            shadowBlur: 40,
            shadowColor: 'rgba(40, 40, 40, 0.5)',
        }
    };

    var placeHolderStyle = {
        normal: {
            color: 'rgba(44,59,70,1)', // 未完成的圆环的颜色
            label: {
                show: false
            },
            labelLine: {
                show: false
            }
        },
        emphasis: {
            color: 'rgba(44,59,70,1)' // 未完成的圆环的颜色
        }
    };

    option = {
        title: {
            text: '50%',
            x: 'center',
            y: 'center',
            textStyle: {
                fontWeight: 'normal',
                color: '#b697cd',
                fontSize: 35
            }
        },
        tooltip: {
            show: false,
        },
        toolbox: {
            show: false,
        },
        // color : ['#3dd4de','#b697cd','#a6f08f'],
        backgroundColor: 'rgba(0,0,0,0.8)',
        series: [{
            name: 'Pie2',
            type: 'pie',
            clockWise: false,
            radius: [80, 85],
            itemStyle: dataStyle,
            hoverAnimation: false,
            center: ['50%', '50%'],
            data: [{
                value:50,
                itemStyle: {
                    normal: {
                        color: '#b697cd',
                        shadowColor: '#b697cd',
                        shadowBlur: 10
                    }
                }
            }, {
                value: 50,
                name: 'invisible',
                itemStyle: placeHolderStyle,
            }]
        }]
    }

    // 使用刚指定的配置项和数据显示图表。
    myChart.setOption(option);
</script>
</body>
</html>

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值