From c8f17fe819f0fe47a19bc13824d95ea5f8ba8fc9 Mon Sep 17 00:00:00 2001 From: Mark Watkins Date: Sat, 10 Sep 2011 17:36:53 +1000 Subject: [PATCH] Fix SummaryChart total calculations --- Graphs/gBarChart.cpp | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/Graphs/gBarChart.cpp b/Graphs/gBarChart.cpp index d60abbb6..264ead31 100644 --- a/Graphs/gBarChart.cpp +++ b/Graphs/gBarChart.cpp @@ -315,12 +315,21 @@ void SummaryChart::paint(gGraph & w,int left, int top, int width, int height) w.renderText(a,px+24,py+5); } - if (total_days>0) { - float val=total_val/float(total_days); - QString z=m_label+"="+QString::number(val,'f',2)+" days="+QString::number(total_days,'f',0); - w.renderText(z,left,top-1); - // val = AHI for selected area. + QString z=m_label; + if (m_graphtype==GT_LINE) { + if (totalcounts[0]>0) { + float val=totalvalues[0]/float(totalcounts[0]); + z+="="+QString::number(val,'f',2)+" days="+QString::number(totalcounts[0],'f',0); + } + // val = AHI for selected area. + } else { // Bar chart works in total mode + if (total_days>0) { + float val=total_val/float(total_days); + z+="="+QString::number(val,'f',2)+" days="+QString::number(total_days,'f',0); + } + } + w.renderText(z,left,top-1); } bool SummaryChart::mouseMoveEvent(QMouseEvent *event) {