From c9d2356c70b2233a85430ac63d1d34d77bee61f0 Mon Sep 17 00:00:00 2001 From: ulleo Date: Tue, 24 Oct 2023 17:30:34 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20Antv=E5=92=8CECharts=E7=BB=84=E5=90=88?= =?UTF-8?q?=E5=9B=BE=E4=BA=92=E7=9B=B8=E8=A6=86=E7=9B=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit #6188 --- core/frontend/src/views/chart/group/Group.vue | 16 +++++++++---- .../src/views/chart/view/ChartEdit.vue | 23 +++++++++++++------ 2 files changed, 27 insertions(+), 12 deletions(-) diff --git a/core/frontend/src/views/chart/group/Group.vue b/core/frontend/src/views/chart/group/Group.vue index 75196e3707..96ef3276bd 100644 --- a/core/frontend/src/views/chart/group/Group.vue +++ b/core/frontend/src/views/chart/group/Group.vue @@ -631,9 +631,14 @@ export default { panelInfo() { return this.$store.state.panel.panelInfo }, + isPlugin() { + const plugins = localStorage.getItem('plugin-views') && JSON.parse(localStorage.getItem('plugin-views')) || [] + return plugins.some(plugin => plugin.value === this.view.type && plugin.render === this.view.render) + }, watchChartTypeChangeObj() { const { type, render } = this.view - return { type, render } + const isPlugin = this.isPlugin + return { type, render, isPlugin } } }, watch: { @@ -657,10 +662,11 @@ export default { // this.view.isPlugin = val && this.$refs['cu-chart-type'] && this.$refs['cu-chart-type'].currentIsPlugin(val) // }, watchChartTypeChangeObj(newVal, oldVal) { - if (newVal.type === oldVal.type && newVal.render === oldVal.render) { - return - } - this.view.isPlugin = this.$refs['cu-chart-type'] && this.$refs['cu-chart-type'].currentIsPlugin(newVal.type, newVal.render) + this.view.isPlugin = newVal.isPlugin + // if (newVal.type === oldVal.type && newVal.render === oldVal.render && newVal.isPlugin === oldVal.isPlugin) { + // return + // } + // this.view.isPlugin = this.$refs['cu-chart-type'] && this.$refs['cu-chart-type'].currentIsPlugin(newVal.type, newVal.render) } }, diff --git a/core/frontend/src/views/chart/view/ChartEdit.vue b/core/frontend/src/views/chart/view/ChartEdit.vue index 4c716111d0..3a01e3f495 100644 --- a/core/frontend/src/views/chart/view/ChartEdit.vue +++ b/core/frontend/src/views/chart/view/ChartEdit.vue @@ -1996,9 +1996,14 @@ export default { !equalsAny(this.view.type, 'liquid', 'bidirectional-bar', 'word-cloud', 'table-pivot', 'label', 'richTextView', 'flow-map') }, + isPlugin() { + const plugins = localStorage.getItem('plugin-views') && JSON.parse(localStorage.getItem('plugin-views')) || [] + return plugins.some(plugin => plugin.value === this.view.type && plugin.render === this.view.render) + }, watchChartTypeChangeObj() { const { type, render } = this.view - return { type, render } + const isPlugin = this.isPlugin + return { type, render, isPlugin } }, ...mapState([ 'curComponent', @@ -2036,10 +2041,12 @@ export default { this.$emit('typeChange', newVal) }, watchChartTypeChangeObj(newVal, oldVal) { - if (newVal.type === oldVal.type && newVal.render === oldVal.render) { + this.view.isPlugin = newVal.isPlugin + if (newVal.type === oldVal.type && newVal.render === oldVal.render && newVal.isPlugin === oldVal.isPlugin) { return } - this.view.isPlugin = this.$refs['cu-chart-type'] && this.$refs['cu-chart-type'].currentIsPlugin(newVal.type, newVal.render) + this.setChartDefaultOptions() + this.calcData(true, 'chart', true, newVal.type !== oldVal.type, newVal.render !== oldVal.render) } }, created() { @@ -3317,12 +3324,14 @@ export default { this.$store.commit('recordViewEdit', { viewId: this.param.id, hasEdit: status }) }, changeChartRender() { - this.setChartDefaultOptions() - this.calcData(true, 'chart', true, false, true) + // 调整为监听 watchChartTypeChangeObj + // this.setChartDefaultOptions() + // this.calcData(true, 'chart', true, false, true) }, changeChartType() { - this.setChartDefaultOptions() - this.calcData(true, 'chart', true, true) + // 调整为监听 watchChartTypeChangeObj + // this.setChartDefaultOptions() + // this.calcData(true, 'chart', true, true) }, setChartDefaultOptions() {