echart折线图区域背景渐进、坐标轴样式设置

先看效果:

 

代码实现如下:

option = {
  backgroundColor: 'blue',
  title: {
    text: '', // 标题
    left: 18,
    top: 5,
    textStyle: { color: 'rgba(255,255,255,.6)', fontSize: '29', align: 'right' }
  },
  // 弹出层样式
  tooltip: {
    trigger: 'axis',
    borderColor: '#1f6485', // 边框颜色
    backgroundColor: 'rgba(25,51,85,.8)',
    borderWidth: 1,
    textStyle: {
      align: 'left'
    },
    formatter: (params) => {
      const title = params[0].axisValue;
      const data = params[0].data;
      const ytitle = '降雨量';
      return `<div style='padding:4px 10px;'><span style='font-size: 18px;'>${title}时</span><br /><span style='color: #9dbdfb;font-size: 16px;'>${ytitle}</span>:<span style='font-size: 16px;'>${data}</span><span style='font-size: 16px;'>mm</span></div>`;
    }
  },
  xAxis: {
    type: 'category',
    name: '时',
    nameTextStyle :{ // 设置单位样式
			fontSize: 24
		},
    boundaryGap: true, // 坐标轴两边留白
    axisLabel: {
      show: true,
      textStyle: {
        color: 'rgba(255,255,255,.6)', //更改坐标轴文字颜色
        fontSize: 26 //更改坐标轴文字大小
      }
    },
    axisLine: { // 坐标轴
      lineStyle: {
        color: '#ccc', // 坐标轴线颜色
        width: 1 // 坐标轴线粗度
      }
    },
    axisTick: { // 设置刻度相关
      show: false // 不显示刻度
    },
    data: ['2', '4', '6', '8', '10', '12', '14', '16', '18', '20', '22', '24']
  },
  yAxis: {
    type: 'value',
    name: '单位:mm',
    max: 1, // 设置最大值
    nameTextStyle :{ // 设置单位样式
			fontSize: 24
		},
    splitLine: {
        show: false, // 不显示网格线
        lineStyle: {
            // type: 'dashed', //默认实线,dashed虚线
            width: 1,
            color: '#0a2a5d'
        }
    },
    axisLabel: {
      show: true,
      textStyle: {
        color: 'rgba(255,255,255,.6)', //更改坐标轴文字颜色
        fontSize: 26 //更改坐标轴文字大小
      }
    },
    axisLine: { // 坐标轴
      show: true,
      lineStyle: {
        color: '#ccc', // 坐标轴线颜色
        width: 1 // 坐标轴线粗度
      }
    },
    axisTick: { // 设置刻度相关
      show: true,
      inside: false, // 刻度是否朝内,默认朝外
      length: 5 // 刻度长度,默认为5
    }
  },
  series: [
    {
      data: [0.28, 0.4, 0.31, 0.37,  0.5, 0.3, 0.38, 0.25,0.4,  0.56, 0.6, 0.44],
      type: 'line',
      smooth: 0.2,
      symbol: 'none',
      areaStyle: {},
      itemStyle: {
        normal: {
          areaStyle: {
            type: 'default',
            color: new echarts.graphic.LinearGradient( // 渐变色实现
              0,
              0,
              0,
              1,
              [ // 三种由深及浅的颜色
                {
                  offset: 0,
                  color: 'rgba(103, 210, 255, 1)'
                },
                {
                  offset: 1,
                  color: 'rgba(255, 255, 255, 0.1)'
                }
              ]
            )
          },
          lineStyle: { //线的颜色
            color: '#00ffee'
          }
        }
      }
    }
  ]
};

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 1
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

陌盍

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

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

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

打赏作者

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

抵扣说明:

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

余额充值