This example illustrates the fundamental concept of marks and channels in data visualization by generating six separate SVG plots, each encoding the same array of five integers using a different visual channel: x position, y position, circle size, bar length, shape, and hue. The code leverages D3 v7 modules including `selection.join()`, `d3.symbol()` for generating shape paths, and the `schemeCategory10` color scheme. It demonstrates modular JavaScript by importing distinct functions like `xPosition` and `size` from separate files, with each function applying a unique scaling factor to the data. The rendered output shows how identical data can be represented through varied visual attributes.
AI-generated descriptionA demonstration of basic D3 usage to implement the concept of Marks and Channels. Includes usage of:
- Point Marks by X, Y, Size
- Line mark varying in length
- Scaling factors
- SVG Rectangles
selection.each()- SVG Path Elements
d3.symbol()- SVG attributes
transformandfill - D3 Color Schemes
- JavaScript Modules
Part of the Constructing Visualizations Playlist.
See also blocks.roadtolarissa.com: Marks and Channels (a vanilla JavaScript version of this).
Comments
Sign in to join the discussion.