diff --git a/nezha-fronted/package-lock.json b/nezha-fronted/package-lock.json index 6e7a7fb91..5dc85bc4b 100644 --- a/nezha-fronted/package-lock.json +++ b/nezha-fronted/package-lock.json @@ -5943,6 +5943,30 @@ "resolved": "https://registry.npmjs.org/d3-random/-/d3-random-2.2.2.tgz", "integrity": "sha512-0D9P8TRj6qDAtHhRQn6EfdOtHMfsUWanl3yb/84C4DqpZ+VsgfI5iTVRNRbELCfNvRfpMr8OrqqUTQ6ANGCijw==" }, + "d3-sankey": { + "version": "0.12.3", + "resolved": "https://registry.npmjs.org/d3-sankey/-/d3-sankey-0.12.3.tgz", + "integrity": "sha512-nQhsBRmM19Ax5xEIPLMY9ZmJ/cDvd1BG3UVvt5h3WRxKg5zGRbvnteTyWAbzeSvlh3tW7ZEmq4VwR5mB3tutmQ==", + "requires": { + "d3-array": "1 - 2", + "d3-shape": "^1.2.0" + }, + "dependencies": { + "d3-path": { + "version": "1.0.9", + "resolved": "https://registry.npmjs.org/d3-path/-/d3-path-1.0.9.tgz", + "integrity": "sha512-VLaYcn81dtHVTjEHd8B+pbe9yHWpXKZUC87PzoFmsFrJqgFwDe/qxfp5MlfsfM1V5E/iVt0MmEbWQ7FVIXh/bg==" + }, + "d3-shape": { + "version": "1.3.7", + "resolved": "https://registry.npmjs.org/d3-shape/-/d3-shape-1.3.7.tgz", + "integrity": "sha512-EUkvKjqPFUAZyOlhY5gzCxCeI0Aep04LwIRpsZ/mLFelJiUfnK56jo5JMDSE7yyP2kLSb6LtF+S5chMk7uqPqw==", + "requires": { + "d3-path": "1" + } + } + } + }, "d3-scale": { "version": "3.3.0", "resolved": "https://registry.npmjs.org/d3-scale/-/d3-scale-3.3.0.tgz", diff --git a/nezha-fronted/package.json b/nezha-fronted/package.json index 20d780dac..8dfd2e29b 100644 --- a/nezha-fronted/package.json +++ b/nezha-fronted/package.json @@ -37,6 +37,7 @@ "cytoscape": "^3.15.2", "d3": "^6.7.0", "d3-hexbin": "^0.2.2", + "d3-sankey": "^0.12.3", "d3-zoom": "^3.0.0", "echarts": "^5.2.2", "element-ui": "^2.15.3", diff --git a/nezha-fronted/src/assets/css/common.scss b/nezha-fronted/src/assets/css/common.scss index b7099c787..1fa4a0f6f 100644 --- a/nezha-fronted/src/assets/css/common.scss +++ b/nezha-fronted/src/assets/css/common.scss @@ -427,6 +427,7 @@ td .nz-icon-gear:before { } .chart-bar, .chart-gauge, +.chart-sankey, .chart-time-series, .chart-treemap, .chart-pie, diff --git a/nezha-fronted/src/components/chart/ChartScreenHeader.vue b/nezha-fronted/src/components/chart/ChartScreenHeader.vue index 5157b9f75..7b6d46d22 100644 --- a/nezha-fronted/src/components/chart/ChartScreenHeader.vue +++ b/nezha-fronted/src/components/chart/ChartScreenHeader.vue @@ -134,7 +134,9 @@ export default { case 'table' : case 'stat' : case 'gauge' : + case 'sankey' : case 'pie' : + case 'bubble' : case 'treemap' : case 'log' : case 'hexagon' : diff --git a/nezha-fronted/src/components/chart/chart.vue b/nezha-fronted/src/components/chart/chart.vue index b4ebaf6c7..cbea8d374 100644 --- a/nezha-fronted/src/components/chart/chart.vue +++ b/nezha-fronted/src/components/chart/chart.vue @@ -108,6 +108,15 @@ :is-fullscreen="isFullscreen" @chartIsNoData="chartIsNoData" > + - - diff --git a/nezha-fronted/src/components/chart/chart/chartSankey.vue b/nezha-fronted/src/components/chart/chart/chartSankey.vue new file mode 100644 index 000000000..d6db167e3 --- /dev/null +++ b/nezha-fronted/src/components/chart/chart/chartSankey.vue @@ -0,0 +1,387 @@ + + + diff --git a/nezha-fronted/src/components/chart/chart/tools.js b/nezha-fronted/src/components/chart/chart/tools.js index cd425d4a1..cbb1fbfa7 100644 --- a/nezha-fronted/src/components/chart/chart/tools.js +++ b/nezha-fronted/src/components/chart/chart/tools.js @@ -114,6 +114,9 @@ export function isTable (type) { export function isGauge (type) { return type === chartType.gauge } +export function isSankey (type) { + return type === chartType.sankey +} export function isClock (type) { return type === chartType.clock } diff --git a/nezha-fronted/src/components/common/js/constants.js b/nezha-fronted/src/components/common/js/constants.js index a522aafd6..5077b18ab 100644 --- a/nezha-fronted/src/components/common/js/constants.js +++ b/nezha-fronted/src/components/common/js/constants.js @@ -408,6 +408,7 @@ export const chartType = { table: 'table', stat: 'stat', gauge: 'gauge', + sankey: 'sankey', pie: 'pie', bubble: 'bubble', treemap: 'treemap', diff --git a/nezha-fronted/src/components/common/rightBox/chart/chartConfig.vue b/nezha-fronted/src/components/common/rightBox/chart/chartConfig.vue index 9a2fdc346..ef2103942 100644 --- a/nezha-fronted/src/components/common/rightBox/chart/chartConfig.vue +++ b/nezha-fronted/src/components/common/rightBox/chart/chartConfig.vue @@ -340,6 +340,7 @@ +
@@ -360,6 +361,40 @@ show-word-limit v-model="chartConfig.param.max"/>
+ +
+ + + + + + + + +
+
@@ -898,7 +933,7 @@ import chartTypeShow from '@/components/common/rightBox/chart/chartTypeShow' import VueTagsInput from '@johmun/vue-tags-input' import draggable from 'vuedraggable' import { randomcolor, ColorReverse } from '@/components/common/js/radomcolor/randomcolor' -import { isGauge } from '@/components/chart/chart/tools' +import { isGauge, isSankey } from '@/components/chart/chart/tools' export default { name: 'chartConfig', @@ -969,6 +1004,10 @@ export default { id: 'gauge', name: this.$t('dashboard.panel.chartForm.typeVal.gauge.label') }, + { + id: 'sankey', + name: this.$t('dashboard.panel.chartForm.typeVal.sankey.label') + }, { id: 'treemap', name: this.$t('dashboard.panel.chartForm.typeVal.treemap.label') @@ -995,6 +1034,7 @@ export default { }, methods: { isGauge, + isSankey, beforeInit () { this.promqlType = this.type this.chartTypeList = this[this.type + 'ChartTypeList'] @@ -1017,6 +1057,18 @@ export default { this.expressionChange() } }, + // 变量名校验 防止重复 + labelValidator (rule, value, callback) { + const sourceLabel = this.chartConfig.param.sourceLabel + const targetLabel = this.chartConfig.param.targetLabel + setTimeout(() => { + if (sourceLabel === targetLabel) { + callback(new Error(this.$t('error.labelEqual'))) + } else { + callback() + } + }, 100) + }, chartTypeChange (type) { switch (type) { case 'line': @@ -1053,8 +1105,9 @@ export default { case 'stat': case 'hexagon': case 'gauge': + case 'sankey': case 'bubble': - if (this.oldType === 'stat' || this.oldType === 'gauge' || this.oldType === 'hexagon' || this.oldType === 'bubble') { + if (this.oldType === 'stat' || this.oldType === 'gauge' || this.oldType === 'sankey' || 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 31f9949d0..086b64b6a 100644 --- a/nezha-fronted/src/components/common/rightBox/chart/chartTypeShow.js +++ b/nezha-fronted/src/components/common/rightBox/chart/chartTypeShow.js @@ -74,6 +74,7 @@ export default { case 'gauge': case 'pie': case 'bubble': + case 'sankey': return true default: return false } @@ -91,6 +92,7 @@ export default { case 'stat': case 'hexagon': case 'gauge': + case 'sankey': case 'bubble': return false default: return false @@ -106,6 +108,7 @@ export default { case 'stat': case 'hexagon': case 'gauge': + case 'sankey': case 'treemap': case 'pie': case 'bubble': @@ -134,6 +137,7 @@ export default { case 'hexagon': case 'bar': case 'gauge': + case 'sankey': case 'treemap': case 'pie': case 'bubble': @@ -151,6 +155,7 @@ export default { case 'stat': case 'hexagon': case 'gauge': + case 'sankey': return false case 'line': case 'area': @@ -169,6 +174,7 @@ export default { case 'stat': case 'hexagon': case 'gauge': + case 'sankey': return true case 'line': case 'area': @@ -201,6 +207,7 @@ export default { case 'stat': case 'hexagon': case 'gauge': + case 'sankey': return true default: return false } diff --git a/nezha-fronted/src/components/common/rightBox/chart/publicConfig.js b/nezha-fronted/src/components/common/rightBox/chart/publicConfig.js index d0d34a5a9..0458bfd0c 100644 --- a/nezha-fronted/src/components/common/rightBox/chart/publicConfig.js +++ b/nezha-fronted/src/components/common/rightBox/chart/publicConfig.js @@ -247,6 +247,10 @@ export default { id: 'gauge', name: this.$t('dashboard.panel.chartForm.typeVal.gauge.label') }, + { + id: 'sankey', + name: this.$t('dashboard.panel.chartForm.typeVal.sankey.label') + }, { id: 'treemap', name: this.$t('dashboard.panel.chartForm.typeVal.treemap.label') @@ -294,6 +298,10 @@ export default { id: 'gauge', name: this.$t('dashboard.panel.chartForm.typeVal.gauge.label') }, + { + id: 'sankey', + name: this.$t('dashboard.panel.chartForm.typeVal.sankey.label') + }, { id: 'treemap', name: this.$t('dashboard.panel.chartForm.typeVal.treemap.label')