mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-07-23 06:31:20 -04:00
only show relevant entries in statistics graphs
git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@8254 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
819c7b66c5
commit
0e16733ce0
2 changed files with 22 additions and 15 deletions
|
@ -105,12 +105,13 @@ QString RSGraphSource::displayValue(float v) const
|
||||||
return QString::number(v,'f',_digits) + " " + unitName() ;
|
return QString::number(v,'f',_digits) + " " + unitName() ;
|
||||||
}
|
}
|
||||||
|
|
||||||
void RSGraphSource::getCurrentValues(std::vector<float>& vals) const
|
void RSGraphSource::getCurrentValues(std::vector<QPointF>& vals) const
|
||||||
{
|
{
|
||||||
std::map<std::string,std::list<std::pair<qint64,float> > >::const_iterator it = _points.begin();
|
std::map<std::string,std::list<std::pair<qint64,float> > >::const_iterator it = _points.begin();
|
||||||
|
qint64 now = getTime() ;
|
||||||
|
|
||||||
for(it = _points.begin();it!=_points.end();++it)
|
for(it = _points.begin();it!=_points.end();++it)
|
||||||
vals.push_back(it->second.back().second) ;
|
vals.push_back(QPointF( (now - it->second.back().first)/1000.0f,it->second.back().second)) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString RSGraphSource::legend(int i,float v) const
|
QString RSGraphSource::legend(int i,float v) const
|
||||||
|
@ -565,15 +566,19 @@ void RSGraphWidget::paintLegend()
|
||||||
{
|
{
|
||||||
int bottom = _rec.height();
|
int bottom = _rec.height();
|
||||||
|
|
||||||
std::vector<float> vals ;
|
std::vector<QPointF> vals ;
|
||||||
_source->getCurrentValues(vals) ;
|
_source->getCurrentValues(vals) ;
|
||||||
|
int j=0;
|
||||||
|
|
||||||
for(uint i=0;i<vals.size();++i)
|
for(uint i=0;i<vals.size();++i)
|
||||||
if( _masked_entries.find(_source->displayName(i).toStdString()) == _masked_entries.end() )
|
if( _masked_entries.find(_source->displayName(i).toStdString()) == _masked_entries.end() )
|
||||||
{
|
{
|
||||||
|
if( _rec.width() - (vals[i].x()-0)*_time_scale < SCALE_WIDTH )
|
||||||
|
continue ;
|
||||||
|
|
||||||
qreal paintStep = 4+FONT_SIZE;
|
qreal paintStep = 4+FONT_SIZE;
|
||||||
qreal pos = 20+i*paintStep;
|
qreal pos = 20+j*paintStep;
|
||||||
QString text = _source->legend(i,vals[i]) ;
|
QString text = _source->legend(i,vals[i].y()) ;
|
||||||
|
|
||||||
QPen oldPen = _painter->pen();
|
QPen oldPen = _painter->pen();
|
||||||
_painter->setPen(QPen(getColor(i), Qt::SolidLine));
|
_painter->setPen(QPen(getColor(i), Qt::SolidLine));
|
||||||
|
@ -582,6 +587,8 @@ void RSGraphWidget::paintLegend()
|
||||||
|
|
||||||
_painter->setPen(SCALE_COLOR);
|
_painter->setPen(SCALE_COLOR);
|
||||||
_painter->drawText(QPointF(SCALE_WIDTH + 40,pos + 0.5*FONT_SIZE), text) ;
|
_painter->drawText(QPointF(SCALE_WIDTH + 40,pos + 0.5*FONT_SIZE), text) ;
|
||||||
|
|
||||||
|
++j ;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -70,7 +70,7 @@ public:
|
||||||
virtual QString displayValue(float v) const ;
|
virtual QString displayValue(float v) const ;
|
||||||
|
|
||||||
// return the vector of last values up to date
|
// return the vector of last values up to date
|
||||||
virtual void getCurrentValues(std::vector<float>& vals) const ;
|
virtual void getCurrentValues(std::vector<QPointF>& vals) const ;
|
||||||
|
|
||||||
// returns what to display in the legend. Derive this to show additional info.
|
// returns what to display in the legend. Derive this to show additional info.
|
||||||
virtual QString legend(int i,float v) const ;
|
virtual QString legend(int i,float v) const ;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue