基于vue的可视化大屏2

打印 上一主题 下一主题

主题 912|帖子 912|积分 2736


这个可视化大屏分为四个部分
一个引入代码,引入全局 index.vue.
左边代码centerleft.vue
右边代码centerright.vue
中间代码center.vue

主代码:
这是一段 Vue 框架的代码。

在 <template> 部分:



  • 界说了一个根 div 元素。
  • 此中包含一个名为 env_content 的 div 元素,它内部包含三个自界说组件 envLeft 、 envCenter 和 envRight 。

在 <script> 部分:



  • 引入了三个组件:envLeft.vue 、 envCenter.vue 和 envRight.vue 。
  • 界说了默认的导出对象,此中 components 属性中注册了这三个引入的组件。

在 <style scoped> 部分:



  • 为 env_content 类界说了样式,使用 flex 布局,并设置了元素之间的间距为 space-between ,实现了三个子元素在水平方向上两头对齐的布局效果。

总体来说,这段代码通过组件化的方式构建了一个页面结构,并使用样式进行了布局设置。
  1. <template>
  2.   <div>
  3.     <div class="env_content">
  4.       <env-left />
  5.       <env-center />
  6.       <env-right />
  7.     </div>
  8.   </div>
  9. </template>
  10. <script>
  11. import envLeft from "./components/envLeft.vue";
  12. import envRight from "./components/envRight.vue";
  13. import envCenter from "./components/envCenter.vue";
  14. export default {
  15.   components: { envLeft, envCenter, envRight },
  16. };
  17. </script>
  18. <style scoped>
  19. .env_content {
  20.   display: flex;
  21.   justify-content: space-between;
  22. }
  23. </style>
复制代码
左边代码
模板(<template>)部分



  • 整体被一个具有 content 类的 div 包裹。

    • 内部的第一个 div 中包含一个自界说组件 dv-border-box-8 ,其内部有一个 head 部分。

      • head 中又包含三个具有 head_content 类的 div ,每个内部都有一个 h1 和 h2 元素,分别展示不同的风力、风速和光照数据。

    • 第二个 div 具有 body 类,包含两个部分。

      • 第一个部分是一个自界说组件 dv-border-box-6 ,内部使用 Echart 组件来展示风速监测图表,并通过 options1 对象设置了图表的各种属性,如颜色、标题、提示框、图例、工具框、网格、坐标轴和数据系列等。
      • 第二个部分是一个自界说组件 dv-border-box-10 ,内部通过 dv-scroll-board 组件展示城市空气污染物监测数据。



脚本(<script>)部分



  • 引入了 Echart 组件和 echarts 库。
  • 界说了默认导出对象。

    • components 中注册了 Echart 组件。
    • data 函数返回了两个数据对象:options1 用于设置风速监测图表,airData 用于提供城市空气污染物监测数据。


样式(<style scoped>)部分



  • content 类的 div 宽度设置为 30% 。
  • head 类的 div 有内边距、高度,并使用 flex 布局实现元素之间的等间距分列。
  • head_content 类的 div 使用 flex-direction: column 实现纵向布局,并通过 justify-content: space-between 和 align-items: center 来调整内部元素的垂直和水平对齐方式。
  • body 类的 div 有上边距。

