Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ignore truncated pixels in bar width calculation #8995

Merged
merged 1 commit into from Apr 28, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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