echarts实现炫酷科技感的流光效果

前言:

        echarts实现炫酷科技感的流光效果

效果图:

实现步骤:

1、引入echarts,直接安装或者cdn引入
npm i echarts
https://cdn.jsdelivr.net/npm/echarts@5.4.3/dist/echarts.min.js
2、封装 option方法,第一个数据是折线数据,第二个是流动的点
commonOption(name,xData,yData){
          let dtList = []
          xData.forEach((item,i)=>{
            let arr = []
            arr.push(item)
            arr.push(yData[i])
            dtList[i] = arr
          })
          return {
            title: {
              text: name,
              textStyle: {
                color: "#fff",
                fontSize: 16,
                fontWeight: "500",
              }
            },
            "grid": {
              "containLabel": true,
              "bottom": "20",
              "top": "40",
              "left": "20",
              "right": "20"
            },
            "xAxis": {
              "triggerEvent": true,
              "axisLabel": {
                "show": true,
                "fontSize": 12,
                "color": "#fff",
                "align": "center",
                "verticalAlign": "top"
              },
              "axisLine": {
                "show": false
              },
              "axisTick": {
                "show": true,
                "lineStyle": {
                  "show": true,
                  "color": "#0B3561",
                  "width": 2
                }
              },
              "data": xData
            },
            "yAxis": [{
              "axisLabel": {
                "interval": 0,
                "show": true,
                "fontSize": 14,
                "color": "#fff"
              },
              "axisLine": {
                "show": false
              },
              "axisTick": {
                "show": false
              },
              "splitLine": {
                "lineStyle": {
                  "type": "dashed",
                  "color": "rgba(255,255,255,0.15)"
                }
              }
            }],
            "series": [{
              "name": "demo1",
              "type": "line",
              "smooth": false,
              "symbol": "circle",
              "symbolSize": 3,
              "showSymbol": false,
              "lineStyle": {
                "normal": {
                  "width": 2,
                  "shadowColor": "#159AFF",
                  "shadowBlur": 8
                }
              },
              "itemStyle": {
                "normal": {
                  "color": "#159AFF"
                }
              },
              "data": yData
            },{
              "name": "demo1",
              "type": "lines",
              "polyline": true,
              "showSymbol": false,
              "coordinateSystem": "cartesian2d",
              "effect": {
                "trailLength": 0.3,
                "show": true,
                "period": 6,
                "symbolSize": 4,
                "loop": true
              },
              "lineStyle": {
                "color": "#fff",
                "width": 0,
                "opacity": 0,
                "curveness": 0,
                "type": "dashed"
              },
              "data": [{
                "coords": dtList // 动态的图
              }]
            }]
          }
        },
3、然后方法中使用
let myChart = echarts.init(dom);

let arr1 = ['星期一', '星期二', '星期三', '星期四', '星期五', '星期六', '星期日']
let arr = [11, 12, 10, 11, 10, 10, 11]
let option = this.commonOption('学员一队',arr1,arr)

myChart.setOption(option);

相关推荐

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2024-04-08 00:46:02       94 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-04-08 00:46:02       100 阅读
  3. 在Django里面运行非项目文件

    2024-04-08 00:46:02       82 阅读
  4. Python语言-面向对象

    2024-04-08 00:46:02       91 阅读

热门阅读

  1. 前端开发之el-select 设置默认值后选项无法切换

    2024-04-08 00:46:02       169 阅读
  2. 违法解除劳动合同后【股票争议】——案例学习

    2024-04-08 00:46:02       41 阅读
  3. 第十五题:最大距离

    2024-04-08 00:46:02       64 阅读
  4. 【算法】求平方根 - 二分法/牛顿迭代

    2024-04-08 00:46:02       36 阅读
  5. 专业虚拟社区用户知识共享行为影响因素研究

    2024-04-08 00:46:02       38 阅读
  6. 数据库基础教程 第三版 —建表

    2024-04-08 00:46:02       39 阅读
  7. 谷歌Rust生产力高于C++两倍?

    2024-04-08 00:46:02       38 阅读
  8. 2024.2.17力扣每日一题——N叉树的层序遍历

    2024-04-08 00:46:02       34 阅读
  9. SQL高级教程

    2024-04-08 00:46:02       39 阅读