echarts双x轴

效果图:
在这里插入图片描述
代码:

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>第一个 ECharts 实例</title>
    <!--echarts引用-->
    <script src="https://cdn.staticfile.org/echarts/4.3.0/echarts.min.js"></script>
</head>
<body>
    <div id="main" style="width: 600px;height:400px;"></div>
    <script type="text/javascript">
        var myChart = echarts.init(document.getElementById('main'));

        var option = {
            title: {text: '实例'},
            tooltip: {},
            legend: {data:['销量','销量2']},
            xAxis: [
            	/*第一个x轴*/
	            {data: ["笔记本","圆珠笔","文具袋","钢尺","圆规","橡皮"]},
	            /*第二个x轴*/
	            {
	            	type: 'category',//类型
	              	offset: 25,//偏移的位置
	              	axisPointer: {type: 'none'},//将表格线取消
		            axisTick:{show: false},
		            axisLine:{show: false},
		          	position: 'bottom',//x轴的位置
		        	data: ["1月","2月","3月","4月","5月","6月"]
		        }
            ],
            yAxis: {},
            series: [
	            {
	                name: '销量',
	                type: 'bar',
	                barWidth:20,
	                color:'#90EE90',
	                data: [5, 20, 36, 10, 10, 20],
	                itemStyle: {borderWidth:1,borderColor:'black'}
	            },
	            {
	                name: '销量2',
	                symbolSize:8,
	                type: 'line',
	                xAxisIndex: 1,//标记为第二个x轴数据
	                color:'#ee6666',
	                data: [5, 10, 8, 15, 20, 10],
	                itemStyle:{normal:{lineStyle:{width:1.5}}},
                    symbol: 'circle'
	            }
            ]
        };
 
        myChart.setOption(option);
    </script>
</body>
</html>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值