From 2e315f32ff6cdd8e4ba89ff281831069f7b7d183 Mon Sep 17 00:00:00 2001 From: Mark Liversedge Date: Thu, 17 Apr 2014 10:05:40 +0100 Subject: [PATCH] CPPlot y-axis for power .. always a multiple of 100w --- src/CPPlot.cpp | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/src/CPPlot.cpp b/src/CPPlot.cpp index 2d867fd9c..c8302f4b1 100644 --- a/src/CPPlot.cpp +++ b/src/CPPlot.cpp @@ -889,7 +889,20 @@ CPPlot::plotBests() ymax = 100 * ceil(values[0] / 100); if (ymax == 100) ymax = 5 * ceil(values[0] / 5); } - setAxisScale(yLeft, 0, ymax); + + // adjust if for power + if (rideSeries == RideFile::watts) { + + // set ymax to nearest 100 if power + int max = ymax * 1.1f; + max = ((max/100) + 1) * 100; + + setAxisScale(yLeft, 0, max); + } else { + + // or just add 10% headroom + setAxisScale(yLeft, 0, 1.1*ymax); + } } // plot the currently selected ride @@ -1540,7 +1553,19 @@ CPPlot::calculateForDateRanges(QList compareDateRanges) } } } - setAxisScale(yLeft, 0, 1.1*ymax); + + if (rideSeries == RideFile::watts) { + + // set ymax to nearest 100 if power + int max = ymax * 1.1f; + max = ((max/100) + 1) * 100; + + setAxisScale(yLeft, 0, max); + } else { + + // or just add 10% headroom + setAxisScale(yLeft, 0, 1.1*ymax); + } replot(); }