package.src.identity.js Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of d3-scale Show documentation
Show all versions of d3-scale Show documentation
Encodings that map abstract data to visual representation.
The newest version!
import {linearish} from "./linear.js";
import number from "./number.js";
export default function identity(domain) {
var unknown;
function scale(x) {
return x == null || isNaN(x = +x) ? unknown : x;
}
scale.invert = scale;
scale.domain = scale.range = function(_) {
return arguments.length ? (domain = Array.from(_, number), scale) : domain.slice();
};
scale.unknown = function(_) {
return arguments.length ? (unknown = _, scale) : unknown;
};
scale.copy = function() {
return identity(domain).unknown(unknown);
};
domain = arguments.length ? Array.from(domain, number) : [0, 1];
return linearish(scale);
}