Created
October 24, 2021 06:14
-
-
Save ChristopherME/310bf7dc73b61f9f7fa57734a01ff303 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
/** | |
* Calculates the Y pixel coordinate for a given transaction rate. | |
* | |
* @param higherTransactionRateValue the highest rate value in the whole list of transactions. | |
* @param currentTransactionRate the current transaction RATE while iterating the list of transactions. | |
* @param canvasHeight the canvas HEIGHT for draw the linear chart. | |
* | |
* @return [Float] Y coordinate for a transaction rate. | |
*/ | |
private fun calculateYCoordinate( | |
higherTransactionRateValue: Double, | |
currentTransactionRate: Double, | |
canvasHeight: Float | |
): Float { | |
val maxAndCurrentValueDifference = (higherTransactionRateValue - currentTransactionRate) | |
.toFloat() | |
val relativePercentageOfScreen = (canvasHeight / higherTransactionRateValue) | |
.toFloat() | |
return maxAndCurrentValueDifference * relativePercentageOfScreen | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment