'commit'
This commit is contained in:
@@ -1 +1,5 @@
|
||||
EXCEL_PATH=r'D:\dsWork\YunNanProject\Doc\数据库-2015-2024-v2.xlsx'
|
||||
# 数据库
|
||||
EXCEL_PATH = r'D:\dsWork\YunNanProject\Doc\数据库-2015-2024-v2.xlsx'
|
||||
|
||||
# Echarts的静态资源路径
|
||||
ONLINE_HOST = "https://gcore.jsdelivr.net/npm/echarts@6.0.0/dist/"
|
||||
|
Binary file not shown.
@@ -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]
|
||||
|
Binary file not shown.
Reference in New Issue
Block a user