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

Get node attributes when render SVG? #33

Closed
duongtb1989 opened this issue Jul 25, 2014 · 1 comment
Closed

Get node attributes when render SVG? #33

duongtb1989 opened this issue Jul 25, 2014 · 1 comment

Comments

@duongtb1989
Copy link

Hi.
I want to get node attributes: pos, color,.... when using Viz.js render SVG?
Can you please help me?
Thanks in advance for your attention!

@mdaines
Copy link
Owner

mdaines commented Jul 27, 2014

You should be able to get node attributes using the DOM after inserting the generated SVG into the document. To make this more convenient, add "id" attributes to the nodes you create.

Given this graph:

digraph g {
a -> b;
a[id="a"];
}

After inserting the SVG into the document, you can say something like this to return the stroke color for the ellipse shape in the node "a":

document.querySelector("#a ellipse").getAttribute("stroke")

@mdaines mdaines closed this as completed Jul 27, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants