-
Notifications
You must be signed in to change notification settings - Fork 4
Description
系统:Win10
IDE:pycharm
python版本:3.6+
pyecharts版本==1.5.1
snapshot-phantomjs==0.0.3
官方示例的代码如下:
`from pyecharts import options as opts
from pyecharts.charts import Bar
from pyecharts.render import make_snapshot
from snapshot_phantomjs import 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
make_snapshot(snapshot, bar_chart().render(), "bar0.png")`
产生的报错信息如下:
Traceback (most recent call last):
File "F:/工程/Python/chap02/chart1.py", line 24, in
make_snapshot(snapshot, 'snapshot.html', 'bar1.png')
File "F:\工程\Python\chap02\venv\lib\site-packages\pyecharts\render\snapshot.py", line 39, in make_snapshot
raise OSError(content_array)
OSError: ["ReferenceError: Can't find variable: echarts\n\n undefined:1\nnull\n"]
首先 bar_chart().render() 是可以运行渲染出html在网页中渲染成功的,但是后续这个函数报错我也不知道如何解决了
我通过谷歌查找了一下解决方案仍然没有解决,希望作者能够回复我一下。