Skip to main content
Public

Share visualization

Loading preview…

Reusable Scatterplot Example

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

Reusable Scatterplot Example

0
RRobFaj
Last edited Mar 24, 2023
Created on Mar 24, 2023

A reusable scatterplot visualizes the Iris dataset, encoding sepal and petal lengths along the X and Y axes, with point size representing sepal width and color encoding species. Built with React and D3, the example uses `VizContainer` to abstract SVG groups and margin conventions, while a standalone `ScatterPlot` function configures scales, axes, and labels. D3's `d3.scale.linear`, `d3.svg.axis`, and `d3.csv` handle data loading and rendering. The visualization demonstrates a modular pattern where React manages layout and D3 handles chart internals, showing margins via an optional prop.

AI-generated description

Boilerplate code for a React + D3 visualization with:

  • CDN links for React, ReactDOM, and D3
  • Basic React boilerplate
  • Variables for dimensions and margins
  • A VizContainer component that:
    • Abstracts SVG/group container elements
    • Follows the margin convention
    • Show the margins, which can be easily removed by deleting the showMargins={true} prop

Comments

Sign in to join the discussion.

MIT Licensed