Last active
June 14, 2022 09:03
-
-
Save aqua30/90bfc6239a3daf096373563b784d273c to your computer and use it in GitHub Desktop.
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
val xAxisSpace = (size.width - paddingSpace.toPx()) / xValues.size | |
val yAxisSpace = size.height / yValues.size | |
/** placing x axis points */ | |
for (i in xValues.indices) { | |
drawContext.canvas.nativeCanvas.drawText( | |
"${xValues[i]}", | |
xAxisSpace * (i + 1), | |
size.height - 30, | |
textPaint | |
) | |
} | |
/** placing y axis points */ | |
for (i in yValues.indices) { | |
drawContext.canvas.nativeCanvas.drawText( | |
"${yValues[i]}", | |
paddingSpace.toPx() / 2f, | |
size.height - yAxisSpace * (i + 1), | |
textPaint | |
) | |
} | |
/** placing points */ | |
for (i in points.indices) { | |
val x1 = xAxisSpace * xValues[i] | |
val y1 = size.height - (yAxisSpace * (points[i]/verticalStep.toFloat())) | |
coordinates.add(PointF(x1,y1)) | |
/** drawing circles to indicate all the points */ | |
drawCircle( | |
color = Color.Red, | |
radius = 10f, | |
center = Offset(x1,y1) | |
) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment