Skip to main content
Public

Share visualization

Loading preview…

Rendering Marks and Channels with React & 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

Rendering Marks and Channels with React & D3

0
SSumanya4
Last edited Mar 7, 2022
Created on Mar 7, 2022

This example shows motorcycle sales data across 20 countries as a horizontal bar chart, using blue rectangles positioned with `d3.scaleBand` and `d3.scaleLinear`. The code initializes React state with `useState` and loads CSV data asynchronously via `d3.csv`. Axes are manually drawn using React elements and `xScale.ticks()`, while `d3.max` computes the domain. The SVG rendering is handled entirely through React components, demonstrating how D3 scales and data join with React’s declarative approach.

AI-generated description

A bare minimum HTML page demonstrating use of CSS and JavaScript.

See also React Starter.

Comments

Sign in to join the discussion.

MIT Licensed