Giter Site home page Giter Site logo

Comments (8)

Thaars avatar Thaars commented on May 17, 2024 1

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.

benpickles avatar benpickles commented on May 17, 2024

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.

JohannesRudolph avatar JohannesRudolph commented on May 17, 2024

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.

benpickles avatar benpickles commented on May 17, 2024

That sounds like a good solution (zero being falsy). It'd be nice to have a working test case though.

from peity.

benpickles avatar benpickles commented on May 17, 2024

Hmmm, I wonder if it's because the element hasn't yet been attached to the DOM? (Just thinking out loud...)

from peity.

Thaars avatar Thaars commented on May 17, 2024

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.

benpickles avatar benpickles commented on May 17, 2024

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.

gypapp avatar gypapp commented on May 17, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.