diff --git a/src/animations/pieanimation.cpp b/src/animations/pieanimation.cpp index 39a1584..a4b017c 100644 --- a/src/animations/pieanimation.cpp +++ b/src/animations/pieanimation.cpp @@ -37,8 +37,12 @@ PieAnimation::~PieAnimation() ChartAnimation *PieAnimation::updateValue(PieSliceItem *sliceItem, const PieSliceData &sliceData) { PieSliceAnimation *animation = m_animations.value(sliceItem); - Q_ASSERT(animation); - animation->stop(); + if (!animation) { + animation = new PieSliceAnimation(sliceItem); + m_animations.insert(sliceItem, animation); + } else { + animation->stop(); + } animation->updateValue(sliceData); animation->setDuration(ChartAnimationDuration); diff --git a/src/animations/piesliceanimation.cpp b/src/animations/piesliceanimation.cpp index 6271322..328c611 100644 --- a/src/animations/piesliceanimation.cpp +++ b/src/animations/piesliceanimation.cpp @@ -59,8 +59,10 @@ QBrush linearPos(QBrush start, QBrush end, qreal pos) PieSliceAnimation::PieSliceAnimation(PieSliceItem *sliceItem) : ChartAnimation(sliceItem), - m_sliceItem(sliceItem) + m_sliceItem(sliceItem), + m_currentValue(m_sliceItem->m_data) { + } PieSliceAnimation::~PieSliceAnimation() diff --git a/src/piechart/piesliceitem_p.h b/src/piechart/piesliceitem_p.h index adc7617..32111ad 100644 --- a/src/piechart/piesliceitem_p.h +++ b/src/piechart/piesliceitem_p.h @@ -81,6 +81,8 @@ private: QPainterPath m_labelArmPath; QRectF m_labelTextRect; bool m_hovered; + + friend class PieSliceAnimation; }; QTCOMMERCIALCHART_END_NAMESPACE