Skip to content

Commit

Permalink
fix: calc visible points on update #10467
Browse files Browse the repository at this point in the history
  • Loading branch information
dangreen committed Jul 28, 2022
1 parent 8ccff8c commit 69a82fa
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/helpers/helpers.collection.js
Expand Up @@ -33,7 +33,7 @@ export function _lookup(table, value, cmp) {
* @private
*/
export const _lookupByKey = (table, key, value) =>
_lookup(table, value, index => table[index][key] < value);
_lookup(table, value, index => table[index][key] <= value);

/**
* Reverse binary search
Expand Down
47 changes: 47 additions & 0 deletions test/specs/controller.line.tests.js
Expand Up @@ -1016,4 +1016,51 @@ describe('Chart.controllers.line', function() {
expect(point.stop).toBe(i === 3);
}
});

it('should correctly calc visible points on update', async() => {
var chart = window.acquireChart({
type: 'line',
data: {
datasets: [{
data: [
{x: 10, y: 20},
{x: 15, y: 19},
]
}],
},
options: {
scales: {
y: {
type: 'linear',
min: 0,
max: 25,
},
x: {
type: 'linear',
min: 0,
max: 50
},
}
}
});

chart.data.datasets[0].data = [
{x: 10, y: 20},
{x: 15, y: 19},
{x: 17, y: 12},
{x: 50, y: 9},
{x: 50, y: 9},
{x: 50, y: 9},
];
chart.update();

var point = chart.getDatasetMeta(0).data[0];
var event = {
type: 'mousemove',
native: true,
...point
};

chart._handleEvent(event, false, true);
}, 500);
});

0 comments on commit 69a82fa

Please sign in to comment.