Skip to main content
100%

Viz-Hub Smiley

✓ Published1🌍 Public
SSharmilaChowdhari
Last edited Feb 19, 2022
Created on Feb 19, 2022

This example renders a simple smiley face using React and D3 v6, drawing the head, eyes, and mouth as SVG elements. The face is centered via a group with a translate transform, and the yellow circular head has a black stroke. The mouth is generated using the `arc` helper from the `d3-shape` package, configured with inner and outer radii and start/end angles to form a curved line. Two black circles positioned at fixed offsets serve as the eyes, and the entire composition is static with hard-coded dimensions and no data input.

AI-generated description

Part-3) D3 intro

  • Getting started with the D3 library

  • Using arc from the d3-shape package arc is a helper function used for drawing an arc shape for the mouth.

  • SVG path elements

  • SVG group elements and the transform attribute

  • Using ES6 Template Literals

  • Adding the mouth to our face

Assignment: Tweak the Face!!

MIT Licensed

Similar vizzes