diff --git a/controllers/echarts.py b/controllers/echarts.py index e90b717602935ee61477aee4ff60c8503ad13e5e..247971da1831ed8ae83c37c693847620fcf13c0c 100755 --- a/controllers/echarts.py +++ b/controllers/echarts.py @@ -3,6 +3,7 @@ import json import random from pyecharts.charts import Bar from pyecharts import options as opts +from pyecharts.globals import ThemeType import logging @@ -12,10 +13,15 @@ _logger = logging.getLogger(__name__) class PyEcharts(http.Controller): @http.route('/pyecharts', auth='public', type='http', cors='*', methods=['POST', 'GET'], csrf=False) def pyecharts(self): - return json.dumps(json.loads(bar_base())) + return json.dumps({ + 'bar1': json.loads(bar1_base()), + 'bar2': json.loads(bar2_base()), + 'bar3': json.loads(bar3_base()), + 'bar4': json.loads(bar4_base()), + }) -def bar_base(): +def bar1_base(): c = ( Bar() .add_xaxis(["衬衫", "羊毛衫", "雪纺衫", "裤子", "高跟鞋", "袜子"]) @@ -25,3 +31,37 @@ def bar_base(): .dump_options_with_quotes() ) return c + + +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="副标题")) + .dump_options_with_quotes() + ) + return c + + +def bar2_base(): + c = ( + Bar() + .add_xaxis(["衬衫", "羊毛衫", "雪纺衫", "裤子", "高跟鞋", "袜子"]) + .add_yaxis("商家A", [5, 20, 36, 10, 75, 90]) + .dump_options_with_quotes() + ) + return c + + +def bar4_base(): + 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="副标题")) + .dump_options_with_quotes() + ) + return c diff --git a/static/img/example.jpg b/static/img/example.jpg new file mode 100644 index 0000000000000000000000000000000000000000..e6e7537a61e70f8541944923aa4b4c63c3309823 Binary files /dev/null and b/static/img/example.jpg differ diff --git a/static/src/xml/load_echarts_bar.xml b/static/src/xml/load_echarts_bar.xml index 715c66e62030cf4568fe7b07b2101ed2f7360374..ec07c0e8abddbc37e0ba5507b778aabfd0ec2272 100755 --- a/static/src/xml/load_echarts_bar.xml +++ b/static/src/xml/load_echarts_bar.xml @@ -2,14 +2,30 @@
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+