Description
from pyecharts import options as opts
from pyecharts.charts import Gauge
from pyecharts.render import make_snapshot
from snapshot_phantomjs import snapshot
import os
def bar_chart():
c = (
Gauge(init_opts=opts.InitOpts(bg_color="white"))
.add(
"",
[("AA", 40.4)], title_label_opts=opts.LabelOpts(
font_size=22, font_weight='700', color="#00BEE6", font_family="Microsoft YaHei"),
split_number=10,
axisline_opts=opts.AxisLineOpts(
linestyle_opts=opts.LineStyleOpts(
color=[[0.2, "#67e0e3"], [0.8, "#37a2da"], [1, "#fd666d"]], width=30
)
),
detail_label_opts=opts.LabelOpts(formatter="{value}%"),
)
.set_global_opts(
title_opts=opts.TitleOpts(),
legend_opts=opts.LegendOpts(is_show=False),
)
)
make_snapshot(snapshot, c.render(), "TEST.png",is_remove_html=False)
if name == 'main':
bar_chart()
在不连网的情况下,在win10系统下上述代码会报错
_### _File "C:\software\anaconda\lib\site-packages\pyecharts\render\snapshot.py", line 45, in make_snapshot
raise OSError(content_array)
OSError: ["ReferenceError: Can't find variable: echarts\n\n file:///H:/Python/python/render.html:12 in global code\nReferenceError: Can't find variable: echarts\n\n undefined:1\nnull\n"]__
怎么正确在Gauge(init_opts=opts.InitOpts(bg_color="white"))中opts_InitOpts添加js_host使得代码能运行?