diff --git a/Config/Config.py b/Config/Config.py index 5f28244..8b43921 100644 --- a/Config/Config.py +++ b/Config/Config.py @@ -1 +1,5 @@ -EXCEL_PATH=r'D:\dsWork\YunNanProject\Doc\数据库-2015-2024-v2.xlsx' \ No newline at end of file +# 数据库 +EXCEL_PATH = r'D:\dsWork\YunNanProject\Doc\数据库-2015-2024-v2.xlsx' + +# Echarts的静态资源路径 +ONLINE_HOST = "https://gcore.jsdelivr.net/npm/echarts@6.0.0/dist/" diff --git a/Config/__pycache__/Config.cpython-310.pyc b/Config/__pycache__/Config.cpython-310.pyc index 205bedf..de93dd9 100644 Binary files a/Config/__pycache__/Config.cpython-310.pyc and b/Config/__pycache__/Config.cpython-310.pyc differ diff --git a/Model/RenkouModel.py b/Model/RenkouModel.py index 7c54d12..6fc2a16 100644 --- a/Model/RenkouModel.py +++ b/Model/RenkouModel.py @@ -1,20 +1,18 @@ import json -import os + from pyecharts import options as opts from pyecharts.charts import Bar, Line from pyecharts.globals import CurrentConfig -# 配置使用自定义的ECharts路径 -CurrentConfig.ONLINE_HOST = "https://gcore.jsdelivr.net/npm/echarts@6.0.0/dist/" +from Config.Config import ONLINE_HOST +CurrentConfig.ONLINE_HOST = ONLINE_HOST class RenkouModel: @staticmethod def load_population_data(): try: # 获取当前文件所在目录的父目录,然后找到Data文件夹 - current_dir = os.path.dirname(os.path.abspath(__file__)) - project_root = os.path.dirname(current_dir) # 修正路径计算,只需要上一级目录 - data_path = os.path.join(project_root, "Data", "RenKou.json") + data_path = "./Data/RenKou.json" with open(data_path, "r", encoding="utf-8") as f: data = json.load(f) @@ -27,10 +25,8 @@ class RenkouModel: def generate_population_chart_config(year="2024"): # 加载人口数据 population_data = RenkouModel.load_population_data() - # 筛选出州市级数据 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] total_populations = [city["total_population"].get(year, 0) for city in cities] diff --git a/Model/__pycache__/RenkouModel.cpython-310.pyc b/Model/__pycache__/RenkouModel.cpython-310.pyc index f63dc9d..7346ab3 100644 Binary files a/Model/__pycache__/RenkouModel.cpython-310.pyc and b/Model/__pycache__/RenkouModel.cpython-310.pyc differ