From fb212223fdc2f692896da5483ba2b1a8aec22d5f Mon Sep 17 00:00:00 2001
From: TreeWish <1131093754@qq.com>
Date: 星期一, 27 二月 2023 19:15:20 +0800
Subject: [PATCH] 修改基础数据

---
 src/components/chart/FileFormat.vue |  256 ++++++++++++++++++++++++++++++++-------------------
 1 files changed, 160 insertions(+), 96 deletions(-)

diff --git a/src/components/chart/FileFormat.vue b/src/components/chart/FileFormat.vue
index 505499b..9418542 100644
--- a/src/components/chart/FileFormat.vue
+++ b/src/components/chart/FileFormat.vue
@@ -1,11 +1,10 @@
 <template>
-  <div class="file-format" ref="chart"></div>
+  <div class="FileFormat" ref="chart"></div>
 </template>
 
 <script>
-const fileTypeBar = require("@/assets/img/Screen/fileTypeBar.png")
 import * as echarts from "echarts"
-import { GetTypeVisitsCount } from "@/api/screen.js"
+import { countFileFormat } from "@/api/screen.js"
 export default {
   data() {
     return {
@@ -59,112 +58,177 @@
           value: 20,
         },
       ]
-      const res = await GetTypeVisitsCount()
-      let xAxis = []
-      let yAxis = []
+      const res = await countFileFormat()
       if (res.code == 200) {
         data = res.result.map(item => {
-          xAxis.push(item.name)
-          yAxis.push(item.count)
+          return {
+            name: item.type,
+            value: item.number,
+          }
         })
       }
+      data.sort((a, b) => b.value - a.value)
+      data = data.slice(0, 4)
+      let getArrByKey = (data, k) => {
+        let key = k || "value"
+        let res = []
+        if (data) {
+          data.forEach(function (t) {
+            res.push(t[key])
+          })
+        }
+        return res
+      }
+      let getSymbolData = data => {
+        let arr = []
+        for (var i = 0; i < data.length; i++) {
+          arr.push({
+            value: data[i].value,
+            symbolPosition: "end",
+          })
+        }
+        return arr
+      }
+      let opt = {
+        index: 0,
+      }
+      let color = ["#A71A2B"]
+      data = data.sort((a, b) => {
+        return b.value - a.value
+      })
       let option = {
+        backgroundColor: "transparent",
         grid: {
-          // 璁╁浘琛ㄥ崰婊″鍣�
-          top: "12%",
-          left: "15%",
-          right: "10%",
-          bottom: "15%",
-        },
-        tooltip: {
-          show: true
+          top: "10%",
+          bottom: "10%",
+          right: "5%",
+          left: "10%",
+          containLabel: true,
         },
         xAxis: {
-          data: xAxis,
-          axisLabel: {
-            show: true,
-            color: "#ffff",
-          },
-          axisTick: {
-            show: false,
-          },
-          axisLine: {
-            show: true,
-            lineStyle: {
-              color: "rgba(95, 180, 237, 0.32)",
-            },
-          },
+          show: false,
         },
-        yAxis: {
-          axisLine: {
-            show: false,
-          },
-          axisTick: {
-            show: false,
-          },
-          axisLabel: {
-            color: "#ffff",
-          },
-          // 鍒嗗壊绾�
-          splitLine: {
-            lineStyle: {
-              color: "#5d7289",
-              width: 1,
-              type: "dashed",
-            },
-          },
-        },
-        series: [
+        yAxis: [
           {
-            // 椤堕儴鍦嗙墖
-            type: "pictorialBar",
-            animation: false,
-            itemStyle: {
-              color: "rgba(115, 240, 252, 1)",
+            triggerEvent: true,
+            show: true,
+            inverse: true,
+            data: getArrByKey(data, "name"),
+            axisLine: {
+              show: false,
             },
-            symbolRepeat: false,
-            symbolSize: [15, 8],
-            symbolMargin: 1,
-            z: 10,
-            data: data,
-            symbolPosition: "end",
-            symbolOffset: [0, -4],
-          },
-          {
-            // 搴曢儴鍦嗙墖
-            type: "pictorialBar",
-            animation: false,
-
-            itemStyle: {
-              color: "rgba(50, 96, 225, 0.8)",
+            splitLine: {
+              show: false,
             },
-            symbolRepeat: false,
-            symbolSize: [15, 8],
-            symbolMargin: 1,
-            z: 10,
-            data: data,
-            symbolPosition: "start",
-            symbolOffset: [0, 3],
-          },
-          {
-            barWidth: 15,
-            animation: false,
-
-            type: "bar",
-            label: {
-              show: true,
-              position: "top",
-              textStyle: {
-                color: "#ffff",
+            axisTick: {
+              show: false,
+            },
+            axisLabel: {
+              show: false,
+              interval: 0,
+              color: "#fff",
+              align: "left",
+              margin: 0,
+              fontSize: 13,
+              formatter: function (value, index) {
+                return "{title|" + value + "}"
+              },
+              rich: {
+                title: {
+                  width: 165,
+                },
               },
             },
-            itemStyle: {
-              color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
-                { offset: 1, color: "rgba(82, 180, 249, 0.35)" },
-                { offset: 0, color: "rgba(82, 180, 249, 1)" },
-              ]),
+          },
+          {
+            triggerEvent: true,
+            show: true,
+            inverse: true,
+            data: getArrByKey(data, "name"),
+            axisLine: {
+              show: false,
             },
-            data: yAxis,
+            splitLine: {
+              show: false,
+            },
+            axisTick: {
+              show: false,
+            },
+            axisLabel: {
+              interval: 0,
+              shadowOffsetX: "-20px",
+              color: "#fff",
+              align: "right",
+              verticalAlign: "bottom",
+              lineHeight: 20,
+              fontSize: 13,
+              formatter: function (value, index) {
+                return data[index].value
+              },
+            },
+          },
+        ],
+        series: [
+          {
+            name: "XXX",
+            type: "pictorialBar",
+            symbol:
+              "image://data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADoAAAA6CAMAAADWZboaAAAAZlBMVEUAAABe3uVe3+Vf3uVf3+Zf3uVg3+Zg3+Zf3+Vi4OZh4OZg3+Z86/Bh3+Zi4Odj4Odi4OZ86/B76/B86/Bj4ed56+9x5+xn4umB7/N87PB36e+A7/N+7fF/7vJ/7vJ+7fGA7/OB7/PReX+lAAAAIXRSTlMABQkVDREmIhk3MR10LEFFPHh7cUprXE35h2XnqMLAp+mHAG9cAAAB5ElEQVRIx83WjU7CMBQFYIoiKMqU/XUboHv/l/Tce7t2XamDNSacETEmX86tlK2rx4py150o+MstMBLwWRfHKo6JCVxLnvmFGBjFQ58oF1//sUZhGy/ClSTWObgnL4O+bkeN4nY2okfNMbkRt9/vtxz8InoTsWplJSCzFxPmO8+GpSIByX3YQAuGDWtRKhKjCnxDXhF6Z4yxnZ20Wgko7BMRDmxtSGVaI4kdTIgb+zTYoJQlIMlDlmUFgrcDWWC201qSayqlTkiCddWWeV62VU0YlnpRi9VOKaSUsiyq/N0krwq2Ugt7lVpZl5BfHNiytjagMi+XYp0kCR45hMlivVQrE/uU5pXSrCB5bM6d1t2lOZItMqmliT3q5uVxqxzyW/ccfYLNKx7ZTeykMvNyac2yt2Fbc61MHLSC0rwoxbiNdlQ3GBm1NLHQsHUrtEXppR/ljNpW6DbSCoqlFiVoN6YdaFlgsSFVPs1BdT8OaB5QyQzVcaqWDows/zepxR8ObLglTrdtCRVuRNj4Rrxh+//0ke2f8KVL+Kon3GCSbmsJN9OUW3j6g0Ns+LgCij2u0h+Sghc8mlMPBMgdx5DFh59VmOVHrvmDnoNxCz3J7MFWsMuaLyR089xz/xhlfijvwutR8gv3zk6BLUUeCgAAAABJRU5ErkJggg==",
+            symbolSize: [35, 35],
+            symbolOffset: [20, 0],
+            z: 5,
+            data: getSymbolData(data),
+          },
+          {
+            name: "鏉�",
+            type: "bar",
+            showBackground: true,
+            barBorderRadius: 10,
+            yAxisIndex: 0,
+            data: data,
+            barWidth: 8,
+            // align: left,
+            itemStyle: {
+              normal: {
+                color: new echarts.graphic.LinearGradient(
+                  0,
+                  0,
+                  1,
+                  0,
+                  [
+                    {
+                      offset: 0,
+                      color: "#5A9DFF",
+                    },
+                    {
+                      offset: 0.7,
+                      color: "#1878FF",
+                    },
+                    {
+                      offset: 1,
+                      color: "#164182",
+                    },
+                  ],
+                  false
+                ),
+                barBorderRadius: 5,
+              },
+              // color: '#A71A2B',
+              barBorderRadius: 2,
+            },
+            label: {
+              normal: {
+                color: "#fff",
+                show: true,
+                position: ["0px", "-25px"],
+                textStyle: {
+                  fontSize: 14,
+                },
+                formatter: function (a, b) {
+                  return a.name
+                },
+              },
+            },
           },
         ],
       }
@@ -181,8 +245,8 @@
 </script>
 
 <style lang="less" scoped>
-.file-format {
+.FileFormat {
   width: 100%;
-  height: calc(100% - 30px);
+  height: calc(100% - 40px);
 }
 </style>

--
Gitblit v1.9.3