Scale
Scales for plots.
Chart axes in plots can be scaled using the following functions. Each scale function accepts optional min and max value. Power scale accepts an extra exponent parameter.
Squiggle uses D3 for the tick formats. You can read about d3 tick formats here.
Numeric Scales
linear
Scale.linear({ min: 3, max: 10 })
log
Scale.log({ min: 1, max: 100 })
symlog
Symmetric log scale. Useful for plotting data that includes zero or negative values.
The function accepts an additional constant
parameter, used as follows: Scale.symlog(\{constant: 0.1\})
. This parameter allows you to allocate more pixel space to data with lower or higher absolute values. By adjusting this constant, you effectively control the scale's focus, shifting it between smaller and larger values. For more detailed information on this parameter, refer to the D3 Documentation.
The default value for constant
is 0.0001
.
Scale.symlog({ min: -10, max: 10 })
power
Power scale. Accepts an extra exponent
parameter, like, Scale.power(\{exponent: 2, min: 0, max: 100\})
.
The default value for exponent
is 0.1
.
Scale.power({ min: 1, max: 100, exponent: 0.1 })
Date Scales
date
Only works on Date values. Is a linear scale under the hood.
Scale.date({ min: Date(2022), max: Date(2025) })