'commit'
This commit is contained in:
@@ -51,11 +51,7 @@ class RuYuanZaiYuanModel:
|
||||
# 计算总和作为总入园数,而非使用文件中的total字段
|
||||
calculated_total = enroll_data.get("urban", 0) + enroll_data.get("town", 0) + enroll_data.get("rural", 0)
|
||||
total_enroll.append(calculated_total / 10000) # 转换为万人
|
||||
# print(f"{year}年城区入园数: {enroll_data.get('urban', 0)}")
|
||||
# print(f"{year}年镇区入园数: {enroll_data.get('town', 0)}")
|
||||
# print(f"{year}年乡村入园数: {enroll_data.get('rural', 0)}")
|
||||
# print(f"{year}年入园数: {calculated_total}")
|
||||
|
||||
|
||||
# 构建ECharts配置
|
||||
option = {
|
||||
# "title": {
|
||||
@@ -109,7 +105,7 @@ class RuYuanZaiYuanModel:
|
||||
"type": "value",
|
||||
"name": "总入园数",
|
||||
"min": 0,
|
||||
"max": 140, # 增加最大值以留出更多空间
|
||||
"max": 140,
|
||||
"interval": 20,
|
||||
"position": "right",
|
||||
"nameLocation": "end", # 将名称放在轴末端
|
||||
@@ -175,4 +171,150 @@ class RuYuanZaiYuanModel:
|
||||
"containLabel": True
|
||||
}
|
||||
}
|
||||
return option
|
||||
|
||||
@staticmethod
|
||||
def generate_in_school_education_config():
|
||||
# 获取学前教育相关数据
|
||||
enrollment_data, in_school_data = RuYuanZaiYuanModel.load_student_data()
|
||||
|
||||
# 提取云南省级数据
|
||||
yunnan_in_school = next((item for item in in_school_data if item["area_name"] == "云南省"), None)
|
||||
|
||||
if not yunnan_in_school:
|
||||
return {}
|
||||
|
||||
# 提取年份数据(2015-2024)
|
||||
years = [str(year) for year in range(2015, 2025)]
|
||||
|
||||
# 构建学前教育数据
|
||||
urban_data = [] # 城区数据
|
||||
town_data = [] # 镇区数据
|
||||
rural_data = [] # 乡村数据
|
||||
total_in_school = [] # 总在园数
|
||||
|
||||
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) # 转换为万人
|
||||
|
||||
# 构建ECharts配置
|
||||
option = {
|
||||
"tooltip": {
|
||||
"trigger": "axis",
|
||||
"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": ["城区", "镇区", "乡村", "总在园数"],
|
||||
"top": 30,
|
||||
"textStyle": {"color": "#333"},
|
||||
"icon": "roundRect",
|
||||
"itemWidth": 12,
|
||||
"itemHeight": 12
|
||||
},
|
||||
"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)"}}
|
||||
},
|
||||
{
|
||||
"type": "value",
|
||||
"name": "总在园数",
|
||||
"min": 0,
|
||||
"max": 140,
|
||||
"interval": 20,
|
||||
"position": "right",
|
||||
"nameLocation": "end",
|
||||
"nameGap": 30,
|
||||
"axisLabel": {
|
||||
"formatter": "{value} 万人",
|
||||
"color": "#ee6666"
|
||||
},
|
||||
"axisLine": {"show": True, "lineStyle": {"color": "#ee6666"}},
|
||||
"axisTick": {"show": True},
|
||||
"splitLine": {"show": False}
|
||||
}
|
||||
],
|
||||
"series": [
|
||||
{
|
||||
"name": "城区",
|
||||
"type": "bar",
|
||||
"data": urban_data,
|
||||
"itemStyle": {
|
||||
"color": "#5470c6",
|
||||
"borderRadius": [6, 6, 0, 0]
|
||||
},
|
||||
"barWidth": "25%",
|
||||
"barGap": "-10%"
|
||||
},
|
||||
{
|
||||
"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",
|
||||
"yAxisIndex": 1,
|
||||
"data": total_in_school,
|
||||
"lineStyle": {"color": "#ee6666", "width": 3},
|
||||
"symbol": "circle",
|
||||
"symbolSize": 8,
|
||||
"itemStyle": {"color": "#ee6666"}
|
||||
}
|
||||
],
|
||||
"grid": {
|
||||
"left": "3%",
|
||||
"right": "8%",
|
||||
"bottom": "3%",
|
||||
"containLabel": True
|
||||
}
|
||||
}
|
||||
return option
|
Reference in New Issue
Block a user