Threshold Key
This example displays a horizontal threshold key with colored rectangles that map to a d3.scaleThreshold’s range, and tick marks positioned by a d3.scaleLinear. The key’s extent is set by the linear scale’s domain of 0 to 100%, with ticks labeled as percentages or numbers. The code builds the key by inverting each color’s extent from the threshold scale and inserting rectangles before the axis ticks. The visualization mirrors a New York Times map of police stops involving force, using SVG rendering and a gist-hosted data source.
AI-generated descriptionThis example demonstrates how to construct a key from a threshold scale, in the style of Ford Fessenden’s map of police stops involving force. A linear scale is used to set the x-position of each colored rectangle in the key. There is one rectangle per color in the threshold scale’s range, and one tick per value in the threshold scale’s domain. The linear scale’s domain sets the implied extent of the key, here spanning 0 to 100%.
forked from <a href='http://bl.ocks.org/git-ashish/'>git-ashish</a>'s block: <a href='http://bl.ocks.org/git-ashish/3f7f86edf4ef46efb2c4585d1fa53ade'>Threshold Key</a>