Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/traces/histogram/calc.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ module.exports = function calc(gd, trace) {
// decrease end a little in case of rounding errors
binend = pr2c(binspec.end) + (i - Axes.tickIncrement(i, binspec.size, false, calendar)) / 1e6;

while(i < binend && pos.length < 5000) {
while(i < binend && pos.length < 1e6) {
i2 = Axes.tickIncrement(i, binspec.size, false, calendar);
pos.push((i + i2) / 2);
size.push(sizeinit);
Expand All @@ -116,6 +116,8 @@ module.exports = function calc(gd, trace) {
// nonuniform bins also need nonuniform normalization factors
if(densitynorm) inc.push(1 / (i2 - i));
if(doavg) counts.push(0);
// break to avoid infinite loops
if(i2 <= i) break;
i = i2;
}

Expand Down
13 changes: 13 additions & 0 deletions test/jasmine/tests/histogram_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,19 @@ describe('Test histogram', function() {
]);
});

it('should handle very small bins', function() {
var out = _calc({
x: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9],
xbins: {
start: 0,
end: 10,
size: 0.001
}
});

expect(out.length).toEqual(9001);
});

describe('cumulative distribution functions', function() {
var base = {
x: [0, 5, 10, 15, 5, 10, 15, 10, 15, 15],
Expand Down