Skip to main content
Public

Share visualization

Loading preview…

Viz-Hub Smiley

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

Viz-Hub Smiley

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

Comments

Sign in to join the discussion.

MIT Licensed