Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

图片导出时,使用自定义vue节点绘制的svg不能被导出 #2423

Closed
Huzi-y opened this issue Jul 26, 2022 · 19 comments
Closed

图片导出时,使用自定义vue节点绘制的svg不能被导出 #2423

Huzi-y opened this issue Jul 26, 2022 · 19 comments
Labels
type: discussion 讨论 Usage questions, guidance, and other discussions

Comments

@Huzi-y
Copy link

Huzi-y commented Jul 26, 2022

Describe the bug

在自定义的vue节点内部,如果使用了svg,在导出图片的时候会出现空白情况。导出svg是正常的。

Your Example Website or App

https://codesandbox.io/s/vue-shape-forked-yvr0fk?file=/src/components/Count.vue

Steps to Reproduce the Bug or Issue

单击保存图片

Expected behavior

生成完整的png图片

Screenshots or Videos

1658817148293
1658817165009

Platform

  • OS: [e.g. macOS, Windows, Linux]
  • Browser: [e.g. Chrome, Safari, Firefox]
  • Version: [e.g. 91.1]

Additional context

No response

@DanielLeefu
Copy link
Contributor

看起来和这个issues#1443相似,图片使用base64试下呢

@Huzi-y
Copy link
Author

Huzi-y commented Jul 27, 2022

看起来和这个issues#1443相似,图片使用base64试下呢

我试了下,用base64是可以了,这个是什么原理😥

@Huzi-y Huzi-y closed this as completed Jul 27, 2022
@Huzi-y Huzi-y reopened this Jul 27, 2022
@Huzi-y
Copy link
Author

Huzi-y commented Jul 27, 2022

@DanielLeefu 复杂的svg,包含了defs标签,使用base64方式好像不能绘制出来。节点里面如果绘了一个图表,图表是用canvas绘制的话,导出的图片节点也是一片空白。

@tonywu6 tonywu6 added the type: bug 缺陷 Defects and unexpected behaviors label Jul 27, 2022
@komagic
Copy link

komagic commented Aug 7, 2022

用blob 导出就行了。x6自带的不好使,用html to image 和blob

@NewByVector
Copy link
Contributor

@komagic 有什么好的库推荐使用吗

@komagic
Copy link

komagic commented Aug 16, 2022

@komagic 有什么好的库推荐使用吗

用 html-to-image toBlob 导出即可

@komagic
Copy link

komagic commented Aug 16, 2022

abc
这个是react 节点的圆形,x6自带的会卡一下,然后下载出来是空的。

用我上面提到的即可解决

@Huzi-y
Copy link
Author

Huzi-y commented Aug 18, 2022

abc [ ![abc]这个是react 节点的圆形,x6自带的会卡一下,然后下载出来是空的。

用我上面提到的即可解决
我用了 html-to-image 的 toBlob导出的图片直接节点都不绘了😭

@Huzi-y
Copy link
Author

Huzi-y commented Aug 18, 2022

我是用vue绘的节点

@komagic
Copy link

komagic commented Aug 20, 2022

@komagic
Copy link

komagic commented Aug 20, 2022

这个与vue react没关系,最终生成的都是html

@Huzi-y
Copy link
Author

Huzi-y commented Aug 22, 2022

这个与vue react没关系,最终生成的都是html

应该是我用的有问题,我是把blob转file,不知道为什么节点没绘出来。

@Huzi-y
Copy link
Author

Huzi-y commented Aug 22, 2022

这个与vue react没关系,最终生成的都是html

我知道为什么了,我开启了滚动,截的图片在滚动条最前面开始截的,导致没显示到节点的位置
image

@Huzi-y
Copy link
Author

Huzi-y commented Aug 22, 2022

通过类名(x6-graph-svg)获取到节点去生成图片就好了。

@NewByVector NewByVector added type: discussion 讨论 Usage questions, guidance, and other discussions and removed type: bug 缺陷 Defects and unexpected behaviors labels Sep 4, 2022
@chengup-git
Copy link

通过类名(x6-graph-svg)获取到节点去生成图片就好了。
Snipaste_2022-09-08_17-31-15

应该是这个导致的,只有svg元素才行,我用上一级的container不行,下一级的x6-graph-svg-viewport也不行,然后看了下文档,发现是这个原因

@oyal
Copy link

oyal commented Nov 21, 2023

使用html-to-image导出的的大小为整个画布,有没有只导出渲染区域的方案?

2023-11-21_17-06-23

@komagic
Copy link

komagic commented Nov 21, 2023 via email

@oyal
Copy link

oyal commented Nov 22, 2023

@komagic 我目前是做的一个自动保存缩略图的功能,用graph.zoomToFit()也不太好,会改变画布缩放以及画布位置😭

@x6-bot
Copy link
Contributor

x6-bot bot commented Nov 22, 2024

This thread has been automatically locked because it has not had recent activity.

Please open a new issue for related bugs and link to relevant comments in this thread.

@x6-bot x6-bot bot locked as resolved and limited conversation to collaborators Nov 22, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
type: discussion 讨论 Usage questions, guidance, and other discussions
Projects
None yet
Development

No branches or pull requests

7 participants