Skip to content

Instantly share code, notes, and snippets.

View ChristopherME's full-sized avatar

Christopher Elias ChristopherME

View GitHub Profile
@HiltViewModel
class ProductDetailViewModel @Inject constructor(
private val savedStateHandle: SavedStateHandle,
...
) : ViewModel() {
...
private fun getProductFromArgs(): ProductDetailArgs {
@Composable
fun LinearTransactionsChart(
modifier: Modifier = Modifier,
transactionsPerSecond: TransactionsPerSecond
) {
if (transactionsPerSecond.transactions.isEmpty()) return
Canvas(modifier = modifier) {
// Total number of transactions.
val totalRecords = transactionsPerSecond.transactions.size
/**
* 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.
*/