fix: 虚拟机利用率

develop
时启龙 2024-08-26 20:30:01 +08:00
parent 6b1e3b6f4c
commit 1e4c72bff2
2 changed files with 76 additions and 65 deletions

View File

@ -1,8 +1,7 @@
<template> <template>
<el-container class="setting-wrapper"> <el-container class="setting-wrapper">
<el-container class="setting-container"> <el-container>
<el-main class="setting-main" id="setting-container"> <el-main>
<el-scrollbar style="height: 100%">
<el-row :gutter="20"> <el-row :gutter="20">
<el-col :span="16"> <el-col :span="16">
<!-- 待办工单 --> <!-- 待办工单 -->
@ -41,7 +40,6 @@
<WarningList /> <WarningList />
</el-col> </el-col>
</el-row> </el-row>
</el-scrollbar>
</el-main> </el-main>
</el-container> </el-container>
</el-container> </el-container>
@ -73,21 +71,12 @@ export default {
DailyAlarmStatistics, DailyAlarmStatistics,
CPU_MEMORY_Top5, CPU_MEMORY_Top5,
WarningList WarningList
},
setup(props, context) {
return {}
} }
} }
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
.setting-wrapper { .setting-wrapper {
height: calc(100vh - 50px);
overflow: hidden;
flex-direction: column;
font-size: 14px !important; font-size: 14px !important;
.setting-container {
height: calc(100% - 50px);
}
} }
::v-deep { ::v-deep {
.weight600 { .weight600 {

View File

@ -6,7 +6,7 @@
</template> </template>
<script> <script>
import { computed } from 'vue' import { computed, unref, ref } from 'vue'
import useEchart, { commonProps } from '@cmp/cmp-echarts/hooks/useChart' import useEchart, { commonProps } from '@cmp/cmp-echarts/hooks/useChart'
import { merge } from 'lodash-es' import { merge } from 'lodash-es'
import echarts from '@cmp/cmp-echarts/hooks/echarts' import echarts from '@cmp/cmp-echarts/hooks/echarts'
@ -34,14 +34,36 @@ function getLinerColor(startColor, endColor) {
} }
]) ])
} }
const MaxNameLength = 15
export default { export default {
props: { props: {
...commonProps ...commonProps
}, },
setup(props) { setup(props) {
const yLeft = ref(0)
const getTextWidth = (text, font) => {
let canvas = document.createElement('canvas')
let context = canvas.getContext('2d')
context.font = font
let metrics = context.measureText(text)
return metrics.width
}
const getYLeft = data => {
// y
let maxlengthName = data.keys.sort((a, b) => {
return b.length - a.length
})[0]
//
let maxlength = maxlengthName.length
// label10
if (maxlength >= MaxNameLength) maxlengthName = maxlengthName.slice(0, MaxNameLength) + '...'
// listlabel
yLeft.value = getTextWidth(maxlengthName, '14px Microsoft Yahei') + 50
}
// //
function handleData(data) { function handleData(data) {
const { legendLength = 60, series: seriesConfig = {}, colorMap = {} } = props.setting getYLeft(data)
const { legendLength = 60, series: seriesConfig = {} } = props.setting
const legends = [] const legends = []
const series = [] const series = []
const { values = [], keys = [] } = data const { values = [], keys = [] } = data
@ -101,10 +123,9 @@ export default {
}, },
grid: { grid: {
top: 10, top: 10,
left: '-150', left: unref(yLeft),
right: '2%', right: '15%',
bottom: 1, bottom: 1,
containLabel: true,
...grid ...grid
}, },
tooltip: { tooltip: {
@ -141,20 +162,21 @@ export default {
{ {
type: 'category', type: 'category',
inverse: true, inverse: true,
// ...yAxis,
data: keys, data: keys,
axisLine: { axisLine: {
show: false show: false
}, },
position: 'left', position: 'left',
axisLabel: { axisLabel: {
show: true, align: 'left',
margin: 150, baseline: 'middle',
textStyle: { fontSize: 14,
align: 'left' margin: unref(yLeft),
},
color: 'rgba(52, 71, 103, 1)', color: 'rgba(52, 71, 103, 1)',
formatter: function (value, index) { formatter: function (value, index) {
if (value.length >= MaxNameLength) {
value = value.slice(0, MaxNameLength) + '...'
}
return `{rang${index + 1}|}` + ' ' + value return `{rang${index + 1}|}` + ' ' + value
}, },
rich: { rich: {
@ -207,7 +229,7 @@ export default {
{ {
type: 'category', type: 'category',
inverse: true, inverse: true,
// ...yAxis, position: 'right',
data: keys, data: keys,
axisLine: { axisLine: {
show: false show: false
@ -217,8 +239,8 @@ export default {
formatter: function (value, index) { formatter: function (value, index) {
return props.data.values[0].data[index] + '%' return props.data.values[0].data[index] + '%'
}, },
margin: 40, margin: 50,
width: 10, width: 100,
fontSize: 14, fontSize: 14,
fontWeight: 600 fontWeight: 600
}, },