dagre-d3 IE workaround for SVG foreignObject element?

空扰寡人 提交于 2019-12-04 00:44:05

I used SVG and foreignObject heavily in my master thesis project, which was fine because it worked fine in Chrome and Firefox. But my solution/workaround to the issue (i.e. IE not supporting foreignObject), was to use a layered layout. I placed the objects that required SVG in a SVG layer and the objects I could create in HTML I put in an HTML layer (mostly elements with text, which is HTML's "home ground").

It might get a little complex if you need many elements on top of each other, because svg doesn't support z-index (it uses elements order instead). So you might need to create multiple HTML/SVG layers to solve that. Just place the layers exactly on top of each other, and coordinating their positions will get easy. Since SVG objects is placed based on coordinates, you can just place the HTML elements the same way (e.g by translate(...))

I have not used dagre-d3, so I apologize if this answer is way off.

MadsVJ

As of april 29 2015 the functionality for svg-labels (not using foreignObject) was added.

Try this instead of your html-labels.

See demo: http://cpettitt.github.io/project/dagre-d3/latest/demo/svg-labels.html

See commit: https://github.com/cpettitt/dagre-d3/pull/158

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!