Overview Trend Cosmetics

.. fill under a cumulative curve to indicate its not just the metric
.. truncate date ranges to today where it extends to the future
This commit is contained in:
Mark Liversedge
2020-06-15 17:55:44 +01:00
parent c3463860d5
commit bf76bac59d
2 changed files with 21 additions and 1 deletions

View File

@@ -585,6 +585,9 @@ MetricOverviewItem::setData(RideItem *item)
void
MetricOverviewItem::setDateRange(DateRange dr)
{
// for metrics lets truncate to today
if (dr.to > QDate::currentDate()) dr.to = QDate::currentDate();
Specification spec;
spec.setDateRange(dr);
@@ -676,6 +679,9 @@ MetricOverviewItem::setDateRange(DateRange dr)
first = false;
}
// do we want fill?
sparkline->setFill(metric->type()== RideMetric::Total || metric->type()== RideMetric::RunningTotal);
// update the sparkline
sparkline->setPoints(points);
@@ -2759,7 +2765,7 @@ BubbleViz::paint(QPainter*painter, const QStyleOptionGraphicsItem *, QWidget*)
}
Sparkline::Sparkline(QGraphicsWidget *parent, QString name, bool bigdot)
: QGraphicsItem(NULL), parent(parent), name(name), sparkdays(SPARKDAYS), bigdot(bigdot)
: QGraphicsItem(NULL), parent(parent), name(name), sparkdays(SPARKDAYS), bigdot(bigdot), fill(false)
{
min = max = 0.0f;
setGeometry(20,20,100,100);
@@ -2818,6 +2824,18 @@ Sparkline::paint(QPainter*painter, const QStyleOptionGraphicsItem *, QWidget*)
path.lineTo((points[i].x()*xfactor)+xoffset, bottom-((points[i].y()-min)*yfactor));
}
if (fill) {
QColor fillColor=GColor(CPLOTMARKER);
fillColor.setAlpha(64);
QPainterPath fillpath = path;
fillpath.lineTo((points.last().x()*xfactor)+xoffset,bottom);
fillpath.lineTo((points.first().x()*xfactor)+xoffset,bottom);
fillpath.lineTo((points.first().x()*xfactor)+xoffset,bottom);
fillpath.lineTo((points.first().x()*xfactor)+xoffset, bottom-((points.first().y()-min)*yfactor));
painter->fillPath(fillpath, QBrush(fillColor));
}
QPen pen(QColor(150,150,150));
pen.setWidth(8);
//pen.setStyle(Qt::DotLine);

View File

@@ -492,6 +492,7 @@ class Sparkline : public QGraphicsItem
QRectF geometry() { return geom; }
void setDays(int n) { sparkdays=n; } // defaults to SPARKDAYS
void setFill(bool x) { fill = x; }
void setPoints(QList<QPointF>);
void setRange(double min, double max); // upper lower
@@ -510,6 +511,7 @@ class Sparkline : public QGraphicsItem
double min, max;
int sparkdays;
bool bigdot;
bool fill;
QList<QPointF> points;
};