1、生成的echart图,使用本地的echartjs文件;

main
simonyan 6 months ago
parent 53217400ec
commit f131114d58

@ -128,7 +128,11 @@ def main():
# 将结果拷贝的目标目录下 # 将结果拷贝的目标目录下
shutil.copytree(outputDir, outputDistDir) shutil.copytree(outputDir, outputDistDir)
# 将2个js文件拷贝到output目录下
echartjsFilePath = "../../resources/echarts.min.js"
worldjsFilePath = "../../resources/world.js"
shutil.copy(echartjsFilePath, os.path.join(outputDistDir, os.path.basename(echartjsFilePath)))
shutil.copy(worldjsFilePath, os.path.join(outputDistDir, os.path.basename(worldjsFilePath)))
if __name__ == "__main__": if __name__ == "__main__":
try: try:

@ -42,10 +42,14 @@ def rendOutputGeo(outputFilePath: str):
# 修改html支持全屏和自适应 # 修改html支持全屏和自适应
with open(htmlFilePath, "r") as file: with open(htmlFilePath, "r") as file:
data = file.read() data = file.read()
# 设置全屏大小 # 1、设置全屏大小
# 2、将在线js文件替换为本地js文件
data = data.replace( data = data.replace(
"</head>", "</head>",
"<style>html, body{width: 100%;height: 100%;margin:0px;}</style>\n</head>", "<style>html, body{width: 100%;height: 100%;margin:0px;}</style>\n</head>",
) ).replace(
"https://assets.pyecharts.org/assets/v5/echarts.min.js", "echarts.min.js").replace(
"https://assets.pyecharts.org/assets/v5/maps/world.js","world.js")
with open(htmlFilePath, "w", encoding="utf-8") as file: with open(htmlFilePath, "w", encoding="utf-8") as file:
file.write(data) file.write(data)

@ -213,7 +213,9 @@ def handleOutput(lon: float, lat: float, index: int):
data = data.replace( data = data.replace(
"</head>", "</head>",
"<style>html, body{width: 100%;height: 100%;margin:0px;}</style>\n</head>", "<style>html, body{width: 100%;height: 100%;margin:0px;}</style>\n</head>",
) ).replace(
"https://assets.pyecharts.org/assets/v5/echarts.min.js", "echarts.min.js").replace(
"https://assets.pyecharts.org/assets/v5/maps/world.js","world.js")
with open(f"output/{index}_scatter_chart.html", "w", encoding="utf-8") as file: with open(f"output/{index}_scatter_chart.html", "w", encoding="utf-8") as file:
file.write(data) file.write(data)
@ -286,7 +288,9 @@ def renderReflectance(pointList: list, valueList: list):
data = data.replace( data = data.replace(
"</head>", "</head>",
"<style>html, body{width: 100%;height: 100%;margin:0px;}</style>\n</head>", "<style>html, body{width: 100%;height: 100%;margin:0px;}</style>\n</head>",
) ).replace(
"https://assets.pyecharts.org/assets/v5/echarts.min.js", "echarts.min.js").replace(
"https://assets.pyecharts.org/assets/v5/maps/world.js","world.js")
with open(htmlFilePath, "w", encoding="utf-8") as file: with open(htmlFilePath, "w", encoding="utf-8") as file:
file.write(data) file.write(data)
pass pass
@ -513,6 +517,12 @@ def main():
globalUtils.rmPath(projectOutputDir) globalUtils.rmPath(projectOutputDir)
# 将结果拷贝到目的目录 # 将结果拷贝到目的目录
shutil.copytree("output", projectOutputDir) shutil.copytree("output", projectOutputDir)
# 将2个js文件拷贝到output目录下
echartjsFilePath = "../../resources/echarts.min.js"
worldjsFilePath = "../../resources/world.js"
shutil.copy(echartjsFilePath, os.path.join(projectOutputDir, os.path.basename(echartjsFilePath)))
shutil.copy(worldjsFilePath, os.path.join(projectOutputDir, os.path.basename(worldjsFilePath)))
return return

Loading…
Cancel
Save