Time Cartesian Axis auto range does not respect datapoints beyond fixed Y-axis range
- Dominant language
- JavaScript
- Stars
- 67.7k
- Forks
- 11.9k
- Avg merge
- 7h 39m
- Merged PRs (30d)
- 5
Description
### Expected behavior
When `min` and `max` are specified for Y-axis, data points with values out of this range should still be included in the Time Cartesian Axis range.
Following chart
```js
{
type: 'line',
data: { datasets: [{ data: [
{ x: '2024-01-06 07:00:00', y: 0 },
{ x: '2024-01-06 08:00:00', y: 2 },
{ x: '2024-01-06 09:00:00', y: 4 },
]}]},
options: { scales: {
x: { type: 'time' },
y: { min: 0, max: 3 },
}}
}
```
Should be displayed as follows
Note that X-axis range is [7:00, 9:00].
### Current behavior
It is however displayed as follows
Note that X-axis range is [7:00, 8:00].
It could be fixed either by
- Changing X-axis type to `category`
- Setting X-axis `suggestedMax` to `2021-11-06 09:00:00`
- Changing Y-axis range max
### Reproducible sample
https://stackblitz.com/edit/line-chart-5yxrkz?file=app%2Fapp.component.ts
### Optional extra steps/info to reproduce
_No response_
### Possible solution
_No response_
### Context
I was adding manual Y-axis range controls in HomeAssistant history graphs: https://github.com/home-assistant/frontend/pull/19297
Data values out of the specified range led to unexpected behaviour where some of data were not displayed at all.
### chart.js version
v4.4.1
### 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.