From 031edd0ece116f8b685744f21d3a1c036ffb2247 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Damian=20Kr=C3=B3lik?= <66667989+Damian-Nordic@users.noreply.github.com> Date: Mon, 28 Feb 2022 10:14:32 +0100 Subject: [PATCH] [android] Minor fix for pressure graph rendering (#15564) Some graph labels were truncated. Signed-off-by: Damian Krolik --- .../chiptool/clusterclient/SensorClientFragment.kt | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/clusterclient/SensorClientFragment.kt b/src/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/clusterclient/SensorClientFragment.kt index b1a69680f003f8..3ad6ad6e12ed96 100644 --- a/src/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/clusterclient/SensorClientFragment.kt +++ b/src/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/clusterclient/SensorClientFragment.kt @@ -92,15 +92,17 @@ class SensorClientFragment : Fragment() { sensorGraph.viewport.isXAxisBoundsManual = true sensorGraph.viewport.setMinX(currentTime.toDouble()) sensorGraph.viewport.setMaxX(currentTime.toDouble() + MIN_REFRESH_PERIOD_S * 1000 * MAX_DATA_POINTS) - sensorGraph.gridLabelRenderer.padding = 20 + sensorGraph.gridLabelRenderer.padding = 30 sensorGraph.gridLabelRenderer.numHorizontalLabels = 4 sensorGraph.gridLabelRenderer.setHorizontalLabelsAngle(150) sensorGraph.gridLabelRenderer.labelFormatter = object : LabelFormatter { override fun setViewport(viewport: Viewport?) = Unit override fun formatLabel(value: Double, isValueX: Boolean): String { - if (!isValueX) - return "%.2f".format(value) - return SimpleDateFormat("H:mm:ss").format(Date(value.toLong())).toString() + if (isValueX) + return SimpleDateFormat("H:mm:ss").format(Date(value.toLong())).toString() + if (value >= 100.0) + return "%.1f".format(value) + return "%.2f".format(value) } } }