Skip to main content
100%

scaleOrdinal() other variations

✓ Published1🌍 Public
SSubhendu Karmakar
Last edited Dec 27, 2023
Created on Dec 27, 2023

This example demonstrates the use of `d3.scaleOrdinal()` to map categorical month names to colors from the `d3.schemePaired` palette, with each month rendered as an `SVG` text element. The x-positions are determined by a `d3.scaleLinear()` scale mapping indices 0–11 to a 600-pixel range. The visualization shows how ordinal scales assign discrete colors to categories, while the linear scale controls spatial layout. The code uses D3's selection and `.join()` operation to create the text elements within the SVG wrapper. The data is a hardcoded array of month abbreviations.

AI-generated description

D3 Scales - scaleTime()

MIT Licensed

Similar vizzes