echart折线图,线性渐变

 

setEchart(val){
    // 基于DOM,初始化echarts实例(注意!Vue的DOM日怪的很,一般要腾个1秒才加载完)
    this.lineChart = this.$echarts.init( document.getElementById("charts"));
    onresize=()=>{
        .lineChart.resize();//当页面大小变化→图标对应变化
    }
    var xList = [];   //X轴坐标值
    var dayIncomesList = [];  //X轴数据
    if(val){
       val.forEach(item =>{
           if(item.date < 10){
               item.date = item.date.slice(1)
           }
            xList.push(item.date+'号');
            dayIncomesList.push(item.amount);
        })
    }
                
   // 绘制折线图(曲线图)
   this.lineChart.setOption({
      title: {
           text: '日度收入入账趋势图',
           textStyle: {
               color: '#fff', 
               fontSize:"15"
           },
      },
       grid: {
           top: 35,
           left: '3%',
           right: '5%',
           bottom: '5%',
           containLabel: true//false是依据坐标轴来对齐的,true是依据坐标轴上面的文字边界来对齐
    },
    xAxis: {
        boundaryGap: false, //防止统计图左侧和纵轴有间隙
        axisLabel: { 
            textStyle: {
                color: "#fff"
            } 
        },
        axisTick: { 
             show: false
        }, //隐藏横坐标刻度小线条
        splitLine: {
            show: true,
            lineStyle: { 
                color: ["#2E3B48"] 
            } //纵向分割线    182D40
        },
        data: xList
    },
    yAxis: {
        type: "value",
        min: 0,
        minInterval: 1,
        nameLocation: "end",
        nameTextStyle: { 
            color: "#fff",
            fontSize: "12" 
        },
        axisLabel: { 
             extStyle: { 
                  color: "#fff" 
             } 
        ,
        axisTick: { 
             show: false
        }, //隐藏纵坐标刻度小线条
        splitLine: {
            show: false,
            lineStyle: { 
                  color: ["#fff"]
            } //横向分割线
        },
        axisLine: {
             lineStyle: {
                  color: "2E3B48",
                  width: 1
             } 
        }
   },
   series: [
       {
            smooth: true, //平滑
            symbol: "none", // 去掉小圆点
            type: "line",
            symbolSize: 10, //折线拐点大小
            data: dayIncomesList,
            itemStyle: {
                normal: {
                    color: "#18c196", //图例颜色
                    borderWidth: 4,
                    borderColor: "#18c196",
                    lineStyle: { color: "#18c196", width: 2 }
                }
            },
            areaStyle: {
                 normal: {// 渐变填充色(线条下半部分)
                      color: new this.$echarts.graphic.LinearGradient(0, 0, 0, 1, [
                           { offset: 0, color: "#18c196" },
                           { offset: 1, color: "#18c19600" }
                      ])
                  }
             }
      },
   ]
});
}

  • 2
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值