diff --git a/README.md b/README.md index 820ed560b96697c1ccb89e8fd9f588e27829489d..7a32bacac7d29478b680832b3a39c0c55b2bb3fa 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,10 @@ library_pyecharts具有体积小、易扩展、易使用等特点,方便开发人员专注业务层面的逻辑开发,轻松实现多角度的数据展现与分析 -![Image text](https://gitee.com/esplets/library-pyecharts/raw/12.0/static/img/example.jpg) +![Image text](https://gitee.com/esplets/library-pyecharts/raw/12.0/static/img/example0.jpg) + +![Image text](https://gitee.com/esplets/library-pyecharts/raw/12.0/static/img/example1.png) + #### 软件架构 diff --git a/controllers/echarts.py b/controllers/echarts.py index 247971da1831ed8ae83c37c693847620fcf13c0c..52e4f4bc003a06c866b4c497a50df33f68c868f8 100755 --- a/controllers/echarts.py +++ b/controllers/echarts.py @@ -3,7 +3,9 @@ import json import random from pyecharts.charts import Bar from pyecharts import options as opts -from pyecharts.globals import ThemeType +from pyecharts.charts import Line +from pyecharts.charts import Pie +from pyecharts.faker import Faker import logging @@ -35,11 +37,10 @@ def bar1_base(): def bar3_base(): c = ( - Bar(init_opts=opts.InitOpts(theme=ThemeType.WALDEN)) - .add_xaxis(["衬衫", "羊毛衫", "雪纺衫", "裤子", "高跟鞋", "袜子"]) - .add_yaxis("商家A", [5, 20, 36, 10, 75, 90]) - .add_yaxis("商家B", [15, 6, 45, 20, 35, 66]) - .set_global_opts(title_opts=opts.TitleOpts(title="主标题", subtitle="副标题")) + Pie() + .add("", [list(z) for z in zip(Faker.choose(), Faker.values())]) + .set_global_opts(title_opts=opts.TitleOpts(title="Pie-基本示例")) + .set_series_opts(label_opts=opts.LabelOpts(formatter="{b}: {c}")) .dump_options_with_quotes() ) return c @@ -56,12 +57,28 @@ def bar2_base(): def bar4_base(): + x_data = ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"] + y_data = [820, 932, 901, 934, 1290, 1330, 1320] + c = ( - Bar(init_opts=opts.InitOpts(theme=ThemeType.LIGHT)) - .add_xaxis(["衬衫", "羊毛衫", "雪纺衫", "裤子", "高跟鞋", "袜子"]) - .add_yaxis("商家A", [5, 20, 36, 10, 75, 90]) - .add_yaxis("商家B", [15, 6, 45, 20, 35, 66]) - .set_global_opts(title_opts=opts.TitleOpts(title="主标题", subtitle="副标题")) + Line() + .set_global_opts( + tooltip_opts=opts.TooltipOpts(is_show=False), + xaxis_opts=opts.AxisOpts(type_="category"), + yaxis_opts=opts.AxisOpts( + type_="value", + axistick_opts=opts.AxisTickOpts(is_show=True), + splitline_opts=opts.SplitLineOpts(is_show=True), + ), + ) + .add_xaxis(xaxis_data=x_data) + .add_yaxis( + series_name="", + y_axis=y_data, + symbol="emptyCircle", + is_symbol_show=True, + label_opts=opts.LabelOpts(is_show=False), + ) .dump_options_with_quotes() ) return c diff --git a/static/img/example.jpg b/static/img/example0.jpg similarity index 100% rename from static/img/example.jpg rename to static/img/example0.jpg diff --git a/static/img/example1.png b/static/img/example1.png new file mode 100644 index 0000000000000000000000000000000000000000..24f462a4d2730230517373bd45f03899d5cbc9bd Binary files /dev/null and b/static/img/example1.png differ