echarts设置上下Y轴,多轴设计

echarts 设计双Y轴,X轴在中间位置,实现图形上下延伸,
echars设置双Y轴,图形上下延伸

option = {
    legend:{
        data:["直接访问","间接"],
    },
    
    color: ['#3398DB'],
    tooltip : {
        trigger: 'axis',
        axisPointer : {            // 坐标轴指示器,坐标轴触发有效
            type : 'shadow'        // 默认为直线,可选为:'line' | 'shadow'
        }
    },
    grid:[     //用于调整X轴以及Y轴的位置
        {
          show: false,
          bottom: '12%',
          left: 93,
          right: 100,
          containLabel: true,
          height: '40%'
        }, {
          show: false,
          top: '48%',
          left: 124,
          right: 100,
          height: '0%',
          zlevel:100
        }, {
          show: false,
          top: '8%',
          // left: 76,
          left: 93,
          right: 100,
          containLabel: true,
          height: '40%'
        }
    ],
    xAxis : [
       {
            type: 'category',
            position: 'bottom',
            axisLine: {
              show: false,
            },
            axisTick: {
              show: false
            },
            axisLabel: {
              show: false,
            },
            data: [],
 
          }, {
            gridIndex: 1,
            type: 'category',
            position: 'center',
            axisLine: {
              show: true
            },
            axisTick: {
              show: true
            },
            zlevel:200,
            axisLabel: {
              show: true,
              align: 'center',
              textStyle: {
                color: '#323232',
                fontSize: 12
              }
            },
            data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'],
          },
          {
            gridIndex: 2,
            type: 'category',
            position: 'top',
            axisLine: {
              show: false
            },
            axisTick: {
              show: false
            },
            axisLabel: {
              show: false,
            },
            data: [],
          }
    ],
    yAxis : [
        {
          type: 'value',
          inverse: true,   //echarts Y轴翻转属性,
          position: 'left',   //位置属性
          axisLabel: {
            show: true,
            textStyle: {
              color: '#646464',
              fontSize: 12,             
            }
          },
          splitLine: {
            show: true,
            lineStyle: {
              color: "rgba(0,162,255,0.08)",
              width: 1,
            }
          }
        }, {
          gridIndex: 1,   //对应的是grid  通过grid设置X Y相对位置
          show: false,
        }, {
          gridIndex: 2,
          type: 'value',
          position: 'left',    //双Y轴一个翻转一个不翻转
          axisLabel: {
            show: true,
            textStyle: {
              color: '#646464',
              fontSize: 12,            
            }
          },
          splitLine: {
            show: true,
            lineStyle: {
              color: "rgba(0,162,255,0.08)",
              width: 1,
            }
          }
        }
    ],
    series : [
        {
            gridIndex:0,   //选取调整好的轴,调整图形是向上还是向下
            name:'直接访问',
            type:'bar',
            barWidth: '40%',
            data:[300, 52, 200, 334, 390, 330, 220],
            xAxisIndex: 2,
            yAxisIndex: 2,
            itemStyle:{
                color:"#B23AEE"
            }
        },
        {
            gridIndex:2,  选取调整好的轴,调整图形是向上还是向下
            name:'间接',
            type:'bar',
            barWidth: '40%',
            data:[100, 300, 50, 150, 210, 110, 48],
        }
    ]
};

  • 3
    点赞
  • 23
    收藏
    觉得还不错? 一键收藏
  • 4
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值