echarts的基本使用

安装命令:

npm install echarts 或 yarn add echarts

项目中引入echarts:

import * as echarts from "echarts"

 getEcharts() {

      // 获取echarts作用实例作用dom

      this.myChart = echarts.init(document.getElementById("mmmm"));

      const option = {

        title: {

          // text: "单位 : 场",

          subtext: '单位 : 场',

          left: '5%',

          top: 0,

        },

        tooltip: {

          show: true,

          trigger: 'axis',

          axisPointer: {

            label: {

              backgroundColor: '#6a7985'

            }

          },

          // 鼠标悬停显示的信息提示框

          formatter: function (params) {

            const data = params[0].data

            const time = params[0].axisValue

            return `时间: ${time}<br/>

              新增人数: ${data}人`

          }

        },

        xAxis: {

          type: "category",

          data: this.timeData,

          axisTick: {

            show: false // 隐藏x轴刻度

          },

          boundaryGap: false, // false时从0刻度开始

          axisLabel: {

            formatter: function (val) {

              let strs = val; //转化为字符串数组

              var str = "";

              for (var i = 0, s; (s = strs[i++]);) {

                str += s;

                if (!(i % 5))

                  //两个字符换行

                  str += "\n";

              }

              return str.substr(6, 9);

            },

          },

        },

        yAxis: {

          type: "value",

        },

        series: [

          {

            data: this.statisticalData, //所需数据

            symbolSize: 10, // 空心圆的大小

            type: 'line',

            // 线条配置

            showSymbol: true,

            type: "line",

            smooth: true, // 折线是否为平滑曲线

            itemStyle: {

              normal: {

                color: "#60D139", //线条颜色

                lineStyle: {

                  width: 3, //设置线条粗细

                },

              },

            },

          },

        ],

      };

      option && this.myChart.setOption(option);

    }

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值