Fix Sens curve scale if alone on a graph

=> I also fix deviation slope curve if secondary behind Sens curve
This commit is contained in:
Philoul 2021-05-23 14:37:18 +02:00
parent b9a9a86739
commit 62c063a5bc
3 changed files with 15 additions and 6 deletions

View file

@ -273,8 +273,8 @@ class OverviewData @Inject constructor(
var maxFromMaxValueFound = Double.MIN_VALUE var maxFromMaxValueFound = Double.MIN_VALUE
var maxFromMinValueFound = Double.MIN_VALUE var maxFromMinValueFound = Double.MIN_VALUE
val dsMaxScale = Scale() var dsMaxScale = Scale()
val dsMinScale = Scale() var dsMinScale = Scale()
var dsMaxSeries: LineGraphSeries<ScaledDataPoint> = LineGraphSeries() var dsMaxSeries: LineGraphSeries<ScaledDataPoint> = LineGraphSeries()
var dsMinSeries: LineGraphSeries<ScaledDataPoint> = LineGraphSeries() var dsMinSeries: LineGraphSeries<ScaledDataPoint> = LineGraphSeries()

View file

@ -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.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.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.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 // set manual x bounds to have nice steps
secondGraphData.formatAxis(overviewData.fromTime, overviewData.endTime) secondGraphData.formatAxis(overviewData.fromTime, overviewData.endTime)

View file

@ -164,13 +164,22 @@ class GraphData(
} }
// scale in % of vertical size (like 0.3) // 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) { if (useForScale) {
maxY = max(overviewData.maxFromMaxValueFound, overviewData.maxFromMinValueFound) maxY = max(overviewData.maxFromMaxValueFound, overviewData.maxFromMinValueFound)
minY = -maxY minY = -maxY
} }
overviewData.dsMaxScale.setMultiplier(maxY * scale / overviewData.maxFromMaxValueFound) var graphMaxY = maxY
overviewData.dsMinScale.setMultiplier(maxY * scale / overviewData.maxFromMinValueFound) 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.dsMaxSeries)
addSeries(overviewData.dsMinSeries) addSeries(overviewData.dsMinSeries)
} }