diff --git a/examples/horizontalbarchart/main.cpp b/examples/horizontalbarchart/main.cpp index 8c0937d..d1f4b34 100644 --- a/examples/horizontalbarchart/main.cpp +++ b/examples/horizontalbarchart/main.cpp @@ -62,6 +62,7 @@ int main(int argc, char *argv[]) chart->addSeries(series); chart->setTitle("Simple horizontal barchart example"); chart->createDefaultAxes(); + chart->setAnimationOptions(QChart::SeriesAnimations); //![3] //![4] diff --git a/src/animations/horizontalbaranimation.cpp b/src/animations/horizontalbaranimation.cpp index 250561d..15a2ef8 100644 --- a/src/animations/horizontalbaranimation.cpp +++ b/src/animations/horizontalbaranimation.cpp @@ -39,11 +39,22 @@ HorizontalBarAnimation::~HorizontalBarAnimation() QVariant HorizontalBarAnimation::interpolated(const QVariant &from, const QVariant &to, qreal progress) const { - // TODO: - Q_UNUSED(from); - Q_UNUSED(to); - Q_UNUSED(progress); - return to; + QVector startVector = qVariantValue >(from); + QVector endVector = qVariantValue >(to); + QVector result; + + Q_ASSERT(startVector.count() == endVector.count()); + + for(int i = 0; i < startVector.count(); i++) { + qreal h = endVector[i].height(); + qreal w = startVector[i].width() + ((endVector[i].width() - startVector[i].width()) * progress); + qreal x = endVector[i].topLeft().x(); + qreal y = endVector[i].topLeft().y(); + + QRectF value(x,y,w,h); + result << value; + } + return qVariantFromValue(result); } #include "moc_horizontalbaranimation_p.cpp"