fang-zeqiang/PyQt_Echarts_GUI

setoption出现了错误

Opened this issue · 13 comments

错误代码:
js: Uncaught ReferenceError: echarts is not defined
js: Uncaught TypeError: Cannot read property 'setOption' of undefined
估计是初始化时出错的,但不知错误在何处!

错误代码:
js: Uncaught ReferenceError: echarts is not defined
js: Uncaught TypeError: Cannot read property 'setOption' of undefined
估计是初始化时出错的,但不知错误在何处!

我之前调试也出现过这种问题,大概率是pyechats的版本问题,我这里使用的是pyecharts 0.5,最新版本是2.0不支持向下兼容,之后会考虑兼容新版本echarts,感谢反馈!

错误代码:
js: Uncaught ReferenceError: echarts is not defined
js: Uncaught TypeError: Cannot read property 'setOption' of undefined
估计是初始化时出错的,但不知错误在何处!
我之前调试也出现过这种问题,大概率是pyechats的版本问题,我这里使用的是pyecharts 0.5,最新版本是2.0不支持向下兼容,之后会考虑兼容新版本echarts,感谢反馈!

====出现同样的问题

pyqt5等必须库的版本能提供下嘛?

错误代码:
js: Uncaught ReferenceError: echarts is not defined
js: Uncaught TypeError: Cannot read property 'setOption' of undefined
估计是初始化时出错的,但不知错误在何处!
我之前调试也出现过这种问题,大概率是pyechats的版本问题,我这里使用的是pyecharts 0.5,最新版本是2.0不支持向下兼容,之后会考虑兼容新版本echarts,感谢反馈!

====出现同样的问题

pyqt5等必须库的版本能提供下嘛?

感谢反馈!
试试重新装一下pyecharts,pip3 install pyecharts==0.5.11
pyqt5 请直接安装 pip3 install PyQt5
我写了个tutorial在Readme.md,看看是否有帮助呢

错误代码:
js: Uncaught ReferenceError: echarts is not defined
js: Uncaught TypeError: Cannot read property 'setOption' of undefined
估计是初始化时出错的,但不知错误在何处!

@fish1512 借用了同事的windows调试,发现是以下几个问题

  1. 需要安装一下以下依赖库
    pip3 install pyecharts_snapshot

  2. 由于windows格式不同,需要在load_url方法下

def load_url(self):
        url = QUrl("file:///D:/PyQt_Echarts_GUI/template.html")
        print(url)
        self.view.load(url)

改一下Url路径url = QUrl("file:///D:/PyQt_Echarts_GUI/template.html")

错误代码:
js: Uncaught ReferenceError: echarts is not defined
js: Uncaught TypeError: Cannot read property 'setOption' of undefined
估计是初始化时出错的,但不知错误在何处!
我之前调试也出现过这种问题,大概率是pyechats的版本问题,我这里使用的是pyecharts 0.5,最新版本是2.0不支持向下兼容,之后会考虑兼容新版本echarts,感谢反馈!

====出现同样的问题
pyqt5等必须库的版本能提供下嘛?

感谢反馈!
试试重新装一下pyecharts,pip3 install pyecharts==0.5.11
pyqt5 请直接安装 pip3 install PyQt5
我写了个tutorial在Readme.md,看看是否有帮助呢

@ViesLink 我借用了电脑调试,用以下方法可以解决你们的问题:

  1. 需要安装一下以下依赖库
    pip3 install pyecharts_snapshot

  2. 由于windows格式不同,需要在load_url方法下

def load_url(self):
        url = QUrl("file:///D:/PyQt_Echarts_GUI/template.html")
        print(url)
        self.view.load(url)

改一下Url路径url = QUrl("file:///D:/PyQt_Echarts_GUI/template.html")

你好,出现以下错误:
TypeError: Object of type LabelOpts is not JSON serializable
错误是从Translator报的。

你好,出现以下错误:
TypeError: Object of type LabelOpts is not JSON serializable
错误是从Translator报的。

具体是哪一行的代码出错呢没有找到LabelOpts,你试试这个https://www.cnblogs.com/tangda/p/11594215.html能不能解决

你好,出现以下错误:
TypeError: Object of type LabelOpts is not JSON serializable
错误是从Translator报的。

具体是哪一行的代码出错呢没有找到LabelOpts,你试试这个https://www.cnblogs.com/tangda/p/11594215.html能不能解决

@fang-zeqiang
我的pyecharts版本是1.9.0,我按照这个版本的要求更改了一些代码,报错就是以下信息,在create_pie里面的TRANSLATOR.translate(pie.options)报错的,下面就是报错信息:

Traceback (most recent call last):
File "D:\2. Python\Winpython64-3.8.3.0\WPy64-3830\python-3.8.3.amd64\lib\site-packages\pyecharts_javascripthon\api.py", line 111, in default
return obj.astype(float).tolist()
AttributeError: 'LabelOpts' object has no attribute 'astype'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "D:\2. Python\Winpython64-3.8.3.0\WPy64-3830\python-3.8.3.amd64\lib\site-packages\pyecharts_javascripthon\api.py", line 115, in default
return obj.astype(str).tolist()
AttributeError: 'LabelOpts' object has no attribute 'astype'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "D:/2. Python/script/1.xiaopeng/PyQt_Echarts_GUI-master/start.py", line 245, in set_options
options = self.get_options()
File "D:/2. Python/script/1.xiaopeng/PyQt_Echarts_GUI-master/start.py", line 265, in get_options
options = self.create_pie(v)
File "D:/2. Python/script/1.xiaopeng/PyQt_Echarts_GUI-master/start.py", line 292, in create_pie
snippet = TRANSLATOR.translate(pie.options)
File "D:\2. Python\Winpython64-3.8.3.0\WPy64-3830\python-3.8.3.amd64\lib\site-packages\pyecharts_javascripthon\api.py", line 127, in translate
option_snippet = json.dumps(options, indent=4, cls=self.json_encoder)
File "D:\2. Python\Winpython64-3.8.3.0\WPy64-3830\python-3.8.3.amd64\lib\json_init_.py", line 234, in dumps
return cls(
File "D:\2. Python\Winpython64-3.8.3.0\WPy64-3830\python-3.8.3.amd64\lib\json\encoder.py", line 201, in encode
chunks = list(chunks)
File "D:\2. Python\Winpython64-3.8.3.0\WPy64-3830\python-3.8.3.amd64\lib\json\encoder.py", line 431, in _iterencode
yield from _iterencode_dict(o, _current_indent_level)
File "D:\2. Python\Winpython64-3.8.3.0\WPy64-3830\python-3.8.3.amd64\lib\json\encoder.py", line 405, in _iterencode_dict
yield from chunks
File "D:\2. Python\Winpython64-3.8.3.0\WPy64-3830\python-3.8.3.amd64\lib\json\encoder.py", line 325, in _iterencode_list
yield from chunks
File "D:\2. Python\Winpython64-3.8.3.0\WPy64-3830\python-3.8.3.amd64\lib\json\encoder.py", line 405, in _iterencode_dict
yield from chunks
File "D:\2. Python\Winpython64-3.8.3.0\WPy64-3830\python-3.8.3.amd64\lib\json\encoder.py", line 438, in _iterencode
o = _default(o)
File "D:\2. Python\Winpython64-3.8.3.0\WPy64-3830\python-3.8.3.amd64\lib\site-packages\pyecharts_javascripthon\api.py", line 118, in default
return super(DefaultJsonEncoder, self).default(obj)
File "D:\2. Python\Winpython64-3.8.3.0\WPy64-3830\python-3.8.3.amd64\lib\json\encoder.py", line 179, in default
raise TypeError(f'Object of type {o.class.name} '
TypeError: Object of type LabelOpts is not JSON serializable

@liuqing5363 如果是版本问题这个恐怕我无法解决,你看看stack overflow上其他人这个报错的解法呢https://stackoverflow.com/questions/56747167/typeerror-object-is-not-json-serializable/56820906

你好,首先非常感谢您的分享。但是我遇到生成图右侧工具栏内下载图片按钮无响应问题(没办法下载绘制的图片),但其他查看数据、更新等按钮功能正常。我在网上寻找了很久并未找打相关解决方案,所以向您前来请教,我的基本环境是pyqt5、python3.8以及pyechart0.5.11。

你好,首先非常感谢您的分享。但是我遇到生成图右侧工具栏内下载图片按钮无响应问题(没办法下载绘制的图片),但其他查看数据、更新等按钮功能正常。我在网上寻找了很久并未找打相关解决方案,所以向您前来请教,我的基本环境是pyqt5、python3.8以及pyechart0.5.11。

通过该网址https://blog.csdn.net/this_is_id/article/details/86688585,在对应page加载下面添加self.view.page().profile().downloadRequested.connect(lambda downloaditem: downloaditem.accept()),可以实现将图片自动保存在本地Downloads,但是不能实现路径文件名自定义。

你好,首先非常感谢您的分享。但是我遇到生成图右侧工具栏内下载图片按钮无响应问题(没办法下载绘制的图片),但其他查看数据、更新等按钮功能正常。我在网上寻找了很久并未找打相关解决方案,所以向您前来请教,我的基本环境是pyqt5、python3.8以及pyechart0.5.11。

@Hellen-master 你好,根据你发的csdn链接以及我以前开发的经验,我是在google上搜索“pyqt5 downloaditem address”,发现在这个博客文章里的内容也许可以帮助到你(如下)

###download file
downloadItem.setSavePageFormat(QWebEngineDownloadItem.CompleteHtmlSaveFormat)
downloadItem.setPath(the_sourceFile)
downloadItem.accept()
downloadItem.finished.connect(self.on_downloadfinished)
downloadItem.setPath(the_sourceFile)

你好,首先非常感谢您的分享。但是我遇到生成图右侧工具栏内下载图片按钮无响应问题(没办法下载绘制的图片),但其他查看数据、更新等按钮功能正常。我在网上寻找了很久并未找打相关解决方案,所以向您前来请教,我的基本环境是pyqt5、python3.8以及pyechart0.5.11。

@Hellen-master 你好,根据你发的csdn链接以及我以前开发的经验,我是在google上搜索“pyqt5 downloaditem address”,发现在这个博客文章里的内容也许可以帮助到你(如下)

###download file
downloadItem.setSavePageFormat(QWebEngineDownloadItem.CompleteHtmlSaveFormat)
downloadItem.setPath(the_sourceFile)
downloadItem.accept()
downloadItem.finished.connect(self.on_downloadfinished)
downloadItem.setPath(the_sourceFile)

非常感谢您的及时帮助,通过您的指引以和具体博客我已经顺利完成了自定义下载图片功能。再次感谢您的帮助