总体而言,这段代码构建了一个展示风力、风速、光照以及风速和城市空气污染物监测数据的页面组件,并通过设置数据和样式来出现相应的内容和布局。

  1. <template>
  2.   <div class="content">
  3.     <div>
  4.       <dv-border-box-8 :reverse="true">
  5.         <div class="head">
  6.           <div class="head_content">
  7.             <h1>2.5</h1>
  8.             <h2>风力(级)</h2>
  9.           </div>
  10.           <div class="head_content">
  11.             <h1>5</h1>
  12.             <h2>风速(m/s)</h2>
  13.           </div>
  14.           <div class="head_content">
  15.             <h1>45</h1>
  16.             <h2>光照(klm)</h2>
  17.           </div>
  18.         </div>
  19.       </dv-border-box-8>
  20.     </div>
  21.     <div class="body">
  22.       <!-- 风速监测表 -->
  23.       <dv-border-box-6
  24.         ><Echart :options="options1" height="500px"
  25.       /></dv-border-box-6>
  26.       <!-- 城市空气污染物监测表 -->
  27.       <dv-border-box-10>
  28.         <div style="padding: 5px">
  29.           <dv-scroll-board :config="airData" style="height: 300px" />
  30.         </div>
  31.       </dv-border-box-10>
  32.     </div>
  33.   </div>
  34. </template>
  35. <script>
  36. import Echart from "@/common/echart/index.vue";
  37. import * as echarts from "echarts";
  38. export default {
  39.   components: { Echart },
  40.   data() {
  41.     return {
  42.       options1: {
  43.         color: ["#80FFA5"],
  44.         title: {
  45.           text: "24小时风速监测",
  46.         },
  47.         tooltip: {
  48.           trigger: "axis",
  49.           axisPointer: {
  50.             type: "cross",
  51.             label: {
  52.               backgroundColor: "#6a7985",
  53.             },
  54.           },
  55.         },
  56.         legend: {
  57.           data: ["air spend"],
  58.         },
  59.         toolbox: {
  60.           feature: {
  61.             saveAsImage: {},
  62.           },
  63.         },
  64.         grid: {
  65.           left: "3%",
  66.           right: "4%",
  67.           bottom: "3%",
  68.           containLabel: true,
  69.         },
  70.         xAxis: [
  71.           {
  72.             name: "h",
  73.             type: "category",
  74.             boundaryGap: false,
  75.             data: [0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24],
  76.           },
  77.         ],
  78.         yAxis: [
  79.           {
  80.             name: "风速m/s",
  81.             type: "value",
  82.             min: 0,
  83.             max: 6,
  84.           },
  85.         ],
  86.         series: [
  87.           {
  88.             type: "line",
  89.             stack: "Total",
  90.             smooth: true,
  91.             lineStyle: {
  92.               width: 0,
  93.             },
  94.             showSymbol: false,
  95.             areaStyle: {
  96.               opacity: 0.8,
  97.               color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
  98.                 {
  99.                   offset: 0,
  100.                   color: "rgb(128, 255, 165)",
  101.                 },
  102.                 {
  103.                   offset: 1,
  104.                   color: "rgb(1, 191, 236)",
  105.                 },
  106.               ]),
  107.             },
  108.             emphasis: {
  109.               focus: "series",
  110.             },
  111.             data: [
  112.               1, 1.3, 1.1, 0.8, 2.4, 3.5, 3.1, 1.2, 2.5, 4.2, 3.2, 1.5, 0.9,
  113.             ],
  114.           },
  115.         ],
  116.       },
  117.       airData: {
  118.         header: ["城市", "首要污染物", "等级", "AQI"],
  119.         data: [
  120.           ["平桥区区", "——", "优", 34],
  121.           ["浉河区区", "——", "优", 31],
  122.           ["罗山县", "O3", "轻度污染", 94],
  123.           ["息县", "PM2.5", "良", 52],
  124.           ["光山县", "——", "优", 34],
  125.           ["新县", "——", "优", 31],
  126.           ["潢川县", "O3", "轻度污染", 94],
  127.           ["商城县", "PM2.5", "良", 52],
  128.           ["淮滨县", "——", "优", 31],
  129.           ["固始县", "O3", "轻度污染", 94]
  130.         ],
  131.       },
  132.     };
  133.   },
  134. };
  135. </script>
  136. <style scoped>
  137. .content {
  138.   width: 30%;
  139. }
  140. .head {
  141.   padding: 10px;
  142.   height: 80px;
  143.   display: flex;
  144.   justify-content: space-around;
  145. }
  146. .head_content {
  147.   display: flex;
  148.   flex-direction: column;
  149.   justify-content: space-between;
  150.   align-items: center;
  151. }
  152. .body {
  153.   margin-top: 10px;
  154. }
  155. </style>
复制代码
 效果:

右边代码
模板(<template>)部分



  • 整体由一个具有 content 类的 div 包裹。

    • 第一个 div 内包含一个自界说的 dv-border-box-8 组件,其内部有 head 部分,head 又包含三个具有 head_content 类的 div ,分别展示了 PM2.5、PM10 和 TSP 的数据及对应的单元。
    • 第二个 div 具有 body 类,包含两个主要部分。

      • 第一个部分是 body_table1 类的 div,此中包含一个自界说的 dv-border-box-6 组件,展示了标题“主要污染物分布”和使用 Echart 组件绘制的饼图。
      • 第二个部分是另一个自界说的 dv-border-box-6 组件,展示了标题“空气污染物监测”和使用 Echart 组件绘制的不同污染物在不同月份的折线图。



脚本(<script>)部分



  • 引入了 Echart 组件。
  • 界说了默认导出对象。

    • components 中注册了 Echart 组件。
    • data 函数返回了两个 options 对象:options1 用于设置主要污染物分布的饼图,options2 用于设置空气污染物监测的折线图。


样式(<style scoped>)部分



  • content 类的 div 宽度设置为 30% 。
  • head 类的 div 有内边距、高度,并使用 flex 布局实现元素之间的等间距分列。
  • head_content 类的 div 使用纵向的 flex 布局,并调整内部元素的垂直和水平对齐方式。
  • body 类的 div 有上边距。
  • body_table1 类的 div 使用 flex 布局。
  1. <template>
  2.   <div class="content">
  3.     <div>
  4.       <dv-border-box-8 :reverse="true">
  5.         <div class="head">
  6.           <div class="head_content">
  7.             <h1>35</h1>
  8.             <h2>PM2.5(μg/m³)</h2>
  9.           </div>
  10.           <div class="head_content">
  11.             <h1>75</h1>
  12.             <h2>PM10(mg/m³)</h2>
  13.           </div>
  14.           <div class="head_content">
  15.             <h1>125</h1>
  16.             <h2>TSP(mg/m³)</h2>
  17.           </div>
  18.         </div>
  19.       </dv-border-box-8>
  20.     </div>
  21.     <div class="body">
  22.       <!-- 城市空气污染物比例占比 -->
  23.       <div class="body_table1">
  24.         <dv-border-box-6 style="padding: 10px">
  25.           <h2>主要污染物分布</h2>
  26.           <Echart
  27.             :options="options1"
  28.             height="400px"
  29.             width="400px"
  30.             style="margin: auto"
  31.           />
  32.         </dv-border-box-6>
  33.       </div>
  34.       <!-- 城市空气污染物监测 -->
  35.       <div>
  36.         <dv-border-box-6 style="padding: 10px">
  37.           <h2>空气污染物监测</h2>
  38.           <Echart :options="options2" height="340px" width="500px" />
  39.         </dv-border-box-6>
  40.       </div>
  41.     </div>
  42.   </div>
  43. </template>
  44. <script>
  45. import Echart from "@/common/echart/index.vue";
  46. export default {
  47.   components: { Echart },
  48.   data() {
  49.     return {
  50.       options1: {
  51.         legend: {
  52.           top: "bottom",
  53.         },
  54.         toolbox: {
  55.           show: true,
  56.           feature: {
  57.             mark: { show: true },
  58.             dataView: { show: true, readOnly: false },
  59.             restore: { show: true },
  60.             saveAsImage: { show: true },
  61.           },
  62.         },
  63.         series: [
  64.           {
  65.             name: "Nightingale Chart",
  66.             type: "pie",
  67.             radius: [50, 180],
  68.             center: ["50%", "50%"],
  69.             roseType: "area",
  70.             itemStyle: {
  71.               borderRadius: 8,
  72.             },
  73.             data: [
  74.               { value: 15, name: "SO2" },
  75.               { value: 50, name: "PM2.5" },
  76.               { value: 80, name: "PM10" },
  77.               { value: 60, name: "NO2" },
  78.               { value: 106, name: "O3" },
  79.               { value: 90, name: "CO" },
  80.             ],
  81.           },
  82.         ],
  83.       },
  84.       options2: {
  85.         tooltip: {
  86.           trigger: "axis",
  87.         },
  88.         legend: {
  89.           data: ["PM2.5", "PM10", "SO2", "NO2", "O3"],
  90.         },
  91.         grid: {
  92.           left: "3%",
  93.           right: "4%",
  94.           bottom: "3%",
  95.           containLabel: true,
  96.         },
  97.         toolbox: {
  98.           feature: {
  99.             saveAsImage: {},
  100.           },
  101.         },
  102.         xAxis: {
  103.           type: "category",
  104.           boundaryGap: false,
  105.           data: ["1月", "3月", "5月", "7月", "9月", "11月"],
  106.         },
  107.         yAxis: {
  108.           type: "value",
  109.         },
  110.         series: [
  111.           {
  112.             name: "PM2.5",
  113.             type: "line",
  114.             data: [41, 60, 43, 46, 70, 50],
  115.             smooth: true,
  116.           },
  117.           {
  118.             name: "PM10",
  119.             type: "line",
  120.             data: [71, 78, 90, 70, 76, 80],
  121.             smooth: true,
  122.           },
  123.           {
  124.             name: "SO2",
  125.             type: "line",
  126.             data: [15, 23, 20, 15, 19, 10],
  127.             smooth: true,
  128.           },
  129.           {
  130.             name: "NO2",
  131.             type: "line",
  132.             data: [103, 90, 60, 70, 40, 35],
  133.             smooth: true,
  134.           },
  135.           {
  136.             name: "O3",
  137.             type: "line",
  138.             data: [60, 70, 85, 105, 120, 80],
  139.             smooth: true,
  140.           },
  141.         ],
  142.       },
  143.     };
  144.   },
  145. };
  146. </script>
  147. <style scoped>
  148. .content {
  149.   width: 30%;
  150. }
  151. .head {
  152.   padding: 10px;
  153.   height: 80px;
  154.   display: flex;
  155.   justify-content: space-around;
  156. }
  157. .head_content {
  158.   display: flex;
  159.   flex-direction: column;
  160.   justify-content: space-between;
  161.   align-items: center;
  162. }
  163. .body {
  164.   margin-top: 10px;
  165. }
  166. .body_table1 {
  167.   display: flex;
  168. }
  169. </style>
