Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

在不连网的情况下,在win10系统下,无法将html图片保存为本地图片,怎么正确添加js_host可以正常运行 #49

Open
Kevenyf opened this issue Apr 25, 2022 · 0 comments

Comments

@Kevenyf
Copy link

Kevenyf commented Apr 25, 2022

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使得代码能运行?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant