question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Animated Sunburst can not take SVG Pattern

See original GitHub issue

Hi all

Similar to this #721 , when I tried to applied the SVG pattern to the Sunburst, it shows the black box like the following: image

However, when I remove animation from Sunburst, it works perfectly! image

Just wondering if this is caused by the animated Sunburst? I think I met a similar issue for the animated bar chart as well.

Issue Analytics

  • State:open
  • Created 5 years ago
  • Comments:8 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
martin-luocommented, Oct 28, 2018

Thanks Wattengerger! That’s a quite good point. I modified the code to try to replicate the problem, but it looks well for me now. I’ll dig into it tomorrow and let you know the results!

0reactions
martin-luocommented, Oct 31, 2018

I think I found out the reason why it does not work with animation: instead of get d.color in getColor in Sunburst, I add some logics in to find out the Id of the SVG pattern.

The function of SVG pattern generation looks like this:

 private __getSVGPatternID = (
    showPattern: boolean,
    legendColor: string = "#ffffff"
  ): string => (showPattern ? `sunburst-legend-${legendColor}` : "");

It work well on static Sunburst because the value we get from d.color is a hex code, for example, #52BAAB. However, in animated Sunburst, the color we get changed to RGB which is rgb(82, 186, 171).

My pattern ID generation function did not recognize the changes and keep treating the color as hex code, and the SVG with that ID does not exist, that is why the second ring in the animated sunburst turns to black.

Hopefully this helps.

Regards

After updating my id generation logic. the animation works well!

  private __getSVGPatternID = (
    showPattern: boolean,
    legendColor: string = "#ffffff"
  ): string => {
    if (!showPattern) {
      return "";
    }
    let hexColor: string = legendColor;
    const isHex: boolean =
      hexColor.length > 1 &&
      hexColor.slice(1).length === 6 &&
      !isNaN(parseInt(hexColor.slice(1), 16));

    if (!isHex) {
      hexColor = hexColor
        .split("(")[1]
        .split(")")[0]
        .split(",")
        .map(color => {
          const hex = parseInt(color).toString(16);
          return hex.length === 1 ? "0" + hex : hex;
        })
        .join("");
      hexColor = `#${hexColor.toUpperCase()}`;
    }

    return `sunburst-legend-${hexColor}`;
  };

image

Just a suggestion, should we make it more clear in the documentation that when use animation, the color representation changed?

Kind Regards

References:

Read more comments on GitHub >

github_iconTop Results From Across the Web

sunburst / Seamless, Animated Repeating Background ...
Customize your SVG-based, repeating background patterns in SVG / GIF / APNG formats on ... Animated background patterns for sunburst, donut chart, pie...
Read more >
D3 - Transition Arcs in Sunburst Chart
Your problem is that you are not really binding data to the elements, and therefore the transition is not possible. I mangled your...
Read more >
Sunburst SVG. 16 Hand Drawn Circles. Sunburst Vector EPS
Sunburst SVG. 16 Hand Drawn Circles. Sunburst Vector EPS Graphics. Clipart. Vintage Sunbursts. Instant Download. 16 Transparent PNG Files. $3.00 · In stock....
Read more >
1242256 - A continuously animated GIF in an SVG pattern ...
The image actually comes from an SVG pattern fill. A relatively simple fix would be to consider all images in SVG patterns visible....
Read more >
Rounded Mandala Coaster SVG Sunburst Svg Circle Lace ...
Your files will be available to download once payment is confirmed. Here's how. Instant download items don't accept returns, exchanges or ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found