Echarts 之横向柱状图(完成进度)

效果图

代码  

<script src="../js/echarts-4.1.0/echarts.js"></script>
<script src="../js/theme/customed.js"></script>
<script type="text/javascript">
    var legendData = ['xx事件总计划','xx事件已完成','xx事件1总计划','xx事件2已完成'];
    var yAxisData = ['分类1','分类2','分类3','分类4','分类5','分类6','分类7'];
    var llData = [5520,11730,7044,5547,5126,7710,7872];
    var llwwcData = [1380,2070,2739,2732,2197,1579,2351];

    var jsData = [1680,2640,4393,5205,4673,3905,2784];
    var jswwcData = [720,1760,1239,918,957,1518,1499];

    //总计
    var allllData = function() {
        var datas = [];
        for (var i = 0; i < llData.length; i++) {
            datas.push(llData[i] + llwwcData[i]);
        }
        return datas;
    }();

    //总计
    var alljsData = function() {
        var datas = [];
        for (var i = 0; i < jsData.length; i++) {
            datas.push(jsData[i] + jswwcData[i]);
        }
        return datas;
    }();
    
    var option = {
        // legend: {
        //     icon: "circle",
        //     itemWidth: 10,  // 设置宽度
        //     itemHeight: 10, // 设置高度
        //     itemGap: 2, // 设置间距
        //     textStyle:{
        //         fontSize:10,
        //     },
        //     x: 'right',
        //     top:'-1',
        //     data: legendData
        // },
        grid: {
            top:'5%',
            left: '1%',
            right: '4%',
            bottom: '3%',
            containLabel: true
        },
    
        tooltip: {
            show:"true",
            trigger: 'axis',
            axisPointer: { // 坐标轴指示器,坐标轴触发有效
                type: 'shadow' // 默认为直线,可选为:'line' | 'shadow'
            }
        },
        xAxis:  {
            type: 'value',
            axisTick : {show: false},
            axisLine: {
                show: false,
                // lineStyle:{
                //     color:'#fff',
                // }
            },
            splitLine: {
                show: false
            },
        },
        yAxis: [
            {
                type: 'category',
                axisLabel: {
                    interval: 0,
                    rotate: 30
                },
                axisTick : {show: false},
                axisLine: {
                    show: true,
                    // lineStyle:{
                    //     color:'#fff',
                    // }
                },
                data: yAxisData
            },
            {
                type: 'category',
                axisLine: {show:false},
                axisTick: {show:false},
                axisLabel: {show:false},
                splitArea: {show:false},
                splitLine: {show:false},
                data: yAxisData
            },
    
        ],
        series: [
            {
                name: legendData[0],
                type: 'bar',
                yAxisIndex:1,
                itemStyle:{
                    normal: {
                        show: true,
                        color: '#277ace',
                        barBorderRadius:50,
                        borderWidth:0,
                        borderColor:'#333',
                    }
                },
                barGap:'0%',
                barCategoryGap:'50%',
                data: allllData
            },
            {
                name: legendData[1],
                type: 'bar',
                itemStyle:{
                    normal: {
                        show: true,
                        color: '#5de3e1',
                        barBorderRadius:50,
                        borderWidth:0,
                        borderColor:'#333',
                    }
                },
                barGap:'0%',
                barCategoryGap:'50%',
                data: llData
            },{
                name: legendData[2],
                type: 'bar',
                yAxisIndex:1,
                itemStyle:{
                    normal: {
                        show: true,
                        color: '#ce58c4',
                        barBorderRadius:50,
                        borderWidth:0,
                        borderColor:'#333',
                    }
                },
                barGap:'0%',
                barCategoryGap:'50%',
                data: alljsData
            },
            {
                name: legendData[3],
                type: 'bar',
                itemStyle:{
                    normal: {
                        show: true,
                        color: '#d89de3',
                        barBorderRadius:50,
                        borderWidth:0,
                        borderColor:'#333',
                    }
                },
                barGap:'0%',
                barCategoryGap:'50%',
                data: jsData
            }
    
    
    
        ]
    };
</script>

工作中使用到的,总结归纳后,仅供各位大神们参考......

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值