'commit'
This commit is contained in:
@@ -52,13 +52,23 @@ 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) # 转换为万人
|
||||
|
||||
# 添加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 = {
|
||||
# "title": {
|
||||
# "text": "云南省学前教育人数统计",
|
||||
# "left": "center",
|
||||
# "textStyle": {"color": "#333"}
|
||||
# },
|
||||
"tooltip": {
|
||||
"trigger": "axis",
|
||||
"axisPointer": {
|
||||
@@ -71,7 +81,7 @@ class RuYuanZaiYuanModel:
|
||||
"borderWidth": 1
|
||||
},
|
||||
"legend": {
|
||||
"data": ["城区", "镇区", "乡村", "总入园数"],
|
||||
"data": ["城区", "镇区", "乡村", "总入园数", "2022年基数(万人)"],
|
||||
"top": 30,
|
||||
"textStyle": {"color": "#333"},
|
||||
"icon": "roundRect",
|
||||
@@ -112,9 +122,9 @@ class RuYuanZaiYuanModel:
|
||||
"nameGap": 30, # 增加名称与轴的间距
|
||||
"axisLabel": {
|
||||
"formatter": "{value} 万人",
|
||||
"color": "#ee6666"
|
||||
"color": "#00a859"
|
||||
},
|
||||
"axisLine": {"show": True, "lineStyle": {"color": "#ee6666"}},
|
||||
"axisLine": {"show": True, "lineStyle": {"color": "#00a859"}}, # 改为绿色
|
||||
"axisTick": {"show": True},
|
||||
"splitLine": {"show": False}
|
||||
}
|
||||
@@ -158,10 +168,25 @@ class RuYuanZaiYuanModel:
|
||||
"type": "line",
|
||||
"yAxisIndex": 1,
|
||||
"data": total_enroll,
|
||||
"lineStyle": {"color": "#ee6666", "width": 3},
|
||||
"lineStyle": {"color": "#00a859", "width": 3}, # 改为绿色
|
||||
"symbol": "circle",
|
||||
"symbolSize": 8,
|
||||
"itemStyle": {"color": "#ee6666"}
|
||||
"itemStyle": {"color": "#00a859"} # 改为绿色
|
||||
},
|
||||
# 添加2022年基数的粉色折线
|
||||
{
|
||||
"name": "2022年基数(万人)",
|
||||
"type": "line",
|
||||
"yAxisIndex": 1,
|
||||
"data": base_2022_line,
|
||||
"lineStyle": {"color": "#ff9e9e", "width": 2, "type": "solid"},
|
||||
"symbol": "circle",
|
||||
"symbolSize": 6,
|
||||
"itemStyle": {"color": "#ff9e9e"},
|
||||
"emphasis": {
|
||||
"focus": "series"
|
||||
},
|
||||
"z": 5 # 确保折线图显示在柱状图之上,但在总入园数折线之下
|
||||
}
|
||||
],
|
||||
"grid": {
|
||||
@@ -211,6 +236,21 @@ class RuYuanZaiYuanModel:
|
||||
calculated_total = (urban_val + town_val + rural_val) / 10000 # 先计算总和再转换为万人
|
||||
total_in_school.append(calculated_total)
|
||||
|
||||
# 添加2022年基数的粉色折线
|
||||
base_year = "2022"
|
||||
# 找到2022年在years中的索引位置
|
||||
base_index = years.index(base_year) if base_year in years else 0
|
||||
# 获取2022年的总在园数作为基数
|
||||
base_value = total_in_school[base_index] if base_index < len(total_in_school) 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 = {
|
||||
"tooltip": {
|
||||
@@ -225,7 +265,7 @@ class RuYuanZaiYuanModel:
|
||||
"borderWidth": 1
|
||||
},
|
||||
"legend": {
|
||||
"data": ["城区", "镇区", "乡村", "总在园数"],
|
||||
"data": ["城区", "镇区", "乡村", "总在园数", "2022年基数(万人)"],
|
||||
"top": 30,
|
||||
"textStyle": {"color": "#333"},
|
||||
"icon": "roundRect",
|
||||
@@ -266,9 +306,9 @@ class RuYuanZaiYuanModel:
|
||||
"nameGap": 30,
|
||||
"axisLabel": {
|
||||
"formatter": "{value} 万人",
|
||||
"color": "#ee6666"
|
||||
"color": "#00a859" # 改为绿色
|
||||
},
|
||||
"axisLine": {"show": True, "lineStyle": {"color": "#ee6666"}},
|
||||
"axisLine": {"show": True, "lineStyle": {"color": "#00a859"}}, # 改为绿色
|
||||
"axisTick": {"show": True},
|
||||
"splitLine": {"show": False}
|
||||
}
|
||||
@@ -312,14 +352,29 @@ class RuYuanZaiYuanModel:
|
||||
"type": "line",
|
||||
"yAxisIndex": 1,
|
||||
"data": total_in_school,
|
||||
"lineStyle": {"color": "#ee6666", "width": 3},
|
||||
"lineStyle": {"color": "#00a859", "width": 3}, # 改为绿色
|
||||
"symbol": "circle",
|
||||
"symbolSize": 8,
|
||||
"itemStyle": {"color": "#ee6666"},
|
||||
"itemStyle": {"color": "#00a859"}, # 改为绿色
|
||||
"emphasis": {
|
||||
"focus": "series"
|
||||
},
|
||||
"z": 10 # 确保折线图显示在最上层
|
||||
},
|
||||
# 添加2022年基数的粉色折线
|
||||
{
|
||||
"name": "2022年基数(万人)",
|
||||
"type": "line",
|
||||
"yAxisIndex": 1,
|
||||
"data": base_2022_line,
|
||||
"lineStyle": {"color": "#ff9e9e", "width": 2, "type": "solid"},
|
||||
"symbol": "circle",
|
||||
"symbolSize": 6,
|
||||
"itemStyle": {"color": "#ff9e9e"},
|
||||
"emphasis": {
|
||||
"focus": "series"
|
||||
},
|
||||
"z": 5 # 确保折线图显示在柱状图之上,但在总在园数折线之下
|
||||
}
|
||||
],
|
||||
"grid": {
|
||||
|
Binary file not shown.
Reference in New Issue
Block a user