Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
line-chart-widget
List<Offset> _computePoints(Offset lt, double boxW, double boxH, double hr) {
return _Y.map((yp) {
final yy = boxH - (yp - _min) * hr;
final dp = lt + Offset(0, yy);
lt += Offset(boxW, 0);
return dp;
}).toList();
}
Path _computePath(List<Offset> points) {
final path = Path();
for (var i = 0; i < points.length; i++) {
final p = points[i];
if (i == 0) {
path.moveTo(p.dx, p.dy);
} else {
path.lineTo(p.dx, p.dy);
}
}
return path;
}
void _drawDataPoints(Canvas canvas, List<Offset> points, Paint dotPaintFill) {
points.forEach((dp) {
canvas.drawCircle(dp, radius, dotPaintFill);
canvas.drawCircle(dp, radius, linePaint);
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment