echarts实现数量超过14条显示滚动条

在这里插入图片描述

let dataX = ['XX街道','XX街道','XX街道','XX街道','XX街道','XX街道','XX街道','XX街道','XX街道','XX街道','XX街道','XX街道','XX街道','XX街道','XX街道','XX街道','XX街道','XX街道']; //名称
let dataY = [20,50,15,35,50,30,40,50,60,20,50,15,35,50,30,40,50,60]; //数据
let zoomShow = false;
if (dataY.length > 14) {
    zoomShow = true;
} else {
    zoomShow = false;
}
var option = {
    backgroundColor: '#0D2753',
    tooltip: {
        trigger: 'axis',
        axisPointer: {
            type: 'shadow',
        },
    },
    grid: {
        top: '10%',
        right: '5%',
        left: '5%',
        bottom: '10%',
    },
    xAxis: [
        {
            type: 'category',
            data: dataX,
            axisLine: {
                lineStyle: {
                    color: 'rgba(66, 192, 255, .3)',
                },
            },
            axisLabel: {
                interval:0,
                margin: 10,
                color: '#05D5FF',
                textStyle: {
                    fontSize: 11,
                },
                rotate: '45',
            },
            axisTick: {//刻度
                show: false,
            },
        },
    ],
    yAxis: [
        {
            axisLabel: {
                padding: [3, 0, 0, 0],
                formatter: '{value}',
                color: 'rgba(95, 187, 235, 1)',
                textStyle: {
                    fontSize: 11,
                },
            },
            axisTick: {
                show: true,
            },
            axisLine: {
                lineStyle: {
                    color: 'rgba(66, 192, 255, .3)',
                },
            },
            splitLine: {
                lineStyle: {
                    color: 'rgba(255,255,255,0)',
                },
            },
        },
    ],
    dataZoom: [//滚动条
        {
            show: zoomShow,
            type: 'slider',
            realtime: true,
            startValue: 0,
            endValue: 14,
            xAxisIndex: [0],
            bottom: '10',
            left: '30',
            height: 10,
            borderColor: 'rgba(0,0,0,0)',
            textStyle: {
                color: '#05D5FF',
            },
        },
    ],
    series: [
        {
            type: 'bar',
            data: dataY,
            barWidth: '10',
            itemStyle: {
                normal: {
                    color: new echarts.graphic.LinearGradient(
                        0,
                        0,
                        0,
                        1,
                        [
                            {
                                offset: 0,
                                color: 'rgba(5, 213, 255, 1)', // 0% 处的颜色
                            },
                            {
                                offset: 0.98,
                                color: 'rgba(5, 213, 255, 0)', // 100% 处的颜色
                            },
                        ],
                        false
                    ),
                    shadowColor: 'rgba(5, 213, 255, 1)',
                    shadowBlur: 4,
                },
            },
            label: {
                normal: {
                    show: true,
                    lineHeight: 10,
                    formatter: '{c}',
                    position: 'top',
                    textStyle: {
                        color: '#fff',
                        fontSize: 10,
                    },
                },
            },
        },
    ],
};
  • 1
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值