Skip to main content
100%

Marks and Channels

✓ Published0🌍 Public
CCurran Kelleher
Last edited Apr 19, 2023
Created on Apr 19, 2023

This example demonstrates D3 marks and channels by rendering six small multiples, each using a different visual channel—x position, y position, size, length, shape, and hue—to encode the same array `[0,1,2,3,4]`. Each SVG is generated using D3’s `select`, `selectAll`, and `join` API, with channels implemented via attribute callbacks like `attr("cx", ...)` and `attr("r", ...)`. It also uses `d3.symbol()` for generating SVG path symbols, `d3.schemeCategory10` for color, and the `selection.each()` method to apply each channel’s function. The code uses the `d3` module from a local script, relying on `d3.select`, `d3.selectAll`, and `d3.join` to build and update the SVG elements.

AI-generated description

A port of VizHub: Marks and Channels to vanilla JavaScript.

A 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 transform and fill
  • D3 Color Schemes
  • JavaScript Modules

Part of the Constructing Visualizations Playlist.

Similar vizzes