Skip to main content
Public

Share visualization

Loading preview…

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

Smiley Face Part-3 (React and d3)

20
IIlgar Akalın
Last edited Sep 16, 2021
Created on Sep 16, 2021

A React component renders a yellow smiley face in an SVG, with eyes as circles and a mouth drawn using the `arc` helper from the `d3-shape` package. The face’s elements are positioned inside a group element via a transform translation, with the mouth path generated from inner and outer radii and angular start and end points. The code uses ES6 template literals for the transform string, and the static data (dimensions, offsets, and radii) is hardcoded in constants.

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