vue 项目 中echarts 折线图使用基础要点

带渐变区域颜色的折线图
在1这里插入图片描述

vue 项目 中echarts 折线图使用基础要点

import echarts from 'echarts';//项目引入
 setChart() {
      const myChart = echarts.init(this.$refs.box);
      const option = {
        title: {
        //   text: '某楼盘销售情况',
        //   subtext: '纯属虚构'
        },
        tooltip: {//标点显示内容
          trigger: 'axis'
        },
        legend: {
          data: ['发票', '智能柜', '极汇购'],
		 // x: 'center', // 居右显示,控制标尺显示位置
		  right: '100',
		  icon: 'circle', // 圆形,默认长条
          textStyle: { color: '#fff' }//标记文本颜色
        },
        color: ['rgb(95,107,176)', 'rgb(167,28,159)', 'rgb(196,124,70)'],//控制标尺每个标记的颜色
        // backgroundColor: 'rgba(0,0,0,0)',
        toolbox: {//工具栏
          show: false,
          feature: {
            mark: { show: true },
            dataView: { show: true, readOnly: false },
            magicType: { show: true, type: ['line', 'bar', 'stack', 'tiled'] },
            restore: { show: true },
            saveAsImage: { show: true }
          }
        },
        calculable: true,
        xAxis: [
          {
            type: 'category',
            boundaryGap: false,
            data: ['0', '5', '10', '15', '20', '25', '30'],
            splitLine: { show: false }, // 去除网格线
            splitArea: { show: false }, // 保留网格区域
            axisLine: {
              lineStyle: {
                type: 'solid',
                color: '#137abf', // 左边线的颜色
                // width: '2'// 坐标线的宽度
              }
            },
            axisLabel: {
              textStyle: {
                color: '#fff', // 坐标值得具体的颜色

              }
            }
            // splitArea: {// 折线图背景
            //   show: true,
            //   areaStyle: {
            //     color: ['rgba(216,216,216,0.08)', 'rgba(216,216,216,0.04)']
            //   }
            // }
          }
        ],
        yAxis: [
          {
            type: 'value',
            splitLine: { show: true, lineStyle: { color: '#137abf' } }, // 去除网格线
            splitArea: { show: false }, // 保留网格区域
            axisLine: {
              lineStyle: {
                type: 'solid',
                color: '#137abf',
              }
            },
            axisLabel: {
              textStyle: {
                color: '#fff', // 坐标值得具体的颜色

              }
            }
          }
        ],
        series: [
          {
            name: '发票',
            type: 'line',
            // smooth: true,
           	lineStyle: { color: 'rgb(95,107,176)' },//折线颜色
            itemStyle: {
              normal: {
                areaStyle: {//折现区域颜色
                  color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
                    offset: 0,
                    color: '#297dc5'
                  }, {
                    offset: 1,
                    color: 'transparent'
                  }])
                }
			 }
            },
            data: [1500, 1700, 2300, 100, 0, 0, 0],
          },
          {
            name: '智能柜',
            type: 'line',
            // smooth: true,
            lineStyle: { color: 'rgb(167,28,159)' },
            itemStyle: {
              normal: {
                areaStyle: {
                  color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
                    offset: 0,
                    color: 'rgb(179,71,121)'
                  }, {
                    offset: 1,
                    color: 'rgba(255, 70, 131,0)'
                  }])
                }
			 }
            },
            data: [1800, 1900, 2100, 2100, 2500, 3500, 3100]
          },
          {
            name: '极汇购',
            type: 'line',
            // smooth: true,
            lineStyle: { color: 'rgb(196,124,70)' },
            itemStyle: {
              normal: {
                areaStyle: {
                  color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
                    offset: 0,
                    color: 'rgb(126,69,78)'
                  }, {
                    offset: 1,
                    color: 'rgba(255, 70, 131,0)'
                  }])
                }
			 }
            },
            data: [2100, 1600, 1900, 1900, 2500, 3900, 3200]
          }
        ]
      };
	  myChart.setOption(option);
	  },
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值