diff --git a/Model/RuYuanZaiYuanCount.py b/Model/RuYuanZaiYuanCount.py index 11f6de3..beafa19 100644 --- a/Model/RuYuanZaiYuanCount.py +++ b/Model/RuYuanZaiYuanCount.py @@ -196,13 +196,21 @@ class RuYuanZaiYuanModel: for year in years: # 将education_data改为student_data in_school_year_data = yunnan_in_school["student_data"]["preschool"].get(year, {}) - urban_data.append(in_school_year_data.get("urban", 0) / 10000) # 转换为万人 - town_data.append(in_school_year_data.get("town", 0) / 10000) # 转换为万人 - rural_data.append(in_school_year_data.get("rural", 0) / 10000) # 转换为万人 - # 计算总和作为总在园数 - calculated_total = in_school_year_data.get("urban", 0) + in_school_year_data.get("town", 0) + in_school_year_data.get("rural", 0) - total_in_school.append(calculated_total / 10000) # 转换为万人 - + + # 先获取原始数据 + urban_val = in_school_year_data.get("urban", 0) + town_val = in_school_year_data.get("town", 0) + rural_val = in_school_year_data.get("rural", 0) + + # 转换为万人并添加到各自列表 + urban_data.append(urban_val / 10000) # 转换为万人 + town_data.append(town_val / 10000) # 转换为万人 + rural_data.append(rural_val / 10000) # 转换为万人 + + # 计算总和并转换为万人 + calculated_total = (urban_val + town_val + rural_val) / 10000 # 先计算总和再转换为万人 + total_in_school.append(calculated_total) + # 构建ECharts配置 option = { "tooltip": { @@ -238,8 +246,8 @@ class RuYuanZaiYuanModel: "type": "value", "name": "人数", "min": 0, - "max": 100, - "interval": 20, + "max": 200, # 将左侧Y轴最大值从100修改为200万 + "interval": 40, # 调整间隔为40万,确保坐标轴上有5个主要刻度(0,40,80,120,160,200) "axisLabel": { "formatter": "{value} 万人", "color": "#333" @@ -251,8 +259,8 @@ class RuYuanZaiYuanModel: "type": "value", "name": "总在园数", "min": 0, - "max": 140, - "interval": 20, + "max": 320, # 将右侧Y轴最大值从160扩大一倍到320万 + "interval": 60, # 调整间隔为60万 "position": "right", "nameLocation": "end", "nameGap": 30, @@ -307,12 +315,16 @@ class RuYuanZaiYuanModel: "lineStyle": {"color": "#ee6666", "width": 3}, "symbol": "circle", "symbolSize": 8, - "itemStyle": {"color": "#ee6666"} + "itemStyle": {"color": "#ee6666"}, + "emphasis": { + "focus": "series" + }, + "z": 10 # 确保折线图显示在最上层 } ], "grid": { "left": "3%", - "right": "8%", + "right": "15%", # 稍微增加右侧边距,确保Y轴标签不被截断 "bottom": "3%", "containLabel": True } diff --git a/Model/__pycache__/RuYuanZaiYuanCount.cpython-310.pyc b/Model/__pycache__/RuYuanZaiYuanCount.cpython-310.pyc index 9ec1255..6400e73 100644 Binary files a/Model/__pycache__/RuYuanZaiYuanCount.cpython-310.pyc and b/Model/__pycache__/RuYuanZaiYuanCount.cpython-310.pyc differ