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

相关推荐
前端炒粉3 小时前
长会话虚拟滚动与渲染优化
前端·javascript·vue.js
sibylyue4 小时前
基于 Vben Admin 框架的 Vue 3 前端项目配置文件及常用命令
前端·javascript·vue.js
张人玉6 小时前
基于 Python 的桌面端智能识别与可视化系统——生活垃圾分类可视化大屏
python·分类·sqlite·echarts·生活
小蒜学长7 小时前
vue旅游攻略网站(代码+数据库+LW)
java·数据库·vue.js·spring boot·后端·旅游
paopaokaka_luck1 天前
基于springboot3+vue3的支教志愿者管理系统(AI问答、协同过滤算法、Echarts图形化分析)
spring boot·echarts
sir.山1 天前
在 Vue 3 项目中使用 Mock 数据
前端·vue.js·vue3·vite
你别说话了2 天前
Vue项目解决跨域
前端·javascript·vue.js
学习星球2 天前
Solid.js 实战:拆解官方 RealWorld 项目
开发语言·javascript·vue.js
paopaokaka_luck2 天前
基于springboot3+vue3的文山民族文化资源展示与推广平台(协同过滤算法、Echarts 图形化分析)
java·前端·spring boot·学习·echarts
尚可签2 天前
基于 Spring Boot + Vue 的 AI 智能在线订餐系统
vue.js·人工智能·spring boot