From 33a617ef91429b0e36804749326c63df878c50e9 Mon Sep 17 00:00:00 2001 From: d266377 Date: Thu, 29 Jan 2026 17:28:43 +0800 Subject: [PATCH] =?UTF-8?q?=E6=80=81=E5=8A=BF=E6=84=9F=E7=9F=A5=E5=B9=B3?= =?UTF-8?q?=E5=8F=B0-=E6=AD=A6=E6=B1=89=E5=B8=82=E5=BC=80=E6=BA=90?= =?UTF-8?q?=E7=94=9F=E6=80=81=E5=BB=BA=E8=AE=BE-=E9=B8=BF=E8=92=99?= =?UTF-8?q?=E9=A1=B9=E7=9B=AE=E5=9F=8E=E5=B8=82=E5=88=86=E5=B8=83=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3=E5=AF=B9=E6=8E=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Community/components/HarmonyEcoCharts.vue | 60 +++++++++++++++++-- 1 file changed, 54 insertions(+), 6 deletions(-) diff --git a/src/views/Jyh/Community/components/HarmonyEcoCharts.vue b/src/views/Jyh/Community/components/HarmonyEcoCharts.vue index 4c52191..4ca8d3d 100644 --- a/src/views/Jyh/Community/components/HarmonyEcoCharts.vue +++ b/src/views/Jyh/Community/components/HarmonyEcoCharts.vue @@ -338,9 +338,10 @@ import { ref, onMounted, nextTick, onUnmounted } from 'vue'; import * as echarts from 'echarts'; import HMStatsBar from './HMStatsBar.vue'; +import { hmCityDataPage3 } from '@/api/jyh/situation'; // ================= 数据定义 ================= -const hmCityData = [ +const hmCityData = ref([ { name: '广东', value: 185 }, { name: '北京', value: 95 }, { name: '上海', value: 88 }, @@ -351,7 +352,7 @@ const hmCityData = [ { name: '福建', value: 30 }, { name: '陕西', value: 28 }, { name: '山东', value: 24 } -]; +]); const hmDevCityData = [ { name: '其他地区', value: 25.7 }, @@ -776,10 +777,10 @@ const initHmCityChart = () => { cityChart.setOption({ tooltip: { trigger: 'axis' }, grid: { left: '3%', right: '4%', bottom: '3%', top: '10%', containLabel: true }, - xAxis: { type: 'category', data: hmCityData.map(i => i.name), axisLabel: { color: '#64748b' } }, + xAxis: { type: 'category', data: hmCityData.value.map(i => i.name), axisLabel: { color: '#64748b' } }, yAxis: { type: 'value', name: '单位:个', axisLabel: { color: '#64748b' } }, series: [{ - type: 'bar', barWidth: '40%', data: hmCityData.map(i => i.value), + type: 'bar', barWidth: '40%', data: hmCityData.value.map(i => i.value), itemStyle: { color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{ offset: 0, color: '#3b82f6' }, { offset: 1, @@ -790,6 +791,50 @@ const initHmCityChart = () => { }); }; +// 获取鸿蒙项目城市分布数据 +const fetchHmCityData = async () => { + try { + const response = await hmCityDataPage3(); + if (response.code === 200 && response.data) { + hmCityData.value = response.data; + // 重新初始化图表以显示新数据 + initHmCityChart(); + } else { + console.error('获取鸿蒙项目城市分布数据失败:', response.msg || '未知错误'); + // 使用默认数据 + hmCityData.value = [ + { name: '广东', value: 185 }, + { name: '北京', value: 95 }, + { name: '上海', value: 88 }, + { name: '江苏', value: 70 }, + { name: '浙江', value: 52 }, + { name: '湖北', value: 38 }, + { name: '四川', value: 32 }, + { name: '福建', value: 30 }, + { name: '陕西', value: 28 }, + { name: '山东', value: 24 } + ]; + initHmCityChart(); + } + } catch (error) { + console.error('获取鸿蒙项目城市分布数据异常:', error); + // 使用默认数据 + hmCityData.value = [ + { name: '广东', value: 185 }, + { name: '北京', value: 95 }, + { name: '上海', value: 88 }, + { name: '江苏', value: 70 }, + { name: '浙江', value: 52 }, + { name: '湖北', value: 38 }, + { name: '四川', value: 32 }, + { name: '福建', value: 30 }, + { name: '陕西', value: 28 }, + { name: '山东', value: 24 } + ]; + initHmCityChart(); + } +}; + const initHmEntCityChart = () => { const chartDom = document.getElementById('hmEntCityChart'); if (!chartDom) return; @@ -1004,8 +1049,11 @@ const handleResize = () => { entCityChart?.resize(); }; -onMounted(() => { - nextTick(() => { +onMounted(async () => { + nextTick(async () => { + // 先获取鸿蒙项目城市分布数据 + await fetchHmCityData(); + initHmCityChart(); initHmEnterpriseChart(); initHmEntCityChart();