feat: echarts 图标开发

dev-deviceSetting
JINGYJ 1 year ago
parent 0acca1af27
commit b9c70c9fa1

@ -38,6 +38,7 @@
"axios": "^1.4.0",
"dayjs": "^1.11.8",
"echarts": "^5.4.2",
"echarts-gl": "^2.0.9",
"element-plus": "2.3.6",
"js-cookie": "^3.0.5",
"mitt": "^3.0.0",

@ -32,6 +32,9 @@ dependencies:
echarts:
specifier: ^5.4.2
version: 5.4.2
echarts-gl:
specifier: ^2.0.9
version: 2.0.9(echarts@5.4.2)
element-plus:
specifier: 2.3.6
version: 2.3.6(vue@3.3.4)
@ -958,8 +961,7 @@ packages:
/@esbuild/android-arm64@0.17.19:
resolution:
{
integrity: sha512-KBMWvEZooR7+kzY0BtbTQn0OAYY7CsiydT63pVEaPtVYF0hXbUaOyZog37DKxK7NF3XacBJOpYT4adIJh+avxA==,
tarball: https://registry.npmmirror.com/@esbuild/android-arm64/-/android-arm64-0.17.19.tgz
integrity: sha512-KBMWvEZooR7+kzY0BtbTQn0OAYY7CsiydT63pVEaPtVYF0hXbUaOyZog37DKxK7NF3XacBJOpYT4adIJh+avxA==
}
engines: { node: ">=12" }
cpu: [arm64]
@ -971,8 +973,7 @@ packages:
/@esbuild/android-arm@0.17.19:
resolution:
{
integrity: sha512-rIKddzqhmav7MSmoFCmDIb6e2W57geRsM94gV2l38fzhXMwq7hZoClug9USI2pFRGL06f4IOPHHpFNOkWieR8A==,
tarball: https://registry.npmmirror.com/@esbuild/android-arm/-/android-arm-0.17.19.tgz
integrity: sha512-rIKddzqhmav7MSmoFCmDIb6e2W57geRsM94gV2l38fzhXMwq7hZoClug9USI2pFRGL06f4IOPHHpFNOkWieR8A==
}
engines: { node: ">=12" }
cpu: [arm]
@ -984,8 +985,7 @@ packages:
/@esbuild/android-x64@0.17.19:
resolution:
{
integrity: sha512-uUTTc4xGNDT7YSArp/zbtmbhO0uEEK9/ETW29Wk1thYUJBz3IVnvgEiEwEa9IeLyvnpKrWK64Utw2bgUmDveww==,
tarball: https://registry.npmmirror.com/@esbuild/android-x64/-/android-x64-0.17.19.tgz
integrity: sha512-uUTTc4xGNDT7YSArp/zbtmbhO0uEEK9/ETW29Wk1thYUJBz3IVnvgEiEwEa9IeLyvnpKrWK64Utw2bgUmDveww==
}
engines: { node: ">=12" }
cpu: [x64]
@ -997,8 +997,7 @@ packages:
/@esbuild/darwin-arm64@0.17.19:
resolution:
{
integrity: sha512-80wEoCfF/hFKM6WE1FyBHc9SfUblloAWx6FJkFWTWiCoht9Mc0ARGEM47e67W9rI09YoUxJL68WHfDRYEAvOhg==,
tarball: https://registry.npmmirror.com/@esbuild/darwin-arm64/-/darwin-arm64-0.17.19.tgz
integrity: sha512-80wEoCfF/hFKM6WE1FyBHc9SfUblloAWx6FJkFWTWiCoht9Mc0ARGEM47e67W9rI09YoUxJL68WHfDRYEAvOhg==
}
engines: { node: ">=12" }
cpu: [arm64]
@ -1010,8 +1009,7 @@ packages:
/@esbuild/darwin-x64@0.17.19:
resolution:
{
integrity: sha512-IJM4JJsLhRYr9xdtLytPLSH9k/oxR3boaUIYiHkAawtwNOXKE8KoU8tMvryogdcT8AU+Bflmh81Xn6Q0vTZbQw==,
tarball: https://registry.npmmirror.com/@esbuild/darwin-x64/-/darwin-x64-0.17.19.tgz
integrity: sha512-IJM4JJsLhRYr9xdtLytPLSH9k/oxR3boaUIYiHkAawtwNOXKE8KoU8tMvryogdcT8AU+Bflmh81Xn6Q0vTZbQw==
}
engines: { node: ">=12" }
cpu: [x64]
@ -1023,8 +1021,7 @@ packages:
/@esbuild/freebsd-arm64@0.17.19:
resolution:
{
integrity: sha512-pBwbc7DufluUeGdjSU5Si+P3SoMF5DQ/F/UmTSb8HXO80ZEAJmrykPyzo1IfNbAoaqw48YRpv8shwd1NoI0jcQ==,
tarball: https://registry.npmmirror.com/@esbuild/freebsd-arm64/-/freebsd-arm64-0.17.19.tgz
integrity: sha512-pBwbc7DufluUeGdjSU5Si+P3SoMF5DQ/F/UmTSb8HXO80ZEAJmrykPyzo1IfNbAoaqw48YRpv8shwd1NoI0jcQ==
}
engines: { node: ">=12" }
cpu: [arm64]
@ -1036,8 +1033,7 @@ packages:
/@esbuild/freebsd-x64@0.17.19:
resolution:
{
integrity: sha512-4lu+n8Wk0XlajEhbEffdy2xy53dpR06SlzvhGByyg36qJw6Kpfk7cp45DR/62aPH9mtJRmIyrXAS5UWBrJT6TQ==,
tarball: https://registry.npmmirror.com/@esbuild/freebsd-x64/-/freebsd-x64-0.17.19.tgz
integrity: sha512-4lu+n8Wk0XlajEhbEffdy2xy53dpR06SlzvhGByyg36qJw6Kpfk7cp45DR/62aPH9mtJRmIyrXAS5UWBrJT6TQ==
}
engines: { node: ">=12" }
cpu: [x64]
@ -1049,8 +1045,7 @@ packages:
/@esbuild/linux-arm64@0.17.19:
resolution:
{
integrity: sha512-ct1Tg3WGwd3P+oZYqic+YZF4snNl2bsnMKRkb3ozHmnM0dGWuxcPTTntAF6bOP0Sp4x0PjSF+4uHQ1xvxfRKqg==,
tarball: https://registry.npmmirror.com/@esbuild/linux-arm64/-/linux-arm64-0.17.19.tgz
integrity: sha512-ct1Tg3WGwd3P+oZYqic+YZF4snNl2bsnMKRkb3ozHmnM0dGWuxcPTTntAF6bOP0Sp4x0PjSF+4uHQ1xvxfRKqg==
}
engines: { node: ">=12" }
cpu: [arm64]
@ -1062,8 +1057,7 @@ packages:
/@esbuild/linux-arm@0.17.19:
resolution:
{
integrity: sha512-cdmT3KxjlOQ/gZ2cjfrQOtmhG4HJs6hhvm3mWSRDPtZ/lP5oe8FWceS10JaSJC13GBd4eH/haHnqf7hhGNLerA==,
tarball: https://registry.npmmirror.com/@esbuild/linux-arm/-/linux-arm-0.17.19.tgz
integrity: sha512-cdmT3KxjlOQ/gZ2cjfrQOtmhG4HJs6hhvm3mWSRDPtZ/lP5oe8FWceS10JaSJC13GBd4eH/haHnqf7hhGNLerA==
}
engines: { node: ">=12" }
cpu: [arm]
@ -1075,8 +1069,7 @@ packages:
/@esbuild/linux-ia32@0.17.19:
resolution:
{
integrity: sha512-w4IRhSy1VbsNxHRQpeGCHEmibqdTUx61Vc38APcsRbuVgK0OPEnQ0YD39Brymn96mOx48Y2laBQGqgZ0j9w6SQ==,
tarball: https://registry.npmmirror.com/@esbuild/linux-ia32/-/linux-ia32-0.17.19.tgz
integrity: sha512-w4IRhSy1VbsNxHRQpeGCHEmibqdTUx61Vc38APcsRbuVgK0OPEnQ0YD39Brymn96mOx48Y2laBQGqgZ0j9w6SQ==
}
engines: { node: ">=12" }
cpu: [ia32]
@ -1088,8 +1081,7 @@ packages:
/@esbuild/linux-loong64@0.17.19:
resolution:
{
integrity: sha512-2iAngUbBPMq439a+z//gE+9WBldoMp1s5GWsUSgqHLzLJ9WoZLZhpwWuym0u0u/4XmZ3gpHmzV84PonE+9IIdQ==,
tarball: https://registry.npmmirror.com/@esbuild/linux-loong64/-/linux-loong64-0.17.19.tgz
integrity: sha512-2iAngUbBPMq439a+z//gE+9WBldoMp1s5GWsUSgqHLzLJ9WoZLZhpwWuym0u0u/4XmZ3gpHmzV84PonE+9IIdQ==
}
engines: { node: ">=12" }
cpu: [loong64]
@ -1101,8 +1093,7 @@ packages:
/@esbuild/linux-mips64el@0.17.19:
resolution:
{
integrity: sha512-LKJltc4LVdMKHsrFe4MGNPp0hqDFA1Wpt3jE1gEyM3nKUvOiO//9PheZZHfYRfYl6AwdTH4aTcXSqBerX0ml4A==,
tarball: https://registry.npmmirror.com/@esbuild/linux-mips64el/-/linux-mips64el-0.17.19.tgz
integrity: sha512-LKJltc4LVdMKHsrFe4MGNPp0hqDFA1Wpt3jE1gEyM3nKUvOiO//9PheZZHfYRfYl6AwdTH4aTcXSqBerX0ml4A==
}
engines: { node: ">=12" }
cpu: [mips64el]
@ -1114,8 +1105,7 @@ packages:
/@esbuild/linux-ppc64@0.17.19:
resolution:
{
integrity: sha512-/c/DGybs95WXNS8y3Ti/ytqETiW7EU44MEKuCAcpPto3YjQbyK3IQVKfF6nbghD7EcLUGl0NbiL5Rt5DMhn5tg==,
tarball: https://registry.npmmirror.com/@esbuild/linux-ppc64/-/linux-ppc64-0.17.19.tgz
integrity: sha512-/c/DGybs95WXNS8y3Ti/ytqETiW7EU44MEKuCAcpPto3YjQbyK3IQVKfF6nbghD7EcLUGl0NbiL5Rt5DMhn5tg==
}
engines: { node: ">=12" }
cpu: [ppc64]
@ -1127,8 +1117,7 @@ packages:
/@esbuild/linux-riscv64@0.17.19:
resolution:
{
integrity: sha512-FC3nUAWhvFoutlhAkgHf8f5HwFWUL6bYdvLc/TTuxKlvLi3+pPzdZiFKSWz/PF30TB1K19SuCxDTI5KcqASJqA==,
tarball: https://registry.npmmirror.com/@esbuild/linux-riscv64/-/linux-riscv64-0.17.19.tgz
integrity: sha512-FC3nUAWhvFoutlhAkgHf8f5HwFWUL6bYdvLc/TTuxKlvLi3+pPzdZiFKSWz/PF30TB1K19SuCxDTI5KcqASJqA==
}
engines: { node: ">=12" }
cpu: [riscv64]
@ -1140,8 +1129,7 @@ packages:
/@esbuild/linux-s390x@0.17.19:
resolution:
{
integrity: sha512-IbFsFbxMWLuKEbH+7sTkKzL6NJmG2vRyy6K7JJo55w+8xDk7RElYn6xvXtDW8HCfoKBFK69f3pgBJSUSQPr+4Q==,
tarball: https://registry.npmmirror.com/@esbuild/linux-s390x/-/linux-s390x-0.17.19.tgz
integrity: sha512-IbFsFbxMWLuKEbH+7sTkKzL6NJmG2vRyy6K7JJo55w+8xDk7RElYn6xvXtDW8HCfoKBFK69f3pgBJSUSQPr+4Q==
}
engines: { node: ">=12" }
cpu: [s390x]
@ -1153,8 +1141,7 @@ packages:
/@esbuild/linux-x64@0.17.19:
resolution:
{
integrity: sha512-68ngA9lg2H6zkZcyp22tsVt38mlhWde8l3eJLWkyLrp4HwMUr3c1s/M2t7+kHIhvMjglIBrFpncX1SzMckomGw==,
tarball: https://registry.npmmirror.com/@esbuild/linux-x64/-/linux-x64-0.17.19.tgz
integrity: sha512-68ngA9lg2H6zkZcyp22tsVt38mlhWde8l3eJLWkyLrp4HwMUr3c1s/M2t7+kHIhvMjglIBrFpncX1SzMckomGw==
}
engines: { node: ">=12" }
cpu: [x64]
@ -1166,8 +1153,7 @@ packages:
/@esbuild/netbsd-x64@0.17.19:
resolution:
{
integrity: sha512-CwFq42rXCR8TYIjIfpXCbRX0rp1jo6cPIUPSaWwzbVI4aOfX96OXY8M6KNmtPcg7QjYeDmN+DD0Wp3LaBOLf4Q==,
tarball: https://registry.npmmirror.com/@esbuild/netbsd-x64/-/netbsd-x64-0.17.19.tgz
integrity: sha512-CwFq42rXCR8TYIjIfpXCbRX0rp1jo6cPIUPSaWwzbVI4aOfX96OXY8M6KNmtPcg7QjYeDmN+DD0Wp3LaBOLf4Q==
}
engines: { node: ">=12" }
cpu: [x64]
@ -1179,8 +1165,7 @@ packages:
/@esbuild/openbsd-x64@0.17.19:
resolution:
{
integrity: sha512-cnq5brJYrSZ2CF6c35eCmviIN3k3RczmHz8eYaVlNasVqsNY+JKohZU5MKmaOI+KkllCdzOKKdPs762VCPC20g==,
tarball: https://registry.npmmirror.com/@esbuild/openbsd-x64/-/openbsd-x64-0.17.19.tgz
integrity: sha512-cnq5brJYrSZ2CF6c35eCmviIN3k3RczmHz8eYaVlNasVqsNY+JKohZU5MKmaOI+KkllCdzOKKdPs762VCPC20g==
}
engines: { node: ">=12" }
cpu: [x64]
@ -1192,8 +1177,7 @@ packages:
/@esbuild/sunos-x64@0.17.19:
resolution:
{
integrity: sha512-vCRT7yP3zX+bKWFeP/zdS6SqdWB8OIpaRq/mbXQxTGHnIxspRtigpkUcDMlSCOejlHowLqII7K2JKevwyRP2rg==,
tarball: https://registry.npmmirror.com/@esbuild/sunos-x64/-/sunos-x64-0.17.19.tgz
integrity: sha512-vCRT7yP3zX+bKWFeP/zdS6SqdWB8OIpaRq/mbXQxTGHnIxspRtigpkUcDMlSCOejlHowLqII7K2JKevwyRP2rg==
}
engines: { node: ">=12" }
cpu: [x64]
@ -1205,8 +1189,7 @@ packages:
/@esbuild/win32-arm64@0.17.19:
resolution:
{
integrity: sha512-yYx+8jwowUstVdorcMdNlzklLYhPxjniHWFKgRqH7IFlUEa0Umu3KuYplf1HUZZ422e3NU9F4LGb+4O0Kdcaag==,
tarball: https://registry.npmmirror.com/@esbuild/win32-arm64/-/win32-arm64-0.17.19.tgz
integrity: sha512-yYx+8jwowUstVdorcMdNlzklLYhPxjniHWFKgRqH7IFlUEa0Umu3KuYplf1HUZZ422e3NU9F4LGb+4O0Kdcaag==
}
engines: { node: ">=12" }
cpu: [arm64]
@ -1218,8 +1201,7 @@ packages:
/@esbuild/win32-ia32@0.17.19:
resolution:
{
integrity: sha512-eggDKanJszUtCdlVs0RB+h35wNlb5v4TWEkq4vZcmVt5u/HiDZrTXe2bWFQUez3RgNHwx/x4sk5++4NSSicKkw==,
tarball: https://registry.npmmirror.com/@esbuild/win32-ia32/-/win32-ia32-0.17.19.tgz
integrity: sha512-eggDKanJszUtCdlVs0RB+h35wNlb5v4TWEkq4vZcmVt5u/HiDZrTXe2bWFQUez3RgNHwx/x4sk5++4NSSicKkw==
}
engines: { node: ">=12" }
cpu: [ia32]
@ -1231,8 +1213,7 @@ packages:
/@esbuild/win32-x64@0.17.19:
resolution:
{
integrity: sha512-lAhycmKnVOuRYNtRtatQR1LPQf2oYCkRGkSFnseDAKPl8lu5SOsK/e1sXe5a0Pc5kHIHe6P2I/ilntNv2xf3cA==,
tarball: https://registry.npmmirror.com/@esbuild/win32-x64/-/win32-x64-0.17.19.tgz
integrity: sha512-lAhycmKnVOuRYNtRtatQR1LPQf2oYCkRGkSFnseDAKPl8lu5SOsK/e1sXe5a0Pc5kHIHe6P2I/ilntNv2xf3cA==
}
engines: { node: ">=12" }
cpu: [x64]
@ -1622,8 +1603,7 @@ packages:
/@nuxt/kit@3.6.0:
resolution:
{
integrity: sha512-rqQYyWlhE42oWRQNR58KU1JYhoWryN78x8eYzFTHgalfpMjtPqZv2j9K4+hFRk0XLRUKnut4tE/3+UYyZ7ybVw==,
tarball: https://registry.npmmirror.com/@nuxt/kit/-/kit-3.6.0.tgz
integrity: sha512-rqQYyWlhE42oWRQNR58KU1JYhoWryN78x8eYzFTHgalfpMjtPqZv2j9K4+hFRk0XLRUKnut4tE/3+UYyZ7ybVw==
}
engines: { node: ^14.18.0 || >=16.10.0 }
requiresBuild: true
@ -1677,8 +1657,7 @@ packages:
/@pkgjs/parseargs@0.11.0:
resolution:
{
integrity: sha512-+1VkjdD0QBLPodGrJUeqarH8VAIvQODIbwh9XpP5Syisf7YoQgsJKPNFoqqLQlu+VQ/tVSshMR6loPMn8U+dPg==,
tarball: https://registry.npmmirror.com/@pkgjs/parseargs/-/parseargs-0.11.0.tgz
integrity: sha512-+1VkjdD0QBLPodGrJUeqarH8VAIvQODIbwh9XpP5Syisf7YoQgsJKPNFoqqLQlu+VQ/tVSshMR6loPMn8U+dPg==
}
engines: { node: ">=14" }
requiresBuild: true
@ -1806,8 +1785,7 @@ packages:
/@sxzz/popperjs-es@2.11.7:
resolution:
{
integrity: sha512-Ccy0NlLkzr0Ex2FKvh2X+OyERHXJ88XJ1MXtsI9y9fGexlaXaVTPzBCRBwIxFkORuOb+uBqeu+RqnpgYTEZRUQ==,
tarball: https://registry.npmmirror.com/@sxzz/popperjs-es/-/popperjs-es-2.11.7.tgz
integrity: sha512-Ccy0NlLkzr0Ex2FKvh2X+OyERHXJ88XJ1MXtsI9y9fGexlaXaVTPzBCRBwIxFkORuOb+uBqeu+RqnpgYTEZRUQ==
}
dev: false
@ -3063,6 +3041,13 @@ packages:
dev: false
optional: true
/claygl@1.3.0:
resolution:
{
integrity: sha512-+gGtJjT6SSHD2l2yC3MCubW/sCV40tZuSs5opdtn79vFSGUgp/lH139RNEQ6Jy078/L0aV8odCw8RSrUcMfLaQ==
}
dev: false
/clean-stack@2.2.0:
resolution:
{
@ -3911,6 +3896,19 @@ packages:
}
dev: true
/echarts-gl@2.0.9(echarts@5.4.2):
resolution:
{
integrity: sha512-oKeMdkkkpJGWOzjgZUsF41DOh6cMsyrGGXimbjK2l6Xeq/dBQu4ShG2w2Dzrs/1bD27b2pLTGSaUzouY191gzA==
}
peerDependencies:
echarts: ^5.1.2
dependencies:
claygl: 1.3.0
echarts: 5.4.2
zrender: 5.4.3
dev: false
/echarts@5.4.2:
resolution:
{
@ -4688,8 +4686,7 @@ packages:
/fsevents@2.3.2:
resolution:
{
integrity: sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==,
tarball: https://registry.npmmirror.com/fsevents/-/fsevents-2.3.2.tgz
integrity: sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==
}
engines: { node: ^8.16.0 || ^10.6.0 || >=11.0.0 }
os: [darwin]

@ -0,0 +1,36 @@
<template>
<div ref="elChart" style="width: 100%; height: 100%" />
</template>
<script lang="ts" setup>
import { ref, onMounted, onUpdated, onUnmounted } from "vue";
import * as echarts from "echarts";
const props = defineProps({
option: {
type: Object
},
data: {
type: Object
}
});
const elChart = ref();
let chart: any = null;
function clear() {
chart && chart.dispose();
}
function draw() {
if (chart) {
chart.setOption(props.option);
} else {
clear();
chart = echarts.init(elChart.value);
chart.setOption(props.option);
}
}
onMounted(draw);
onUpdated(draw);
onUnmounted(clear);
</script>

@ -18,8 +18,8 @@ const { isDark } = useDark();
const theme = computed(() => (isDark.value ? "dark" : "light"));
const chartRef = ref();
const { setOptions } = useECharts(chartRef, {
const barChartRef = ref();
const { setOptions } = useECharts(barChartRef, {
theme
});
@ -120,7 +120,7 @@ watch(
},
formatter: function (params) {
const item = params[1];
return `${item.name}:${item.value}`;
return `${item.name}:${item.value}`;
}
},
grid: {
@ -169,7 +169,7 @@ watch(
show: false,
lineStyle: {
// width: 1,
fontSize: 12,
// fontSize: 12,
color: "#666666"
}
},
@ -306,5 +306,5 @@ watch(
</script>
<template>
<div ref="chartRef" style="width: 100%" />
<div ref="barChartRef" style="width: 100%" />
</template>

@ -1 +1,3 @@
export { default as barChart } from "./bar.vue";
export { default as pieChart } from "./pie.vue";
export { default as pie3DChart } from "./pie3D.vue";

@ -0,0 +1,142 @@
<script setup lang="ts">
import { ref, computed, watch, type Ref } from "vue";
import { useAppStoreHook } from "@/store/modules/app";
import {
delay,
useDark,
useECharts,
type EchartOptions
} from "@pureadmin/utils";
const { isDark } = useDark();
const theme: EchartOptions["theme"] = computed(() => {
return isDark.value ? "dark" : "light";
});
const pieChartRef = ref<HTMLDivElement | null>(null);
const { setOptions, resize } = useECharts(pieChartRef as Ref<HTMLDivElement>, {
theme
});
setOptions(
{
// title: {
// text: "",
// left: "left",
// textStyle: {
// fontSize: 14,
// color: "#333"
// }
// },
tooltip: {
trigger: "item",
formatter: function (params) {
//
return `${params.value}%`;
}
},
// legend: {
// // icon: "rect",
// // // orient: "vertical",
// // align: "auto",
// // bottom: "0",
// // // top: "40%",
// // // right: "15%",
// // // itemGap: 18,
// // textStyle: {
// // fontSize: 12,
// // color: "#333"
// // }
// // right: true
// },
series: [
{
type: "pie",
radius: ["30%", "50%"], //
color: ["#1D39EF", "#F58702"],
// depth: 30,
labelLine: {
// type: "dashed",
length: 20, // 线
length2: 30 // 线
},
label: {
// formatter: "{b} {c}", //
lineHeight: 20, //
// backgroundColor: ["#1D39EF", "#F58702"],
align: "center",
verticalAlign: "middle",
formatter: function (params) {
// formatter
const { name, percent } = params;
if (name === "未占用") {
// Apple
return `{red|${name}: ${percent}%}`;
} else {
//
return `{blue|${name}: ${percent}%}`;
}
},
rich: {
red: {
backgroundColor: "#1D39EF",
// width: 79,
height: 24,
padding: [5, 8], //
borderRadius: 4, //
color: "#fff"
},
blue: {
backgroundColor: "#F58702",
// width: 79,
height: 24,
padding: [5, 8], //
borderRadius: 4, //
color: "#fff"
}
}
},
data: [
{ value: 22, name: "未占用" },
{ value: 78, name: "已占用" }
],
emphasis: {
itemStyle: {
shadowBlur: 10,
shadowOffsetX: 0,
shadowColor: "rgba(0, 0, 0, 0.5)"
}
}
}
]
},
{
name: "click",
callback: params => {
console.log("click", params);
}
},
//
{
type: "zrender",
name: "click",
callback: params => {
console.log("点击空白处", params);
}
}
);
watch(
() => useAppStoreHook().getSidebarStatus,
() => {
delay(600).then(() => resize());
}
);
</script>
<template>
<div ref="pieChartRef" style="width: 100%" />
</template>

@ -0,0 +1,327 @@
<template>
<div
style="display: flex; justify-content: center; width: 100%; height: 278px"
>
<div style="position: relative; width: 100%; height: 100%">
<!-- <img class="pie_img" :src="pieBg" alt="" /> -->
<vue-chart
:option="chartOption"
style="position: absolute; width: 100%; height: 100%"
/>
</div>
</div>
</template>
<script lang="ts" setup>
import VueChart from "./VueChart.vue";
// import * as echarts from "echarts";
import "echarts-gl";
import { computed } from "vue";
// import pieBg from "@/assets/screen/pie_bg.png";
const props = defineProps({
data: {
type: Array,
default: () => []
}
});
// const selectedIndex = "";
// const hoveredIndex = "";
// const option_data = getPie3D(props.data, 0);
//
function getParametricEquation(
startRatio,
endRatio,
isSelected,
isHovered,
k,
h
) {
//
const midRatio = (startRatio + endRatio) / 2;
const startRadian = startRatio * Math.PI * 2;
const endRadian = endRatio * Math.PI * 2;
const midRadian = midRatio * Math.PI * 2;
//
if (startRatio === 0 && endRatio === 1) {
// eslint-disable-next-line no-param-reassign
isSelected = false;
}
// / k 1/3
// eslint-disable-next-line no-param-reassign
k = typeof k !== "undefined" ? k : 1 / 3;
// x y 0
const offsetX = isSelected ? Math.cos(midRadian) * 0.1 : 0;
const offsetY = isSelected ? Math.sin(midRadian) * 0.1 : 0;
// 1
const hoverRate = isHovered ? 1.05 : 1;
//
return {
u: {
min: -Math.PI,
max: Math.PI * 3,
step: Math.PI / 32
},
v: {
min: 0,
max: Math.PI * 2,
step: Math.PI / 20
},
x(u, v) {
if (u < startRadian) {
return (
offsetX + Math.cos(startRadian) * (1 + Math.cos(v) * k) * hoverRate
);
}
if (u > endRadian) {
return (
offsetX + Math.cos(endRadian) * (1 + Math.cos(v) * k) * hoverRate
);
}
return offsetX + Math.cos(u) * (1 + Math.cos(v) * k) * hoverRate;
},
y(u, v) {
if (u < startRadian) {
return (
offsetY + Math.sin(startRadian) * (1 + Math.cos(v) * k) * hoverRate
);
}
if (u > endRadian) {
return (
offsetY + Math.sin(endRadian) * (1 + Math.cos(v) * k) * hoverRate
);
}
return offsetY + Math.sin(u) * (1 + Math.cos(v) * k) * hoverRate;
},
z(u, v) {
if (u < -Math.PI * 0.5) {
return Math.sin(u);
}
if (u > Math.PI * 2.5) {
return Math.sin(u) * h * 0.1;
}
// Zhvalue
return Math.sin(v) > 0 ? 1 * h * 0.1 : -1;
}
};
}
// 3D
function getPie3D(pieData, internalDiameterRatio) {
const series = [];
//
let sumValue = 0;
let startValue = 0;
let endValue = 0;
const legendData = [];
const k =
typeof internalDiameterRatio !== "undefined"
? (1 - internalDiameterRatio) / (1 + internalDiameterRatio)
: 1 / 3;
// series-surface
for (let i = 0; i < pieData.length; i += 1) {
sumValue += pieData[i].value;
const seriesItem = {
name:
typeof pieData[i].name === "undefined" ? `series${i}` : pieData[i].name,
type: "surface",
parametric: true,
wireframe: {
show: false
},
pieData: pieData[i],
pieStatus: {
selected: false,
hovered: false,
k
},
itemStyle: {}
};
if (typeof pieData[i].itemStyle !== "undefined") {
const { itemStyle } = pieData[i];
// eslint-disable-next-line no-unused-expressions
typeof pieData[i].itemStyle.color !== "undefined"
? (itemStyle.color = pieData[i].itemStyle.color)
: null;
// eslint-disable-next-line no-unused-expressions
typeof pieData[i].itemStyle.opacity !== "undefined"
? (itemStyle.opacity = pieData[i].itemStyle.opacity)
: null;
seriesItem.itemStyle = itemStyle;
}
series.push(seriesItem);
}
// 使 sumValue getParametricEquation
// series-surface series-surface.parametricEquation
for (let i = 0; i < series.length; i += 1) {
endValue = startValue + series[i].pieData.value;
series[i].pieData.startRatio = startValue / sumValue;
series[i].pieData.endRatio = endValue / sumValue;
series[i].parametricEquation = getParametricEquation(
series[i].pieData.startRatio,
series[i].pieData.endRatio,
false,
false,
k,
// 使10
series[i].pieData.value
);
startValue = endValue;
legendData.push(series[i].name);
}
series.push({
name: "pie2d",
type: "pie",
label: {
show: false,
opacity: 10,
lineHeight: 10,
fontSize: 16,
color: "#fff",
fontWeight: 500,
formatter: function (params) {
return params.name + " " + "{hr|" + params.value + "}" + "%";
},
rich: {
hr: {
align: "center",
color: "inherit",
fontSize: 18,
fontFamily: "D-DIN",
fontWeight: 600
}
}
},
labelLine: {
show: false,
length: 10,
length2: 90,
lineStyle: {
color: "#fff" // 线
}
},
startAngle: 0, //[0, 360]
clockwise: false, //3d
radius: ["20%", "50%"],
center: ["50%", "50%"],
data: props.data,
itemStyle: {
opacity: 0
}
});
// legendDataseries
const option = {
color: ["#E80D0D", "#FF8800", "#3250FF"],
title: {
show: false,
text: "设备告警情况",
textStyle: {
color: "#fff",
fontSize: 24,
fontWeight: 400,
letterSpacing: 3.6
},
left: "center", // center horizontally
bottom: 0
},
legend: {
bottom: 0,
data: legendData
},
// animation: false,
tooltip: {
formatter: params => {
if (params.seriesName !== "mouseoutSeries") {
return `${
params.seriesName
}<br/><span style="display:inline-block;margin-right:5px;border-radius:10px;width:10px;height:10px;background-color:${
params.color
};"></span>${
option.series[params.seriesIndex].pieData?.value || ""
}%`;
}
return "{value} %";
}
},
xAxis3D: {
min: -1,
max: 1
},
yAxis3D: {
min: -1,
max: 1
},
zAxis3D: {
min: -1,
max: 1
},
grid3D: {
show: false,
boxHeight: 12,
top: "-10%",
viewControl: {
// 3d
alpha: 24,
// beta: 30,
rotateSensitivity: 1,
zoomSensitivity: 0,
panSensitivity: 0,
// autoRotate: true,
distance: 250
},
// SSAO
postEffect: {
// 齿
enable: false,
bloom: {
enable: true,
bloomIntensity: 0.1
},
SSAO: {
enable: true,
quality: "medium",
radius: 2
}
// temporalSuperSampling: {
// enable: true,
// },
}
},
series
};
return option;
}
const chartOption = computed(() => {
return getPie3D(props.data, 0);
});
</script>
<style scoped>
.pie_img {
position: absolute;
bottom: 48px;
left: 180px;
width: 340px;
}
</style>

@ -1,6 +1,6 @@
<script setup lang="ts">
import ReCol from "@/components/ReCol";
import { barChart } from "./components/chart";
import { barChart, pieChart, pie3DChart } from "./components/chart";
defineOptions({
name: "Workbench"
@ -17,6 +17,13 @@ defineOptions({
// questionData: [2116, 3148, 3255, 3788, 4821, 4970, 5390]
// }
// ];
const pie3Ddata = {
data: [
{ name: "紧急", value: 30 },
{ name: "较高", value: 10 },
{ name: "一般", value: 60 }
]
};
</script>
<template>
@ -140,7 +147,9 @@ defineOptions({
>
<span>设备告警情况</span>
<el-card class="line-card" shadow="never">
<div class="flex justify-between h-[282px]">33</div>
<div class="flex justify-between h-[282px]">
<pie3DChart :data="pie3Ddata.data" />
</div>
</el-card>
</re-col>
<re-col
@ -164,7 +173,9 @@ defineOptions({
>
<span>算力占用</span>
<el-card class="line-card" shadow="never">
<div class="flex justify-between h-[282px]">33</div>
<div class="flex justify-between h-[282px]">
<pieChart />
</div>
</el-card>
</re-col>
</el-row>

Loading…
Cancel
Save