clamp property
Whether or not the scale currently clamps values to within the range
.
If clamping is disabled and the scale is passed a value outside the
domain
, the scale may return a value outside the range
through
extrapolation. If clamping is enabled, the return value of the scale is
always within the scale’s range. Clamping similarly applies to
ScaleContinuousNumberExtension.invert. For example:
var x = ScaleLinear(
domain: [10, 130],
range: [0, 960],
interpolate: interpolateNumber,
);
x(-10); // -160, outside range
x.invert(-160); // -10, outside domain
x.clamp = true;
x(-10); // 0, clamped to range
x.invert(-160); // 10, clamped to domain
Implementation
bool get clamp => _clamp;
Implementation
set clamp(bool clamp) {
_clamp = clamp;
_clampf = identity;
_rescale();
}