diff --git a/Routes/BigScreen.py b/Routes/BigScreen.py index a9bc1b4..489cf85 100644 --- a/Routes/BigScreen.py +++ b/Routes/BigScreen.py @@ -72,8 +72,8 @@ def generate_population_chart_config(year="2024"): population_data = load_population_data() # 筛选出州市级数据(排除县级数据) - # 正确的格式是 9 位数字,且以 000 结尾但不以 000000 结尾 - cities = [item for item in population_data if len(item["area_code"]) == 9 and item["area_code"].endswith("000") and not item["area_code"].endswith("000000")] + # 正确的格式是9位数字,以000结尾且第5-6位为00(表示州市级) + cities = [item for item in population_data if len(item["area_code"]) == 9 and item["area_code"].endswith("000") and item["area_code"][4:6] == "00"] # 提取城市名称和人口数据 city_names = [city["area_name"] for city in cities] @@ -89,12 +89,19 @@ def generate_population_chart_config(year="2024"): .add_yaxis("城镇人口", urban_populations, stack="stack1") .add_yaxis("农村人口", rural_populations, stack="stack1") .set_global_opts( - title_opts=opts.TitleOpts(title=f"云南省各州市人口分布图({year}年)"), + title_opts=opts.TitleOpts( + title=f"云南省各州市人口分布图({year}年)", + pos_top="1%", # 调整标题位置到顶部1% + pos_left="center" + ), tooltip_opts=opts.TooltipOpts( trigger="axis", axis_pointer_type="shadow" ), - legend_opts=opts.LegendOpts(pos_top="5%"), + legend_opts=opts.LegendOpts( + pos_top="8%", # 调整图例位置到标题下方 + pos_right="5%" + ), datazoom_opts=[opts.DataZoomOpts()], xaxis_opts=opts.AxisOpts( axislabel_opts=opts.LabelOpts(rotate=45) @@ -127,8 +134,8 @@ def generate_urbanization_rate_chart_config(): population_data = load_population_data() # 筛选出州市级数据(排除县级数据) - # 正确的格式是 9 位数字,且以 000 结尾但不以 000000 结尾 - cities = [item for item in population_data if len(item["area_code"]) == 9 and item["area_code"].endswith("000") and not item["area_code"].endswith("000000")] + # 排除省级数据(如云南省530000000)和县级数据,只保留州市级数据 + cities = [item for item in population_data if len(item["area_code"]) == 9 and item["area_code"].endswith("000") and item["area_code"][4:6] == "00" and item["area_code"][2:8] != "000000"] # 提取城市名称和城镇化率数据 city_names = [city["area_name"] for city in cities] @@ -147,9 +154,16 @@ def generate_urbanization_rate_chart_config(): markpoint_opts=opts.MarkPointOpts(data=[opts.MarkPointItem(type_="max")])) line.set_global_opts( - title_opts=opts.TitleOpts(title="云南省各州市城镇化率变化趋势"), + title_opts=opts.TitleOpts( + title="云南省各州市城镇化率变化趋势", + pos_top="1%", # 调整标题位置到顶部1% + pos_left="center" + ), tooltip_opts=opts.TooltipOpts(trigger="axis"), - legend_opts=opts.LegendOpts(pos_top="5%"), + legend_opts=opts.LegendOpts( + pos_top="8%", # 调整图例位置到标题下方 + pos_right="5%" + ), datazoom_opts=[opts.DataZoomOpts()], xaxis_opts=opts.AxisOpts( axislabel_opts=opts.LabelOpts(rotate=45) diff --git a/Routes/__pycache__/BigScreen.cpython-310.pyc b/Routes/__pycache__/BigScreen.cpython-310.pyc index 5afa766..858b390 100644 Binary files a/Routes/__pycache__/BigScreen.cpython-310.pyc and b/Routes/__pycache__/BigScreen.cpython-310.pyc differ diff --git a/static/css/style.css b/static/css/style.css new file mode 100644 index 0000000..3da218b --- /dev/null +++ b/static/css/style.css @@ -0,0 +1,79 @@ +body { + margin: 0; + padding: 20px; + font-family: 'Microsoft YaHei', sans-serif; + background-color: #f5f7fa; +} +.header { + text-align: center; + margin-bottom: 30px; +} +.header h1 { + color: #2c3e50; + margin-bottom: 10px; +} +.chart-container { + width: 100%; + max-width: 1200px; + margin: 0 auto 30px; + background-color: #fff; + border-radius: 8px; + box-shadow: 0 2px 12px rgba(0, 0, 0, 0.1); + padding: 20px; +} +.chart { + width: 100%; + height: 400px; +} +.controls { + margin-bottom: 20px; + text-align: center; +} +.controls select, .controls input { + padding: 8px 12px; + border: 1px solid #ddd; + border-radius: 4px; + margin-right: 10px; +} +.controls button { + padding: 8px 16px; + background-color: #409eff; + color: white; + border: none; + border-radius: 4px; + cursor: pointer; + margin-right: 10px; +} +.controls button:hover { + background-color: #66b1ff; +} +.message { + text-align: center; + color: #666; + margin: 20px 0; +} +.tabs { + display: flex; + margin-bottom: 20px; + border-bottom: 1px solid #ddd; +} +.tab { + padding: 10px 20px; + cursor: pointer; + background-color: #f5f7fa; + border: 1px solid #ddd; + border-bottom: none; + border-radius: 4px 4px 0 0; + margin-right: 5px; +} +.tab.active { + background-color: #fff; + border-bottom: 1px solid #fff; + margin-bottom: -1px; +} +.tab-content { + display: none; +} +.tab-content.active { + display: block; +} \ No newline at end of file diff --git a/static/index.html b/static/index.html index 5a49cda..6a9f4bc 100644 --- a/static/index.html +++ b/static/index.html @@ -4,89 +4,9 @@