ECharts半圓環形圖

                                                        ECharts半圓環形圖

1、原文:ECharts半圓環形圖 去看看

2、效果

3、完整代碼

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>ECharts半圓環形圖</title>
    <script src="http://code.jquery.com/jquery-1.4.1.min.js"></script>
    <!-- 引入 echarts.js -->
    <script src="http://echarts.baidu.com/examples/vendors/echarts/echarts.min.js?_v_=1526486305040"></script>
</head>
<body>
<!-- 爲ECharts準備一個具備大小(寬高)的Dom -->
<div id='consume_pie' style="width:500px;height:400px;margin-left:20px;"> </div>
</body>
</html>
<script type="text/javascript">
    loadRingChart();	//加載半圓環形圖

    //加載半圓環形圖
    function  loadRingChart (){
        var myChart = echarts.init(document.getElementById( 'consume_pie' ));	//圖表的ID
        var option = {
            title: {
                "text": '姓名',
                subtext:'1516',
                itemGap:3,
                "x": '49%',
                "y": '62%',
                textAlign: "center",
                "textStyle": {
                    "fontWeight": 'normal',
                    "fontSize": 12,
                    color:'#aaaaaa',

                },
                "subtextStyle": {
                    "fontWeight": 'normal',
                    "fontSize": 12,
                    color:'#aaaaaa',
                    lineHeight:14
                },

            },

            tooltip: {
                trigger: 'item',
                formatter: "{a} <br/>{b}: {c} ({d}%)",
                position: ['10%', '50%']
            },
            /*legend: {
                x: 'left',
                data:['視頻','影院','直播']
            },*/
            "color": ["#0696ff","#7ed321","#ffc31a", "transparent"],
            "startAngle": 180,
            series: [
                {
                    name:'',
                    type:'pie',
                    radius: ['45%', '90%'],
                    avoidLabelOverlap: false,
                    startAngle: 180,
                    center:["50%","70%"],
                    label: {

                        normal: {
                            position: 'inner',
                            textStyle: {
                                color: '#fff',
                                fontSize: 12
                            }
                        },
                        emphasis: {
                            show: true,
                            textStyle: {
                                fontSize: '12',
                                fontWeight: 'bold'
                            }
                        }
                    },
                    labelLine: {
                        normal: {
                            show: false
                        }
                    },
                    data:[{value:335, name:'姓名0'},{value:310, name:'姓名1'},{value:234, name:'姓名2'},{value:879, name:'',tooltip:{formatter:function(a){return ""}}}]
                },

            ]
        };

        // 使用剛指定的配置項和數據顯示圖表。
        myChart.setOption( option );
    }

</script>

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章