程序员开发实例大全宝库

网站首页 > 编程文章 正文

8.7k star,一款超炫酷的动态可视化大屏项目

zazugpt 2025-04-24 10:29:26 编程文章 8 ℃ 0 评论

一、项目描述

一个基于 vue、datav、Echart 框架的大数据可视化(大屏展示)模板,提供数据动态刷新渲染、屏幕适应、内部图表自由替换、Mixins注入等功能。

主要文件介绍

文件作用/功能main.js主目录文件,引入 Echart/DataV 等文件utils工具函数与 mixins 函数等views/ index.vue项目主结构views/其余文件界面各个区域组件(按照位置来命名)assets静态资源目录,放置 logo 与背景图片assets / style.scss通用 CSS 文件,全局项目快捷样式调节assets / index.scssIndex 界面的 CSS 文件components/echart所有 echart 图表(按照位置来命名)common/...全局封装的 ECharts 和 flexible 插件代码(适配屏幕尺寸,可定制化修改)

项目动态展示

使用介绍

动态渲染图表

动态渲染图表案例为 components 目录下各个图表组件,index 文件负责数据获取和处理,chart 文件负责监听和数据渲染。

chart 文件的主要逻辑为:

<template>
  <div>
    <Echart :options="options" id="id" height="height" width="width" ></Echart>
  </div>
</template>

<script>
  // 引入封装组件
import Echart from '@/common/echart'
export default {
  // 定义配置数据
  data(){ return { options: {}}},
  // 声明组件
  components: { Echart},
  // 接收数据
  props: {
    cdata: {
      type: Object,
      default: () => ({})
    },
  },
  // 进行监听,也可以使用 computed 计算属性实现此功能
  watch: {
    cdata: {
      handler (newData) {
        this.options ={
          // 这里编写 ECharts 配置
        }
      },
      // 立即监听
      immediate: true,
      // 深度监听
      deep: true
    }
  }
};
</script>

复用图表组件

复用图表组件案例为中间部分的 任务通过率与任务达标率 模块,两个图表类似,区别在于颜色和主要渲染数据。只需要传入对应的唯一 id 和样式,然后在复用的组件 components/echart/center/centerChartRate 里进行接收并在对应位置赋值即可。

如:在调用处 views/center.vue 里去定义好数据并传入组件

//组件调用
<span>今日任务通过率</span>
<centerChart :id="rate[0].id" :tips="rate[0].tips" :colorObj="rate[0].colorData" />

<span>今日任务达标率</span>
<centerChart :id="rate[1].id" :tips="rate[1].tips" :colorObj="rate[1].colorData" />

...
import centerChart from "@/components/echart/center/centerChartRate";

data() {
  return {
    rate: [
      {
        id: "centerRate1",
        tips: 60,
        ...
      },
      {
        id: "centerRate2",
        tips: 40,
        colorData: {
          ...
        }
      }
    ]
  }
}

请求数据

现在的项目未使用前后端数据请求,建议使用 axios 进行数据请求,在 main.js 位置进行全局配置。

axios 的 main.js 配置参考范例(因人而异)

import axios from 'axios';

//把方法放到vue的原型上,这样就可以全局使用了
Vue.prototype.$http = axios.create({
  //设置20秒超时时间
  timeout: 20000,
  baseURL: 'http://172.0.0.1:80080', //这里写后端地址
});

基于本项目的二开案例

支持地图下钻:

https://gitee.com/memeda520/IofTV-Screen

重写结构,支持响应式布局:

https://gitee.com/BigCatHome/koi-screen

开源地址

https://gitee.com/MTrun/big-screen-vue-datav

本文暂时没有评论,来添加一个吧(●'◡'●)

欢迎 发表评论:

最近发表
标签列表