diff --git a/nezha-fronted/src/assets/css/components/chart/chart.scss b/nezha-fronted/src/assets/css/components/chart/chart.scss index 701d59f7b..ad64df03d 100644 --- a/nezha-fronted/src/assets/css/components/chart/chart.scss +++ b/nezha-fronted/src/assets/css/components/chart/chart.scss @@ -339,6 +339,26 @@ color: $--color-text-regular; } } +.chart-gauge{ + width: 100%; + height: calc(100% - 20px); + display: flex; + flex-wrap: wrap; + padding: 5px; + box-sizing: border-box; + .chart-gauge-item{ + display: flex; + justify-content: center; + align-items: center; + font-size: 30px; + word-break: break-all; + border-radius: 2px; + box-sizing: border-box; + padding: 2px; + overflow: hidden; + color: $--color-text-regular; + } +} .chart-diagram{ height: 100%; width: 100%; diff --git a/nezha-fronted/src/components/chart/chart.vue b/nezha-fronted/src/components/chart/chart.vue index 39610a7bf..731429024 100644 --- a/nezha-fronted/src/components/chart/chart.vue +++ b/nezha-fronted/src/components/chart/chart.vue @@ -75,6 +75,14 @@ :chart-option="chartOption" :is-fullscreen="isFullscreen" > + diff --git a/nezha-fronted/src/components/chart/chart/chartGauge.vue b/nezha-fronted/src/components/chart/chart/chartGauge.vue index 259bf9dac..4f75b9880 100644 --- a/nezha-fronted/src/components/chart/chart/chartGauge.vue +++ b/nezha-fronted/src/components/chart/chart/chartGauge.vue @@ -1,10 +1,216 @@ diff --git a/nezha-fronted/src/components/chart/chart/chartTable.vue b/nezha-fronted/src/components/chart/chart/chartTable.vue index 824bf91d3..04d761ab9 100644 --- a/nezha-fronted/src/components/chart/chart/chartTable.vue +++ b/nezha-fronted/src/components/chart/chart/chartTable.vue @@ -171,7 +171,7 @@ export default { let value = null if (lodash.get(params, label)) { value = lodash.get(params, label) - if (label.indexOf('$value')) { + if (label.indexOf('$value') !== -1) { value = chartDataFormat.getUnit(column.unit ? column.unit : 2).compute(value, null, -1, 2) } } diff --git a/nezha-fronted/src/components/chart/chart/options/chartGauge.js b/nezha-fronted/src/components/chart/chart/options/chartGauge.js index 5b61384ae..b3af69e73 100644 --- a/nezha-fronted/src/components/chart/chart/options/chartGauge.js +++ b/nezha-fronted/src/components/chart/chart/options/chartGauge.js @@ -1,4 +1,38 @@ const chartGaugeOption = { - + series: [ + { + type: 'gauge', + startAngle: 200, + endAngle: -20, + progress: { + show: true, + width: 30 + }, + pointer: { + show: false + }, + axisLine: { + lineStyle: { + width: 30 + } + }, + axisTick: { + show: false + }, + splitLine: { + show: false + }, + axisLabel: { + show: false + }, + anchor: { + show: false + }, + title: { + show: false + }, + data: [] + } + ] } export default chartGaugeOption diff --git a/nezha-fronted/src/components/chart/chart/tools.js b/nezha-fronted/src/components/chart/chart/tools.js index 38f977e73..f11e3d09a 100644 --- a/nezha-fronted/src/components/chart/chart/tools.js +++ b/nezha-fronted/src/components/chart/chart/tools.js @@ -1,6 +1,5 @@ import { chartType } from '@/components/common/js/constants' import chartBarOption from './options/chartBar' -import chartGaugeOption from './options/chartGauge' import chartPieOption from './options/chartPie' import lodash from 'lodash' import { @@ -9,6 +8,7 @@ import { chartTimeSeriesAreaOption } from './options/chartTimeSeries' import chartTreemapOption from './options/chartTreemap' +import chartGaugeOption from './options/chartGauge' import { randomcolor } from '@/components/common/js/radomcolor/randomcolor' export function getOption (type) { @@ -42,6 +42,10 @@ export function getOption (type) { chartOption = lodash.cloneDeep(chartTreemapOption) break } + case chartType.guage: { + chartOption = lodash.cloneDeep(chartGaugeOption) + break + } default: break } return chartOption @@ -97,6 +101,9 @@ export function isMap (type) { export function isTable (type) { return type === chartType.table } +export function isGauge (type) { + return type === chartType.guage +} export function getGroupHeight (arr) { if (arr.length) { let lastItem = [] diff --git a/nezha-fronted/src/components/common/js/constants.js b/nezha-fronted/src/components/common/js/constants.js index 3a121e4a3..0e202a877 100644 --- a/nezha-fronted/src/components/common/js/constants.js +++ b/nezha-fronted/src/components/common/js/constants.js @@ -393,7 +393,7 @@ export const chartType = { bar: 'bar', table: 'table', stat: 'stat', - gauge: 'gauge', + guage: 'guage', pie: 'pie', treemap: 'treemap', log: 'log', diff --git a/nezha-fronted/src/permission.js b/nezha-fronted/src/permission.js index e0965e5a5..4621414f9 100644 --- a/nezha-fronted/src/permission.js +++ b/nezha-fronted/src/permission.js @@ -24,7 +24,7 @@ router.beforeEach((to, from, next) => { localStorage.setItem('nz-sys-favicon', res.data.system_favicon) localStorage.setItem('nz-language', res.data.lang) localStorage.setItem('nz-sys-timezone', res.data.timezone) - localStorage.setItem('nz-sys-bgImg', res.data.system_bgImg) + localStorage.setItem('nz-sys-bgImg', res.data.system_bgImg || '') localStorage.setItem('nz-default-theme', res.data.theme) localStorage.setItem('nz-default-dateFormat', res.data.dateFormat) changeFavicon(res.data.system_favicon)