used more saturated colors in stats graph

This commit is contained in:
csoler 2017-05-11 18:46:40 +02:00
parent 7a19deea03
commit 38d07430b7
2 changed files with 15 additions and 9 deletions

View File

@ -385,12 +385,16 @@ default:
} }
} }
QColor RSGraphWidget::getColor(int i) QColor RSGraphWidget::getColor(const std::string& name)
{ {
// shuffle the colors a little bit uint32_t r = 57 ;
int h = (i*86243)%359 ; for(uint32_t i=0;i<name.length();++i)
r = (113*name[i] + r)^0x93859aeb;
return QColor::fromHsv(h,128+127*(i&1),255) ; // shuffle the colors a little bit
int h = (r*86243)%359 ;
return QColor::fromHsv(h,255,255) ;
} }
void RSGraphWidget::setCurvesOpacity(float f) void RSGraphWidget::setCurvesOpacity(float f)
@ -421,17 +425,19 @@ void RSGraphWidget::paintData()
QVector<QPointF> points ; QVector<QPointF> points ;
pointsFromData(values,points) ; pointsFromData(values,points) ;
QColor pcolor = getColor(source.displayName(i).toStdString()) ;
/* Plot the bandwidth data as area graphs */ /* Plot the bandwidth data as area graphs */
if (_flags & RSGRAPH_FLAGS_PAINT_STYLE_PLAIN) if (_flags & RSGRAPH_FLAGS_PAINT_STYLE_PLAIN)
paintIntegral(points, getColor(i), _opacity); paintIntegral(points, pcolor, _opacity);
/* Plot the bandwidth as solid lines. If the graph style is currently an /* Plot the bandwidth as solid lines. If the graph style is currently an
* area graph, we end up outlining the integrals. */ * area graph, we end up outlining the integrals. */
if(_flags & RSGRAPH_FLAGS_PAINT_STYLE_DOTS) if(_flags & RSGRAPH_FLAGS_PAINT_STYLE_DOTS)
paintDots(points, getColor(i)); paintDots(points, pcolor);
else else
paintLine(points, getColor(i)); paintLine(points, pcolor);
} }
if(_maxValue > 0.0f) if(_maxValue > 0.0f)
{ {
@ -731,7 +737,7 @@ void RSGraphWidget::paintLegend()
QPen oldPen = _painter->pen(); QPen oldPen = _painter->pen();
QPen pen(getColor(i), Qt::SolidLine) ; QPen pen(getColor(_source->displayName(i).toStdString()), Qt::SolidLine) ;
pen.setWidth(_linewidthscale); pen.setWidth(_linewidthscale);
_painter->setPen(pen); _painter->setPen(pen);

View File

@ -191,7 +191,7 @@ private:
void paintScale1(); void paintScale1();
void paintScale2(); void paintScale2();
QColor getColor(int i) ; QColor getColor(const std::string &name) ;
/** Returns a formatted string representation of total. */ /** Returns a formatted string representation of total. */
QString totalToStr(qreal total); QString totalToStr(qreal total);