Skip to content

Conversation

@Akshat-0001
Copy link

Fixes #12174

Problem

When zooming into a range that contains no data points
(between widely spaced points), the line chart disappears
even though the connecting line segment should be visible.

Cause

The line controller only rendered points strictly inside
the visible scale range. When zero points were visible,
no line segments were drawn.

Solution

Include the nearest boundary points (before and after the
visible range) when computing the draw window so line
segments crossing the viewport are rendered correctly.

Verification

  • Reproduced using the original CodePen
  • Verified line disappears with the CDN build
  • Rebuilt Chart.js with this patch
  • Confirmed the line remains visible when zooming into
    sparse regions with zero visible points

When zooming into a range with no visible data points,
the line controller skipped rendering entirely.

This change includes boundary points before and after
the visible range so line segments crossing the viewport
are still drawn.

Fixes chartjs#12174
Copilot AI review requested due to automatic review settings January 10, 2026 14:40
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request fixes a bug where line charts disappear when zooming into regions between widely spaced data points. The issue occurred because the line controller only rendered points strictly inside the visible range, causing line segments that cross the viewport to not be drawn.

Changes:

  • Added _includeBoundaryPoints method to find and include the nearest data points before and after the visible range
  • Modified the update method to call _includeBoundaryPoints before setting draw start and count
  • Moved the assignment of _drawStart and _drawCount to after the boundary point inclusion

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@Akshat-0001 Akshat-0001 marked this pull request as draft January 10, 2026 15:34
@Akshat-0001 Akshat-0001 marked this pull request as ready for review January 10, 2026 15:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Line chart disappears when zooming

1 participant