javascript - D3 arc gradient -


i'm trying create timer using d3 has gradient change between 0 , 100%. example dark orange @ 0% , light orange @ 100%. can make arc transition between dark , light orange having problems finding allows me apply gradient arc. example of trying achieve can seen in image below.

enter image description here

been searching/frying brain trying achieve day or now.

svg not allow these kind of gradients. i've done similar before, created "donut chart" each wedge different color:

http://jsfiddle.net/duopixel/gfvrk/

var arc, data, padding, steps = 2, r=400/2, pi = math.pi; var padding = 2 * r / 200; arc = d3.svg.arc()   .innerradius(r-40)   .outerradius(r).startangle(function(d) { return d.startangle; })   .endangle(function(d) { return d.endangle; });  data = d3.range(180).map(function(d, i) {   *= steps;   return {     startangle: * (pi / 180),     endangle: (i + 2) * (pi / 180),     fill: d3.hsl(i, 1, .5).tostring()   }; });  d3.select("#wheel")   .insert('svg', 'svg')   .attr("id", "icon")   .append('g')     .attr("transform", "translate(" + r + "," + r + ") rotate(90) scale(-1,1)")     .selectall('path')       .data(data)       .enter()       .append('path').attr("d", arc)       .attr("stroke-width", 1)       .attr("stroke", function(d) { return d.fill;})       .attr("fill", function(d) { return d.fill; }); 

Comments

Popular posts from this blog

ios - UICollectionView Self Sizing Cells with Auto Layout -

node.js - ldapjs - write after end error -

DOM Manipulation in Wordpress (and elsewhere) using php -