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;
total+=tmp;
m_values[dn][j+1]=tmp;
if (tmp<m_miny) m_miny=tmp;
if (tmp>m_maxy) m_maxy=tmp;
break;
// }
@ -92,12 +94,16 @@ void SummaryChart::SetDay(Day * nullday)
if (fnd) {
if (!m_fday) m_fday=dn;
m_values[dn][0]=total;
if (total<m_miny) m_miny=total;
if (total>m_maxy) m_maxy=total;
if (m_graphtype==GT_BAR) {
if (total<m_miny) m_miny=total;
if (total>m_maxy) m_maxy=total;
}
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_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;
zd--;
QHash<int,QHash<short,EventDataType> >::iterator d=m_values.find(zd);
if (d==m_values.end()) {
d=m_values.find(zd--);
}
// if (d==m_values.end()) {
// d=m_values.find(zd--);
// }
lastdaygood=true;
for (int i=0;i<numcodes;i++) {
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;
}
if (m_graphtype==GT_LINE) {
// minx-=86400000L;
//px-=barw;
}
for (qint64 Q=minx;Q<=maxx+86400000L;Q+=86400000L) {
zd=Q/86400000L;
QHash<int,QHash<short,EventDataType> >::iterator d=m_values.find(zd);
d=m_values.find(zd);
qint64 extra=86400000;
if (m_graphtype==GT_LINE) {
// extra*=2;
//extra=0;
}
if (Q<minx) continue;
if (d!=m_values.end()) {
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");
}
tmp=g.value(); //(g.value()/float(total));
tmp=g.value();
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) {
QColor col2=brighten(col);
@ -271,7 +270,7 @@ void SummaryChart::paint(gGraph & w,int left, int top, int width, int height)
} // if (bar
py-=h;
} 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;
if (lastdaygood) {
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;
m=floor(miny/50.0);
miny=m*50;
} else if (maxy>80) {
} else if (maxy>100) {
m=ceil(maxy/20.0);
maxy=m*20;
m=floor(miny/20.0);
miny=m*20;
} else if (maxy>30) {
} else if (maxy>40) {
m=ceil(maxy/10.0);
m++;
maxy=m*10;
m=floor(miny/10.0);
if(m<0) m--;
miny=m*10;
} else if (maxy>=4) {
m=ceil(maxy/5.0);
} else if (maxy>=5) {
m=ceil(maxy/5.0)+1;
maxy=m*5;
m=floor(miny/5.0);
miny=m*5;

View File

@ -95,7 +95,8 @@ Overview::Overview(QWidget *parent,gGraphView * shared) :
PR->AddLayer(new gXGrid());
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"));
//pr->addSlice(CPAP_IPAP,QColor("red"));
LK->AddLayer(new gYAxis(),LayerLeft,gYAxis::Margin);