echart-堆叠的柱形图

1:正常的堆叠

var option = {
    tooltip: {
        trigger: "axis",
    },
    legend: {
        itemWidth: 10,  // 设置宽度
        itemHeight: 10, // 设置高度
        data:['缺勤','出勤'],
        x: '4%',
        y: '5',
        textStyle: {                      // 图例的公用文本样式。
            fontSize: 14, color: '#1E2031'
        },
    },
    grid: {
        left: '3%',
        right: '6%',
        bottom: '0%',
        containLabel: true
    },
    xAxis: {
        name: '日期',
        data: ['周一','周二','周三'],
        splitLine:{
            show:false,
        },
    },
    yAxis: {
        name: '次',
        splitLine:{
            show:false,
        },
    },
    series: [{
        name: '缺勤',
        type: 'bar',
        barWidth: 15,
        stack:'使用情况',
        data:[10, 20, 15],
        itemStyle:{
            normal:{color:"#FF5500"},
        }
    },{
        name: '出勤',
        type: 'bar',
        barWidth: 15,
        stack:'使用情况',
        data: [10, 20, 15],
        itemStyle:{
            normal:{color:"#13C2C2"},
        }
    }]
};

在这里插入图片描述

2:用作图例显示

var option = {
    title: {
        text: "没有数据",
        x: "center",
        y: "65%",
        textStyle: {
            //文字颜色
            color: "#ccc",
            //字体风格,'normal','italic','oblique'
            fontStyle: "normal",
            //字体粗细 'normal','bold','bolder','lighter',100 | 200 | 300 | 400...
            fontWeight: "lighter",
            fontSize: 12,
        },
    },
    grid: {
        left: "40%",
        right: "40%",
        bottom: "40%",
        containLabel: true,
    },
    xAxis: {
        data: ["", "", ""],
        splitLine: {
            show: false,
        },
        axisTick: {
            //轴刻度线
            show: false,
        },
        axisLine: {
            show: false,
        },
    },
    yAxis: {
        axisLabel: {
            formatter: function () {
                return "";
            },
        },

        splitLine: {
            show: false,
        },
        axisTick: {
            //y轴刻度线
            show: false,
        },
        axisLine: {
            //y轴
            show: false,
        },
    },
    series: [
        {
            type: "bar",
            barWidth: 50,
            stack: "使用情况",
            data: [10, 20, 15],
            itemStyle: {
                normal: { color: "#b3d7f7" },
            },
        },
        {
            type: "bar",
            barWidth: 50,
            stack: "使用情况",
            data: [5, 12, 8],
            itemStyle: {
                normal: { color: "#fbe8a6" },
            },
        },
    ],
};

在这里插入图片描述

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值