Scale
Mapping abstract data to visual representation.
cm.scaleLinear(domain, range)
Constructs a new linear scale with the specified domain and range. Linear scales map a continuous, quantitative to a continuous output using a linear transformation.
const scale = cm.scaleLinear([0, 1], [0, 100]);
scale(0); // 0;
scale(0.5); // 50;
scale(1); // 100;
cm.scaleSqrt(domain, range)
Constructs a new sqrt scale with the specified domain and range. Sqrt scales are similar to linear scale, except a square root transform is applied to the input domain value before the output range is computed.
const scale = cm.scaleSqrt([0, 1], [0, 100]);
scale(0.09); // 30
scale(0.64); // 80
scale(0.81); // 90
cm.scaleLog(domain, range)
Constructs a new log scale with the specified domain and range. Log scales are similar to linear scale, except a logarithmic transform transform is applied to the input domain value before the output range is computed.
const scale = cm.scaleLog([1, 10], [0, 960]);
cm.scaleOrdinal(domain, range)
Constructs a new ordinal scale with the specified domain and range. Unlike linear scale, ordinal scales have a discrete domain and range. Given a value in the input domain, returns the corresponding in the output range.
const scale = cm.scaleOrdinal(["A", "B", "C"], ["steelblue", "yellow", "red"]);
scale("A"); // "steelblue"
scale("B"); // "yellow"
scale("C"); // "red"