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

Сlipped chart when zoomed maximum or shifted with onPan event #799

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
12 changes: 7 additions & 5 deletions src/lib/scale/evaluator.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,13 +144,15 @@ function showMax(width, threshold) {
}

function getFilteredResponse(data, left, right, xAccessor) {
const newLeftIndex = getClosestItemIndexes(data, left, xAccessor).right;
const newRightIndex = getClosestItemIndexes(data, right, xAccessor).left;
const closestLeftIndex = getClosestItemIndexes(data, left, xAccessor).right;
const closestRightIndex = getClosestItemIndexes(data, right, xAccessor).left;

const filteredData = data.slice(newLeftIndex, newRightIndex + 1);
// console.log(right, newRightIndex, dataForInterval.length);
// add extra data point on the sides, in case when
// the chart is maximum zoomed and data disappears from sides due filtering logic
const newLeftIndex = closestLeftIndex >= 1 ? closestLeftIndex - 1 : closestLeftIndex;
const newRightIndex = closestRightIndex < data.length ? closestRightIndex + 1 : closestRightIndex;

return filteredData;
return data.slice(newLeftIndex, newRightIndex + 1);
}

export default function({
Expand Down