echarts [Bug] node-canvas could not load image

bsxbgnwa  于 2个月前  发布在  Echarts
关注(0)|答案(3)|浏览(34)

Version

5.4.3

https://github.com/itzdrli/example

Steps to Reproduce

Use the code from Here . The code has written by following official document

Current Behavior

Error:
C:\Users\xxxx\Desktop\t\node_modules.pnpm\echarts@5.4.3\node_modules\echarts\dist\echarts.js:9083
for (var i = 0; i < cachedImgObj.pending.length; i++) {
^

TypeError: Cannot read properties of undefined (reading 'pending')
at imageOnLoad (C:\Users\xxxx\Desktop\t\node_modules.pnpm\echarts@5.4.3\node_modules\echarts\dist\echarts.js:9083:42)
at setSource (C:\Users\xxxx\Desktop\t\node_modules.pnpm\canvas@2.11.2\node_modules\canvas\lib\image.js:94:13)
at Image.set (C:\Users\xxxx\Desktop\t\node_modules.pnpm\canvas@2.11.2\node_modules\canvas\lib\image.js:40:9)
at Object.loadImage (C:\Users\xxxx\Desktop\t\index.js:16:13)
at createOrUpdateImage (C:\Users\xxxx\Desktop\t\node_modules.pnpm\echarts@5.4.3\node_modules\echarts\dist\echarts.js:9067:37)
at brushImage (C:\Users\xxxx\Desktop\t\node_modules.pnpm\echarts@5.4.3\node_modules\echarts\dist\echarts.js:27311:34)
at brush (C:\Users\xxxx\Desktop\t\node_modules.pnpm\echarts@5.4.3\node_modules\echarts\dist\echarts.js:27627:17)
at CanvasPainter._doPaintEl (C:\Users\xxxx\Desktop\t\node_modules.pnpm\echarts@5.4.3\node_modules\echarts\dist\echarts.js:40498:17)
at repaint (C:\Users\xxxx\Desktop\t\node_modules.pnpm\echarts@5.4.3\node_modules\echarts\dist\echarts.js:40433:31)
at _loop_1 (C:\Users\xxxx\Desktop\t\node_modules.pnpm\echarts@5.4.3\node_modules\echarts\dist\echarts.js:40464:21)

Expected Behavior

the image would show

Environment

- OS:Windows 11
- Node-Canvas

Any additional comments?

No response

kr98yfug

kr98yfug1#

not sure what you are trying to accomplish with loadImage since it is not used anywhere...
Images could be used as background or symbols - Demo Code

nxagd54h

nxagd54h2#

not sure what you are trying to accomplish with loadImage since it is not used anywhere...
Images could be used as background or symbols - [Demo Code)

Check the code he provided, he is indeed using symbols. And if the image is not loaded, this error will not appear at all

Even when using the Demo code you provided, this error still occurs in node-canvas.

x7rlezfr

x7rlezfr3#

wth, if you remove img.onload = onload.bind(img); it will works as intented.
Possible related commit: ecomfe/zrender@c564acd

Anyway, the offical documentation are not written correctly. https://echarts.apache.org/handbook/en/how-to/cross-platform/server/#loading-of-images

相关问题