'commit'
This commit is contained in:
@@ -68,11 +68,11 @@ class RuYuanZaiYuanModel:
|
||||
else:
|
||||
base_2022_line.append(None) # 2022年之前不显示
|
||||
data = {"xAxis_data": years,
|
||||
"series_data_0": urban_data, # 城区
|
||||
"series_data_1": town_data, # 镇区
|
||||
"series_data_2": rural_data, # 乡村
|
||||
"series_data_3": total_enroll, # 总入园数
|
||||
"series_data_4": base_2022_line # 2022年基数
|
||||
"series_data_0": urban_data, # 城区
|
||||
"series_data_1": town_data, # 镇区
|
||||
"series_data_2": rural_data, # 乡村
|
||||
"series_data_3": total_enroll, # 总入园数
|
||||
"series_data_4": base_2022_line # 2022年基数
|
||||
}
|
||||
return data
|
||||
|
||||
@@ -129,137 +129,14 @@ class RuYuanZaiYuanModel:
|
||||
else:
|
||||
base_2022_line.append(None) # 2022年之前不显示
|
||||
|
||||
# 构建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": ["城区", "镇区", "乡村", "总在园数", "2022年基数(万人)"],
|
||||
"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": 200, # 将左侧Y轴最大值从100修改为200万
|
||||
"interval": 40, # 调整间隔为40万,确保坐标轴上有5个主要刻度(0,40,80,120,160,200)
|
||||
"axisLabel": {
|
||||
"formatter": "{value} 万人",
|
||||
"color": "#333"
|
||||
},
|
||||
"axisLine": {"lineStyle": {"color": "#333"}},
|
||||
"splitLine": {"lineStyle": {"color": "rgba(0,0,0,0.1)"}}
|
||||
},
|
||||
{
|
||||
"type": "value",
|
||||
"name": "总在园数",
|
||||
"min": 0,
|
||||
"max": 320, # 将右侧Y轴最大值从160扩大一倍到320万
|
||||
"interval": 60, # 调整间隔为60万
|
||||
"position": "right",
|
||||
"nameLocation": "end",
|
||||
"nameGap": 30,
|
||||
"axisLabel": {
|
||||
"formatter": "{value} 万人",
|
||||
"color": "#00a859" # 改为绿色
|
||||
},
|
||||
"axisLine": {"show": True, "lineStyle": {"color": "#00a859"}}, # 改为绿色
|
||||
"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": "#00a859", "width": 3}, # 改为绿色
|
||||
"symbol": "circle",
|
||||
"symbolSize": 8,
|
||||
"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": {
|
||||
"left": "3%",
|
||||
"right": "15%", # 稍微增加右侧边距,确保Y轴标签不被截断
|
||||
"bottom": "3%",
|
||||
"containLabel": True
|
||||
}
|
||||
data = {
|
||||
"data1": ["城区", "镇区", "乡村", "总在园数", "2022年基数"],
|
||||
"data2": years,
|
||||
"data3": urban_data,
|
||||
"data4": town_data,
|
||||
"data5": rural_data,
|
||||
"data6": total_in_school,
|
||||
"data7": base_2022_line
|
||||
}
|
||||
return option
|
||||
|
||||
return data
|
||||
|
Reference in New Issue
Block a user