echats大规模面积图在vue中

3 篇文章 0 订阅

在这里插入图片描述

    // 大面积图
    initCharArea (element, title, titleArr, numberArr) {
      // 基于准备好的dom,初始化echarts实例
      const myChart = echarts.init(element)
      // 绘制图表
      myChart.setOption({
        title: {
          text: '',
          x: '10px',
          color: '#fff'
        },
        tooltip: { trigger: 'axis', formatter: `{b}: 当前${title}{c}%` },
        legend: {
          orient: 'horizontal',
          x: '50px',
          y: 'top',
          // data: ['cpu'],
        },
        grid: {
          // containLabel: false,
          show: true,
          top: '16%',
          left: '8%',
          right: '8%',
          bottom: '3%',
          containLabel: true,
          borderColor: '#096aae',
          borderWidth: 1
        },
        xAxis: {
          name: '',
          type: 'category',
          data: [' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '],
          splitLine: {
            show: true,
            lineStyle: {
              type: 'solid',
              color: '#096aae',
            }
          },
          nameTextStyle: {
            color: '#fff'
          },
          nameLocation: 'middle',
          axisLabel: {
            color: '#fff',
            rotate: 30,
            interval: 0
          },
          axisTick: {
            lineStyle: {
              color: '#096aae'
            }
          }
        },
        dataZoom: [{
          type: 'slider',
          show: false, // flase直接隐藏图形
          xAxisIndex: [0],
          left: '9%', // 滚动条靠左侧的百分比
          bottom: 0,
          startValue: this.chatStart, // 滚动条的起始位置
          endValue: this.chatEnd // 滚动条的截止位置(按比例分割你的柱状图x轴长度)
        }],
        yAxis: {
          // show: false,
          max: '100',
          axisLabel: {
            color: '#fff',
            rotate: 30,
            interval: 0
          },
          axisLine: {
            show: false
          },
          splitLine: {    // 网格线
            lineStyle: {
              type: 'solid',
              color: '#096aae'   // 设置网格线类型 dotted:虚线   solid:实线
            },
            show: true // 隐藏或显示
          },
          axisTick: {
            lineStyle: {
              color: '#096aae'
            }
          }
        },
        series: [{
          name: title,
          type: 'line',
          smooth: true,
          data: numberArr,
          itemStyle: {
            normal: {
              color: '#f11ab3',
              lineStyle: {
                color: '#f11ab3',
              }
            }
          },
          areaStyle: {
            /* normal: { origin: 'start', color: 'rgba(57,127,255,.1)', opacity: 1 }, */
            normal: {
              color: {
                type: 'linear', // 设置线性渐变
                x: 0,
                y: 0,
                x2: 0,
                y2: 1,
                colorStops: [{
                  offset: 0, color: '#f11ab3' // 0% 处的颜色
                }, {
                  offset: 1, color: 'rgb(96,104,241)' // 100% 处的颜色
                }],
                globalCoord: false // 缺省为 false
              },

            }
          },
        },
        ]
      })
    }
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值