liveBook · Manning

Component

As explained in D3.js in Action, Third Edition

A component is a modular, reusable user-interface unit that encapsulates part of an application's structure or behavior.

A component is a modular, reusable interface unit that encapsulates part of an application's structure or behavior. In a React visualization project, components divide the dashboard into focused units rather than one large file. section 8.2

A practical component structure separates responsibilities:

  • ChartComponents contain singular chart elements, such as circles, rectangles, and axes. section 8.2
  • Charts contain complete visualizations, such as scatterplots and bar charts. section 8.2
  • Interactions hold interaction code, while UI contains unrelated elements such as buttons and cards. section 8.2

A reusable rectangle component

A bar chart can use a Rectangle component responsible only for drawing one rectangle, calling it once for each bar from BarChart. The same pattern applies to an Axis component, which can receive a type such as "band" and an array of labels. section 8.6.2

How D3.js in Action, Third Edition covers it

How deep it goes
Explains folder responsibilities and a Rectangle-to-BarChart decomposition, but does not cover component internals.
Examples
Uses dashboard folders, Rectangle.js, BarChart.js, Axis components, scatterplots, and bar charts as concrete examples.
What it assumes
Assumes familiarity with a frontend framework's syntax while reinforcing component decomposition through a concrete chart.
What you can do after
Build reusable chart elements and compose them into a bar chart or complete visualization.
How it connects
Connects components with React, Angular, Svelte, D3, bar charts, axes, and user-interface elements.

Also explained in

Compare how 10 books explain component →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of D3.js in Action, Third Edition. The section links point to the parts of the book it draws on.