您当前的位置: 首页 >  ar

哆啦A梦_i

暂无认证

  • 1浏览

    0关注

    629博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文

Echarts:10-7-2:堆叠柱状图+堆叠条形图(多类别堆叠+最大最小值)

哆啦A梦_i 发布时间:2020-10-07 14:48:17 ,浏览量:1

option = {
    title: {
        text: '柱状堆叠图'
    },
    tooltip: {
        trigger: 'axis',
        axisPointer: {            // 坐标轴指示器,坐标轴触发有效
            type: 'shadow'        // 默认为直线,可选为:'line' | 'shadow'
        }
    },
    legend: {
        data: ['直接访问', '邮件营销', '联盟广告', '视频广告', '搜索引擎', '百度', '谷歌', '必应', '其他']
    },
    grid: {
        left: '3%',
        right: '4%',
        bottom: '3%',
        containLabel: true
    },
    xAxis: [
        {
            type: 'category',
            data: ['周一', '周二', '周三', '周四', '周五', '周六', '周日']
        }
    ],
    yAxis: [
        {
            type: 'value'
        }
    ],
    series: [
        {
            name: '直接访问',
            type: 'bar',
            stack: '百度',
            label: {
                normal: {
                    show: true,
                    position: 'top'
                }
            },
            data: [320, 332, 301, 334, 390, 330, 320]
        },
        {
            name: '邮件营销',
            type: 'bar',
            stack: '百度',
            label: {
                normal: {
                    show: true,
                    position: 'top'
                }
            },
            data: [120, 132, 101, 134, 90, 230, 210]
        },
        {
            name: '联盟广告',
            type: 'bar',
            stack: '联盟广告',
            label: {
                normal: {
                    show: true,
                    position: 'top'
                }
            },
            data: [220, 182, 191, 234, 290, 330, 310]
        },
        {
            name: '视频广告',
            type: 'bar',
            stack: '联盟广告',
            label: {
                normal: {
                    show: true,
                    position: 'top'
                }
            },
            data: [150, 232, 201, 154, 190, 330, 410]
        },
        {
            name: '搜索引擎',
            type: 'bar',
            label: {
                normal: {
                    show: true,
                    position: 'top'
                }
            },
            markLine: {
                lineStyle: {
                    type: 'dashed'
                },
                data: [
                    [{type: 'min'}, {type: 'max'}]
                ]
            },
            data: [862, 1018, 964, 1026, 1679, 1600, 1570]
        },
        {
            name: '百度',
            type: 'bar',
            label: {
                normal: {
                    show: true,
                    position: 'top'
                }
            },
            data: [620, 732, 701, 734, 1090, 1130, 1120]
        },
        {
            name: '谷歌',
            type: 'bar',
            stack: '联盟广告',
            label: {
                normal: {
                    show: true,
                    position: 'top'
                }
            },
            data: [120, 132, 101, 134, 290, 230, 220]
        },
        {
            name: '必应',
            type: 'bar',
            stack: '联盟广告',
            label: {
                normal: {
                    show: true,
                    position: 'top'
                }
            },
            data: [60, 72, 71, 74, 190, 130, 110]
        },
        {
            name: '其他',
            type: 'bar',
            stack: '联盟广告',
            label: {
                normal: {
                    show: true,
                    position: 'top'
                }
            },
            data: [62, 82, 91, 84, 109, 110, 120]
        }
    ]
};

 

将 xAxis: []与 yAxis: []的内容对换,便可以得到堆叠条形图。

(position: 'top'改为position: 'inside',表示数值显示在条形图里并默认居中,‘insideRight’:向右靠拢,‘insideLeft’:向左靠拢)

关注
打赏
1556978864
查看更多评论
立即登录/注册

微信扫码登录

0.0374s