Last active
September 18, 2019 09:38
-
-
Save CMyae/d625405d4225c3feda004ba8429988ee to your computer and use it in GitHub Desktop.
Code snippet for calculating data points for bezier curve
This file contains hidden or 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
//Sample Data points -> 50,25,100,80,...(your data to be represented in graph) | |
private fun calculatePointsForData() { | |
val bottomY = getLargeBarHeight() - CURVE_BOTTOM_MARGIN | |
val xDiff = width.toFloat() / data.size | |
val maxData = data.maxBy { it.amount }!!.amount | |
for (i in 0 until data.size) { | |
val y = bottomY - (data[i].amount / maxData * bottomY) | |
points.add(PointF(xDiff * i, y)) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment