feat: 违规总量

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

@ -1,7 +1,7 @@
import type { App } from "vue"; import type { App } from "vue";
import * as echarts from "echarts/core"; import * as echarts from "echarts/core";
import { CanvasRenderer } from "echarts/renderers"; import { CanvasRenderer } from "echarts/renderers";
import { PieChart, BarChart, LineChart } from "echarts/charts"; import { PieChart, BarChart, LineChart, CustomChart } from "echarts/charts";
import { import {
GridComponent, GridComponent,
TitleComponent, TitleComponent,
@ -27,7 +27,8 @@ use([
ToolboxComponent, ToolboxComponent,
TooltipComponent, TooltipComponent,
DataZoomComponent, DataZoomComponent,
VisualMapComponent VisualMapComponent,
CustomChart
]); ]);
/** /**

@ -0,0 +1,310 @@
<script setup lang="ts">
import { useDark, useECharts } from "@pureadmin/utils";
import { type PropType, ref, computed, watch, nextTick } from "vue";
import * as echarts from "echarts/core";
const props = defineProps({
requireData: {
type: Array as PropType<Array<number>>,
default: () => []
},
questionData: {
type: Array as PropType<Array<number>>,
default: () => []
}
});
const { isDark } = useDark();
const theme = computed(() => (isDark.value ? "dark" : "light"));
const chartRef = ref();
const { setOptions } = useECharts(chartRef, {
theme
});
const name = [
"1月",
"2月",
"3月",
"4月",
"5月",
"6月",
"7月",
"8月",
"9月",
"10月",
"11月",
"12月"
];
const value = [100, 500, 400, 600, 700, 200, 450, 670, 900, 450, 670, 900];
// const toolTims = null;
const offsetX = 16;
const offsetY = 8;
//
const CubeLeft = echarts.graphic.extendShape({
shape: {
x: 0,
y: 0
},
buildPath: function (ctx, shape) {
const xAxisPoint = shape.xAxisPoint;
const c0 = [shape.x, shape.y];
const c1 = [shape.x - offsetX, shape.y - offsetY];
const c2 = [xAxisPoint[0] - offsetX, xAxisPoint[1] - offsetY];
const c3 = [xAxisPoint[0], xAxisPoint[1]];
ctx
.moveTo(c0[0], c0[1])
.lineTo(c1[0], c1[1])
.lineTo(c2[0], c2[1])
.lineTo(c3[0], c3[1])
.closePath();
}
});
//
const CubeRight = echarts.graphic.extendShape({
shape: {
x: 0,
y: 0
},
buildPath: function (ctx, shape) {
const xAxisPoint = shape.xAxisPoint;
const c1 = [shape.x, shape.y];
const c2 = [xAxisPoint[0], xAxisPoint[1]];
const c3 = [xAxisPoint[0] + offsetX, xAxisPoint[1] - offsetY];
const c4 = [shape.x + offsetX, shape.y - offsetY];
ctx
.moveTo(c1[0], c1[1])
.lineTo(c2[0], c2[1])
.lineTo(c3[0], c3[1])
.lineTo(c4[0], c4[1])
.closePath();
}
});
//
const CubeTop = echarts.graphic.extendShape({
shape: {
x: 0,
y: 0
},
buildPath: function (ctx, shape) {
const c1 = [shape.x, shape.y];
const c2 = [shape.x + offsetX, shape.y - offsetY]; //
const c3 = [shape.x, shape.y - offsetX];
const c4 = [shape.x - offsetX, shape.y - offsetY];
ctx
.moveTo(c1[0], c1[1])
.lineTo(c2[0], c2[1])
.lineTo(c3[0], c3[1])
.lineTo(c4[0], c4[1])
.closePath();
}
});
//
echarts.graphic.registerShape("CubeLeft", CubeLeft);
echarts.graphic.registerShape("CubeRight", CubeRight);
echarts.graphic.registerShape("CubeTop", CubeTop);
watch(
() => props,
async () => {
await nextTick(); // DOM
setOptions({
container: ".bar-card",
// color: ["#41b6ff", "#e85f33"],
// backgroundColor: "#010d3a",
tooltip: {
trigger: "axis",
axisPointer: {
type: "shadow"
},
formatter: function (params) {
const item = params[1];
return `${item.name}:${item.value}`;
}
},
grid: {
top: "8%",
left: "0%",
right: "0%",
bottom: "0%",
containLabel: true
},
// legend: {
// data: ["", ""],
// textStyle: {
// color: "#606266",
// fontSize: "0.875rem"
// },
// bottom: 0
// },
xAxis: [
{
type: "category",
data: name,
// X
axisLine: {
show: true,
lineStyle: {
// width: 1,
type: "dashed",
color: "#666"
}
},
axisTick: {
show: false
},
axisLabel: {
fontSize: 14,
interval: 0
}
}
],
yAxis: [
{
// name: "",
type: "value",
// y
axisLine: {
show: false,
lineStyle: {
// width: 1,
fontSize: 12,
color: "#666666"
}
},
splitLine: {
show: true,
// y-line
lineStyle: {
// width: 1,
type: "dashed",
color: "#DCDCDC"
}
},
axisTick: {
show: false
},
axisLabel: {
fontSize: 14
}
// name: ": "
}
],
series: [
{
// name: "",
type: "custom",
renderItem: (params, api) => {
const location = api.coord([api.value(0), api.value(1)]);
return {
type: "group",
children: [
{
type: "CubeLeft",
shape: {
api,
xValue: api.value(0),
yValue: api.value(1),
x: location[0],
y: location[1],
xAxisPoint: api.coord([api.value(0), 0])
},
style: {
fill: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
{
offset: 0,
color: "#417EFD"
},
{
offset: 1,
color: "#0044D2"
}
])
}
},
{
type: "CubeRight",
shape: {
api,
xValue: api.value(0),
yValue: api.value(1),
x: location[0],
y: location[1],
xAxisPoint: api.coord([api.value(0), 0])
},
style: {
fill: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
{
offset: 0,
color: "#417EFD"
},
{
offset: 1,
color: "#0044D2"
}
])
}
},
{
type: "CubeTop",
shape: {
api,
xValue: api.value(0),
yValue: api.value(1),
x: location[0],
y: location[1],
xAxisPoint: api.coord([api.value(0), 0])
},
style: {
fill: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
{
offset: 0,
color: "#0044D2"
},
{
offset: 1,
color: "#417EFD"
}
])
}
}
]
};
},
data: value
},
{
// name: "",
type: "bar",
label: {
// normal: {
show: false,
position: "top",
formatter: e => {
return `${e.value}`;
},
fontSize: 16,
color: "#43C4F1",
offset: [0, -15]
// }
},
itemStyle: {
color: "transparent"
},
tooltip: {},
data: value
}
]
});
},
{
deep: true,
immediate: true
}
);
</script>
<template>
<div ref="chartRef" style="width: 100%" />
</template>

@ -0,0 +1 @@
export { default as barChart } from "./bar.vue";

@ -1,9 +1,22 @@
<script setup lang="ts"> <script setup lang="ts">
import ReCol from "@/components/ReCol"; import ReCol from "@/components/ReCol";
import { barChart } from "./components/chart";
defineOptions({ defineOptions({
name: "Workbench" name: "Workbench"
}); });
/** 分析概览 */
// const barChartData = [
// {
// requireData: [2101, 5288, 4239, 4962, 6752, 5208, 7450],
// questionData: [2216, 1148, 1255, 1788, 4821, 1973, 4379]
// },
// {
// requireData: [2101, 3280, 4400, 4962, 5752, 6889, 7600],
// questionData: [2116, 3148, 3255, 3788, 4821, 4970, 5390]
// }
// ];
</script> </script>
<template> <template>
@ -51,8 +64,11 @@ defineOptions({
} }
}" }"
> >
<el-card class="line-card" shadow="never"> <span>违规总量</span>
<div class="flex justify-between h-[422px]">222</div> <el-card class="line-card" shadow="always">
<div class="flex justify-between h-[422px]">
<barChart />
</div>
</el-card> </el-card>
</re-col> </re-col>
<re-col <re-col
@ -74,8 +90,9 @@ defineOptions({
} }
}" }"
> >
<span>消息通知</span>
<el-card class="line-card" shadow="never"> <el-card class="line-card" shadow="never">
<div class="flex justify-between h-[422px]">222</div> <div class="flex justify-between h-[422px]" />
</el-card> </el-card>
</re-col> </re-col>
<re-col <re-col
@ -97,6 +114,7 @@ defineOptions({
} }
}" }"
> >
<span>设备状态</span>
<el-card class="line-card" shadow="never"> <el-card class="line-card" shadow="never">
<div class="flex justify-between h-[282px]">33</div> <div class="flex justify-between h-[282px]">33</div>
</el-card> </el-card>
@ -120,6 +138,7 @@ defineOptions({
} }
}" }"
> >
<span>设备告警情况</span>
<el-card class="line-card" shadow="never"> <el-card class="line-card" shadow="never">
<div class="flex justify-between h-[282px]">33</div> <div class="flex justify-between h-[282px]">33</div>
</el-card> </el-card>
@ -143,6 +162,7 @@ defineOptions({
} }
}" }"
> >
<span>算力占用</span>
<el-card class="line-card" shadow="never"> <el-card class="line-card" shadow="never">
<div class="flex justify-between h-[282px]">33</div> <div class="flex justify-between h-[282px]">33</div>
</el-card> </el-card>

Loading…
Cancel
Save