From 03f11c8283084f875247dbdd01584bc8c1056f12 Mon Sep 17 00:00:00 2001 From: zhangyu Date: Mon, 13 Dec 2021 20:30:33 +0800 Subject: [PATCH] =?UTF-8?q?feat=EF=BC=9A=E6=B7=BB=E5=8A=A0=20chart-group?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/components/chart/chart/chartGroup.vue | 3 +- .../chart/chart/chartTimeSeries.vue | 3 + .../chart/chart/options/chartTreemap.js | 1 + .../src/components/chart/chart/tools.js | 24 ++++++++ .../src/components/chart/chartHeader.vue | 10 ++- .../src/components/chart/chartList.vue | 61 ++++++++++++++++++- .../src/components/chart/chartMixin.js | 1 + .../src/components/chart/panelChart.vue | 36 ++++++++++- .../common/rightBox/chart/chartRightBox.vue | 3 + .../rightBox/chart/otherChartConfig.vue | 3 +- nezha-fronted/src/store/panel.js | 18 +++++- 11 files changed, 157 insertions(+), 6 deletions(-) diff --git a/nezha-fronted/src/components/chart/chart/chartGroup.vue b/nezha-fronted/src/components/chart/chart/chartGroup.vue index d7c6980e1..922ffa0dd 100644 --- a/nezha-fronted/src/components/chart/chart/chartGroup.vue +++ b/nezha-fronted/src/components/chart/chart/chartGroup.vue @@ -10,6 +10,7 @@ :panel-lock="panelLock" :isGroup="true" :time-range="searchTime" + :groupInfo="chartInfo" @on-refresh-time="refreshTime" :loading="chartListLoading" > @@ -23,7 +24,7 @@ import chartFormat from '@/components/chart/chartFormat' export default { name: 'chart-group', props: { - panelLock: Boolean + panelLock: Boolean, }, mixins: [chartMixin, chartFormat], computed: { diff --git a/nezha-fronted/src/components/chart/chart/chartTimeSeries.vue b/nezha-fronted/src/components/chart/chart/chartTimeSeries.vue index 229871576..80cba2f29 100644 --- a/nezha-fronted/src/components/chart/chart/chartTimeSeries.vue +++ b/nezha-fronted/src/components/chart/chart/chartTimeSeries.vue @@ -244,6 +244,9 @@ export default { option.tooltip[0].formatter = self.tooltipFormatter(self.isStack) myChart.setOption(option) } + }, + resize () { + getChart(this.chartId).resize() } }, mounted () { diff --git a/nezha-fronted/src/components/chart/chart/options/chartTreemap.js b/nezha-fronted/src/components/chart/chart/options/chartTreemap.js index 55e8eec04..ef10ffeea 100644 --- a/nezha-fronted/src/components/chart/chart/options/chartTreemap.js +++ b/nezha-fronted/src/components/chart/chart/options/chartTreemap.js @@ -22,6 +22,7 @@ const chartTreemapOption = { type: 'treemap', visibleMin: 40, childrenVisibleMin: 40, + nodeClick: false, label: { show: true, position: 'inside', diff --git a/nezha-fronted/src/components/chart/chart/tools.js b/nezha-fronted/src/components/chart/chart/tools.js index 803dad732..567fb4214 100644 --- a/nezha-fronted/src/components/chart/chart/tools.js +++ b/nezha-fronted/src/components/chart/chart/tools.js @@ -83,6 +83,30 @@ export function isGroup (type) { return type === chartType.group } +export function getGroupHeight (arr) { + if (arr.length) { + let lastItem = [] + let maxY = 0 + arr.forEach((children, index) => { + if (maxY == children.y) { + lastItem.push(children) + } else { + maxY = children.y + lastItem = [children] + } + }) + let maxHeight = 0 + lastItem.forEach(last => { + if (maxHeight < last.height) { + maxHeight = last.height + } + }) + return maxHeight + maxY + } else { + return 1 + } +} + export function initColor (colorNum = 20) { const colorList = [ '#FF5200', '#3685FF', '#FF8D00', '#00DCA2', diff --git a/nezha-fronted/src/components/chart/chartHeader.vue b/nezha-fronted/src/components/chart/chartHeader.vue index fc85f7ee9..8e5cde1de 100644 --- a/nezha-fronted/src/components/chart/chartHeader.vue +++ b/nezha-fronted/src/components/chart/chartHeader.vue @@ -1,6 +1,7 @@