Vue + Echarts 实现科技感数据大屏

一、布局实现

1. flex进行"左中右"布局

html 复制代码
<div class="data-container">
    <div class="left">
    </div>
    <div class="right">
    </div>
    <div class="middle">
    </div>
</div>
//css部分
.data-container {
  background: linear-gradient(#0056b1, #248fd8);
  position: flex;
  display: flex;
  /* padding: 0px 10px 10px 10px; */
  height: 100%;
  width: 100%;
}

.left {
  width: 280px;
  background:rgb(147, 144, 238);
  padding: 20px 10px 20px 20px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.right{
  width:250px;
  padding: 20px 20px 20px 10px;
  background:lightgreen;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.middle {
  flex: 1;
  background:rgb(238, 219, 144);
  padding: 20px 10px 20px 10px;
  display: flex;
  flex-direction: column;
}

2. div划分模块,设计科技感配色

html 复制代码
<div class="data-container">
    <!-- 数据面板 -->
    <div class="left">
      <div class="card">
        
      </div>
      <!--  -->
      <div class="card ">
       
      </div>
    </div>
    <div class="middle">
      <!-- 地图 -->
      <div class="map-chart">
        
      </div>
      <!--  -->
      <div class="grid" >
        <div class="grid-content grid-con-1 card">
          
        </div>
        <div class="grid-content grid-con-2 card">
          
        </div>
        <div class="grid-content grid-con-3 card">
         
        </div>
      </div>
    </div>
    <div class="right">
      <div class="card right-top">
       
      </div>
      <div class="card right-mid">
      </div>

      <div class="card right-bottom">
        
      </div>
    </div>

  </div>

// css

.card {
  border-width: 1px;
  border-color:  rgba(25,25,112,0.4);
  background-color: rgba(25,25,112,0.2);
  box-shadow: 0 2px 12px 0 rgba(18, 45, 136, 0.7);
  padding: 10px;
  border-radius: 5px;
  justify-content: center;
  align-items: center;
  /* margin-top: 10px; */
}

二、echarts中的图表展示

  1. 地图:

https://blog.csdn.net/qq_44846654/article/details/147929138?spm=1011.2415.3001.5331

  1. 统一管理图表
html 复制代码
<!-- components/EchartsMap.vue -->
<template>
  <div ref="chartDom" :style="{'width':width, 'height': height}"></div>
</template>

<script>
// eslint-disable-next-line standard/object-curly-even-spacing
import { ref, onMounted, onBeforeUnmount, watch} from 'vue'
import {BAROPTION, MAPOPTION, RADAROPTION, GAUGEOPTIO} from './defaultOption'
import echarts from '../../plugins/echarts'

export default {
  name: 'MapEchart',
  props: {
    region: {type: String, default: 'china'},
    mapData: { type: Array, default: () => [] }, // 地图数据(如省份值)
    option: { type: Object, default: () => ({}) }, // 自定义配置覆盖
    echartsType: {type: String, default: 'map'}, // such as: map, bar, line...
    width: {type: String},
    height: {type: String}
  },
  setup (props) {
    const chartDom = ref(null)
    let chartInstance = null

    // 初始化图表
    const initChart = () => {
      console.log(props.echartsType)
      if (!chartInstance) {
        chartInstance = echarts.init(chartDom.value)
      }
      let baseOption = null
      if (props.echartsType === 'map') {
        const geoJson = require(`../../mapJson/${props.region}.json`)
        echarts.registerMap(props.region, geoJson)
        baseOption = MAPOPTION
      } else if (props.echartsType === 'bar') {
        baseOption = BAROPTION
      } else if (props.echartsType === 'radar') {
        baseOption = RADAROPTION
      } else if (props.echartsType === 'gauge') {
        baseOption = GAUGEOPTIO
      }
      // 合并外部配置
      chartInstance.setOption(baseOption)
      console.log(baseOption)
    }
    // 响应窗口变化
    const resizeChart = () => {
      if (chartDom.value) {
        chartInstance.resize()
      }
    }

    // 监听数据变化
    watch(() => props.mapData, (newVal) => {
      // chartInstance.setOption({ series: [{ data: newVal }] });
    })

    onMounted(() => {
      initChart()
      window.addEventListener('resize', resizeChart)
    })

    onBeforeUnmount(() => {
      window.removeEventListener('resize', resizeChart)
      // if(chartDom.value){
      //   chartInstance.dispose();
      // }
    })

    return { chartDom }
  }
}
</script>
  1. 可滚动的排行榜

https://blog.csdn.net/qq_44846654/article/details/148044424

相关推荐
Hi_kenyon1 天前
VUE3套用组件库快速开发(以Element Plus为例)二
开发语言·前端·javascript·vue.js
Irene19911 天前
Vue 3 响应式系统类型关系总结(附:computed、props)
vue.js·props·响应式类型
起名时在学Aiifox1 天前
Vue 3 响应式缓存策略:从页面状态追踪到智能数据管理
前端·vue.js·缓存
天若有情6731 天前
校园二手交易系统实战开发全记录(vue+SpringBoot+MySQL)
vue.js·spring boot·mysql
计算机程序设计小李同学1 天前
个人数据管理系统
java·vue.js·spring boot·后端·web安全
JosieBook1 天前
【Vue】09 Vue技术——JavaScript 数据代理的实现与应用
前端·javascript·vue.js
Eason_Lou1 天前
webstorm开发vue项目快捷跳转到vue文件
ide·vue.js·webstorm
起名时在学Aiifox1 天前
前端文件下载功能深度解析:从基础实现到企业级方案
前端·vue.js·typescript
云上凯歌1 天前
01 ruoyi-vue-pro框架架构剖析
前端·vue.js·架构
毕设十刻1 天前
基于Vue的迅读网上书城22f4d(程序 + 源码 + 数据库 + 调试部署 + 开发环境配置),配套论文文档字数达万字以上,文末可获取,系统界面展示置于文末
前端·数据库·vue.js