Skip to main content
Public

Share visualization

Loading preview…

Fork of Smiley Face Part-3 (React and d3)

vizhub.com

Shared links may look like this on X, LinkedIn, Slack, and Discord.

Before sharing, review the publishing checklist.

Choose how to deliver this visualization

LinkedIn caption

LinkedIn may not keep text supplied by the share sheet. Copy the caption and paste it into the post if needed. You can tag the VizHub company page when posting.

More options

Embed on a websiteCopy iframe embed code
Download & exportPNG, HTML, source ZIP

Fork of Smiley Face Part-3 (React and d3)

0
PPeter Williams
Last edited Oct 22, 2021
Created on Oct 22, 2021

This example shows a simple smiley face built entirely with SVG primitives rendered through React. A yellow circle forms the head, two black circles are the eyes, and an arc-shaped `d` path defines the mouth. The code uses the `arc` helper from the `d3-shape` package to generate the mouth’s path geometry, with the arc’s inner and outer radii and start/end angles set via method chaining. SVG group elements and template literals position the face at the center of a 960×500 viewport.

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!!

Comments

Sign in to join the discussion.

MIT Licensed