createPathFromChartPoints function
Path?
createPathFromChartPoints(
- Size size,
- BoundingBox bounds,
- List<
Point> points, { - bool closePath = false,
Implementation
Path? createPathFromChartPoints(
Size size,
BoundingBox bounds,
List<Point> points, {
bool closePath = false,
}) {
if (points.length < 2) {
return null;
}
final zeroFraction = bounds.getFractionY(0);
final firstPoint = _getOffset(bounds, points.first, size);
final path = Path();
if (closePath) {
path
..moveTo(firstPoint.dx, size.height * zeroFraction.clamp(0, 1))
..lineTo(firstPoint.dx, firstPoint.dy);
} else {
path.moveTo(firstPoint.dx, firstPoint.dy);
}
for (var i = 1; i < points.length; i++) {
final point = _getOffset(bounds, points[i], size);
path.lineTo(point.dx, point.dy);
}
if (closePath) {
final lastPoint = _getOffset(bounds, points.last, size);
path.lineTo(lastPoint.dx, size.height * zeroFraction.clamp(0, 1));
}
return path;
}