Comments (8)
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
$svg.height() || opts.height
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?
from peity.
Interesting, the reason I read back the dimensions after manually setting them is to cater for percentage dimensions - so you can specify { width: '100%' }
and it'll return the SVG element's dimensions in pixels - and it looks like that patch would break that functionality.
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?
from peity.
Hm... my definitions use pixels. I wasn't aware that peity also supported %
dimensions. Getting the width/height of an svg element accurately seems to
be non-straightforward. Can you think of an easy way to reconcile this?
(E.g. we could check if the width and height returned was zero and then use
the user defined option if it's in pixels). This is a PITA.
On Mon, May 18, 2015 at 12:34 PM, Ben Pickles [email protected]
wrote:
Interesting, the reason I read back the dimensions after manually setting
them is to cater for percentage dimensions - so you can specify { width:
'100%' } and it'll return the SVG element's dimensions in pixels - and it
looks like that patch would break that functionality.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?—
Reply to this email directly or view it on GitHub
#68 (comment).
from peity.
That sounds like a good solution (zero being falsy). It'd be nice to have a working test case though.
from peity.
Hmmm, I wonder if it's because the element hasn't yet been attached to the DOM? (Just thinking out loud...)
from peity.
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?
from peity.
It was originally required in an old version that used <canvas>
, the more I think about it the more I think there's probably a better way to do things in S(scalable!)VG.
from peity.
Hmmm, I wonder if it's because the element hasn't yet been attached to the DOM? (Just thinking out loud...)
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:
This callback allows you to 'post process' each row after it have been generated for each table draw, but before it is rendered into the document. This means that the contents of the row might not have dimensions ($().width() for example) if it is not already in the document.
from peity.
Related Issues (20)
- Change data-value to label
- data-value not working with "bar"
- Any react-native port?
- Required Two different color in Line chart HOT 1
- points calculated wrong in DataTables cell HOT 2
- can it have lables HOT 1
- Add ability to use CSS classes on SVG charts HOT 2
- jQuery version and Peity version always conflict HOT 2
- innerHTML to Span HOT 6
- Adding composer.json and submitting to packagist HOT 4
- Smooth animate pie chart on update HOT 2
- when using with bootstrap HOT 4
- This project should be renamed to piety HOT 1
- Charting fractional values HOT 1
- Add a mouseover to view data HOT 1
- Stacked bar HOT 1
- Any way to know if the numerator is greater than the denominator in a pie with delimiter /? HOT 2
- Semicircle donuts?
- show percentage in center donut HOT 1
- Further custom styling
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from peity.