动态更新SVG [英] update SVG dynamically

查看:361
本文介绍了动态更新SVG的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



有什么办法可以:
- 发送关于object(id)的信息,用户点击了'主html文档'?
- 从svg文件中的外部文档中抽取。



可能我的描述不清楚,...我想实现类似这样的内容:


  1. 用户点击svg-image中的任何对象;
  2. 主文档将接收点击对象的id和:

    • 显示关于该对象的一些信息;
    • 在svg-image内部绘制额外的对象。


问题:如何从svg传送文件到文件并传送到svg?

非常感谢您的宝贵意见!



PS可能SVG不是最好的办法吗?还有什么更好的?



编辑:我看到了有关Raphael使用的建议,但是我希望看到'native'选项。 (现在我正在分析Raphaels的实现来看看,但不认为它正在做我所需要的)。

解决方案

<请参阅此示例如何从父文档获取引用的svg的DOM。



这里是一个例子,介绍如何从svg文件调用父文档。



SVG非常适合您的描述。

I have some objects inside of svg that can be clicked by user.

Is there any way to: - send information about object (id) that was clicked by user to the 'main html document'? - draw from outside document in the svg file.

Probably, my description is unclear,... I want to implement something like this:

  1. user click on any object inside of svg-image;
  2. main document will receive id of the clicked object and:
    • display some information about that object;
    • draw additional object inside of the svg-image.

Questions: how to communication from svg to document and from document to svg?

Thanks a lot, any thoughts are welcome!

P.S. Probably SVG is not the best way do that? What is better then?

EDIT: I saw recommendation regarding use of Raphael,.. but I would like to see 'native' options. (For now I'm analyzing Raphaels implementation to see that, but don't think it is doing exactly what I need).

解决方案

See this example for how to get the DOM of a referenced svg from the parent document.

And here's an example of how you can call from an svg file to the parent document.

SVG is very well suited for doing what you describe.

这篇关于动态更新SVG的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