Merge branch 'main' of http://10.10.14.176:3000/huanghai/YunNanProject
This commit is contained in:
@@ -18,3 +18,4 @@ async def get_preschool_education_chart_config():
|
|||||||
async def get_preschool_in_school_chart_config():
|
async def get_preschool_in_school_chart_config():
|
||||||
return RuYuanZaiYuanModel.generate_in_school_education_config()
|
return RuYuanZaiYuanModel.generate_in_school_education_config()
|
||||||
|
|
||||||
|
|
||||||
|
Binary file not shown.
BIN
Doc/全省(城镇乡3分)自动计算模板0415 copy(1).xlsx
Normal file
BIN
Doc/全省(城镇乡3分)自动计算模板0415 copy(1).xlsx
Normal file
Binary file not shown.
@@ -28,145 +28,46 @@ class RuYuanZaiYuanModel:
|
|||||||
@staticmethod
|
@staticmethod
|
||||||
def generate_preschool_education_config():
|
def generate_preschool_education_config():
|
||||||
# 获取学前教育相关数据
|
# 获取学前教育相关数据
|
||||||
enrollment_data, in_school_data = RuYuanZaiYuanModel.load_student_data()
|
# enrollment_data, in_school_data = RuYuanZaiYuanModel.load_student_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) # 转换为万人
|
||||||
|
|
||||||
# 提取云南省级数据
|
xAxis = ["2019", "2020", "2021", "2022", "2023", "2024", "2025", "2026"]
|
||||||
yunnan_enroll = next((item for item in enrollment_data if item["area_name"] == "云南省"), None)
|
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]
|
||||||
if not yunnan_enroll:
|
series_data_3 = [2.4, 5.2, 8.0, 25.4, 27.7, 73.7, 155.6]
|
||||||
return {}
|
series_data_4 = [2.0, 2.2, 3.3, 4.5, 6.3, 10.2, 20.3]
|
||||||
|
line_data = [2.0, 2.2, 3.3, 4.5, 6.3, 10.2, 20.3]
|
||||||
# 提取年份数据(2015-2024)
|
data = {"xAxis": xAxis,
|
||||||
years = [str(year) for year in range(2015, 2025)]
|
"series_data_1": series_data_1,
|
||||||
|
"series_data_2": series_data_2,
|
||||||
# 构建学前教育数据
|
"series_data_3": series_data_3,
|
||||||
urban_data = [] # 城区数据
|
"series_data_4": series_data_4,
|
||||||
town_data = [] # 镇区数据
|
"line_data": line_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"}
|
|
||||||
}
|
}
|
||||||
],
|
return data
|
||||||
"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
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def generate_in_school_education_config():
|
def generate_in_school_education_config():
|
||||||
|
Binary file not shown.
Reference in New Issue
Block a user