Texture Test
This example demonstrates how to combine color and texture scales independently for categorical data, using a 12×12 grid of circles where each circle’s fill encodes a (color, texture) pair. The code pairs three color values with three texture generators from textures.js, then builds a nested ordinal scale to create unique SVG defs for every combination, since textures cannot change color per mark. Circles transition their radius randomly over one-second intervals. The visualization uses d3.scaleOrdinal, textures.lines, textures.circles, textures.paths, and d3.transition to animate the marks.
AI-generated descriptionA test of textures.js that shows one approach for having independent scales for color and texture.
This ended up being more code than expected, because each (color, texture) combination needs to be defined independently. This is because each texture ends up as an SVG def, whose color properties (fill, stroke) cannot be changed per mark. Each (color, texture) pair must exist globally, then be applied to each mark.