echarts 渐变曲线图记录

效果

在这里插入图片描述

代码

let xData = [
  '2022.12',
  '2023.01',
  '2023.02',
  '2023.03',
  '2023.04',
  '2023.05',
  '2023.06',
  '2023.07',
  '2023.08',
  '2023.09',
  '2023.10',
  '2023.11'
];
let { nopass, pass, good } = {
  good: [1000, 900, 800, 1000, 900, 1100, 800, 900, 1000, 1100, 800, 900],
  nopass: [300, 200, 250, 300, 200, 300, 200, 220, 250, 300, 270, 240],
  pass: [2000, 2100, 2200, 1900, 1800, 2000, 2100, 2000, 1900, 2100, 2000, 2200]
};
option = {
  backgroundColor: '#140a69',
  tooltip: {
    trigger: 'axis',
    backgroundColor: 'rgba(69, 14, 255,0.5)',
    borderWidth: '0',
    textStyle: {
      color: '#6DFFFF'
    },
    axisPointer: {
      type: 'shadow'
    }
  },
  grid: {
    left: '3%',
    right: '4%',
    bottom: '3%',
    containLabel: true
  },
  xAxis: [
    {
      type: 'category',
      boundaryGap: false,
      axisLabel: {
        // color: 'rgba(255, 255, 255, 0.15)',
        show: true
      },
      axisLine: {
        show: true
      },
      splitLine: {
        show: false
      },
      data: xData
    }
  ],
  yAxis: [
    {
      type: 'value',
      splitLine: {
        show: true,
        lineStyle: {
          color: 'rgba(255, 255, 255, 0.25)',
          type: 'dashed'
        }
      }
    }
  ],
  series: [
    {
      name: 'good',
      smooth: true, // 是否平滑
      type: 'line',
      symbol: 'circle',
      symbolSize: 8,
      itemStyle: {
        normal: {
          color: '#B1ED82',
          borderColor: '#fff',
          borderWidth: 1,
          lineStyle: {
            color: '#B1ED82 ',
            width: 1
          }
        }
      },
      areaStyle: {
        normal: {
          color: new echarts.graphic.LinearGradient(
            0,
            0,
            0,
            1,
            [
              {
                offset: 0,
                color: 'rgba(177, 237, 130, 0.6)'
              },
              {
                offset: 1,
                color: 'rgba(177, 237, 130, 0)'
              }
            ],
            false
          ),
          shadowColor: 'rgba(0, 0, 0, 0.1)',
          shadowBlur: 10
        }
      },
      data: good
    },
    {
      smooth: true, // 是否平滑
      type: 'line',
      name: 'pass',
      symbol: 'circle',
      symbolSize: 8,
      itemStyle: {
        normal: {
          color: '#FFD639',
          borderColor: '#fff',
          borderWidth: 1,
          lineStyle: {
            color: '#FFD639',
            width: 1
          }
        }
      },
      areaStyle: {
        normal: {
          color: new echarts.graphic.LinearGradient(
            0,
            0,
            0,
            1,
            [
              {
                offset: 0,
                color: 'rgba(255, 214, 57, 0.6)'
              },
              {
                offset: 1,
                color: 'rgba(255, 214, 57, 0)'
              }
            ],
            false
          ),
          shadowColor: 'rgba(0, 0, 0, 0.1)',
          shadowBlur: 10
        }
      },
      data: pass
    },
    {
      smooth: true, // 是否平滑
      type: 'line',
      name: 'nopass',
      symbol: 'circle',
      symbolSize: 8,
      itemStyle: {
        normal: {
          color: '#FC424C',
          borderColor: '#fff',
          borderWidth: 1,
          lineStyle: {
            color: '#FC424C',
            width: 1
          }
        }
      },
      areaStyle: {
        normal: {
          color: new echarts.graphic.LinearGradient(
            0,
            0,
            0,
            1,
            [
              {
                offset: 0,
                color: 'rgba(252, 66, 76, 0.3)'
              },
              {
                offset: 1,
                color: 'rgba(252, 66, 76, 0)'
              }
            ],
            false
          ),
          shadowColor: 'rgba(0, 0, 0, 0.1)',
          shadowBlur: 10
        }
      },
      data: nopass
    }
  ]
};

  • 8
    点赞
  • 9
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

南桥几经秋_

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值