The issue has been closed
Describe the bug / 问题描述
V5版本 renderer设置为svg时,无法导出为svg
Reproduction link / 重现链接
No response
Steps to Reproduce the Bug or Issue / 重现步骤
No response
G6 Version / G6 版本
🆕 5.x
Operating System / 操作系统
Windows
Browser / 浏览器
Chrome, Edge
Additional context / 补充说明
No response

renderer 与导出图片格式无关,目前如果要导出 SVG 可以直接获取画布节点:
graph.getCanvas().getLayer().getContextService().getDomElement()
posted by Aarebecca 9 months ago
获取svg base64
需要手动加上背景
const svgEl = graph
.getCanvas()
.getLayer()
.getContextService()
.getDomElement();
const svgStr = new XMLSerializer()
.serializeToString(svgEl as any as Node)
.replace("background: transparent;", "background: #2b2d30;");
console.log(`data:image/svg+xml;base64,${btoa(svgStr)}`);
posted by STofone 9 months ago