Skip to content

Commit

Permalink
Ignore truncated pixels in bar width calculation (#8995)
Browse files Browse the repository at this point in the history
  • Loading branch information
kurkle committed Apr 28, 2021
1 parent 44e62e7 commit 12bf256
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/controllers/controller.bar.js
@@ -1,7 +1,7 @@
import DatasetController from '../core/core.datasetController';
import {
clipArea, unclipArea, _arrayUnique, isArray, isNullOrUndef,
valueOrDefault, resolveObjectKey, sign
valueOrDefault, resolveObjectKey, sign, defined
} from '../helpers';

function getAllScaleValues(scale) {
Expand All @@ -26,7 +26,14 @@ function computeMinSampleSize(scale) {
let min = scale._length;
let i, ilen, curr, prev;
const updateMinAndPrev = () => {
min = Math.min(min, i && Math.abs(curr - prev) || min);
if (curr === 32767 || curr === -32768) {
// Ingnore truncated pixels
return;
}
if (defined(prev)) {
// curr - prev === 0 is ignored
min = Math.min(min, Math.abs(curr - prev) || min);
}
prev = curr;
};

Expand All @@ -35,6 +42,7 @@ function computeMinSampleSize(scale) {
updateMinAndPrev();
}

prev = undefined;
for (i = 0, ilen = scale.ticks.length; i < ilen; ++i) {
curr = scale.getPixelForTick(i);
updateMinAndPrev();
Expand Down

0 comments on commit 12bf256

Please sign in to comment.