Skip to main content

Scale helpers

Scale​

Scale types and readers for the charts whose axes change kind with their orientation.

Requires: module:d3-scale

Scale~AxisScale : function​

What a chart calls on an axis scale, typed structurally rather than as a d3 scale class.

Several charts hold two different kinds of scale in one variable: xScale is a scaleLinear when the chart is horizontal and a scaleBand when it is vertical, and yScale is the mirror image. No single d3 class describes either, and the isHorizontal flag cannot narrow a module-level let. GridScale in grid.ts and getBaselineExtent's scale parameter in domain.ts already type scales this way, for the same reason -- narrower about what is required, wider about what satisfies it.

The call signature returns number | undefined because a band scale's does: it maps a category name and has nothing to return for a name outside its domain. bandwidth and ticks are optional because only one kind of scale has each.

Kind: inner typedef of Scale