Skip to content

Commit

Permalink
Fix _isPointInArea for undefined point (#8678)
Browse files Browse the repository at this point in the history
  • Loading branch information
kurkle authored Mar 19, 2021
1 parent 9a0a509 commit 81342d6
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/helpers/helpers.canvas.js
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ export function drawPoint(ctx, options, x, y) {
export function _isPointInArea(point, area, margin) {
margin = margin || 0.5; // margin - default is to match rounded decimals

return point.x > area.left - margin && point.x < area.right + margin &&
return point && point.x > area.left - margin && point.x < area.right + margin &&
point.y > area.top - margin && point.y < area.bottom + margin;
}

Expand Down
17 changes: 17 additions & 0 deletions test/specs/controller.line.tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,23 @@ describe('Chart.controllers.line', function() {
expect(meta.yAxisID).toBe('y');
});

it('Should not throw with empty dataset when tension is non-zero', function() {
// https://github.com/chartjs/Chart.js/issues/8676
function createChart() {
return window.acquireChart({
type: 'line',
data: {
datasets: [{
data: [],
tension: 0.5
}],
labels: []
},
});
}
expect(createChart).not.toThrow();
});

it('Should create line elements and point elements for each data item during initialization', function() {
var chart = window.acquireChart({
type: 'line',
Expand Down

0 comments on commit 81342d6

Please sign in to comment.