Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix curve path if scale limits are set for line chart #11377

Merged
merged 2 commits into from
Jul 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/controllers/controller.line.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export default class LineController extends DatasetController {
line._chart = this.chart;
line._datasetIndex = this.index;
line._decimated = !!_dataset._decimated;
line.points = points;
line.points = points.slice(Math.max(this._drawStart - 1, 0), this._drawStart + this._drawCount);

const options = this.resolveDatasetElementOptions(mode);
if (!this.options.showLine) {
Expand Down
2 changes: 1 addition & 1 deletion src/helpers/helpers.extras.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ export function _getStartAndCountOfVisiblePoints(meta: ChartMeta<'line' | 'scatt
if (minDefined) {
start = _limitValue(Math.min(
// @ts-expect-error Need to type _parsed
_lookupByKey(_parsed, iScale.axis, min).lo,
_lookupByKey(_parsed, axis, min).lo,
// @ts-expect-error Need to fix types on _lookupByKey
animationsDisabled ? pointCount : _lookupByKey(points, axis, iScale.getPixelForValue(min)).lo),
0, pointCount - 1);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
module.exports = {
config: {
type: 'line',
data: {
datasets: [
{
data: [
{x: -10, y: 150},
{x: 0, y: 81},
{x: 10, y: 49},
{x: 20, y: 32},
{x: 30, y: 21},
{x: 35, y: 1},
{x: 40, y: 16},
{x: 45, y: 13},
],
borderColor: '#ff0000',
cubicInterpolationMode: 'monotone'
}
]
},
options: {
scales: {
x: {display: false, type: 'linear', min: 5, max: 37},
y: {display: false}
}
}
},
options: {
canvas: {
height: 256,
width: 512
}
}
};
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
module.exports = {
config: {
type: 'line',
data: {
datasets: [
{
data: [
{x: -10, y: 150},
{x: 0, y: 81},
{x: 10, y: 49},
{x: 20, y: 32},
{x: 30, y: 21},
{x: 35, y: 1},
{x: 40, y: 16},
{x: 45, y: 13},
],
borderColor: '#ff0000',
cubicInterpolationMode: 'monotone'
}
]
},
options: {
scales: {
x: {display: false, type: 'linear', max: 30},
stockiNail marked this conversation as resolved.
Show resolved Hide resolved
y: {display: false}
}
}
},
options: {
canvas: {
height: 256,
width: 512
}
}
};
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.