Skip to content

Svg arc.cornerRadius causing invalid paths with attrTween #2183

Closed

Description

@wassx

I use the partition layout to create a sunburst chart where the arcs have rounded corners. The animation works pretty well (except a flickering of the arc which becomes a full circle), but in the console of safari 7.1 and chrome 39.0 a lots of errors are thrown (NOT in firefox).
The animation works but an error occurs in d3.js:8699 "this.setAttribute(name, f(t));"
The log output of chrome:
Error: Invalid value for attribute d="MNaN,NaNANaN,NaN 0 1,1 NaN,NaNLNaN,NaNANaN,NaN 0 0,1 NaN,NaNZ"

There is an ongoing discussion on stackoverflow: http://stackoverflow.com/questions/27838938/d3-sunburst-diagram-setting-arc-cornerradius-causes-invalid-path-with-arctwee

and a codepen to test made by user VividD: http://codepen.io/VividD/pen/myRWRY

Activity

  1. mbostock commented on Jan 13, 2015

    @mbostock
    Member

    Without a test case (a self-contained example on bl.ocks.org or jsfiddle.net, etc.) to verify this bug, I can’t investigate further. My guess is that one of the arc properties you’re specifying is NaN, so that NaN is being propagated into the resulting path string. I would use a debugger to step through your code and see what values you are passing to the arc generator, and then work backwards from there to see why the property is NaN.

    I did notice one bug in your code:

    var range = +y.range();
    var yr = d3.interpolate(range, [dy ? selectionRadius : innerBtnRadius, radius-5]);

    Here you’ve defined range by coercing a scale’s range (which is typically an array of numbers) to a number. That probably means that range’s value is NaN. Then you’re using d3.interpolate to interpolate from NaN to an array of two numbers. That probably means that the interpolator is always returning the latter array, regardless of the value of t.

  2. wassx commented on Jan 14, 2015

    @wassx
    Author

    Hi, sry to ask again, but maybe you haven't noticed, there is a example of the zoomable sunburst on codepen in the issue: " and a codepen to test made by user VividD: http://codepen.io/VividD/pen/myRWRY "
    Is this one helpful for you?

    I debugged and i recognized at "this.attribute(name, f(t))" that f(t) returns this error path when t=1 and f=return o(d) (the arc(d))
    screenshot
    )

    Diggin deeper i found that there a very small x values in the d3.svg.arg function, where calulation results of other vars get NaN:

    screenshot

    Further investigation points me to the d3_geom_polygonIntersect(c,d,a,b) method where the parameters have values but it returns NaN array because the variable ua is undefined:
    screenshot
    screenshot

    So, at least i found a possible workaround/fix: when i add if(!ua) ua = 1; no errors occurr anymore. :)
    screenshot

  3. mbostock commented on Jan 14, 2015

    @mbostock
    Member

    I did miss the link, thank you. And thank you for debugging the divide-by-zero. You can see that the two lines being intersected are coincident, hence the zero denominator. I think your fix probably isn’t what we want, but I haven’t thought through the appropriate fix to svg/arc.js yet.

  4. added
    bug
    on Jan 14, 2015
  5. added this to the 3.5.x milestone on Jan 14, 2015
  6. geofflancaster commented on Aug 27, 2015

    @geofflancaster

    Any idea when this will be released? I'm having this issue trying to draw a simple arc with rounded corners

  7. modified the milestones: 3.5.7, 3.5.x on Oct 22, 2015
  8. added a commit that references this issue on Oct 22, 2015
    c9e9745
  9. mbostock commented on Oct 22, 2015

    @mbostock
    Member

    Fix merged into #2591.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions