feat: Scrollable Signal Chart (#1505)

* Removed repeated calculation.

* Centralized the radius used to plot points and draw lines within GraphUtil.kt.

* Updated the signal metrics chart to use the scroll features.

* SignalMetricsChart long method warning suppression.
This commit is contained in:
Robert-0410 2025-01-03 04:02:32 -08:00 committed by GitHub
parent d14a8de78e
commit 70a08c9d31
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 87 additions and 98 deletions

View file

@ -17,6 +17,7 @@
package com.geeksville.mesh.util
import android.content.res.Resources
import androidx.compose.ui.graphics.Path
import androidx.compose.ui.geometry.Offset
import androidx.compose.ui.graphics.Color
@ -25,6 +26,8 @@ import com.geeksville.mesh.TelemetryProtos.Telemetry
object GraphUtil {
val RADIUS = Resources.getSystem().displayMetrics.density * 2
/**
* @param value Must be zero-scaled before passing.
* @param divisor The range for the data set.
@ -32,7 +35,6 @@ object GraphUtil {
fun plotPoint(
drawContext: DrawContext,
color: Color,
radius: Float,
x: Float,
value: Float,
divisor: Float,
@ -42,7 +44,7 @@ object GraphUtil {
val y = height - (ratio * height)
drawContext.canvas.drawCircle(
center = Offset(x, y),
radius = radius,
radius = RADIUS,
paint = androidx.compose.ui.graphics.Paint().apply { this.color = color }
)
}