chartjs / chartjs/Chart.js

some points and line segments remain clipped when setting `clip: false`

Open
#11,899 0 comments 0 reactions 0 assignees View on GitHub
type: bug
Dominant language
JavaScript
Stars
67.7k
Forks
11.9k
Avg merge
7h 39m
Merged PRs (30d)
5

Description

### Expected behavior

My goal is to render points and line segments outside the chart area. This almost works by setting the dataset `clip` option to `false`, but not quite. Expected that when clipping is disabled, all points and line segments that can be shown, should in fact be shown.

### Current behavior

This function trims data points that are outside the chart area even if they would be visible on the canvas:

https://github.com/chartjs/Chart.js/blob/ea88dba68d41d4974c1fff5ce1c60f5d68279c13/src/controllers/controller.line.js#L46-L49

This prevents the `clip: false` option from working as expected.

### Reproducible sample

https://codepen.io/devon_fg/pen/poXmLQG?editors=0010

| observed | expected |
|--|--|
| ![image](https://github.com/user-attachments/assets/1ac1f070-53ee-4556-8892-fb375827a337) | ![image](https://github.com/user-attachments/assets/32c6fdeb-a12f-4bd0-bb11-2445e9f08082) |

### Optional extra steps/info to reproduce

In the provided codepen, the first three data points are:

```
{x: 1.4, y: 0},
{x: 1.45, y: 12},
{x: 1.6, y: 3},
```

All of these ought to be displayed, but in fact only the last point and the line segment preceding it are.

### Possible solutions

- `_getStartAndCountOfVisiblePoints` could be updated to account for clipping behavior and the full visible canvas
- an option could be provided to disable the point trimming behavior altogether

### Context

In our system we are animating new data entering and exiting the chart as the x-axis timebounds change. The current behavior causes data to suddenly appear rather than smoothly enter from offscreen.

### chart.js version

v4.4.0

### Browser name and version

_No response_

### Link to your project

_No response_

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.