I have the following arc diagram:
I would like to add a gradient to each of the individual arcs, that flows from the outer radius to the inner radius of each individual arc.
I am guessing that I will need to create an individual gradient for each arc?
let radius = 100;
for(let i = 0; i < 5; i ++) {
let grad = defs.append('radialGradient')
.attr('id', 'mygrad' + i)
.attr('gradientUnits', 'userSpaceOnUse')
.attr('cx', '0')
.attr('cy', '0')
.attr('r', radius)
grad.append('stop')
.attr('offset', '0%')
.attr('stop-color', 'white');
grad.append('stop')
.attr('offset', '100%')
.attr('stop-color', 'blue');
let arc = d3.arc()
.outerRadius( radius )
.innerRadius( radius - 50)
.startAngle( degToRad(-90) )
.endAngle( degToRad(90) );
g.append('path')
.attr('d', arc)
.attr('fill', `url(#${'mygrad' + i })`)
.attr('stroke', 'lightgrey');
radius += 50;
}
let grad = defs.append('radialGradient')
.attr('id', 'mygrad' + i)
.attr('r', '80%')
grad.append('stop')
.attr('offset', '0%')
.attr('stop-color', 'white');
grad.append('stop')
.attr('offset', '100%')
.attr('stop-color', 'blue');