-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Adjust Node size to dimensions of data-uri encoded svg background image #1684
Comments
You can create an SVG object and find the attributes with its dimensions. If the SVG doesn't have those attributes defined, then I don't think you can really get the dimensions reliably. You can try adding them to the DOM and querying the size, but the default size is just what's set in the attributes as far as I know -- so SVGs with undefined attributes won't have a reliable size. Really, you're best off just setting node sizes manually in the stylesheet and setting the background width/height appropriately in your stylesheet as well. |
I can't go with fixed node dimensions though, since the svgs from the API vary in size quite a bit. Now with the style option of Also, with the SVG object approach you mentioned, how would I create these object async within the cytoscape mapper function? See 2ndsnippet in original question? |
http://stackoverflow.com/questions/231679/get-size-of-svg-graphics-by-javascript#1577890 Basically, load the svg string as an object and get the attribute or parse/grep the svg as a string and look for the attribute. |
I'm consuming an API that returns a SVG for each node encoded as a Data-URI inside data field.
I'd now like to adjust the nodes width and height to the background SVGs dimensions. I could create a new Image, load the SVG and then get the dimensions. But since this is an async operation, it won't return the width/ height for cytoscape immediately.
Any ideas how to achieve this?
The text was updated successfully, but these errors were encountered: