From c3faf9ae2120f9b0e636ce17b48ef02fc7361753 Mon Sep 17 00:00:00 2001 From: zyh Date: Thu, 21 Jul 2022 10:33:20 +0800 Subject: [PATCH] =?UTF-8?q?NEZ-2037=20feat=EF=BC=9A=E6=96=B0=E5=A2=9Echart?= =?UTF-8?q?=E7=B1=BB=E5=9E=8Bbubble?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- nezha-fronted/src/assets/css/common.scss | 1 + nezha-fronted/src/components/chart/chart.vue | 14 +- .../components/chart/chart/chartBubble.vue | 249 ++++++++++++++++++ .../chart/chart/options/chartBubble.js | 23 ++ .../src/components/chart/chart/tools.js | 8 + .../src/components/common/js/constants.js | 3 +- .../common/rightBox/chart/chartConfig.vue | 7 +- .../common/rightBox/chart/chartTypeShow.js | 8 + .../common/rightBox/chart/publicConfig.js | 8 + .../rightBox/chart/systemChartConfig.vue | 7 +- 10 files changed, 324 insertions(+), 4 deletions(-) create mode 100644 nezha-fronted/src/components/chart/chart/chartBubble.vue create mode 100644 nezha-fronted/src/components/chart/chart/options/chartBubble.js diff --git a/nezha-fronted/src/assets/css/common.scss b/nezha-fronted/src/assets/css/common.scss index 78d2ab60c..7b482338d 100644 --- a/nezha-fronted/src/assets/css/common.scss +++ b/nezha-fronted/src/assets/css/common.scss @@ -420,6 +420,7 @@ td .nz-icon-gear:before { .chart-time-series, .chart-treemap, .chart-pie, +.chart-bubble, .chart-canvas-tooltip, .line-chart-block-Zindex, .alert-label, diff --git a/nezha-fronted/src/components/chart/chart.vue b/nezha-fronted/src/components/chart/chart.vue index 284bd7776..b4ebaf6c7 100644 --- a/nezha-fronted/src/components/chart/chart.vue +++ b/nezha-fronted/src/components/chart/chart.vue @@ -26,6 +26,15 @@ :is-fullscreen="isFullscreen" @chartIsNoData="chartIsNoData" > + +
+
+
+ + + + + diff --git a/nezha-fronted/src/components/chart/chart/options/chartBubble.js b/nezha-fronted/src/components/chart/chart/options/chartBubble.js new file mode 100644 index 000000000..52b9f2c08 --- /dev/null +++ b/nezha-fronted/src/components/chart/chart/options/chartBubble.js @@ -0,0 +1,23 @@ +const chartBubble = { + dataset: { + source: [] + }, + tooltip: { + show: true, + trigger: 'item', + confine: false, + extraCssText: 'z-index:1000;', + z: 9, + animation: false, + appendToBody: true, + className: 'chart-bubble' + }, + hoverLayerThreshold: Infinity, + series: [{ + type: 'custom', + renderItem: undefined, + progressive: 0, + coordinateSystem: 'none' + }] +} +export default chartBubble diff --git a/nezha-fronted/src/components/chart/chart/tools.js b/nezha-fronted/src/components/chart/chart/tools.js index 368e7ca1e..f3a26bf6b 100644 --- a/nezha-fronted/src/components/chart/chart/tools.js +++ b/nezha-fronted/src/components/chart/chart/tools.js @@ -1,6 +1,7 @@ import { chartType } from '@/components/common/js/constants' import chartBarOption from './options/chartBar' import chartPieOption from './options/chartPie' +import chartBubbleOption from './options/chartBubble' import lodash from 'lodash' import { chartTimeSeriesLineOption, @@ -39,6 +40,10 @@ export function getOption (type) { chartOption = lodash.cloneDeep(chartPieOption) break } + case chartType.bubble: { + chartOption = lodash.cloneDeep(chartBubbleOption) + break + } case chartType.treemap: { chartOption = lodash.cloneDeep(chartTreemapOption) break @@ -68,6 +73,9 @@ export function isHexagon (type) { export function isChartPie (type) { return type === chartType.pie } +export function isChartBubble (type) { + return type === chartType.bubble +} export function isChartBar (type) { return type === chartType.bar } diff --git a/nezha-fronted/src/components/common/js/constants.js b/nezha-fronted/src/components/common/js/constants.js index ab5cad394..8b863410f 100644 --- a/nezha-fronted/src/components/common/js/constants.js +++ b/nezha-fronted/src/components/common/js/constants.js @@ -189,7 +189,7 @@ export const endpoint = { { value: 1, label: i18n.t('endpoint.metricLabel') }, { value: 2, label: i18n.t('endpoint.metricEnable') }, { value: 3, label: i18n.t('endpoint.logEnable') } - ], + ] } export const alertMessage = { severityData: [ @@ -407,6 +407,7 @@ export const chartType = { stat: 'stat', gauge: 'gauge', pie: 'pie', + bubble: 'bubble', treemap: 'treemap', log: 'log', text: 'text', diff --git a/nezha-fronted/src/components/common/rightBox/chart/chartConfig.vue b/nezha-fronted/src/components/common/rightBox/chart/chartConfig.vue index ca66684f1..74405cd3f 100644 --- a/nezha-fronted/src/components/common/rightBox/chart/chartConfig.vue +++ b/nezha-fronted/src/components/common/rightBox/chart/chartConfig.vue @@ -910,6 +910,10 @@ export default { id: 'pie', name: this.$t('dashboard.panel.chartForm.typeVal.pie.label') }, + { + id: 'bubble', + name: this.$t('dashboard.panel.chartForm.typeVal.bubble.label') + }, { id: 'log', name: this.$t('dashboard.panel.chartForm.typeVal.log.label') @@ -980,7 +984,8 @@ export default { case 'stat': case 'hexagon': case 'gauge': - if (this.oldType === 'stat' || this.oldType === 'gauge' || this.oldType === 'hexagon') { + case 'bubble': + if (this.oldType === 'stat' || this.oldType === 'gauge' || this.oldType === 'hexagon' || this.oldType === 'bubble') { break } this.chartConfig.param = { diff --git a/nezha-fronted/src/components/common/rightBox/chart/chartTypeShow.js b/nezha-fronted/src/components/common/rightBox/chart/chartTypeShow.js index 2ab508b94..31f9949d0 100644 --- a/nezha-fronted/src/components/common/rightBox/chart/chartTypeShow.js +++ b/nezha-fronted/src/components/common/rightBox/chart/chartTypeShow.js @@ -55,6 +55,7 @@ export default { case 'treemap': case 'gauge': case 'pie': + case 'bubble': return false default: return false } @@ -72,6 +73,7 @@ export default { case 'treemap': case 'gauge': case 'pie': + case 'bubble': return true default: return false } @@ -89,6 +91,7 @@ export default { case 'stat': case 'hexagon': case 'gauge': + case 'bubble': return false default: return false } @@ -105,6 +108,7 @@ export default { case 'gauge': case 'treemap': case 'pie': + case 'bubble': case 'bar': return false default: return false @@ -132,6 +136,7 @@ export default { case 'gauge': case 'treemap': case 'pie': + case 'bubble': return true default: return false } @@ -142,6 +147,7 @@ export default { case 'bar': case 'treemap': case 'pie': + case 'bubble': case 'stat': case 'hexagon': case 'gauge': @@ -159,6 +165,7 @@ export default { case 'bar': case 'treemap': case 'pie': + case 'bubble': case 'stat': case 'hexagon': case 'gauge': @@ -190,6 +197,7 @@ export default { case 'bar': case 'treemap': case 'pie': + case 'bubble': case 'stat': case 'hexagon': case 'gauge': diff --git a/nezha-fronted/src/components/common/rightBox/chart/publicConfig.js b/nezha-fronted/src/components/common/rightBox/chart/publicConfig.js index 325a5d983..e16ea9b47 100644 --- a/nezha-fronted/src/components/common/rightBox/chart/publicConfig.js +++ b/nezha-fronted/src/components/common/rightBox/chart/publicConfig.js @@ -243,6 +243,10 @@ export default { id: 'pie', name: this.$t('dashboard.panel.chartForm.typeVal.pie.label') }, + { + id: 'bubble', + name: this.$t('dashboard.panel.chartForm.typeVal.bubble.label') + }, { id: 'table', name: this.$t('dashboard.panel.chartForm.typeVal.table.label') @@ -286,6 +290,10 @@ export default { id: 'pie', name: this.$t('dashboard.panel.chartForm.typeVal.pie.label') }, + { + id: 'bubble', + name: this.$t('dashboard.panel.chartForm.typeVal.bubble.label') + }, { id: 'log', name: this.$t('dashboard.panel.chartForm.typeVal.log.label') diff --git a/nezha-fronted/src/components/common/rightBox/chart/systemChartConfig.vue b/nezha-fronted/src/components/common/rightBox/chart/systemChartConfig.vue index 76f88a86e..7777cfd55 100644 --- a/nezha-fronted/src/components/common/rightBox/chart/systemChartConfig.vue +++ b/nezha-fronted/src/components/common/rightBox/chart/systemChartConfig.vue @@ -834,6 +834,10 @@ export default { id: 'pie', name: this.$t('dashboard.panel.chartForm.typeVal.pie.label') }, + { + id: 'bubble', + name: this.$t('dashboard.panel.chartForm.typeVal.bubble.label') + }, { id: 'gauge', name: this.$t('dashboard.panel.chartForm.typeVal.gauge.label') @@ -899,7 +903,8 @@ export default { case 'stat': case 'hexagon': case 'gauge': - if (this.oldType === 'stat' || this.oldType === 'gauge' || this.oldType === 'hexagon') { + case 'bubble': + if (this.oldType === 'stat' || this.oldType === 'gauge' || this.oldType === 'hexagon' || this.oldType === 'bubble') { break } this.chartConfig.param = {