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

Function histogram

explainshell/web/static/js/d3.v3.js:5728–5747  ·  view source on GitHub ↗
(data, i)

Source from the content-addressed store, hash-verified

5726 d3.layout.histogram = function() {
5727 var frequency = true, valuer = Number, ranger = d3_layout_histogramRange, binner = d3_layout_histogramBinSturges;
5728 function histogram(data, i) {
5729 var bins = [], values = data.map(valuer, this), range = ranger.call(this, values, i), thresholds = binner.call(this, range, values, i), bin, i = -1, n = values.length, m = thresholds.length - 1, k = frequency ? 1 : 1 / n, x;
5730 while (++i < m) {
5731 bin = bins[i] = [];
5732 bin.dx = thresholds[i + 1] - (bin.x = thresholds[i]);
5733 bin.y = 0;
5734 }
5735 if (m > 0) {
5736 i = -1;
5737 while (++i < n) {
5738 x = values[i];
5739 if (x >= range[0] && x <= range[1]) {
5740 bin = bins[d3.bisect(thresholds, x, 1, m) - 1];
5741 bin.y += k;
5742 bin.push(data[i]);
5743 }
5744 }
5745 }
5746 return bins;
5747 }
5748 histogram.value = function(x) {
5749 if (!arguments.length) return valuer;
5750 valuer = x;

Callers

nothing calls this directly

Calls 1

callMethod · 0.45

Tested by

no test coverage detected