antvis/G6

V5版本 renderer设置为svg时,无法导出为svg #6157

STofone posted onGitHub

Describe the bug / 问题描述

V5版本 renderer设置为svg时,无法导出为svg

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

Fund this Issue

$0.00
Funded

Pull requests