echart 实现多柱状图+多折线图

当图表中存在多个柱状图时,如何让每条折线折点对应在每个柱状图中点位置?

 配置如下:

option = {
    color: ['#83c034', '#ea4748', '#f8ac00', '#00a2ea'], // 柱状图颜色
    legend: {
        data: ['篮球', '足球', '排球', '羽毛球']
    },
    xAxis: [
        {
            type: 'category',
            name: '星期(天)',
            data: ['星期一', '星期二', '星期三', '星期四', '星期五', '星期六', '星期天'],
            axisLabel: {
                color: '#00000',
                fontSize: 10,
                interval: 0,
            }
        },
        {
            type: 'value',
            max: 7 * 100,
            show: false
        }
    ],
    yAxis: [
        {
            type: 'value',
            name: '采购数量(个)'
        }
    ],
    series: [
        {
            data: ['46', '48', '48', '70', '40', '46', '50'],
            name: '篮球',
            type: 'bar',
            emphasis: {
                focus: 'series'
            },
            itemStyle: {}
        },
        {
            data: ['49', '52', '84', '52', '53', '51', '53'],
            name: '足球',
            type: 'bar',
            emphasis: {
                focus: 'series'
            },
        },
        {
            data: ['62', '70', '59', '47', '68', '79', '67'],
            name: '排球',
            type: 'bar',
            emphasis: {
                focus: 'series'
            },
        },
        {
            data: ['75', '58', '45', '54', '46', '61', '58'],
            name: '羽毛球',
            type: 'bar',
            emphasis: {
                focus: 'series'
            },
        },
        {
            xAxisIndex: 1,
            data: [[20, '46'], [120, '48'], [220, '48'], [320, '70'], [420, '40'], [520, '46'], [620, '50']],
            type: 'line',
            symbol: 'circle',
            symbolSize: 6, 
            itemStyle: {
                normal: {
                    lineStyle: {
                        width: 1,
                        color: '#83c034'
                    }
                },
            }
        },
        {
            xAxisIndex: 1,
            data: [[40, '49'], [140, '52'], [240, '84'], [340, '52'], [440, '53'], [540, '51'], [640, '53']],
            type: 'line',
            symbol: 'circle',
            symbolSize: 6, //拐点大小
            itemStyle: {
                normal: {
                    lineStyle: {
                        width: 1, //折线宽度
                        color: '#ea4748' //折线颜色
                    }
                }
            }
        },
        {
            xAxisIndex: 1,
            data: [[60, '62'], [160, '70'], [260, '59'], [360, '47'], [460, '68'], [560, '79'], [660, '67']],
            type: 'line',
            symbol: 'circle', //拐点样式
            symbolSize: 6, //拐点大小
            itemStyle: {
                normal: {
                    lineStyle: {
                        width: 1, //折线宽度
                        color: '#f8ac00' //折线颜色
                    }
                }
            }
        },
        {
            xAxisIndex: 1,
            data: [[80, '75'], [180, '58'], [280, '45'], [380, '54'], [480, '46'], [580, '61'], [680, '58']],
            type: 'line',
            symbol: 'circle', //拐点样式
            symbolSize: 6, //拐点大小
            itemStyle: {
                normal: {
                    lineStyle: {
                        width: 1, //折线宽度
                        color: '#00a2ea' //折线颜色
                    }
                }
            }
        }
    ]
};


图例如下:

  • 6
    点赞
  • 14
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值