-
Notifications
You must be signed in to change notification settings - Fork 400
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
$svg.width() and $svg.height() return zero #68
Comments
Interesting, the reason I read back the dimensions after manually setting them is to cater for percentage dimensions - so you can specify I did previously discover that jQuery doesn't return the dimensions of an SVG element when they're defined as a percentage (I can't quite remember the detail as it was a while ago), could this be the cause? |
Hm... my definitions use pixels. I wasn't aware that peity also supported % On Mon, May 18, 2015 at 12:34 PM, Ben Pickles [email protected]
|
That sounds like a good solution (zero being falsy). It'd be nice to have a working test case though. |
I've got the same error while generating bar charts in an Ionic2 (Angular4) app. The thing is, in our web version of that project (Angular4), it works - with exactly the same versions of peity and jQuery. I've fixed it by using: $svg.width() || opts.width It works for now, but I don't exactly know, if there are any side effects under any circumstances. Could you verify and apply this fix to a next version please? |
Hmmm, I wonder if it's because the element hasn't yet been attached to the DOM? (Just thinking out loud...) |
I really don't know. Is it important to get the dimensions from the svg element? Could we simply get it from the options? Or is it needed for dynamic appending data? |
It was originally required in an old version that used |
At least in my case (#105) this must be the reason. I was trying to use peity within a DataTables table and their docs says:
|
Sometimes the
$svg.width()
and$svg.width()
calls return 0, even though we explicitly set width and height of the element before creating it. I cannot figure out whether this is a bug in jquery or mobile safari (iOS 7.1). In any case, I cannot reproduce it outside of my current project. The fix is simple and probably safe though, so I thought I'd upstream it:The text was updated successfully, but these errors were encountered: