You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

119 lines
5.7 KiB

import json
from flask import Flask, redirect, jsonify
from pyecharts import options as opts
from pyecharts.charts import Bar, Pie, Line
app = Flask(__name__)
@app.route('/report/LxBar', methods=['GET'])
def bar():
# 项目单位情况
# LeiXing = ['小学', '初中', '九年一贯制', '高中', '完全中学', '十二年一贯制']
# c = (
# Bar()
# .add_xaxis(LeiXing)
# .add_yaxis("城区", [10, 20, 64, 40, 32, 28],
# itemstyle_opts=opts.ItemStyleOpts(color="#0984e3"))
# .add_yaxis("乡镇", [26, 34, 55, 46, 11, 22],
# itemstyle_opts=opts.ItemStyleOpts(color="#00b894"), gap="0%", category_gap="50%"
# )
# .set_global_opts(
# legend_opts=opts.LegendOpts(textstyle_opts=opts.TextStyleOpts(color="#80828F")),
# xaxis_opts=opts.AxisOpts(
# axisline_opts=opts.AxisLineOpts(linestyle_opts=opts.LineStyleOpts(color="#80828F")),
# axislabel_opts=opts.LabelOpts(rotate=45)),
# yaxis_opts=opts.AxisOpts(
# axisline_opts=opts.AxisLineOpts(linestyle_opts=opts.LineStyleOpts(color="#80828F")),
# splitline_opts=opts.SplitLineOpts(is_show=True,
# linestyle_opts=opts.LineStyleOpts(color="#404040", type_="dashed")))
# )
# .dump_options()
# )
# 项目类型分布
x_data = ["基础条件装备", "学科装备", "信息技术教学装备", "创新教育装备"]
y_data = [188, 168, 226, 135]
c = (
Pie()
.add(
"",
center=["50%", "40%"],
data_pair=[list(z) for z in zip(x_data, y_data)],
radius=["35%", "60%"],
label_opts=opts.LabelOpts(
position="outside",
formatter="{b}: {c} ({d}%)",
color="#80828F"
)
)
.set_colors(["#0984e3", "#d63031", "#00b894", "#fdcb6e"])
.set_global_opts(legend_opts=opts.LegendOpts(textstyle_opts=opts.TextStyleOpts(color="#80828F"),pos_bottom=20))
.dump_options()
)
# 项目进展情况-趋势分布
# LeiXing = ['1月', '2月', '3月', '4月', '5月', '6月', '7月', '8月', '9月', '10月', '11月', '12月']
# c = (
# Line()
# .add_xaxis(LeiXing)
# .add_yaxis("项目立项", [41, 45, 46, 47, 50, 46, 53, 52, 54, 45, 50, 46],
# areastyle_opts=opts.AreaStyleOpts(opacity=0.1, color="#74b9ff"), color="#fdcb6e")
# .add_yaxis("招标采购", [28, 37, 35, 41, 39, 42, 43, 40, 37, 35, 38, 36],
# areastyle_opts=opts.AreaStyleOpts(opacity=0.1, color="#a29bfe"), color="#00b894")
# .add_yaxis("实施验收", [17, 25, 30, 31, 29, 34, 29, 31, 26, 30, 31, 25],
# areastyle_opts=opts.AreaStyleOpts(opacity=0.1, color="#ff7675"), color="#d63031")
# .add_yaxis("项目拨付", [11, 16, 19, 21, 23, 20, 17, 20, 15, 20, 15, 16],
# areastyle_opts=opts.AreaStyleOpts(opacity=0.1, color="#55efc4"), color="#6c5ce7")
# .add_yaxis("项目结束", [5, 7, 11, 15, 12, 13, 8, 9, 5, 7, 10, 4],
# areastyle_opts=opts.AreaStyleOpts(opacity=0.1, color="#ffeaa7"), color="#0984e3")
#
# .set_global_opts(
# legend_opts=opts.LegendOpts(textstyle_opts=opts.TextStyleOpts(color="#80828F")),
# xaxis_opts=opts.AxisOpts(
# axisline_opts=opts.AxisLineOpts(linestyle_opts=opts.LineStyleOpts(color="#80828F"))),
# yaxis_opts=opts.AxisOpts(
# axisline_opts=opts.AxisLineOpts(linestyle_opts=opts.LineStyleOpts(color="#80828F")),
# splitline_opts=opts.SplitLineOpts(is_show=True,
# linestyle_opts=opts.LineStyleOpts(color="#404040", type_="dashed")))
# )
# .dump_options()
# )
# 项目进展情况 - 单位分布
# LeiXing = ['小学', '初中', '九年一贯制', '高中', '完全中学', '十二年一贯制']
# c = (
# Bar()
# .add_xaxis(LeiXing)
# .add_yaxis("项目立项", [10, 20, 25, 26, 18, 12], stack="stack1", color="#fdcb6e")
# .add_yaxis("招标采购", [11, 16, 19, 21, 23, 20], stack="stack1", color="#00b894")
# .add_yaxis("实施验收", [13, 8, 10, 16, 11, 7], stack="stack1", color="#d63031")
# .add_yaxis("项目拨付", [9, 15, 16, 20, 18, 11], stack="stack1", color="#6c5ce7")
# .add_yaxis("项目结束", [5, 7, 11, 15, 12, 13], stack="stack1", color="#0984e3")
# .set_series_opts(label_opts=opts.LabelOpts(is_show=False))
# .set_global_opts(
# legend_opts=opts.LegendOpts(textstyle_opts=opts.TextStyleOpts(color="#80828F")),
# xaxis_opts=opts.AxisOpts(
# axisline_opts=opts.AxisLineOpts(linestyle_opts=opts.LineStyleOpts(color="#80828F"))),
# yaxis_opts=opts.AxisOpts(
# axisline_opts=opts.AxisLineOpts(linestyle_opts=opts.LineStyleOpts(color="#80828F")),
# splitline_opts=opts.SplitLineOpts(is_show=True,
# linestyle_opts=opts.LineStyleOpts(color="#404040", type_="dashed")))
# )
#
# .dump_options()
# )
print(c)
return jsonify(json.loads(c))
def index():
return redirect('/static/index.html')
if __name__ == '__main__':
# 调试环境配置方法
app.run(host='0.0.0.0', port=8888, debug=True)