复制代码
 效果:

中间代码
模板(<template>)部分



  • 整体被一个具有 content 类的 div 包裹。

    • 第一个 div 内包含一个自界说的 dv-border-box-8 组件,其内部的 head 部分有三个 head_content 类的 div ,分别展示了温度、湿度和噪声的数据及单元。
    • 第二个 div 具有 body 类,包含两个主要部分。

      • 第一个部分是一个自界说的 dv-border-box-6 组件,用于展示温度监测的图表。
      • 第二个部分是 body_table1 类的 div ,此中又包含两个子 div 。

        • 第一个子 div 包含一个自界说的 dv-border-box-2 组件,展示噪音监测的相关内容。
        • 第二个子 div 包含一个自界说的 dv-border-box-2 组件,展示湿度的相关图表。




脚本(<script>)部分



  • 引入了 Echart 组件和 echarts 库。
  • 界说了默认导出对象。

    • components 中注册了 Echart 组件。
    • data 函数返回了多个数据对象:

      • options1 用于设置 24 小时温度监测的折线图。
      • airData (似乎未被现实使用)。
      • noiseData 用于噪音监测的数据。
      • options2 用于设置湿度监测的仪表盘图表。



样式(<style scoped>)部分



  • content 类的 div 宽度设置为 38% 。
  • head 类的 div 有内边距、高度,并使用 flex 布局实现元素之间的等间距分列。
  • head_content 类的 div 使用纵向的 flex 布局,并调整内部元素的垂直和水平对齐方式。
  • body 类的 div 有上边距。
  • body_table1 类的 div 使用 flex 布局。
  1. <template>
  2.   <div class="content">
  3.     <div>
  4.       <dv-border-box-8 :reverse="true">
  5.         <div class="head">
  6.           <div class="head_content">
  7.             <h1>25</h1>
  8.             <h2>温度(℃)</h2>
  9.           </div>
  10.           <div class="head_content">
  11.             <h1>40</h1>
  12.             <h2>湿度(%rh)</h2>
  13.           </div>
  14.           <div class="head_content">
  15.             <h1>65</h1>
  16.             <h2>噪声(dB)</h2>
  17.           </div>
  18.         </div>
  19.       </dv-border-box-8>
  20.     </div>
  21.     <div class="body">
  22.       <!-- 温度监测表 -->
  23.       <dv-border-box-6
  24.         ><Echart :options="options1" height="400px"
  25.       /></dv-border-box-6>
  26.       <!-- 城市噪音监测表与城市湿度 -->
  27.       <div class="body_table1">
  28.         <div>
  29.           <dv-border-box-2 style="padding: 10px">
  30.             <h2>噪音监测</h2>
  31.             <dv-capsule-chart
  32.               :config="noiseData"
  33.               style="width: 370px; height: 380px"
  34.             />
  35.           </dv-border-box-2>
  36.         </div>
  37.         <div>
  38.           <dv-border-box-2 style="padding: 10px">
  39.             <h2>湿度</h2>
  40.             <Echart :options="options2" height="380px" width="300px" />
  41.           </dv-border-box-2>
  42.         </div>
  43.       </div>
  44.     </div>
  45.   </div>
  46. </template>
  47. <script>
  48. import Echart from "@/common/echart/index.vue";
  49. import * as echarts from "echarts";
  50. export default {
  51.   components: { Echart },
  52.   data() {
  53.     return {
  54.       options1: {
  55.         color: ["#005fa2"],
  56.         title: {
  57.           text: "24小时温度监测",
  58.         },
  59.         tooltip: {
  60.           trigger: "axis",
  61.           axisPointer: {
  62.             type: "cross",
  63.             label: {
  64.               backgroundColor: "#6a7985",
  65.             },
  66.           },
  67.         },
  68.         legend: {
  69.           data: ["air spend"],
  70.         },
  71.         toolbox: {
  72.           feature: {
  73.             saveAsImage: {},
  74.           },
  75.         },
  76.         grid: {
  77.           left: "3%",
  78.           right: "4%",
  79.           bottom: "3%",
  80.           containLabel: true,
  81.         },
  82.         xAxis: [
  83.           {
  84.             name: "h",
  85.             type: "category",
  86.             boundaryGap: false,
  87.             data: [0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22],
  88.           },
  89.         ],
  90.         yAxis: [
  91.           {
  92.             name: "摄氏度",
  93.             type: "value",
  94.           },
  95.         ],
  96.         series: [
  97.           {
  98.             type: "line",
  99.             stack: "Total",
  100.             smooth: true,
  101.             lineStyle: {
  102.               width: 0,
  103.             },
  104.             showSymbol: false,
  105.             areaStyle: {
  106.               opacity: 0.8,
  107.               color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
  108.                 {
  109.                   offset: 0,
  110.                   color: "rgb(35, 67, 234)",
  111.                 },
  112.                 {
  113.                   offset: 1,
  114.                   color: "rgb(121, 185, 235)",
  115.                 },
  116.               ]),
  117.             },
  118.             emphasis: {
  119.               focus: "series",
  120.             },
  121.             data: [14, 14, 14, 14, 18, 20, 21, 20, 19, 18, 16, 15],
  122.           },
  123.         ],
  124.       },
  125.       airData: {
  126.         header: ["城市", "首要污染物", "等级", "AQI"],
  127.         data: [
  128.           ["平桥区区", "——", "优", 34],
  129.           ["浉河区区", "——", "优", 31],
  130.           ["罗山县", "O3", "轻度污染", 94],
  131.           ["息县", "PM2.5", "良", 52],
  132.           ["光山县", "——", "优", 34],
  133.           ["新县", "——", "优", 31],
  134.           ["潢川县", "O3", "轻度污染", 94],
  135.           ["商城县", "PM2.5", "良", 52],
  136.           ["淮滨县", "——", "优", 31],
  137.           ["固始县", "O3", "轻度污染", 94]
  138.         ],
  139.       },
  140.       noiseData: {
  141.         data: [
  142.           {
  143.             name: "平桥区",
  144.             value: 167,
  145.           },
  146.           {
  147.             name: "浉河区",
  148.             value: 67,
  149.           },
  150.           {
  151.             name: "罗山县",
  152.             value: 123,
  153.           },
  154.           {
  155.             name: "光山县",
  156.             value: 55,
  157.           },
  158.           {
  159.             name: "息县",
  160.             value: 98,
  161.           },
  162.           {
  163.             name: "新县",
  164.             value: 57,
  165.           },
  166.           {
  167.             name: "潢川县",
  168.             value: 98,
  169.           },
  170.           {
  171.             name: "商城县",
  172.             value: 57,
  173.           },
  174.           {
  175.             name: "固始县",
  176.             value: 98,
  177.           },
  178.           {
  179.             name: "淮滨县",
  180.             value: 57,
  181.           },
  182.         ],
  183.       },
  184.       options2: {
  185.         tooltip: {
  186.           formatter: "{a} <br/>{b} : {c}%",
  187.         },
  188.         series: [
  189.           {
  190.             name: "Pressure",
  191.             type: "gauge",
  192.             detail: {
  193.               formatter: "{value}",
  194.             },
  195.             data: [
  196.               {
  197.                 value: 50,
  198.                 name: "%rh",
  199.               },
  200.             ],
  201.           },
  202.         ],
  203.       },
  204.     };
  205.   },
  206. };
  207. </script>
  208. <style scoped>
  209. .content {
  210.   width: 38%;
  211. }
  212. .head {
  213.   padding: 10px;
  214.   height: 80px;
  215.   display: flex;
  216.   justify-content: space-around;
  217. }
  218. .head_content {
  219.   display: flex;
  220.   flex-direction: column;
  221.   justify-content: space-between;
  222.   align-items: center;
  223. }
  224. .body {
  225.   margin-top: 10px;
  226. }
  227. .body_table1 {
  228.   display: flex;
  229. }
  230. </style>
复制代码
效果:


免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!更多信息从访问主页:qidao123.com:ToB企服之家,中国第一个企服评测及商务社交产业平台。
回复

使用道具 举报

0 个回复

倒序浏览

快速回复

您需要登录后才可以回帖 登录 or 立即注册

本版积分规则

我可以不吃啊

金牌会员
这个人很懒什么都没写!
快速回复 返回顶部 返回列表