From 68bc79452f192a6d1edf3e4245ab9d96d6b36e93 Mon Sep 17 00:00:00 2001 From: HuangHai <10402852@qq.com> Date: Wed, 10 Sep 2025 15:01:32 +0800 Subject: [PATCH] 'commit' --- Test/TestEcharts.py | 39 +++++ Test/__init__.py | 0 Test/bar_markline_custom.html | 286 ++++++++++++++++++++++++++++++++++ Tools/Full_Line.py | 0 4 files changed, 325 insertions(+) create mode 100644 Test/TestEcharts.py create mode 100644 Test/__init__.py create mode 100644 Test/bar_markline_custom.html create mode 100644 Tools/Full_Line.py diff --git a/Test/TestEcharts.py b/Test/TestEcharts.py new file mode 100644 index 0000000..0beca7d --- /dev/null +++ b/Test/TestEcharts.py @@ -0,0 +1,39 @@ +# pip install pyecharts +import pyecharts +import json + +#print(pyecharts.__version__) +from pyecharts import options as opts +from pyecharts.charts import Bar +from pyecharts.faker import Faker +from pyecharts.globals import CurrentConfig + +# 配置使用自定义的 ECharts 路径 +CurrentConfig.ONLINE_HOST = "https://gcore.jsdelivr.net/npm/echarts@6.0.0/dist/" + +c = ( + Bar() + .add_xaxis(Faker.choose()) + .add_yaxis("商家A", Faker.values()) + .add_yaxis("商家B", Faker.values()) + .set_global_opts(title_opts=opts.TitleOpts(title="Bar-MarkLine(自定义)")) + .set_series_opts( + label_opts=opts.LabelOpts(is_show=False), + markline_opts=opts.MarkLineOpts( + data=[opts.MarkLineItem(y=50, name="yAxis=50")] + ), + ) +) + +# 获取图表的选项配置 +options = c.get_options() + +# 将选项转换为 JSON 字符串 +json_str = json.dumps(options, indent=2, ensure_ascii=False) + +# 输出 JSON 字符串 +print(json_str) + +# 可选:将 JSON 保存到文件 +with open("bar_chart_config.json", "w", encoding="utf-8") as f: + f.write(json_str).render("bar_markline_custom.html")) diff --git a/Test/__init__.py b/Test/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/Test/bar_markline_custom.html b/Test/bar_markline_custom.html new file mode 100644 index 0000000..8e2dfeb --- /dev/null +++ b/Test/bar_markline_custom.html @@ -0,0 +1,286 @@ + + + + + Awesome-pyecharts + + + + + +
+ + + diff --git a/Tools/Full_Line.py b/Tools/Full_Line.py new file mode 100644 index 0000000..e69de29