diff --git a/frontend/src/views/chart/chart/map/map.js b/frontend/src/views/chart/chart/map/map.js index eba14b830c..aee4192f28 100644 --- a/frontend/src/views/chart/chart/map/map.js +++ b/frontend/src/views/chart/chart/map/map.js @@ -26,7 +26,7 @@ export function baseMapOption(chart_option, chart) { // 处理data if (chart.data) { chart_option.title.text = chart.title - if (chart.data.series.length > 0) { + if (chart.data.series && chart.data.series.length > 0) { chart_option.series[0].name = chart.data.series[0].name // label if (customAttr.label) { diff --git a/frontend/src/views/chart/components/ChartComponent.vue b/frontend/src/views/chart/components/ChartComponent.vue index c966e46054..3082ccf498 100644 --- a/frontend/src/views/chart/components/ChartComponent.vue +++ b/frontend/src/views/chart/components/ChartComponent.vue @@ -74,7 +74,7 @@ import { import { baseMixOption } from '@/views/chart/chart/mix/mix' - // import eventBus from '@/components/canvas/utils/eventBus' +// import eventBus from '@/components/canvas/utils/eventBus' import { uuid } from 'vue-uuid' @@ -130,7 +130,8 @@ export default { pointParam: null, dynamicAreaCode: null, - borderRadius: '0px' + borderRadius: '0px', + mapCenter: null } }, @@ -276,6 +277,11 @@ export default { const base_json = JSON.parse(JSON.stringify(BASE_MAP)) const chart_option = baseMapOption(base_json, chart) this.myEcharts(chart_option) + const opt = this.myChart.getOption() + if (opt && opt.series) { + const center = opt.series[0].center + this.mapCenter = center + } }, myEcharts(option) { // 指定图表的配置项和数据 @@ -356,6 +362,7 @@ export default { resetZoom() { const options = JSON.parse(JSON.stringify(this.myChart.getOption())) options.series[0].zoom = 1 + options.series[0].center = this.mapCenter this.myChart.setOption(options) } }