From b38eb45b295aaa346ad58e7ba3677456469a2fdd Mon Sep 17 00:00:00 2001 From: Stefan Fuchs Date: Thu, 15 Mar 2018 23:12:45 +0100 Subject: Profile heartrate: Nicer min/max values and tic distance Correct a bug in finding the minimum heartrate. Use the minimum and maximum heartrate value to set min/max and tic distance for the heartrate axis in the profile. Signed-off-by: Stefan Fuchs --- profile-widget/profilewidget2.cpp | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'profile-widget/profilewidget2.cpp') diff --git a/profile-widget/profilewidget2.cpp b/profile-widget/profilewidget2.cpp index b65e76743..4381e6963 100644 --- a/profile-widget/profilewidget2.cpp +++ b/profile-widget/profilewidget2.cpp @@ -644,8 +644,20 @@ void ProfileWidget2::plotDive(struct dive *d, bool force) #ifndef SUBSURFACE_MOBILE if (plotInfo.maxhr) { - heartBeatAxis->setMinimum(plotInfo.minhr); - heartBeatAxis->setMaximum(plotInfo.maxhr); + int heartBeatAxisMin = lrint(plotInfo.minhr / 5.0 - 0.5) * 5; + int heartBeatAxisMax, heartBeatAxisTick; + if (plotInfo.maxhr - plotInfo.minhr < 40) + heartBeatAxisTick = 10; + else if (plotInfo.maxhr - plotInfo.minhr < 80) + heartBeatAxisTick = 20; + else if (plotInfo.maxhr - plotInfo.minhr < 100) + heartBeatAxisTick = 25; + else + heartBeatAxisTick = 50; + for (heartBeatAxisMax = heartBeatAxisMin; heartBeatAxisMax < plotInfo.maxhr; heartBeatAxisMax += heartBeatAxisTick); + heartBeatAxis->setMinimum(heartBeatAxisMin); + heartBeatAxis->setMaximum(heartBeatAxisMax + 1); + heartBeatAxis->setTickInterval(heartBeatAxisTick); heartBeatAxis->updateTicks(HR_AXIS); // this shows the ticks } heartBeatAxis->setVisible(prefs.hrgraph && plotInfo.maxhr); -- cgit v1.2.3-70-g09d2