Giter VIP home page Giter VIP logo

Comments (7)

crisbeto avatar crisbeto commented on May 29, 2024

Hmm are you sure? When the radius is set to 100px, my circle is at exactly 200px by 200px (twice the radius). http://i.imgur.com/IDlxFbf.png

from angular-svg-round-progressbar.

bisubus avatar bisubus commented on May 29, 2024

I need to be more specific: the problem is the size of <svg> (it is 230 with stroke 15 and 202 with stroke 1), not <circle>. Seems like it is little more complicated than just incorrect size, right?

from angular-svg-round-progressbar.

crisbeto avatar crisbeto commented on May 29, 2024

Ah you're correct that the SVG element is slightly larger. I'll look into it.

from angular-svg-round-progressbar.

bisubus avatar bisubus commented on May 29, 2024

Great. I ended up for now with

                    element.css({
                        "width":        size + "px",
                        "height":       (isSemicircle ? size/2 : size) + "px",
                        "margin":       -stroke/2 + "px",
                        "margin-bottom": isSemicircle ? 0 : -stroke/2 + "px",
                        "overflow":     "hidden" // on some browsers the background overflows, if in semicircle mode
                    });

But maybe -Math.floor(stroke/2) would be more appropriate. It may depend on rendering engine, but looks like it always occupies even amount of pixels, at least in Chrome.

from angular-svg-round-progressbar.

crisbeto avatar crisbeto commented on May 29, 2024

It was a while ago when I did this directive, but after looking at it again, I think I remember why the SVG element's size is the diameter + 2*stroke. Its because the stroke throws off the width and height. The browser doesn't consider the stroke as a part of the width of the circle, in reality the circle's width and height are 230px as well. Just for fun I forced the same size on the SVG and the circle ended up overflowing.
It probably depends on what height you expect it to be. I think it would make more sense to take off the stroke from the width and height.

from angular-svg-round-progressbar.

bisubus avatar bisubus commented on May 29, 2024

I was afraid that it the circle would be truncated somehow, but it seems to look well in all browsers. I wasn't fond of temporary margin solution because of that extra 1px caused by antialiasing on odd stroke values.

from angular-svg-round-progressbar.

crisbeto avatar crisbeto commented on May 29, 2024

I've released a fix for this (d57571c). From now the element width and height will be the circle's diameter (radius*2)

from angular-svg-round-progressbar.

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.