-
-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
101 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
98 changes: 98 additions & 0 deletions
98
launcher/src/components/UI/control-page/components/widgets/ChartCpu.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
<template> | ||
<div | ||
class="theCpuParent flex w-full h-full justify-center items-center" | ||
@mouseenter="footerStore.cursorLocation = t('controlPage.cpuUsageIs', { usage: cpu })" | ||
@mouseleave="footerStore.cursorLocation = ''" | ||
> | ||
<div class="cpuIco w-1/3 h-full flex flex-col justify-center items-center"> | ||
<div class="cpuIco-container flex justify-center items-center w-full h-4/5"> | ||
<img class="w-3/4" src="/img/icon/control-page-icons/cpuIcon.svg" /> | ||
</div> | ||
<span class="w-full h-1/5 flex justify-center items-center text-gray-200 text-2xs font-semibold uppercase">CPU</span> | ||
</div> | ||
<div class="cpuCountPart w-2/3 h-full flex justify-center items-center"> | ||
<VueApexCharts :options="chartOptions" :series="chartSeries" class="full-size-chart" /> | ||
</div> | ||
</div> | ||
</template> | ||
<script setup> | ||
import { ref, computed, onMounted, onBeforeUnmount } from "vue"; | ||
import VueApexCharts from "vue3-apexcharts"; | ||
import { useControlStore } from "@/store/theControl"; | ||
import { useFooter } from "@/store/theFooter"; | ||
import i18n from "@/includes/i18n"; | ||
const t = i18n.global.t; | ||
const controlStore = useControlStore(); | ||
const footerStore = useFooter(); | ||
const cpu = computed(() => controlStore.cpu); | ||
const chartData = ref([]); | ||
let pollingInterval; | ||
const chartSeries = computed(() => [{ name: "CPU Usage", data: chartData.value }]); | ||
const chartOptions = { | ||
chart: { | ||
type: "area", | ||
width: "100%", | ||
height: "100%", | ||
toolbar: { show: false }, | ||
animations: { | ||
enabled: true, | ||
easing: "linear", | ||
dynamicAnimation: { speed: 1000 }, | ||
}, | ||
}, | ||
xaxis: { | ||
type: "datetime", | ||
labels: { show: false }, | ||
axisTicks: { show: false }, | ||
axisBorder: { show: false }, | ||
tooltip: { enabled: false }, | ||
crosshairs: { show: false }, | ||
}, | ||
yaxis: { | ||
labels: { show: false }, | ||
axisTicks: { show: false }, | ||
axisBorder: { show: false }, | ||
min: 0, | ||
max: 100, | ||
}, | ||
grid: { | ||
borderColor: "gray", | ||
strokeDashArray: 5, | ||
xaxis: { lines: { show: true } }, | ||
yaxis: { lines: { show: true } }, | ||
padding: { top: -5, bottom: -5 }, | ||
}, | ||
stroke: { width: 1, colors: ["#00ff00"] }, | ||
markers: { size: 5 }, | ||
dataLabels: { enabled: false }, | ||
tooltip: { enabled: false }, | ||
}; | ||
const updateChartData = () => { | ||
const currentTime = Date.now(); | ||
chartData.value.push([currentTime, cpu.value]); | ||
if (chartData.value.length > 10) { | ||
chartData.value.shift(); | ||
} | ||
}; | ||
onMounted(() => { | ||
pollingInterval = setInterval(updateChartData, 1000); | ||
}); | ||
onBeforeUnmount(() => { | ||
clearInterval(pollingInterval); | ||
}); | ||
</script> | ||
<style scoped> | ||
.full-size-chart { | ||
width: 100%; | ||
height: 100%; | ||
min-height: 100%; | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters