国庆一周收入折线图

1、x轴只显示首末日期,其他日期隐藏

2、y轴数字在标线之上

3、tooltip显示带单位的提示

效果如下:

var fontColor = '#DDDDDD'; //轴线的颜色
var legendName = '国庆收入';
var month = 10;
var xData = [
  '10月1日',
  '10月2日',
  '10月3日',
  '10月4日',
  '10月5日',
  '10月6日',
  '10月7日'
];
var seriesData = [82000, 93002, 90100, 93004, 120090, 133000, 130020];
option = {
  tooltip: {
    trigger: 'axis',
    formatter: function (params) {
      return (
        '时间:' +
        params[0].name +
        '<br/>' +
        params[0].seriesName +
        ':' +
        params[0].value +
        '万<br/>'
      );
    }
  },
  legend: {
    data: legendName
  },
  xAxis: {
    type: 'category',
    boundaryGap: false,
    offset: 5,
    axisLine: {
      //坐标轴轴线相关设置
      show: true,
      lineStyle: {
        color: fontColor
      }
    },
    axisTick: {
      show: false
    },
    axisLabel: {
      show: true,
      textStyle: {
        color: fontColor
      },
      // 只显示第一个和最后一个日期
      formatter: function (value, index) {
        return index == 0 || index == xData.length - 1 ? value : '';
      }
    },
    data: xData
  },
  yAxis: {
    type: 'value',
    name: month + '月国庆节收入曲线图',
    nameLocation: 'end',
    nameGap: 30,
    nameTextStyle: {
      padding: [0, 0, 0, 110]
    }, //坐标轴名称的文字样式
    axisLine: {
      //坐标轴轴线相关设置
      show: false
    },
    axisTick: {
      show: false
    }, //标记长度
    axisLabel: {
      show: true,
      inside: true, //刻度标签是否朝内,默认朝外
      margin: 0,
      verticalAlign: 'bottom', //文字垂直对齐方式
      textStyle: {
        color: fontColor
      }
    },
    splitLine: {
      show: true,
      lineStyle: {
        color: fontColor,
        width: 1,
        type: 'solid'
      }
    } //分割线
  },
  series: [
    {
      name: legendName,
      data: seriesData,
      type: 'line',
      smooth: true,
      symbol: 'none',
      itemStyle: {
        normal: {
          color: '#FEA25A'
        }
      },
      areaStyle: {
        //折线颜色不取渐变色,取color设置值
        normal: {
          color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
            {
              offset: 0,
              color: 'rgba(254,162,90,1)'
            },
            {
              offset: 1,
              color: 'rgba(254,162,90,.1)'
            }
          ])
        }
      }
    }
  ]
};

 或者x轴的 boundaryGap: true,展示如下效果

 

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

佛佛ง

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

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

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

打赏作者

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

抵扣说明:

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

余额充值