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

相关推荐
小李子呢021137 分钟前
前端八股Vue---Vue2和Vue3的区别,set up的用法
前端·javascript·vue.js
邂逅星河浪漫1 小时前
【银行内网开发-管理端】Vue管理端+Auth后台开发+Nginx配置+Linux部署(详细解析)
linux·javascript·css·vue.js·nginx·html·前后端联调
一 乐1 小时前
电影院|基于springboot + vue电影院购票管理系统(源码+数据库+文档)
java·数据库·vue.js·spring boot·论文·毕设·电影院购票管理管理系统
奔跑的呱呱牛1 小时前
@giszhc/vue-page-motion:Vue3 路由动画怎么做才“丝滑”?(附在线示例)
前端·javascript·vue.js
一 乐4 小时前
旅游|基于springboot + vue旅游信息推荐系统(源码+数据库+文档)
java·vue.js·spring boot·论文·旅游·毕设·旅游信息推荐系统
最逗前端小白鼠4 小时前
vue3 数据响应式遇到的问题
前端·vue.js
卤蛋fg65 小时前
vxe-table 自定义数字行主键,解决默认字符串主键与后端类型不匹配问题
vue.js
岁月宁静5 小时前
都知道AI大模型能生成文本内容,那你知道大模型是怎样生成文本的吗?
前端·vue.js·人工智能
|晴 天|6 小时前
我如何用Vue 3打造一个现代化个人博客系统(性能提升52%)
前端·javascript·vue.js
yuqifang7 小时前
vue3+typescript+vite封装自己的UI组件库并上传至npm
vue.js·arkui