from snapshot_selenium import snapshot as driver from pyecharts import options as opts from pyecharts.charts import Bar from pyecharts.render import make_snapshot def bar_chart() -> Bar: c = ( Bar() .add_xaxis(["衬衫", "毛衣", "领带", "裤子", "风衣", "高跟鞋", "袜子"]) .add_yaxis("商家A", [114, 55, 27, 101, 125, 27, 105]) .add_yaxis("商家B", [57, 134, 137, 129, 145, 60, 49]) .reversal_axis() .set_series_opts(label_opts=opts.LabelOpts(position="right")) .set_global_opts(title_opts=opts.TitleOpts(title="Bar-测试渲染图片")) ) return c # 输出png文件(用于在ppt中静态展现) make_snapshot(driver, bar_chart().render(), "bar.png") # 输出html(用于在ppt中动态展现) bar_chart().render("bar.html")