diff --git a/src/charts/linechart/linechartitem.cpp b/src/charts/linechart/linechartitem.cpp index 2117da0..84d9e1e 100644 --- a/src/charts/linechart/linechartitem.cpp +++ b/src/charts/linechart/linechartitem.cpp @@ -70,7 +70,10 @@ QPainterPath LineChartItem::shape() const void LineChartItem::updateGeometry() { - const QVector &points = geometryPoints(); + // Store the points to a local variable so that the old line gets properly cleared + // when animation starts. + m_linePoints = geometryPoints(); + const QVector &points = m_linePoints; if (points.size() == 0) { prepareGeometryChange(); @@ -377,8 +380,8 @@ void LineChartItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *opt // to ensure proper continuity of the pattern painter->drawPath(m_linePath); } else { - for (int i(1); i < m_points.size(); i++) - painter->drawLine(m_points.at(i - 1), m_points.at(i)); + for (int i(1); i < m_linePoints.size(); i++) + painter->drawLine(m_linePoints.at(i - 1), m_linePoints.at(i)); } } @@ -389,7 +392,7 @@ void LineChartItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *opt painter->setClipping(true); else painter->setClipping(false); - m_series->d_func()->drawSeriesPointLabels(painter, m_points, m_linePen.width() / 2); + m_series->d_func()->drawSeriesPointLabels(painter, m_linePoints, m_linePen.width() / 2); } painter->restore(); diff --git a/src/charts/linechart/linechartitem_p.h b/src/charts/linechart/linechartitem_p.h index 321a8f6..ebf8a1b 100644 --- a/src/charts/linechart/linechartitem_p.h +++ b/src/charts/linechart/linechartitem_p.h @@ -74,6 +74,7 @@ private: QPainterPath m_fullPath; QPainterPath m_shapePath; + QVector m_linePoints; QRectF m_rect; QPen m_linePen; bool m_pointsVisible;