diff --git a/Model/RuYuanZaiYuanCount.py b/Model/RuYuanZaiYuanCount.py index ce8a04e..4f72f43 100644 --- a/Model/RuYuanZaiYuanCount.py +++ b/Model/RuYuanZaiYuanCount.py @@ -39,118 +39,80 @@ class RuYuanZaiYuanModel: years = [str(year) for year in range(2015, 2025)] # 构建学前教育数据 - urban_enroll = [] # 城区入园人数 - town_enroll = [] # 镇区入园人数 - rural_enroll = [] # 乡村入园人数 - urban_in_school = [] # 城区在园人数 - town_in_school = [] # 镇区在园人数 - rural_in_school = [] # 乡村在园人数 + enroll_total = [] # 入园总数 + in_school_total = [] # 在园总数 for year in years: - # 入园人数(招生数据) - pre_enroll = yunnan_enroll.get("education_data", {}).get("preschool", {}).get(year, {}) - urban_enroll.append(pre_enroll.get("urban", 0)) - town_enroll.append(pre_enroll.get("town", 0)) - rural_enroll.append(pre_enroll.get("rural", 0)) + # 入园总数(招生数据) + enroll_data = yunnan_enroll["education_data"]["preschool"].get(year, {}) + enroll_total.append(enroll_data.get("total", 0)) - # 在园人数(在校生数据) - pre_in_school = yunnan_in_school.get("education_data", {}).get("preschool", {}).get(year, {}) - urban_in_school.append(pre_in_school.get("urban", 0)) - town_in_school.append(pre_in_school.get("town", 0)) - rural_in_school.append(pre_in_school.get("rural", 0)) + # 在园总数(在校生数据) + in_school_data = yunnan_in_school["student_data"]["preschool"].get(year, {}) + in_school_total.append(in_school_data.get("total", 0)) - # 构建option数据结构 + # 构建ECharts配置 option = { - "grid": { - "left": 0, - "right": 0, - "top": 40, - "bottom": 10, - "containLabel": True, - }, - "textStyle": { - "color": "#fff", + "title": { + "text": "云南省学前教育人数统计", + "left": "center", + "textStyle": {"color": "#333"} }, "tooltip": { "trigger": "axis", - "axisPointer": { - "type": "cross", - "crossStyle": { "color": "#999" }, - }, - "textStyle": { "color": "#fff" }, - "backgroundColor": "rgba(96,98,102,0.8)", - "borderColor": "rgba(255,255,255,0.3)", - "borderWidth": 1, + "axisPointer": {"type": "shadow"} }, "legend": { - "data": ["城区入园人数", "镇区入园人数", "乡村入园人数", - "城区在园人数", "镇区在园人数", "乡村在园人数"], - "top": 0, - "textStyle": { "color": "#fff" }, - "icon": "roundRect", - "itemWidth": 12, - "itemHeight": 12, + "data": ["入园总数", "在园总数"], + "top": 30, + "textStyle": {"color": "#333"} }, - "xAxis": [ - { - "type": "category", - "data": years, - "axisPointer": { "type": "shadow" }, - "axisLine": { "lineStyle": { "color": "#fff" } }, - "axisLabel": { "color": "#fff" }, - "nameTextStyle": { "color": "#fff" }, + "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" }, - ], - "yAxis": [ - { - "type": "value", - "axisLabel": { "formatter": "{value} 人", "color": "#fff" }, - } - ], + "axisLine": {"lineStyle": {"color": "#333"}}, + "splitLine": {"lineStyle": {"color": "rgba(0,0,0,0.1)"}} + }, "series": [ { - "name": "城区入园人数", + "name": "入园总数", "type": "bar", - "data": urban_enroll, - "itemStyle": { "borderRadius": [6, 6, 0, 0] }, + "data": enroll_total, + "itemStyle": { + "color": "#5470c6", + "borderRadius": [4, 4, 0, 0] + }, + "barWidth": "40%" }, { - "name": "镇区入园人数", - "type": "bar", - "data": town_enroll, - "itemStyle": { "borderRadius": [6, 6, 0, 0] }, - }, - { - "name": "乡村入园人数", - "type": "bar", - "data": rural_enroll, - "itemStyle": { "borderRadius": [6, 6, 0, 0] }, - }, - { - "name": "城区在园人数", + "name": "在园总数", "type": "line", - "data": urban_in_school, - "yAxisIndex": 0, - "lineStyle": { "width": 3 }, - "symbolSize": 8, - }, - { - "name": "镇区在园人数", - "type": "line", - "data": town_in_school, - "yAxisIndex": 0, - "lineStyle": { "width": 3 }, - "symbolSize": 8, - }, - { - "name": "乡村在园人数", - "type": "line", - "data": rural_in_school, - "yAxisIndex": 0, - "lineStyle": { "width": 3 }, + "data": in_school_total, + "lineStyle": {"color": "#91cc75", "width": 3}, + "symbol": "circle", "symbolSize": 8, + "itemStyle": {"color": "#91cc75"} } ], + "grid": { + "left": "3%", + "right": "4%", + "bottom": "3%", + "containLabel": True + } } return option \ No newline at end of file diff --git a/Model/__pycache__/RuYuanZaiYuanCount.cpython-310.pyc b/Model/__pycache__/RuYuanZaiYuanCount.cpython-310.pyc index fa50296..ed43353 100644 Binary files a/Model/__pycache__/RuYuanZaiYuanCount.cpython-310.pyc and b/Model/__pycache__/RuYuanZaiYuanCount.cpython-310.pyc differ diff --git a/static/preschool_education.html b/static/preschool_education.html index 570a7ca..32536d0 100644 --- a/static/preschool_education.html +++ b/static/preschool_education.html @@ -3,26 +3,73 @@ - 学前教育数据测试 + 云南省学前教育数据 +
-

学前教育招生人数统计

-
+

云南省学前教育人数统计

+ +
+
+ + + +
+
+ +