angular-svg-round-progressbar icon indicating copy to clipboard operation
angular-svg-round-progressbar copied to clipboard

Gradient

Open Avishaidev opened this issue 8 years ago • 9 comments

Please can you explain how to create gradient as at demo? Thanks

Avishaidev avatar May 01 '17 07:05 Avishaidev

You can check out the demo's source code. You're supposed to put an SVG element, containing the gradient, somewhere on the page:

<svg>
  <linearGradient id="your-gradient-id" x1="0" x2="0" y1="0" y2="1">
    <stop offset="5%"  stop-color="green"/>
    <stop offset="95%" stop-color="gold"/>
  </linearGradient>
</svg>

Afterwards you pass the gradient id to the progress circle:

    <round-progress
      [current]="current"
      [max]="max"
      color="url(#your-gradient-id)"></round-progress>

crisbeto avatar May 01 '17 08:05 crisbeto

Has anyone had issues when trying to implement this dynamically? I have a bunch of pre-defined gradients and I am trying to switch between them. For some reason, only the first gradient is working.

sejr avatar Aug 08 '17 21:08 sejr

Do the gradients have unique ids?

crisbeto avatar Aug 08 '17 21:08 crisbeto

@crisbeto Yes they do. I am going to try one possible work-around; if that doesn't work I can provide an update with a JSFiddle or something.

sejr avatar Aug 09 '17 02:08 sejr

I found the solution very simply just leave the color empty like this <round-progress ... color="" ...> </round-progress>

In the global html, add a gradient

<svg width="0px" height="0px" style="position:absolute;left: -9999px;"> <defs> <linearGradient id="progressCircle1" x1="0" x2="0" y1="0" y2="1"> <stop offset="0%" stop-color="#39eeff"/> <stop offset="100%" stop-color="#4da0ff"/> </linearGradient> </defs> </svg>

In styles write just url (id)

.round-progress path { stroke: url(#progressCircle1); }

mmgmail avatar May 17 '18 17:05 mmgmail

@crisbeto Thanks! Works For me

paresh2190 avatar May 28 '18 09:05 paresh2190

@crisbeto Thanks!

diangogav avatar Jun 20 '18 05:06 diangogav

@mmgmail thanks!, works for me

carlosminatoro avatar Oct 29 '20 02:10 carlosminatoro

It seems like rerenders on some web browsers get annoyed that ids are being redefined, so going to try putting the definition globally like in the replies here.

hscheuerle avatar Feb 02 '21 17:02 hscheuerle