【echarts】echarts中x轴的溢出

这篇文章展示了如何在echarts图表中处理x轴数据溢出的问题,通过使用dataZoom组件的slider类型来创建滑动条,并设置startValue和endValue来限制显示的范围。同时,配置了x轴的标签旋转、颜色和字体大小,以及图表的背景色、提示框样式等细节,包括柱状图和线图的数据系列和样式设定。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

echarts中x轴的溢出

var option = {
    backgroundColor: '#051c71',
    //重点 dataZoom导航条
    dataZoom: [{
        type: 'slider',
        show: true,
        startValue: 0,
        endValue: 5,
        height: '15',
        bottom: '3%',
        zoomLock: true
    }],
    tooltip: {
        trigger: "axis",
        backgroundColor: 'rgb(11,11,81)',
        padding: [15,30],
        extraCssText: 'box-shadow: 0px 0px 25px 5px rgb(41, 95, 159) inset;border-radius:10px'
    },
    legend: {
        show: true,
        top: '5%',
        textStyle: {
            color: "#fff"
        },
        data: ["数量", "金额"]
    },
    grid: {
        top: '20%',
        left: "3%",
        right: "4%",
        bottom: "13%",
        containLabel: true
    },
    xAxis: {
  	    type: "category",
      	axisTick: {
      		show: false
      	},
      	axisLabel: {
      		//"rotate": 30, 设置角度旋转
      		interval: 0,
      		color: '#ddd',
      		fontSize: 14
      	},
      	axisLine: {
      		lineStyle: {
      			color: "#5475c8"
      		}
      	},
      	data: ["1月", "2月", "3月", "4月", 
      	"5月", "6月", "7月", "8月", 
      	"9月", "10月", "11月", 
      	"12月", "1月", "2月", 
      	"3月", "4月"]
    },
    yAxis: [],
    series: [{
      	name: "数量",
      	type: "bar",
      	barWidth: 15,
      	label: {
      		normal: {
      			show: false,
      			position: "insideRight"
      		}
      	},
      	itemStyle: {
      		normal: {
      			color:  new echarts.graphic.LinearGradient(
                0, 0, 0, 1,
                [
                    {offset: 0, color: 'rgb(61, 207, 255)'},
                    {offset: 0.5, color: 'rgb(61, 207, 255)'},
                    {offset: 1, color: 'rgba(61, 207, 255, 0.1)'}
                ]
            ),
      		}
      	},
      	data: [10, 7, 15, 8, 6, 2, 1, 3]
    }, {
      	name: "金额",
      	type: "line",
      	yAxisIndex: 1,
      	smooth: false,
      	showAllSymbol: true,
      	symbol: "circle",
      	symbolSize: 10,
      	itemStyle: {
      		color: "rgb(253,146,166)"
      	},
      	lineStyle: {
      		color: "rgb(253,146,166)"
      	},
      	data: [3300, 1000, 1600, 3000, 4000, 2000, 1020, 1500]
    }]
};
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值