Last active
June 13, 2021 18:59
-
-
Save Indy9000/f25b09606ece91f95125077f9be9b530 to your computer and use it in GitHub Desktop.
line-chart-widget
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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