Open ahdg6 opened 10 months ago
echarts.setPlatformAPI({ createCanvas() { return createCanvas(); }, loadImage(src, onload, onerror) { const img = new Image(); // No need to bind context, echarts fixed it. // img.onload = onload.bind(img); // img.onerror = onerror.bind(img); // The problem lies here: Echarts believes that it should be base64, but @napi-rs/canvas operates with Buffer. (works fine with node-canvas) img.src = src; return img; } });
when pass it with base64, it throws
Error: Failed to create reference from Buffer
when pass it with Buffer, it throwsError: Unsupported image type
@napi-rs/canvas
comes with loadImage
function which supports base64
Hey, the issue has been resolved. Just need to change the echarts settings to the following content. I will keep this problem open for others to reference. (Attention: You must use echarts with base64 only)
Old:
when pass it with base64, it throws
Error: Failed to create reference from Buffer
when pass it with Buffer, it throwsError: Unsupported image type