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.
37 lines
1.0 KiB
37 lines
1.0 KiB
from pyecharts import options as opts
|
|
from pyecharts.charts import Pie
|
|
|
|
from Util.MysqlClient import MysqlClient
|
|
|
|
|
|
class xmlxfb:
|
|
def __init__(self):
|
|
pass
|
|
|
|
def getOptions(self):
|
|
# 申请数据库连接
|
|
db = MysqlClient()
|
|
sql = "select xmlb,count from t_gtzz_tj_lxfb"
|
|
keys = []
|
|
values = []
|
|
for x in db.findList(sql)[1]:
|
|
keys.append(x['xmlb'])
|
|
values.append(x['count'])
|
|
|
|
c = (
|
|
Pie()
|
|
.add(
|
|
"",
|
|
[list(z) for z in zip(keys, values)],
|
|
radius=["40%", "75%"],
|
|
)
|
|
.set_global_opts(
|
|
title_opts=opts.TitleOpts(title="项目类型分布"),
|
|
legend_opts=opts.LegendOpts(orient="vertical", pos_top="15%", pos_left="2%"),
|
|
)
|
|
.set_series_opts(label_opts=opts.LabelOpts(formatter="{b}: {c}"))
|
|
.dump_options()
|
|
)
|
|
db.close()
|
|
return c
|