Published
Edited
Mar 31, 2022
3 forks
2 stars
Insert cell
Insert cell
{
const height = 300
const svg = d3.create('svg')
.attr('viewBox', [0, 0, width, 300]);

const circle = svg.append('circle')
.attr('cx', width / 2)
.attr('cy', height / 2)
.attr('r', 80)
.attr('fill', 'green');

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%');

linearGradient.append('stop')
.attr('offset', '0%')
.attr('stop-color', 'yellow');
linearGradient.append('stop')
.attr('offset', '100%')
.attr('stop-color', 'red');

circle.style('fill', 'url(#linear-gradient)');

return svg.node();
}
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more