From b75d1133e6144f6e55638ab47535c0ff86d1cc60 Mon Sep 17 00:00:00 2001 From: undefiened Date: Sat, 22 Jul 2023 14:27:34 +0200 Subject: [PATCH] Increase the offset so that Y-axis labels with decimals places fit (#969) * Added multipler to increase the space reserved for the chart labels which fixes the cases when labels with decimals places do not fit * Changed dirty fix to a less dirty fix * Removed multiplier * Removed x2 multiplier which was in the charting library code because it look like it reserves enough space without it --- .../openscale/gui/measurement/ChartMeasurementView.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/android_app/app/src/main/java/com/health/openscale/gui/measurement/ChartMeasurementView.java b/android_app/app/src/main/java/com/health/openscale/gui/measurement/ChartMeasurementView.java index 29b08eeb..92c50cc1 100644 --- a/android_app/app/src/main/java/com/health/openscale/gui/measurement/ChartMeasurementView.java +++ b/android_app/app/src/main/java/com/health/openscale/gui/measurement/ChartMeasurementView.java @@ -293,14 +293,19 @@ public class ChartMeasurementView extends LineChart { offsetBottom += Math.max(70f, mOffsetsBuffer.bottom); // offsets for y-labels + + // add one symbol worth of offset to avoid cutting decimal places + float additionalWidth = (float) Utils.calcTextWidth(mAxisRendererLeft + .getPaintAxisLabels(), "1"); + if (mAxisLeft.needsOffset()) { offsetLeft += mAxisLeft.getRequiredWidthSpace(mAxisRendererLeft - .getPaintAxisLabels()); + .getPaintAxisLabels()) + additionalWidth; } if (mAxisRight.needsOffset()) { offsetRight += mAxisRight.getRequiredWidthSpace(mAxisRendererRight - .getPaintAxisLabels()); + .getPaintAxisLabels()) + additionalWidth; } if (mXAxis.isEnabled() && mXAxis.isDrawLabelsEnabled()) {