YAxis Scaling Cleanup

This commit is contained in:
Mark Watkins 2011-09-10 16:59:09 +10:00
parent 8968b03a6d
commit fc0f4f695d
3 changed files with 25 additions and 23 deletions

View File

@ -83,6 +83,8 @@ void SummaryChart::SetDay(Day * nullday)
fnd=true; fnd=true;
total+=tmp; total+=tmp;
m_values[dn][j+1]=tmp; m_values[dn][j+1]=tmp;
if (tmp<m_miny) m_miny=tmp;
if (tmp>m_maxy) m_maxy=tmp;
break; break;
// } // }
@ -92,12 +94,16 @@ void SummaryChart::SetDay(Day * nullday)
if (fnd) { if (fnd) {
if (!m_fday) m_fday=dn; if (!m_fday) m_fday=dn;
m_values[dn][0]=total; m_values[dn][0]=total;
if (total<m_miny) m_miny=total; if (m_graphtype==GT_BAR) {
if (total>m_maxy) m_maxy=total; if (total<m_miny) m_miny=total;
if (total>m_maxy) m_maxy=total;
}
m_empty=false; m_empty=false;
} }
} }
m_miny=0; if (m_graphtype==GT_BAR) {
m_miny=0;
}
// m_minx=qint64(QDateTime(m_profile->FirstDay(),QTime(0,0,0),Qt::UTC).toTime_t())*1000L; // m_minx=qint64(QDateTime(m_profile->FirstDay(),QTime(0,0,0),Qt::UTC).toTime_t())*1000L;
m_maxx=qint64(QDateTime(m_profile->LastDay().addDays(1),QTime(0,0,0),Qt::UTC).toTime_t())*1000L; m_maxx=qint64(QDateTime(m_profile->LastDay().addDays(1),QTime(0,0,0),Qt::UTC).toTime_t())*1000L;
@ -197,9 +203,9 @@ void SummaryChart::paint(gGraph & w,int left, int top, int width, int height)
int zd=minx/86400000L; int zd=minx/86400000L;
zd--; zd--;
QHash<int,QHash<short,EventDataType> >::iterator d=m_values.find(zd); QHash<int,QHash<short,EventDataType> >::iterator d=m_values.find(zd);
if (d==m_values.end()) { // if (d==m_values.end()) {
d=m_values.find(zd--); // d=m_values.find(zd--);
} // }
lastdaygood=true; lastdaygood=true;
for (int i=0;i<numcodes;i++) { for (int i=0;i<numcodes;i++) {
totalcounts[i]=0; totalcounts[i]=0;
@ -216,18 +222,10 @@ void SummaryChart::paint(gGraph & w,int left, int top, int width, int height)
lastY[i]=top+height-1-h; lastY[i]=top+height-1-h;
} }
if (m_graphtype==GT_LINE) {
// minx-=86400000L;
//px-=barw;
}
for (qint64 Q=minx;Q<=maxx+86400000L;Q+=86400000L) { for (qint64 Q=minx;Q<=maxx+86400000L;Q+=86400000L) {
zd=Q/86400000L; zd=Q/86400000L;
QHash<int,QHash<short,EventDataType> >::iterator d=m_values.find(zd); d=m_values.find(zd);
qint64 extra=86400000; qint64 extra=86400000;
if (m_graphtype==GT_LINE) {
// extra*=2;
//extra=0;
}
if (Q<minx) continue; if (Q<minx) continue;
if (d!=m_values.end()) { if (d!=m_values.end()) {
int x1=px,x2=px+barw; int x1=px,x2=px+barw;
@ -252,9 +250,10 @@ void SummaryChart::paint(gGraph & w,int left, int top, int width, int height)
col=QColor("gold"); col=QColor("gold");
} }
tmp=g.value(); //(g.value()/float(total)); tmp=g.value();
totalvalues[j]+=tmp; totalvalues[j]+=tmp;
h=tmp*ymult; //(float(total)*ymult); // height of chunk totalcounts[j]++;
h=tmp*ymult; // height in pixels
if (m_graphtype==GT_BAR) { if (m_graphtype==GT_BAR) {
QColor col2=brighten(col); QColor col2=brighten(col);
@ -271,7 +270,7 @@ void SummaryChart::paint(gGraph & w,int left, int top, int width, int height)
} // if (bar } // if (bar
py-=h; py-=h;
} else if (m_graphtype==GT_LINE) { // if (m_graphtype==GT_BAR } else if (m_graphtype==GT_LINE) { // if (m_graphtype==GT_BAR
short px2=px+barw;//lastX[j]+ceil(barw); short px2=px+barw;
short py2=top+height-1-h; short py2=top+height-1-h;
if (lastdaygood) { if (lastdaygood) {
lines->add(lastX[j],lastY[j],px2,py2,col); lines->add(lastX[j],lastY[j],px2,py2,col);

View File

@ -1158,18 +1158,20 @@ void gGraph::roundY(EventDataType &miny, EventDataType &maxy)
maxy=m*50; maxy=m*50;
m=floor(miny/50.0); m=floor(miny/50.0);
miny=m*50; miny=m*50;
} else if (maxy>80) { } else if (maxy>100) {
m=ceil(maxy/20.0); m=ceil(maxy/20.0);
maxy=m*20; maxy=m*20;
m=floor(miny/20.0); m=floor(miny/20.0);
miny=m*20; miny=m*20;
} else if (maxy>30) { } else if (maxy>40) {
m=ceil(maxy/10.0); m=ceil(maxy/10.0);
m++;
maxy=m*10; maxy=m*10;
m=floor(miny/10.0); m=floor(miny/10.0);
if(m<0) m--;
miny=m*10; miny=m*10;
} else if (maxy>=4) { } else if (maxy>=5) {
m=ceil(maxy/5.0); m=ceil(maxy/5.0)+1;
maxy=m*5; maxy=m*5;
m=floor(miny/5.0); m=floor(miny/5.0);
miny=m*5; miny=m*5;

View File

@ -95,7 +95,8 @@ Overview::Overview(QWidget *parent,gGraphView * shared) :
PR->AddLayer(new gXGrid()); PR->AddLayer(new gXGrid());
lk=new SummaryChart(profile,"Avg Leak",GT_LINE); lk=new SummaryChart(profile,"Avg Leak",GT_LINE);
lk->addSlice(CPAP_Leak,QColor("dark grey"),ST_WAVG); lk->addSlice(CPAP_Leak,QColor("dark blue"),ST_WAVG);
lk->addSlice(CPAP_Leak,QColor("dark grey"),ST_90P);
//lk->addSlice(CPAP_Leak,QColor("dark yellow")); //lk->addSlice(CPAP_Leak,QColor("dark yellow"));
//pr->addSlice(CPAP_IPAP,QColor("red")); //pr->addSlice(CPAP_IPAP,QColor("red"));
LK->AddLayer(new gYAxis(),LayerLeft,gYAxis::Margin); LK->AddLayer(new gYAxis(),LayerLeft,gYAxis::Margin);