Skip to content

Commit cc7ee8a

Browse files
authored
Fix curve path if scale limits are set for line chart (#11377)
* Fix curve path if scale limits are set for line chart * add scale limits test case
1 parent 05608b0 commit cc7ee8a

File tree

6 files changed

+72
-2
lines changed

6 files changed

+72
-2
lines changed

src/controllers/controller.line.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ export default class LineController extends DatasetController {
5757
line._chart = this.chart;
5858
line._datasetIndex = this.index;
5959
line._decimated = !!_dataset._decimated;
60-
line.points = points;
60+
line.points = points.slice(Math.max(this._drawStart - 1, 0), this._drawStart + this._drawCount);
6161

6262
const options = this.resolveDatasetElementOptions(mode);
6363
if (!this.options.showLine) {

src/helpers/helpers.extras.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ export function _getStartAndCountOfVisiblePoints(meta: ChartMeta<'line' | 'scatt
9898
if (minDefined) {
9999
start = _limitValue(Math.min(
100100
// @ts-expect-error Need to type _parsed
101-
_lookupByKey(_parsed, iScale.axis, min).lo,
101+
_lookupByKey(_parsed, axis, min).lo,
102102
// @ts-expect-error Need to fix types on _lookupByKey
103103
animationsDisabled ? pointCount : _lookupByKey(points, axis, iScale.getPixelForValue(min)).lo),
104104
0, pointCount - 1);
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
module.exports = {
2+
config: {
3+
type: 'line',
4+
data: {
5+
datasets: [
6+
{
7+
data: [
8+
{x: -10, y: 150},
9+
{x: 0, y: 81},
10+
{x: 10, y: 49},
11+
{x: 20, y: 32},
12+
{x: 30, y: 21},
13+
{x: 35, y: 1},
14+
{x: 40, y: 16},
15+
{x: 45, y: 13},
16+
],
17+
borderColor: '#ff0000',
18+
cubicInterpolationMode: 'monotone'
19+
}
20+
]
21+
},
22+
options: {
23+
scales: {
24+
x: {display: false, type: 'linear', min: 5, max: 37},
25+
y: {display: false}
26+
}
27+
}
28+
},
29+
options: {
30+
canvas: {
31+
height: 256,
32+
width: 512
33+
}
34+
}
35+
};
9.05 KB
Loading
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
module.exports = {
2+
config: {
3+
type: 'line',
4+
data: {
5+
datasets: [
6+
{
7+
data: [
8+
{x: -10, y: 150},
9+
{x: 0, y: 81},
10+
{x: 10, y: 49},
11+
{x: 20, y: 32},
12+
{x: 30, y: 21},
13+
{x: 35, y: 1},
14+
{x: 40, y: 16},
15+
{x: 45, y: 13},
16+
],
17+
borderColor: '#ff0000',
18+
cubicInterpolationMode: 'monotone'
19+
}
20+
]
21+
},
22+
options: {
23+
scales: {
24+
x: {display: false, type: 'linear', max: 30},
25+
y: {display: false}
26+
}
27+
}
28+
},
29+
options: {
30+
canvas: {
31+
height: 256,
32+
width: 512
33+
}
34+
}
35+
};
8.68 KB
Loading

0 commit comments

Comments
 (0)