【echarts】多条X轴 多条Y轴显示

echarts多条X轴 多条Y轴显示配置

在这里插入图片描述

const option = {
        grid: {
          left: '5%',
          right: '8%',
          bottom: '5%',
          containLabel: true
        },
        legend: {
          data: [
            { name: this.fragmentName, icon: 'line' },
            { name: this.lineName }
          ],
          right: 10
        },
        xAxis: [
          {
            type: 'category',
            boundaryGap: false,
            axisLine: {
              show: false,
              onZero: false
            },
            title: false,
            axisTick: {
              show: false
            },
            axisLabel: {
              show: false
            },
            data: _this.xData
          },
          {
            type: 'category',
            boundaryGap: false,
            position: 'bottom',
            axisTick: {
              show: false
            },
            axisLine: {
              show: false, // 不显示坐标轴线
              onZero: false
            },
            axisLabel: {
              showMaxLabel: true,
              textStyle: {
                color: '#8E8DA7' // 横坐标轴上文字颜色
              },
              fontSize: 10,
              margin: 10
            },
            data: _this.date
          }
        ],
        yAxis: [
          {
            name: this.fragmentName,
            type: 'value',
            nameTextStyle: {
              color: '#8E8DA7',
              fontSize: 10
            },
            axisLabel: {
              // formatter: '{value}',
              // 如果是多数据的话自定义Y轴,如果不是就正常显示
              formatter: !_this.isMultidata ? '{value}' : function(v, i) {
                // console.log('y轴刻度', v, i)
                if (i === 0) {
                  v = -0.10
                }
                if (i === 1) {
                  v = -0.05
                }
                if (i === 2) {
                  v = 1.00
                }
                if (i === 3) {
                  v = 1.05
                }
                if (i === 4) {
                  v = 1.10
                }
                return v
              },
              textStyle: {
                color: '#8E8DA7'
              },
              fontSize: 10,
              margin: 20
            },
            axisLine: {
              show: false
            },
            axisTick: {
              show: false,
              alignWithLabel: true // 保证刻度线和标签对齐
            },
            splitLine: {
              show: true, // 显示网格线
              lineStyle: {
                color: 'rgba(142, 141, 167, 0.1)'
              }
            }
          },
          {
            name: this.lineName,
            alignTicks: true,
            type: 'value',
            nameTextStyle: {
              color: '#8E8DA7',
              fontSize: 10,
              textStyle: {
                color: '#8E8DA7'
              }
            },
            axisLabel: {
              // formatter: '{value}',
              // 如果是多数据的话自定义Y轴,如果不是就正常显示
              formatter: !_this.isMultidata ? '{value}' : function(v, i) {
                // console.log('y轴刻度', v, i)
                if (i === 0) {
                  v = -0.10
                }
                if (i === 1) {
                  v = -0.05
                }
                if (i === 2) {
                  v = 1.00
                }
                if (i === 3) {
                  v = 1.05
                }
                if (i === 4) {
                  v = 1.10
                }
                return v
              },
              textStyle: {
                color: '#8E8DA7'
              },
              fontSize: 10
            },
            axisLine: {
              show: false
            },
            axisTick: {
              show: false,
              alignWithLabel: true // 保证刻度线和标签对齐
            },
            splitLine: {
              show: true, // 显示网格线
              lineStyle: {
                color: 'rgba(142, 141, 167, 0.1)'
              }
            }
          }
        ],
        series: [
          {
            name: this.fragmentName,
            type: 'line',
            areaStyle: {},
            lineStyle: {
              width: 1
            },
            emphasis: {
              focus: 'series'
            },
            itemStyle: {
              normal: {
                color: '#E6B37F', // 图例的颜色
                lineStyle: {
                  color: '#E6B37F'// 线的颜色
                }
              }
            },
            // prettier-ignore
            data: _this.fragmentData
          },
          {
            name: this.lineName,
            type: 'line',
            yAxisIndex: 1,
            symbol: 'emptyCircle',
            connectNulls: true,
            itemStyle: {
              normal: {
                color: '#4842F2', // 图例的颜色
                lineStyle: {
                  color: '#4842F2'// 线的颜色
                }
              }
            },
            lineStyle: {
              width: 1
            },
            emphasis: {
              focus: 'series'
            },
            // prettier-ignore
            data: _this.pointData
          }
        ]
      }
  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值