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

Function d3_scale_quantile

explainshell/web/static/js/d3.v3.js:6713–6744  ·  view source on GitHub ↗
(domain, range)

Source from the content-addressed store, hash-verified

6711 return d3_scale_quantile([], []);
6712 };
6713 function d3_scale_quantile(domain, range) {
6714 var thresholds;
6715 function rescale() {
6716 var k = 0, q = range.length;
6717 thresholds = [];
6718 while (++k < q) thresholds[k - 1] = d3.quantile(domain, k / q);
6719 return scale;
6720 }
6721 function scale(x) {
6722 if (isNaN(x = +x)) return NaN;
6723 return range[d3.bisect(thresholds, x)];
6724 }
6725 scale.domain = function(x) {
6726 if (!arguments.length) return domain;
6727 domain = x.filter(function(d) {
6728 return !isNaN(d);
6729 }).sort(d3.ascending);
6730 return rescale();
6731 };
6732 scale.range = function(x) {
6733 if (!arguments.length) return range;
6734 range = x;
6735 return rescale();
6736 };
6737 scale.quantiles = function() {
6738 return thresholds;
6739 };
6740 scale.copy = function() {
6741 return d3_scale_quantile(domain, range);
6742 };
6743 return rescale();
6744 }
6745 d3.scale.quantize = function() {
6746 return d3_scale_quantize(0, 1, [ 0, 1 ]);
6747 };

Callers 1

d3.v3.jsFile · 0.85

Calls 1

rescaleFunction · 0.85

Tested by

no test coverage detected