diff --git a/src/helpers/helpers.canvas.js b/src/helpers/helpers.canvas.js index e3344e6dd41..0472bddb31b 100644 --- a/src/helpers/helpers.canvas.js +++ b/src/helpers/helpers.canvas.js @@ -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; } diff --git a/test/specs/controller.line.tests.js b/test/specs/controller.line.tests.js index df0d7a14f73..93f857832f4 100644 --- a/test/specs/controller.line.tests.js +++ b/test/specs/controller.line.tests.js @@ -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',