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.

45 lines
1.3 KiB

from pyecharts import options as opts
from pyecharts.charts import Bar
# 申请数据库连接
from Util.MysqlClient import MysqlClient
class xmdwqk:
def __init__(self):
pass
def getOptions(self):
# 声明数据库连接
db = MysqlClient()
# 分类名称
LeiXing = []
sql = "select bxlx_name from t_gtzz_dm_bxlx where b_use=1"
for x in db.findList(sql)[1]:
LeiXing.append(x['bxlx_name'])
# 查询sql
# 城区
CityArea = []
sql = "select count from t_gtzz_tj_dwqk where cxlx_name='城区'"
for x in db.findList(sql)[1]:
CityArea.append(x["count"])
# 镇区
ZhenArea = []
sql = "select count from t_gtzz_tj_dwqk where cxlx_name='乡镇'"
for x in db.findList(sql)[1]:
ZhenArea.append(x["count"])
c = (
Bar()
.add_xaxis(LeiXing)
.add_yaxis("城区", CityArea)
.add_yaxis("乡镇", ZhenArea)
.set_global_opts(title_opts=opts.TitleOpts(title="项目单位情况", subtitle=""))
.dump_options()
)
# 关闭数据库
db.close()
return c