diff --git a/Model/RuYuanZaiYuanCountModel.py b/Model/RuYuanZaiYuanCountModel.py index 9cef03d..f697b7f 100644 --- a/Model/RuYuanZaiYuanCountModel.py +++ b/Model/RuYuanZaiYuanCountModel.py @@ -54,7 +54,6 @@ class RuYuanZaiYuanModel: # calculated_total = enroll_data.get("urban", 0) + enroll_data.get("town", 0) + enroll_data.get("rural", 0) # total_enroll.append(calculated_total / 10000) # 转换为万人 -<<<<<<< HEAD xAxis = ["2019", "2020", "2021", "2022", "2023", "2024", "2025", "2026"] series_data_1 = [2.0, 4.9, 7.0, 23.2, 25.6, 76.7, 135.6] series_data_2 = [2.6, 5.9, 9.0, 26.4, 28.7, 70.7, 175.6] @@ -69,145 +68,6 @@ class RuYuanZaiYuanModel: "line_data": line_data } return data -======= - # 提取云南省级数据 - yunnan_enroll = next((item for item in enrollment_data if item["area_name"] == "云南省"), None) - - if not yunnan_enroll: - return {} - - # 提取年份数据(2015-2024) - years = [str(year) for year in range(2015, 2025)] - - # 构建学前教育数据 - urban_data = [] # 城区数据 - town_data = [] # 镇区数据 - rural_data = [] # 乡村数据 - total_enroll = [] # 总入园数 - - for year in years: - enroll_data = yunnan_enroll["education_data"]["preschool"].get(year, {}) - 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字段 - calculated_total = enroll_data.get("urban", 0) + enroll_data.get("town", 0) + enroll_data.get("rural", 0) - total_enroll.append(calculated_total / 10000) # 转换为万人 - - # 添加2022年基数的粉色折线 - base_year = "2022" - # 找到2022年在years中的索引位置 - base_index = years.index(base_year) if base_year in years else 0 - # 获取2022年的总入园数作为基数 - base_value = total_enroll[base_index] if base_index < len(total_enroll) else 0 - # 创建2022年基数折线数据(2022-2024年) - base_2022_line = [] - for i, year in enumerate(years): - # 只在2022年及之后显示基数线 - if i >= base_index: - base_2022_line.append(base_value) - else: - base_2022_line.append(None) # 2022年之前不显示 - - # 构建ECharts配置 - option = { - "grid": { - "left": 0, - "right": 0, - "top": 40, - "bottom": 10, - "containLabel": True, - }, - "textStyle": { - "color": "#fff", - }, - "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 - }, - "legend": { - "data": ["城区", "镇区", "乡村", "总入园数", "2022年基数"], - "top": 0, - "textStyle": {"color": "#fff"}, - "icon": "roundRect", - "itemWidth": 12, - "itemHeight": 12 - }, - "xAxis": [ - { - "type": "category", - "data": years, - "axisPointer": {"type": "shadow"}, - "axisLine": {"lineStyle": {"color": "#fff"}}, - "axisLabel": {"color": "#fff"}, - "nameTextStyle": {"color": "#fff"} - } - ], - "yAxis": [ - { - "type": "value", - - "axisLabel": { - "formatter": "{value}" - , "color": "#fff" - } - }, - { - "type": "value", - - "axisLabel": {"formatter": "{value}", "color": "#fff"}, - }, - - ], - "series": [ - { - "name": "城区", - "type": "bar", - "data": urban_data, - "itemStyle": { - "borderRadius": [6, 6, 0, 0], - } - }, - { - "name": "镇区", - "type": "bar", - "data": town_data, - "itemStyle": { - "borderRadius": [6, 6, 0, 0], - }, - }, - { - "name": "乡村", - "type": "bar", - "data": rural_data, - "itemStyle": { - "borderRadius": [6, 6, 0, 0] - }, - }, - { - "name": "总入园数", - "type": "line", - "yAxisIndex": 1, - "data": total_enroll - }, - # 添加2022年基数的粉色折线 - { - "name": "2022年基数", - "type": "line", - "yAxisIndex": 1, - "data": base_2022_line - } - ] - } - return option ->>>>>>> 40a7a8fb7a0a8fc3ffc2f362b46acfceda2a1602 @staticmethod def generate_in_school_education_config(): diff --git a/Model/__pycache__/RuYuanZaiYuanCountModel.cpython-310.pyc b/Model/__pycache__/RuYuanZaiYuanCountModel.cpython-310.pyc index 53b2301..0440c50 100644 Binary files a/Model/__pycache__/RuYuanZaiYuanCountModel.cpython-310.pyc and b/Model/__pycache__/RuYuanZaiYuanCountModel.cpython-310.pyc differ