MCPcopy Create free account
hub / github.com/idank/explainshell / d3_scale_quantize

Function d3_scale_quantize

explainshell/web/static/js/d3.v3.js:6748–6773  ·  view source on GitHub ↗
(x0, x1, range)

Source from the content-addressed store, hash-verified

6746 return d3_scale_quantize(0, 1, [ 0, 1 ]);
6747 };
6748 function d3_scale_quantize(x0, x1, range) {
6749 var kx, i;
6750 function scale(x) {
6751 return range[Math.max(0, Math.min(i, Math.floor(kx * (x - x0))))];
6752 }
6753 function rescale() {
6754 kx = range.length / (x1 - x0);
6755 i = range.length - 1;
6756 return scale;
6757 }
6758 scale.domain = function(x) {
6759 if (!arguments.length) return [ x0, x1 ];
6760 x0 = +x[0];
6761 x1 = +x[x.length - 1];
6762 return rescale();
6763 };
6764 scale.range = function(x) {
6765 if (!arguments.length) return range;
6766 range = x;
6767 return rescale();
6768 };
6769 scale.copy = function() {
6770 return d3_scale_quantize(x0, x1, range);
6771 };
6772 return rescale();
6773 }
6774 d3.scale.threshold = function() {
6775 return d3_scale_threshold([ .5 ], [ 0, 1 ]);
6776 };

Callers 1

d3.v3.jsFile · 0.85

Calls 1

rescaleFunction · 0.85

Tested by

no test coverage detected