Skip to main content
100%

Let's make a face with D3.js

✓ Published2🌍 Public
RResl411
Last edited Nov 6, 2019
Created on Nov 6, 2019

A yellow smiley face drawn with D3.js appears centered on a dark background, with circular eyes, rectangular eyebrows, and a curved mouth built from an arc path. The example demonstrates SVG shape creation and animation using d3-selection and d3-arc, as the eyebrows transition vertically twice via chained `transition().duration()` calls. The face is constructed from fixed numeric constants for spacing and dimensions, rendered inside an SVG element sized 960 by 500 pixels.

AI-generated description

import { select } from 'd3';

const svg = select('svg');

const circle = +svg.append('circle');

const width = +svg.attr('width');

const height = +svg.attr('height');

console.log(width);

circle.attr('r', height / 2);

circle.attr('cx', width / 2);

circle.attr('cy', height / 2);

MIT Licensed

Similar vizzes