pyecharts 通过本地加载js文件
程序员文章站
2022-03-03 14:33:30
...
参考链接,博主写的很好原博文链接
条形图
from pyecharts.charts import Bar
from pyecharts import options as opts
from pyecharts.globals import ThemeType
bar = (
Bar(
init_opts=opts.InitOpts(
theme=ThemeType.LIGHT,
js_host="./js/" #本地js路径
)
)
.add_xaxis(["衬衫", "羊毛衫", "雪纺衫", "裤子", "高跟鞋", "袜子"])
.add_yaxis("",[5, 20, 36, 10, 75, 90],category_gap="50%")
.set_global_opts(
title_opts=opts.TitleOpts(title="主标题", subtitle="副标题"),
toolbox_opts=opts.ToolboxOpts(),
legend_opts=opts.LegendOpts(is_show=False),
yaxis_opts=opts.AxisOpts(name="y轴标签"),
xaxis_opts=opts.AxisOpts(name="x轴标签")
)
.set_series_opts(
label_opts=opts.LabelOpts(is_show=False),
markpoint_opts=opts.MarkPointOpts(
data=[
opts.MarkPointItem(type_="max",name="最大值"),
opts.MarkPointItem(type_="min",name="最小值")
]
)
)
)
bar.render("bar.html")
扇形图
from pyecharts import options as opt
from pyecharts.charts import Pie
from pyecharts.globals import ThemeType
pie = (
Pie(
init_opts=opt.InitOpts(
page_title="OnlineExam-Analyse",
theme=ThemeType.LIGHT,
js_host="./js/"
)
)
.add("", [('可乐',31), ('雪碧',84), ('橙汁',142), ('绿茶',82), ('奶茶',110)], radius=['40%','55%'])
# .set_colors(["red", "orange", "blue", "purple"])
.set_global_opts(
title_opts=opt.TitleOpts(title="主标题", subtitle="副标题"),
toolbox_opts=opt.ToolboxOpts()
)
.set_series_opts(label_opts=opt.LabelOpts(['可乐','雪碧','橙汁','绿茶','奶茶']))
)
pie.render("pie.html")
上一篇: 数据库安装Ubuntu下Tomcat连接MySql数据库
下一篇: ubuntu安装mysql数据库
推荐阅读