From 62c063a5bc0d8693c06a3d94097549239d8864ee Mon Sep 17 00:00:00 2001 From: Philoul Date: Sun, 23 May 2021 14:37:18 +0200 Subject: [PATCH] Fix Sens curve scale if alone on a graph => I also fix deviation slope curve if secondary behind Sens curve --- .../plugins/general/overview/OverviewData.kt | 4 ++-- .../plugins/general/overview/OverviewFragment.kt | 2 +- .../general/overview/graphData/GraphData.kt | 15 ++++++++++++--- 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/OverviewData.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/OverviewData.kt index b14a819844..1346374246 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/OverviewData.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/OverviewData.kt @@ -273,8 +273,8 @@ class OverviewData @Inject constructor( var maxFromMaxValueFound = Double.MIN_VALUE var maxFromMinValueFound = Double.MIN_VALUE - val dsMaxScale = Scale() - val dsMinScale = Scale() + var dsMaxScale = Scale() + var dsMinScale = Scale() var dsMaxSeries: LineGraphSeries = LineGraphSeries() var dsMinSeries: LineGraphSeries = LineGraphSeries() diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/OverviewFragment.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/OverviewFragment.kt index d4b9d90774..9217164710 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/OverviewFragment.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/OverviewFragment.kt @@ -780,7 +780,7 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList if (menuChartSettings[g + 1][OverviewMenus.CharType.DEV.ordinal]) secondGraphData.addDeviations(useDevForScale, 1.0) if (menuChartSettings[g + 1][OverviewMenus.CharType.BGI.ordinal]) secondGraphData.addMinusBGI(useBGIForScale, if (alignDevBgiScale) 1.0 else 0.8) if (menuChartSettings[g + 1][OverviewMenus.CharType.SEN.ordinal]) secondGraphData.addRatio(useRatioForScale, if (useRatioForScale) 1.0 else 0.8) - if (menuChartSettings[g + 1][OverviewMenus.CharType.DEVSLOPE.ordinal] && buildHelper.isDev()) secondGraphData.addDeviationSlope(useDSForScale, 1.0) + if (menuChartSettings[g + 1][OverviewMenus.CharType.DEVSLOPE.ordinal] && buildHelper.isDev()) secondGraphData.addDeviationSlope(useDSForScale, if(useDSForScale) 1.0 else 0.8, useRatioForScale) // set manual x bounds to have nice steps secondGraphData.formatAxis(overviewData.fromTime, overviewData.endTime) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/graphData/GraphData.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/graphData/GraphData.kt index 498f98ee7f..cbc021b421 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/graphData/GraphData.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/graphData/GraphData.kt @@ -164,13 +164,22 @@ class GraphData( } // scale in % of vertical size (like 0.3) - fun addDeviationSlope(useForScale: Boolean, scale: Double) { + fun addDeviationSlope(useForScale: Boolean, scale: Double, isRatioScale: Boolean = false) { if (useForScale) { maxY = max(overviewData.maxFromMaxValueFound, overviewData.maxFromMinValueFound) minY = -maxY } - overviewData.dsMaxScale.setMultiplier(maxY * scale / overviewData.maxFromMaxValueFound) - overviewData.dsMinScale.setMultiplier(maxY * scale / overviewData.maxFromMinValueFound) + var graphMaxY = maxY + if (isRatioScale) { + graphMaxY = maxY - 100.0 + overviewData.dsMinScale = Scale(100.0) + overviewData.dsMaxScale = Scale(100.0) + } else { + overviewData.dsMinScale = Scale() + overviewData.dsMaxScale = Scale() + } + overviewData.dsMaxScale.setMultiplier(graphMaxY * scale / overviewData.maxFromMaxValueFound) + overviewData.dsMinScale.setMultiplier(graphMaxY * scale / overviewData.maxFromMinValueFound) addSeries(overviewData.dsMaxSeries) addSeries(overviewData.dsMinSeries) }