{
const height = 300;
const svg = d3.create('svg')
.attr('viewBox', [0, 0, width, height]);
const circle = svg.append('circle')
.attr('cx', width / 2)
.attr('cy', height / 2)
.attr('r', 100);
const colors = ['yellow', 'salmon', 'red', 'salmon', 'yellow'];
const defs = svg.append('defs');
const linearGradient = defs.append('linearGradient')
.attr('id', 'linear-gradient');
linearGradient
.attr('x1', '0%')
.attr('y1', '0%')
.attr('x2', '100%')
.attr('y2', '0%')
.attr('spreadMethod', 'reflect');
const getStopOffset = (d, i) => i / (colors.length - 1);
const getStopColor = d => d;
linearGradient.selectAll('.stop')
.data(colors)
.enter().append('stop')
.attr('offset', getStopOffset)
.attr('stop-color', getStopColor);
linearGradient.append('animate')
.attr('attributeName', 'x1')
.attr('values', '0%;100%')
.attr('dur', '5s')
.attr('repeatCount', 'indefinite');
linearGradient.append('animate')
.attr('attributeName', 'x2')
.attr('values', '100%;200%')
.attr('dur', '5s')
.attr('repeatCount', 'indefinite');
circle.style('fill', 'url(#linear-gradient)');
return svg.node();
}