mirror of
https://github.com/GoldenCheetah/GoldenCheetah.git
synced 2026-04-15 05:32:21 +00:00
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:
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user