From d0259d12f33f48fa9efa696bac84c077760ce9a1 Mon Sep 17 00:00:00 2001 From: HuangHai <10402852@qq.com> Date: Wed, 10 Sep 2025 16:39:30 +0800 Subject: [PATCH] 'commit' --- Model/RuYuanZaiYuanCount.py | 129 ++++++++++++------ .../RuYuanZaiYuanCount.cpython-310.pyc | Bin 3110 -> 3561 bytes static/preschool_education.html | 13 +- 3 files changed, 93 insertions(+), 49 deletions(-) diff --git a/Model/RuYuanZaiYuanCount.py b/Model/RuYuanZaiYuanCount.py index 4f72f43..ef2c2ad 100644 --- a/Model/RuYuanZaiYuanCount.py +++ b/Model/RuYuanZaiYuanCount.py @@ -30,26 +30,25 @@ class RuYuanZaiYuanModel: # 提取云南省级数据 yunnan_enroll = next((item for item in enrollment_data if item["area_name"] == "云南省"), None) - yunnan_in_school = next((item for item in in_school_data if item["area_name"] == "云南省"), None) - if not yunnan_enroll or not yunnan_in_school: + if not yunnan_enroll: return {} # 提取年份数据(2015-2024) years = [str(year) for year in range(2015, 2025)] # 构建学前教育数据 - enroll_total = [] # 入园总数 - in_school_total = [] # 在园总数 + urban_data = [] # 城区数据 + town_data = [] # 镇区数据 + rural_data = [] # 乡村数据 + total_enroll = [] # 总入园数 for year in years: - # 入园总数(招生数据) enroll_data = yunnan_enroll["education_data"]["preschool"].get(year, {}) - enroll_total.append(enroll_data.get("total", 0)) - - # 在园总数(在校生数据) - in_school_data = yunnan_in_school["student_data"]["preschool"].get(year, {}) - in_school_total.append(in_school_data.get("total", 0)) + urban_data.append(enroll_data.get("urban", 0) / 10000) # 转换为万人 + town_data.append(enroll_data.get("town", 0) / 10000) # 转换为万人 + rural_data.append(enroll_data.get("rural", 0) / 10000) # 转换为万人 + total_enroll.append(enroll_data.get("total", 0) / 10000) # 转换为万人 # 构建ECharts配置 option = { @@ -60,51 +59,103 @@ class RuYuanZaiYuanModel: }, "tooltip": { "trigger": "axis", - "axisPointer": {"type": "shadow"} + "axisPointer": { + "type": "cross", + "crossStyle": {"color": "#999"} + }, + "textStyle": {"color": "#333"}, + "backgroundColor": "rgba(255, 255, 255, 0.8)", + "borderColor": "rgba(0, 0, 0, 0.2)", + "borderWidth": 1 }, "legend": { - "data": ["入园总数", "在园总数"], + "data": ["城区", "镇区", "乡村", "总入园数"], "top": 30, - "textStyle": {"color": "#333"} + "textStyle": {"color": "#333"}, + "icon": "roundRect", + "itemWidth": 12, + "itemHeight": 12 }, - "xAxis": { - "type": "category", - "data": years, - "axisLabel": {"color": "#333"}, - "axisLine": {"lineStyle": {"color": "#333"}} - }, - "yAxis": { - "type": "value", - "name": "人数", - "min": 0, - "max": 100, - "interval": 30, - "axisLabel": { - "formatter": "{value} 万人", - "color": "#333" + "xAxis": [ + { + "type": "category", + "data": years, + "axisPointer": {"type": "shadow"}, + "axisLabel": {"color": "#333"}, + "axisLine": {"lineStyle": {"color": "#333"}} + } + ], + "yAxis": [ + { + "type": "value", + "name": "人数", + "min": 0, + "max": 100, + "interval": 20, + "axisLabel": { + "formatter": "{value} 万人", + "color": "#333" + }, + "axisLine": {"lineStyle": {"color": "#333"}}, + "splitLine": {"lineStyle": {"color": "rgba(0,0,0,0.1)"}} }, - "axisLine": {"lineStyle": {"color": "#333"}}, - "splitLine": {"lineStyle": {"color": "rgba(0,0,0,0.1)"}} - }, + { + "type": "value", + "name": "总入园数", + "min": 0, + "max": 40, + "interval": 8, + "axisLabel": { + "formatter": "{value} 万人", + "color": "#333" + }, + "axisLine": {"lineStyle": {"color": "#333"}}, + "splitLine": {"show": False} + } + ], "series": [ { - "name": "入园总数", + "name": "城区", "type": "bar", - "data": enroll_total, + "data": urban_data, "itemStyle": { "color": "#5470c6", - "borderRadius": [4, 4, 0, 0] + "borderRadius": [6, 6, 0, 0] }, - "barWidth": "40%" + "barWidth": "25%", # 增加柱子宽度 + "barGap": "-10%" # 设置负数让柱子重叠以减少空隙 }, { - "name": "在园总数", + "name": "镇区", + "type": "bar", + "data": town_data, + "itemStyle": { + "color": "#91cc75", + "borderRadius": [6, 6, 0, 0] + }, + "barWidth": "25%", # 增加柱子宽度 + "barGap": "-10%" # 设置负数让柱子重叠以减少空隙 + }, + { + "name": "乡村", + "type": "bar", + "data": rural_data, + "itemStyle": { + "color": "#fac858", + "borderRadius": [6, 6, 0, 0] + }, + "barWidth": "25%", # 增加柱子宽度 + "barGap": "-10%" # 设置负数让柱子重叠以减少空隙 + }, + { + "name": "总入园数", "type": "line", - "data": in_school_total, - "lineStyle": {"color": "#91cc75", "width": 3}, + "yAxisIndex": 1, + "data": total_enroll, + "lineStyle": {"color": "#ee6666", "width": 3}, "symbol": "circle", "symbolSize": 8, - "itemStyle": {"color": "#91cc75"} + "itemStyle": {"color": "#ee6666"} } ], "grid": { diff --git a/Model/__pycache__/RuYuanZaiYuanCount.cpython-310.pyc b/Model/__pycache__/RuYuanZaiYuanCount.cpython-310.pyc index ed43353a8cf863debdfb9d92c2368dc00857fa5c..8bbcb82445f2ebebc86b80252fce60bb0a49fcdb 100644 GIT binary patch delta 1622 zcmah}-A^1<6rZ_sXLfdWp@3_FqI?u6jD;;w7T8uR6@*fa(b8zLi6O(BaT#5A@Xipr zo87EQHNF@VGvUcK1rvQUsgHiV_!sy-4;m98*%u$0kT$kf&z)IPY?^rQo-^m;cRudD zC;LrTqo>trY0(5+>Fm!NZ+3szx-7LOP;EzAKyn}WrZiZq5I1EDs{%+sKN36%WKeFB zMd7AcmGVNBBFRV!Qmi5^3UAL<)e3=Fw*YFluuChdE$oqMyh3;7N_>|>9JDDlwRc%kUB=Tfhd|VIIpZ*3~?PmthHM8LreRtkh#wt)i_8`qkG=5nuag z5fmgOms7tW_;=`lsQW3oA9+UBMb}@G!EaF}#7_T`GSqU019?Bo@ zq=$3z7F#!pjHkETMg$>8J!iX^li3zC3W4l7o>B1cDY;rsHksqPWjdJ6W_1!!ue539 zw9vTfl?qn5i{;mi(Wy*ktp5?4NYClzj?gnP*5CZ4r}PG|s4GFtV|G4ou^?gGu-(@k zyXaYroknMHV%;#`%QI)I2n$ZF;2>t*VP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+64,7 @@ // 初始化图表 var preschoolChart = echarts.init(document.getElementById('preschoolChart')); var chartData = null; - var currentType = 'both'; + var currentType = 'enroll'; // 显示加载状态 function showLoading() { @@ -89,13 +88,7 @@ var option = JSON.parse(JSON.stringify(chartData)); - // 根据当前选择的类型过滤数据 - if (currentType === 'enroll') { - option.series = [option.series[0]]; // 只显示入园总数 - } else if (currentType === 'inschool') { - option.series = [option.series[1]]; // 只显示在园总数 - } - + // 根据用户要求,现在显示所有系列数据,不需要过滤 preschoolChart.setOption(option); }