summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarek Rosa <marek.rosa@digia.com>2012-11-29 12:35:00 +0200
committerMarek Rosa <marek.rosa@digia.com>2012-11-29 12:37:52 +0200
commit74962bdcee07ccc1cca7f07aaee141a540270827 (patch)
treef53ff75a2585659943f1fd718d07afbaa2bf8654
parent5642c6ee36d370de5db2a8d880639ab98b40170a (diff)
Bar animations refactored
-rw-r--r--src/animations/abstractbaranimation.cpp68
-rw-r--r--src/animations/abstractbaranimation_p.h59
-rw-r--r--src/animations/animations.pri16
-rw-r--r--src/animations/baranimation.cpp41
-rw-r--r--src/animations/baranimation_p.h16
-rw-r--r--src/animations/horizontalbaranimation.cpp74
-rw-r--r--src/animations/horizontalbaranimation_p.h52
-rw-r--r--src/animations/horizontalpercentbaranimation.cpp64
-rw-r--r--src/animations/horizontalpercentbaranimation_p.h52
-rw-r--r--src/animations/horizontalstackedbaranimation.cpp64
-rw-r--r--src/animations/horizontalstackedbaranimation_p.h52
-rw-r--r--src/animations/percentbaranimation.cpp64
-rw-r--r--src/animations/percentbaranimation_p.h55
-rw-r--r--src/animations/stackedbaranimation.cpp63
-rw-r--r--src/animations/stackedbaranimation_p.h55
-rw-r--r--src/barchart/abstractbarchartitem.cpp27
-rw-r--r--src/barchart/abstractbarchartitem_p.h8
-rw-r--r--src/barchart/horizontal/bar/horizontalbarchartitem.cpp42
-rw-r--r--src/barchart/horizontal/bar/horizontalbarchartitem_p.h1
-rw-r--r--src/barchart/horizontal/bar/qhorizontalbarseries.cpp13
-rw-r--r--src/barchart/horizontal/bar/qhorizontalbarseries_p.h1
-rw-r--r--src/barchart/horizontal/percent/horizontalpercentbarchartitem.cpp35
-rw-r--r--src/barchart/horizontal/percent/horizontalpercentbarchartitem_p.h1
-rw-r--r--src/barchart/horizontal/percent/qhorizontalpercentbarseries.cpp12
-rw-r--r--src/barchart/horizontal/percent/qhorizontalpercentbarseries_p.h1
-rw-r--r--src/barchart/horizontal/stacked/horizontalstackedbarchartitem.cpp29
-rw-r--r--src/barchart/horizontal/stacked/horizontalstackedbarchartitem_p.h1
-rw-r--r--src/barchart/horizontal/stacked/qhorizontalstackedbarseries.cpp12
-rw-r--r--src/barchart/horizontal/stacked/qhorizontalstackedbarseries_p.h1
-rw-r--r--src/barchart/qabstractbarseries.cpp14
-rw-r--r--src/barchart/qabstractbarseries_p.h1
-rw-r--r--src/barchart/vertical/bar/barchartitem.cpp30
-rw-r--r--src/barchart/vertical/bar/barchartitem_p.h1
-rw-r--r--src/barchart/vertical/bar/qbarseries.cpp13
-rw-r--r--src/barchart/vertical/bar/qbarseries_p.h1
-rw-r--r--src/barchart/vertical/percent/percentbarchartitem.cpp30
-rw-r--r--src/barchart/vertical/percent/percentbarchartitem_p.h3
-rw-r--r--src/barchart/vertical/percent/qpercentbarseries.cpp12
-rw-r--r--src/barchart/vertical/percent/qpercentbarseries_p.h1
-rw-r--r--src/barchart/vertical/stacked/qstackedbarseries.cpp12
-rw-r--r--src/barchart/vertical/stacked/qstackedbarseries_p.h1
-rw-r--r--src/barchart/vertical/stacked/stackedbarchartitem.cpp36
-rw-r--r--src/barchart/vertical/stacked/stackedbarchartitem_p.h2
43 files changed, 261 insertions, 875 deletions
diff --git a/src/animations/abstractbaranimation.cpp b/src/animations/abstractbaranimation.cpp
deleted file mode 100644
index 6635e3d9..00000000
--- a/src/animations/abstractbaranimation.cpp
+++ /dev/null
@@ -1,68 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Digia Plc
-** All rights reserved.
-** For any questions to Digia, please use contact form at http://qt.digia.com
-**
-** This file is part of the Qt Commercial Charts Add-on.
-**
-** $QT_BEGIN_LICENSE$
-** Licensees holding valid Qt Commercial licenses may use this file in
-** accordance with the Qt Commercial License Agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia.
-**
-** If you have questions regarding the use of this file, please use
-** contact form at http://qt.digia.com
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "abstractbaranimation_p.h"
-#include "abstractbarchartitem_p.h"
-#include <QTimer>
-#include <QDebug>
-
-Q_DECLARE_METATYPE(QVector<QRectF>)
-
-QTCOMMERCIALCHART_BEGIN_NAMESPACE
-
-AbstractBarAnimation::AbstractBarAnimation(AbstractBarChartItem *item)
- : ChartAnimation(item),
- m_item(item)
-{
- setDuration(ChartAnimationDuration);
- setEasingCurve(QEasingCurve::OutQuart);
-}
-
-AbstractBarAnimation::~AbstractBarAnimation()
-{
-}
-
-QVariant AbstractBarAnimation::interpolated(const QVariant &from, const QVariant &to, qreal progress) const
-{
- Q_UNUSED(from);
- Q_UNUSED(to);
- Q_UNUSED(progress);
- qWarning() << "AbstractBarAnimation::interpolated called";
- return to;
-}
-
-void AbstractBarAnimation::updateCurrentValue(const QVariant &value)
-{
- QVector<QRectF> layout = qvariant_cast<QVector<QRectF> >(value);
- m_item->setLayout(layout);
-}
-
-void AbstractBarAnimation::setup(const QVector<QRectF> &oldLayout, const QVector<QRectF> &newLayout)
-{
- QVariantAnimation::KeyValues value;
- setKeyValues(value); //workaround for wrong interpolation call
- setKeyValueAt(0.0, qVariantFromValue(oldLayout));
- setKeyValueAt(1.0, qVariantFromValue(newLayout));
-}
-
-#include "moc_abstractbaranimation_p.cpp"
-
-QTCOMMERCIALCHART_END_NAMESPACE
-
diff --git a/src/animations/abstractbaranimation_p.h b/src/animations/abstractbaranimation_p.h
deleted file mode 100644
index 3a8bb6b8..00000000
--- a/src/animations/abstractbaranimation_p.h
+++ /dev/null
@@ -1,59 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Digia Plc
-** All rights reserved.
-** For any questions to Digia, please use contact form at http://qt.digia.com
-**
-** This file is part of the Qt Commercial Charts Add-on.
-**
-** $QT_BEGIN_LICENSE$
-** Licensees holding valid Qt Commercial licenses may use this file in
-** accordance with the Qt Commercial License Agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia.
-**
-** If you have questions regarding the use of this file, please use
-** contact form at http://qt.digia.com
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-// W A R N I N G
-// -------------
-//
-// This file is not part of the QtCommercial Chart API. It exists purely as an
-// implementation detail. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-
-#ifndef ABSTRACTBARANIMATION_P_H
-#define ABSTRACTBARANIMATION_P_H
-
-#include "chartanimation_p.h"
-
-QTCOMMERCIALCHART_BEGIN_NAMESPACE
-
-class AbstractBarChartItem;
-
-class AbstractBarAnimation : public ChartAnimation
-{
- Q_OBJECT
-
-public:
- AbstractBarAnimation(AbstractBarChartItem *item);
- ~AbstractBarAnimation();
-
-public: // from QVariantAnimation
- virtual QVariant interpolated(const QVariant &from, const QVariant &to, qreal progress) const;
- virtual void updateCurrentValue(const QVariant &value);
-
- void setup(const QVector<QRectF> &oldLayout, const QVector<QRectF> &newLayout);
-
-protected:
- AbstractBarChartItem *m_item;
-};
-
-QTCOMMERCIALCHART_END_NAMESPACE
-
-#endif // ABSTRACTBARANIMATION_P_H
diff --git a/src/animations/animations.pri b/src/animations/animations.pri
index bb09727e..f3f79077 100644
--- a/src/animations/animations.pri
+++ b/src/animations/animations.pri
@@ -7,13 +7,7 @@ SOURCES += \
$$PWD/pieanimation.cpp \
$$PWD/piesliceanimation.cpp \
$$PWD/splineanimation.cpp \
- $$PWD/baranimation.cpp \
- $$PWD/stackedbaranimation.cpp \
- $$PWD/percentbaranimation.cpp \
- $$PWD/abstractbaranimation.cpp \
- $$PWD/horizontalbaranimation.cpp \
- $$PWD/horizontalstackedbaranimation.cpp \
- $$PWD/horizontalpercentbaranimation.cpp
+ $$PWD/baranimation.cpp
PRIVATE_HEADERS += \
$$PWD/axisanimation_p.h \
@@ -22,10 +16,4 @@ PRIVATE_HEADERS += \
$$PWD/pieanimation_p.h \
$$PWD/piesliceanimation_p.h \
$$PWD/splineanimation_p.h \
- $$PWD/baranimation_p.h \
- $$PWD/stackedbaranimation_p.h \
- $$PWD/percentbaranimation_p.h \
- $$PWD/abstractbaranimation_p.h \
- $$PWD/horizontalbaranimation_p.h \
- $$PWD/horizontalstackedbaranimation_p.h \
- $$PWD/horizontalpercentbaranimation_p.h
+ $$PWD/baranimation_p.h
diff --git a/src/animations/baranimation.cpp b/src/animations/baranimation.cpp
index 48b3b064..4c7f6435 100644
--- a/src/animations/baranimation.cpp
+++ b/src/animations/baranimation.cpp
@@ -27,9 +27,11 @@ Q_DECLARE_METATYPE(QVector<QRectF>)
QTCOMMERCIALCHART_BEGIN_NAMESPACE
BarAnimation::BarAnimation(AbstractBarChartItem *item)
- : AbstractBarAnimation(item)
+ : ChartAnimation(item),
+ m_item(item)
{
-
+ setDuration(ChartAnimationDuration);
+ setEasingCurve(QEasingCurve::OutQuart);
}
BarAnimation::~BarAnimation()
@@ -47,27 +49,32 @@ QVariant BarAnimation::interpolated(const QVariant &from, const QVariant &to, qr
for (int i = 0; i < startVector.count(); i++) {
QRectF start = startVector[i].normalized();
QRectF end = endVector[i].normalized();
+ qreal x1 = start.left() + progress * (end.left() - start.left());
+ qreal x2 = start.right() + progress * (end.right() - start.right());
+ qreal y1 = start.top() + progress * (end.top() - start.top());
+ qreal y2 = start.bottom() + progress * (end.bottom() - start.bottom());
- qreal x = end.left();
- qreal y;
- qreal w = end.width();
- qreal h;
-
- if (endVector[i].height() < 0) {
- // Negative bar
- y = end.top();
- h = start.height() + ((end.height() - start.height()) * progress);
- } else {
- h = startVector[i].height() + ((endVector[i].height() - startVector[i].height()) * progress);
- y = endVector[i].top() + endVector[i].height() - h;
- }
-
- QRectF value(x, y, w, h);
+ QRectF value(QPointF(x1, y1), QPointF(x2, y2));
result << value.normalized();
}
return qVariantFromValue(result);
}
+void BarAnimation::updateCurrentValue(const QVariant &value)
+{
+ QVector<QRectF> layout = qvariant_cast<QVector<QRectF> >(value);
+ m_item->setLayout(layout);
+}
+
+void BarAnimation::setup(const QVector<QRectF> &oldLayout, const QVector<QRectF> &newLayout)
+{
+ QVariantAnimation::KeyValues value;
+ setKeyValues(value); //workaround for wrong interpolation call
+ setKeyValueAt(0.0, qVariantFromValue(oldLayout));
+ setKeyValueAt(1.0, qVariantFromValue(newLayout));
+}
+
#include "moc_baranimation_p.cpp"
QTCOMMERCIALCHART_END_NAMESPACE
+
diff --git a/src/animations/baranimation_p.h b/src/animations/baranimation_p.h
index 8b6bd6b3..7115f05c 100644
--- a/src/animations/baranimation_p.h
+++ b/src/animations/baranimation_p.h
@@ -27,18 +27,16 @@
//
// We mean it.
-#ifndef BARANIMATION_P_H
-#define BARANIMATION_P_H
+#ifndef ABSTRACTBARANIMATION_P_H
+#define ABSTRACTBARANIMATION_P_H
-#include "abstractbaranimation_p.h"
#include "chartanimation_p.h"
-#include "abstractbarchartitem_p.h"
QTCOMMERCIALCHART_BEGIN_NAMESPACE
class AbstractBarChartItem;
-class BarAnimation : public AbstractBarAnimation
+class BarAnimation : public ChartAnimation
{
Q_OBJECT
@@ -48,8 +46,14 @@ public:
public: // from QVariantAnimation
virtual QVariant interpolated(const QVariant &from, const QVariant &to, qreal progress) const;
+ virtual void updateCurrentValue(const QVariant &value);
+
+ void setup(const QVector<QRectF> &oldLayout, const QVector<QRectF> &newLayout);
+
+protected:
+ AbstractBarChartItem *m_item;
};
QTCOMMERCIALCHART_END_NAMESPACE
-#endif
+#endif // ABSTRACTBARANIMATION_P_H
diff --git a/src/animations/horizontalbaranimation.cpp b/src/animations/horizontalbaranimation.cpp
deleted file mode 100644
index 39dd9c38..00000000
--- a/src/animations/horizontalbaranimation.cpp
+++ /dev/null
@@ -1,74 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Digia Plc
-** All rights reserved.
-** For any questions to Digia, please use contact form at http://qt.digia.com
-**
-** This file is part of the Qt Commercial Charts Add-on.
-**
-** $QT_BEGIN_LICENSE$
-** Licensees holding valid Qt Commercial licenses may use this file in
-** accordance with the Qt Commercial License Agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia.
-**
-** If you have questions regarding the use of this file, please use
-** contact form at http://qt.digia.com
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "horizontalbaranimation_p.h"
-#include "abstractbarchartitem_p.h"
-#include <QTimer>
-
-Q_DECLARE_METATYPE(QVector<QRectF>)
-
-QTCOMMERCIALCHART_BEGIN_NAMESPACE
-
-HorizontalBarAnimation::HorizontalBarAnimation(AbstractBarChartItem *item)
- : AbstractBarAnimation(item)
-{
-}
-
-HorizontalBarAnimation::~HorizontalBarAnimation()
-{
-
-}
-
-
-QVariant HorizontalBarAnimation::interpolated(const QVariant &from, const QVariant &to, qreal progress) const
-{
- QVector<QRectF> startVector = qvariant_cast<QVector<QRectF> >(from);
- QVector<QRectF> endVector = qvariant_cast<QVector<QRectF> >(to);
- QVector<QRectF> result;
-
- Q_ASSERT(startVector.count() == endVector.count());
-
- for (int i = 0; i < startVector.count(); i++) {
- QRectF start = startVector[i].normalized();
- QRectF end = endVector[i].normalized();
-
- qreal x;
- qreal y = end.top();
- qreal w;
- qreal h = end.height();
-
- if (endVector[i].width() < 0) {
- // Negative bar
- w = start.width() + ((end.width() - start.width()) * progress);
- x = endVector[i].right() - endVector[i].width() - w;
- } else {
- w = startVector[i].width() + ((endVector[i].width() - startVector[i].width()) * progress);
- x = end.left();
- }
-
- QRectF value(x, y, w, h);
- result << value.normalized();
- }
- return qVariantFromValue(result);
-}
-
-#include "moc_horizontalbaranimation_p.cpp"
-
-QTCOMMERCIALCHART_END_NAMESPACE
diff --git a/src/animations/horizontalbaranimation_p.h b/src/animations/horizontalbaranimation_p.h
deleted file mode 100644
index 9c8438b3..00000000
--- a/src/animations/horizontalbaranimation_p.h
+++ /dev/null
@@ -1,52 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Digia Plc
-** All rights reserved.
-** For any questions to Digia, please use contact form at http://qt.digia.com
-**
-** This file is part of the Qt Commercial Charts Add-on.
-**
-** $QT_BEGIN_LICENSE$
-** Licensees holding valid Qt Commercial licenses may use this file in
-** accordance with the Qt Commercial License Agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia.
-**
-** If you have questions regarding the use of this file, please use
-** contact form at http://qt.digia.com
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-// W A R N I N G
-// -------------
-//
-// This file is not part of the QtCommercial Chart API. It exists purely as an
-// implementation detail. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-
-#ifndef HORIZONTALBARANIMATION_P_H
-#define HORIZONTALBARANIMATION_P_H
-
-#include "abstractbaranimation_p.h"
-#include "chartanimation_p.h"
-#include "abstractbarchartitem_p.h"
-
-QTCOMMERCIALCHART_BEGIN_NAMESPACE
-
-class HorizontalBarAnimation : public AbstractBarAnimation
-{
- Q_OBJECT
-public:
- explicit HorizontalBarAnimation(AbstractBarChartItem *item);
- ~HorizontalBarAnimation();
-
- virtual QVariant interpolated(const QVariant &from, const QVariant &to, qreal progress) const;
-
-};
-
-QTCOMMERCIALCHART_END_NAMESPACE
-
-#endif // HORIZONTALBARANIMATION_P_H
diff --git a/src/animations/horizontalpercentbaranimation.cpp b/src/animations/horizontalpercentbaranimation.cpp
deleted file mode 100644
index 13dfa097..00000000
--- a/src/animations/horizontalpercentbaranimation.cpp
+++ /dev/null
@@ -1,64 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Digia Plc
-** All rights reserved.
-** For any questions to Digia, please use contact form at http://qt.digia.com
-**
-** This file is part of the Qt Commercial Charts Add-on.
-**
-** $QT_BEGIN_LICENSE$
-** Licensees holding valid Qt Commercial licenses may use this file in
-** accordance with the Qt Commercial License Agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia.
-**
-** If you have questions regarding the use of this file, please use
-** contact form at http://qt.digia.com
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "horizontalpercentbaranimation_p.h"
-#include "abstractbarchartitem_p.h"
-#include <QTimer>
-
-Q_DECLARE_METATYPE(QVector<QRectF>)
-
-QTCOMMERCIALCHART_BEGIN_NAMESPACE
-
-HorizontalPercentBarAnimation::HorizontalPercentBarAnimation(AbstractBarChartItem *item) :
- AbstractBarAnimation(item)
-{
-}
-
-HorizontalPercentBarAnimation::~HorizontalPercentBarAnimation()
-{
-
-}
-
-
-QVariant HorizontalPercentBarAnimation::interpolated(const QVariant &from, const QVariant &to, qreal progress) const
-{
- QVector<QRectF> startVector = qvariant_cast<QVector<QRectF> >(from);
- QVector<QRectF> endVector = qvariant_cast<QVector<QRectF> >(to);
- QVector<QRectF> result;
-
- Q_ASSERT(startVector.count() == endVector.count());
-
- qreal xAxis = m_item->geometry().x();
-
- for (int i = 0; i < startVector.count(); i++) {
- qreal h = endVector[i].height();
- qreal w = endVector[i].width() * progress;
- qreal x = xAxis + ((endVector[i].left() - xAxis) * progress);
- qreal y = endVector[i].top();
-
- QRectF value(x, y, w, h);
- result << value.normalized();
- }
- return qVariantFromValue(result);
-}
-
-#include "moc_horizontalpercentbaranimation_p.cpp"
-
-QTCOMMERCIALCHART_END_NAMESPACE
diff --git a/src/animations/horizontalpercentbaranimation_p.h b/src/animations/horizontalpercentbaranimation_p.h
deleted file mode 100644
index 82852e66..00000000
--- a/src/animations/horizontalpercentbaranimation_p.h
+++ /dev/null
@@ -1,52 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Digia Plc
-** All rights reserved.
-** For any questions to Digia, please use contact form at http://qt.digia.com
-**
-** This file is part of the Qt Commercial Charts Add-on.
-**
-** $QT_BEGIN_LICENSE$
-** Licensees holding valid Qt Commercial licenses may use this file in
-** accordance with the Qt Commercial License Agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia.
-**
-** If you have questions regarding the use of this file, please use
-** contact form at http://qt.digia.com
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-// W A R N I N G
-// -------------
-//
-// This file is not part of the QtCommercial Chart API. It exists purely as an
-// implementation detail. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-
-#ifndef HORIZONTALPERCENTBARANIMATION_P_H
-#define HORIZONTALPERCENTBARANIMATION_P_H
-
-#include "abstractbaranimation_p.h"
-#include "chartanimation_p.h"
-#include "abstractbarchartitem_p.h"
-
-QTCOMMERCIALCHART_BEGIN_NAMESPACE
-
-class HorizontalPercentBarAnimation : public AbstractBarAnimation
-{
- Q_OBJECT
-public:
- explicit HorizontalPercentBarAnimation(AbstractBarChartItem *item);
- ~HorizontalPercentBarAnimation();
-
- virtual QVariant interpolated(const QVariant &from, const QVariant &to, qreal progress) const;
-
-};
-
-QTCOMMERCIALCHART_END_NAMESPACE
-
-#endif // HORIZONTALPERCENTBARANIMATION_P_H
diff --git a/src/animations/horizontalstackedbaranimation.cpp b/src/animations/horizontalstackedbaranimation.cpp
deleted file mode 100644
index 5279c0fe..00000000
--- a/src/animations/horizontalstackedbaranimation.cpp
+++ /dev/null
@@ -1,64 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Digia Plc
-** All rights reserved.
-** For any questions to Digia, please use contact form at http://qt.digia.com
-**
-** This file is part of the Qt Commercial Charts Add-on.
-**
-** $QT_BEGIN_LICENSE$
-** Licensees holding valid Qt Commercial licenses may use this file in
-** accordance with the Qt Commercial License Agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia.
-**
-** If you have questions regarding the use of this file, please use
-** contact form at http://qt.digia.com
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "horizontalstackedbaranimation_p.h"
-#include "abstractbarchartitem_p.h"
-#include <QTimer>
-
-Q_DECLARE_METATYPE(QVector<QRectF>)
-
-QTCOMMERCIALCHART_BEGIN_NAMESPACE
-
-HorizontalStackedBarAnimation::HorizontalStackedBarAnimation(AbstractBarChartItem *item) :
- AbstractBarAnimation(item)
-{
-}
-
-HorizontalStackedBarAnimation::~HorizontalStackedBarAnimation()
-{
-
-}
-
-
-QVariant HorizontalStackedBarAnimation::interpolated(const QVariant &from, const QVariant &to, qreal progress) const
-{
- QVector<QRectF> startVector = qvariant_cast<QVector<QRectF> >(from);
- QVector<QRectF> endVector = qvariant_cast<QVector<QRectF> >(to);
- QVector<QRectF> result;
-
- Q_ASSERT(startVector.count() == endVector.count());
-
- qreal xAxis = m_item->geometry().x();
-
- for (int i = 0; i < startVector.count(); i++) {
- qreal h = endVector[i].height();
- qreal w = endVector[i].width() * progress;
- qreal x = xAxis + ((endVector[i].left() - xAxis) * progress);
- qreal y = endVector[i].top();
-
- QRectF value(x, y, w, h);
- result << value.normalized();
- }
- return qVariantFromValue(result);
-}
-
-#include "moc_horizontalstackedbaranimation_p.cpp"
-
-QTCOMMERCIALCHART_END_NAMESPACE
diff --git a/src/animations/horizontalstackedbaranimation_p.h b/src/animations/horizontalstackedbaranimation_p.h
deleted file mode 100644
index 1520e4db..00000000
--- a/src/animations/horizontalstackedbaranimation_p.h
+++ /dev/null
@@ -1,52 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Digia Plc
-** All rights reserved.
-** For any questions to Digia, please use contact form at http://qt.digia.com
-**
-** This file is part of the Qt Commercial Charts Add-on.
-**
-** $QT_BEGIN_LICENSE$
-** Licensees holding valid Qt Commercial licenses may use this file in
-** accordance with the Qt Commercial License Agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia.
-**
-** If you have questions regarding the use of this file, please use
-** contact form at http://qt.digia.com
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-// W A R N I N G
-// -------------
-//
-// This file is not part of the QtCommercial Chart API. It exists purely as an
-// implementation detail. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-
-#ifndef HORIZONTALSTACKEDBARANIMATION_P_H
-#define HORIZONTALSTACKEDBARANIMATION_P_H
-
-#include "abstractbaranimation_p.h"
-#include "chartanimation_p.h"
-#include "abstractbarchartitem_p.h"
-
-QTCOMMERCIALCHART_BEGIN_NAMESPACE
-
-class HorizontalStackedBarAnimation : public AbstractBarAnimation
-{
- Q_OBJECT
-public:
- explicit HorizontalStackedBarAnimation(AbstractBarChartItem *item);
- ~HorizontalStackedBarAnimation();
-
- virtual QVariant interpolated(const QVariant &from, const QVariant &to, qreal progress) const;
-
-};
-
-QTCOMMERCIALCHART_END_NAMESPACE
-
-#endif // HORIZONTALSTACKEDBARANIMATION_P_H
diff --git a/src/animations/percentbaranimation.cpp b/src/animations/percentbaranimation.cpp
deleted file mode 100644
index ea09d907..00000000
--- a/src/animations/percentbaranimation.cpp
+++ /dev/null
@@ -1,64 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Digia Plc
-** All rights reserved.
-** For any questions to Digia, please use contact form at http://qt.digia.com
-**
-** This file is part of the Qt Commercial Charts Add-on.
-**
-** $QT_BEGIN_LICENSE$
-** Licensees holding valid Qt Commercial licenses may use this file in
-** accordance with the Qt Commercial License Agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia.
-**
-** If you have questions regarding the use of this file, please use
-** contact form at http://qt.digia.com
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "percentbaranimation_p.h"
-#include "percentbarchartitem_p.h"
-#include <QTimer>
-
-Q_DECLARE_METATYPE(QVector<QRectF>)
-
-QTCOMMERCIALCHART_BEGIN_NAMESPACE
-
-PercentBarAnimation::PercentBarAnimation(PercentBarChartItem *item)
- : AbstractBarAnimation(item)
-{
- setDuration(ChartAnimationDuration);
- setEasingCurve(QEasingCurve::OutQuart);
-}
-
-PercentBarAnimation::~PercentBarAnimation()
-{
-}
-
-QVariant PercentBarAnimation::interpolated(const QVariant &from, const QVariant &to, qreal progress) const
-{
- QVector<QRectF> startVector = qvariant_cast<QVector<QRectF> >(from);
- QVector<QRectF> endVector = qvariant_cast<QVector<QRectF> >(to);
- QVector<QRectF> result;
-
- Q_ASSERT(startVector.count() == endVector.count());
-
- qreal yAxis = m_item->geometry().height() + m_item->geometry().y();
-
- for (int i = 0; i < startVector.count(); i++) {
- qreal w = endVector[i].width();
- qreal h = startVector[i].height() + ((endVector[i].height() - startVector[i].height()) * progress);
- qreal x = endVector[i].topLeft().x();
- qreal y = yAxis + ((endVector[i].topLeft().y() - yAxis) * progress);
-
- QRectF value(x, y, w, h);
- result << value.normalized();
- }
- return qVariantFromValue(result);
-}
-
-#include "moc_percentbaranimation_p.cpp"
-
-QTCOMMERCIALCHART_END_NAMESPACE
diff --git a/src/animations/percentbaranimation_p.h b/src/animations/percentbaranimation_p.h
deleted file mode 100644
index af40d789..00000000
--- a/src/animations/percentbaranimation_p.h
+++ /dev/null
@@ -1,55 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Digia Plc
-** All rights reserved.
-** For any questions to Digia, please use contact form at http://qt.digia.com
-**
-** This file is part of the Qt Commercial Charts Add-on.
-**
-** $QT_BEGIN_LICENSE$
-** Licensees holding valid Qt Commercial licenses may use this file in
-** accordance with the Qt Commercial License Agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia.
-**
-** If you have questions regarding the use of this file, please use
-** contact form at http://qt.digia.com
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-// W A R N I N G
-// -------------
-//
-// This file is not part of the QtCommercial Chart API. It exists purely as an
-// implementation detail. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-
-#ifndef PERCENTBARANIMATION_P_H
-#define PERCENTBARANIMATION_P_H
-
-#include "chartanimation_p.h"
-#include "abstractbaranimation_p.h"
-#include "abstractbarchartitem_p.h"
-
-QTCOMMERCIALCHART_BEGIN_NAMESPACE
-
-class PercentBarChartItem;
-class QBarSet;
-class BarSetAnimation;
-
-class PercentBarAnimation : public AbstractBarAnimation
-{
- Q_OBJECT
-public:
- PercentBarAnimation(PercentBarChartItem *item);
- ~PercentBarAnimation();
-
- virtual QVariant interpolated(const QVariant &from, const QVariant &to, qreal progress) const;
-};
-
-QTCOMMERCIALCHART_END_NAMESPACE
-
-#endif // PERCENTBARANIMATION_P_H
diff --git a/src/animations/stackedbaranimation.cpp b/src/animations/stackedbaranimation.cpp
deleted file mode 100644
index 1d9b9e65..00000000
--- a/src/animations/stackedbaranimation.cpp
+++ /dev/null
@@ -1,63 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Digia Plc
-** All rights reserved.
-** For any questions to Digia, please use contact form at http://qt.digia.com
-**
-** This file is part of the Qt Commercial Charts Add-on.
-**
-** $QT_BEGIN_LICENSE$
-** Licensees holding valid Qt Commercial licenses may use this file in
-** accordance with the Qt Commercial License Agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia.
-**
-** If you have questions regarding the use of this file, please use
-** contact form at http://qt.digia.com
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "stackedbaranimation_p.h"
-#include "stackedbarchartitem_p.h"
-#include <QTimer>
-
-Q_DECLARE_METATYPE(QVector<QRectF>)
-
-QTCOMMERCIALCHART_BEGIN_NAMESPACE
-
-StackedBarAnimation::StackedBarAnimation(StackedBarChartItem *item)
- : AbstractBarAnimation(item)
-{
- setEasingCurve(QEasingCurve::OutQuart);
-}
-
-StackedBarAnimation::~StackedBarAnimation()
-{
-}
-
-QVariant StackedBarAnimation::interpolated(const QVariant &from, const QVariant &to, qreal progress) const
-{
- QVector<QRectF> startVector = qvariant_cast<QVector<QRectF> >(from);
- QVector<QRectF> endVector = qvariant_cast<QVector<QRectF> >(to);
- QVector<QRectF> result;
-
- Q_ASSERT(startVector.count() == endVector.count());
-
- qreal yAxis = m_item->geometry().height() + m_item->geometry().y();
-
- for (int i = 0; i < startVector.count(); i++) {
- qreal w = endVector[i].width();
- qreal h = startVector[i].height() + ((endVector[i].height() - startVector[i].height()) * progress);
- qreal x = endVector[i].topLeft().x();
- qreal y = yAxis + ((endVector[i].topLeft().y() - yAxis) * progress);
-
- QRectF value(x, y, w, h);
- result << value.normalized();
- }
- return qVariantFromValue(result);
-}
-
-#include "moc_stackedbaranimation_p.cpp"
-
-QTCOMMERCIALCHART_END_NAMESPACE
diff --git a/src/animations/stackedbaranimation_p.h b/src/animations/stackedbaranimation_p.h
deleted file mode 100644
index 7661cdd1..00000000
--- a/src/animations/stackedbaranimation_p.h
+++ /dev/null
@@ -1,55 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Digia Plc
-** All rights reserved.
-** For any questions to Digia, please use contact form at http://qt.digia.com
-**
-** This file is part of the Qt Commercial Charts Add-on.
-**
-** $QT_BEGIN_LICENSE$
-** Licensees holding valid Qt Commercial licenses may use this file in
-** accordance with the Qt Commercial License Agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia.
-**
-** If you have questions regarding the use of this file, please use
-** contact form at http://qt.digia.com
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-// W A R N I N G
-// -------------
-//
-// This file is not part of the QtCommercial Chart API. It exists purely as an
-// implementation detail. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-
-#ifndef STACKEDBARANIMATION_P_H
-#define STACKEDBARANIMATION_P_H
-
-#include "chartanimation_p.h"
-#include "abstractbarchartitem_p.h"
-#include "abstractbaranimation_p.h"
-
-QTCOMMERCIALCHART_BEGIN_NAMESPACE
-
-class StackedBarChartItem;
-class QBarSet;
-class BarSetAnimation;
-
-class StackedBarAnimation : public AbstractBarAnimation
-{
- Q_OBJECT
-public:
- StackedBarAnimation(StackedBarChartItem *item);
- ~StackedBarAnimation();
-
- virtual QVariant interpolated(const QVariant &from, const QVariant &to, qreal progress) const;
-};
-
-QTCOMMERCIALCHART_END_NAMESPACE
-
-#endif // STACKEDBARANIMATION_P_H
diff --git a/src/barchart/abstractbarchartitem.cpp b/src/barchart/abstractbarchartitem.cpp
index 01bbfa91..deb31660 100644
--- a/src/barchart/abstractbarchartitem.cpp
+++ b/src/barchart/abstractbarchartitem.cpp
@@ -27,7 +27,7 @@
#include "qchart.h"
#include "chartpresenter_p.h"
#include "charttheme_p.h"
-#include "abstractbaranimation_p.h"
+#include "baranimation_p.h"
#include "chartdataset_p.h"
#include <QPainter>
@@ -46,7 +46,7 @@ AbstractBarChartItem::AbstractBarChartItem(QAbstractBarSeries *series, QGraphics
connect(series->d_func(), SIGNAL(restructuredBars()), this, SLOT(handleDataStructureChanged()));
connect(series, SIGNAL(visibleChanged()), this, SLOT(handleVisibleChanged()));
connect(series, SIGNAL(opacityChanged()), this, SLOT(handleOpacityChanged()));
- setZValue(ChartPresenter::BarSeriesZValue);
+ setZValue(ChartPresenter::BarSeriesZValue);
handleDataStructureChanged();
handleVisibleChanged();
handleUpdatedBars();
@@ -70,16 +70,23 @@ QRectF AbstractBarChartItem::boundingRect() const
void AbstractBarChartItem::applyLayout(const QVector<QRectF> &layout)
{
- if (m_animation) {
- m_animation->setup(m_layout, layout);
- presenter()->startAnimation(m_animation);
- } else {
- setLayout(layout);
- update();
+ QSizeF size = geometry().size();
+ if (geometry().size().isValid()) {
+ if (m_animation) {
+ if (m_layout.count() == 0 || m_oldSize != size) {
+ initializeLayout();
+ m_oldSize = size;
+ }
+ m_animation->setup(m_layout, layout);
+ presenter()->startAnimation(m_animation);
+ } else {
+ setLayout(layout);
+ update();
+ }
}
}
-void AbstractBarChartItem::setAnimation(AbstractBarAnimation *animation)
+void AbstractBarChartItem::setAnimation(BarAnimation *animation)
{
m_animation = animation;
}
@@ -154,7 +161,7 @@ void AbstractBarChartItem::handleDataStructureChanged()
connect(bar, SIGNAL(hovered(bool,QBarSet*)), m_series, SIGNAL(hovered(bool,QBarSet*)));
connect(bar, SIGNAL(clicked(int,QBarSet*)), set, SIGNAL(clicked(int)));
connect(bar, SIGNAL(hovered(bool,QBarSet*)), set, SIGNAL(hovered(bool)));
- m_layout.append(QRectF(0, 0, 0, 0));
+ // m_layout.append(QRectF(0, 0, 1, 1));
// Labels
m_labels.append(new QGraphicsSimpleTextItem(this));
diff --git a/src/barchart/abstractbarchartitem_p.h b/src/barchart/abstractbarchartitem_p.h
index 6ae78d94..d2194c10 100644
--- a/src/barchart/abstractbarchartitem_p.h
+++ b/src/barchart/abstractbarchartitem_p.h
@@ -41,7 +41,7 @@ QTCOMMERCIALCHART_BEGIN_NAMESPACE
class Bar;
class QAxisCategories;
class QChart;
-class AbstractBarAnimation;
+class BarAnimation;
class AbstractBarChartItem : public ChartItem
{
@@ -55,8 +55,9 @@ public:
QRectF boundingRect() const;
virtual QVector<QRectF> calculateLayout() = 0;
+ virtual void initializeLayout() = 0;
virtual void applyLayout(const QVector<QRectF> &layout);
- virtual void setAnimation(AbstractBarAnimation *animation);
+ virtual void setAnimation(BarAnimation *animation);
void setLayout(const QVector<QRectF> &layout);
void updateLayout(const QVector<QRectF> &layout);
QRectF geometry() const { return m_rect;}
@@ -80,11 +81,12 @@ protected:
QRectF m_rect;
QVector<QRectF> m_layout;
- AbstractBarAnimation *m_animation;
+ BarAnimation *m_animation;
QAbstractBarSeries *m_series; // Not owned.
QList<Bar *> m_bars;
QList<QGraphicsSimpleTextItem *> m_labels;
+ QSizeF m_oldSize;
};
QTCOMMERCIALCHART_END_NAMESPACE
diff --git a/src/barchart/horizontal/bar/horizontalbarchartitem.cpp b/src/barchart/horizontal/bar/horizontalbarchartitem.cpp
index f51343de..c3633e54 100644
--- a/src/barchart/horizontal/bar/horizontalbarchartitem.cpp
+++ b/src/barchart/horizontal/bar/horizontalbarchartitem.cpp
@@ -30,6 +30,33 @@ HorizontalBarChartItem::HorizontalBarChartItem(QAbstractBarSeries *series, QGrap
{
}
+void HorizontalBarChartItem::initializeLayout()
+{
+ qreal categoryCount = m_series->d_func()->categoryCount();
+ qreal setCount = m_series->count();
+ qreal barWidth = m_series->d_func()->barWidth();
+
+ m_layout.clear();
+ for(int category = 0; category < categoryCount; category++) {
+ for (int set = 0; set < setCount; set++) {
+ QRectF rect;
+ QPointF topLeft;
+ QPointF bottomRight;
+ if (domain()->type() == AbstractDomain::LogXYDomain || domain()->type() == AbstractDomain::LogXLogYDomain) {
+ topLeft = domain()->calculateGeometryPoint(QPointF(domain()->minX(), category - barWidth / 2 + set/setCount * barWidth));
+ bottomRight = domain()->calculateGeometryPoint(QPointF(domain()->minX(), category + barWidth / 2 + (set + 1)/setCount * barWidth));
+ } else {
+ topLeft = domain()->calculateGeometryPoint(QPointF(0, category - barWidth / 2 + set/setCount * barWidth));
+ bottomRight = domain()->calculateGeometryPoint(QPointF(0, category - barWidth / 2 + (set + 1)/setCount * barWidth));
+ }
+
+ rect.setTopLeft(topLeft);
+ rect.setBottomRight(bottomRight);
+ m_layout.append(rect.normalized());
+ }
+ }
+}
+
QVector<QRectF> HorizontalBarChartItem::calculateLayout()
{
QVector<QRectF> layout;
@@ -39,27 +66,20 @@ QVector<QRectF> HorizontalBarChartItem::calculateLayout()
qreal setCount = m_series->count();
qreal barWidth = m_series->d_func()->barWidth();
- int itemIndex(0);
for(int category = 0; category < categoryCount; category++) {
for (int set = 0; set < setCount; set++) {
qreal value = m_series->barSets().at(set)->at(category);
QRectF rect;
QPointF topLeft;
if (domain()->type() == AbstractDomain::LogXYDomain || domain()->type() == AbstractDomain::LogXLogYDomain)
- topLeft = domain()->calculateGeometryPoint(QPointF(domain()->minX(), category - barWidth / 2 + (set + 1)/(setCount) * barWidth));
+ topLeft = domain()->calculateGeometryPoint(QPointF(domain()->minX(), category - barWidth / 2 + set/setCount * barWidth));
else
- topLeft = domain()->calculateGeometryPoint(QPointF(0, category - barWidth / 2 + (set + 1)/(setCount) * barWidth));
+ topLeft = domain()->calculateGeometryPoint(QPointF(0, category - barWidth / 2 + set/setCount * barWidth));
- QPointF bottomRight = domain()->calculateGeometryPoint(QPointF(value, category - barWidth / 2 + (set)/(setCount) * barWidth));
+ QPointF bottomRight = domain()->calculateGeometryPoint(QPointF(value, category - barWidth / 2 + (set + 1)/setCount * barWidth));
rect.setTopLeft(topLeft);
rect.setBottomRight(bottomRight);
- layout.append(rect);
-
- QGraphicsSimpleTextItem *label = m_labels.at(itemIndex);
- label->setPos(rect.center() - label->boundingRect().center());
- label->setZValue(200);
- itemIndex++;
- label->setBrush(Qt::black);
+ layout.append(rect.normalized());
}
}
return layout;
diff --git a/src/barchart/horizontal/bar/horizontalbarchartitem_p.h b/src/barchart/horizontal/bar/horizontalbarchartitem_p.h
index 4d7aeb90..2e4834f4 100644
--- a/src/barchart/horizontal/bar/horizontalbarchartitem_p.h
+++ b/src/barchart/horizontal/bar/horizontalbarchartitem_p.h
@@ -43,6 +43,7 @@ public:
private:
virtual QVector<QRectF> calculateLayout();
+ void initializeLayout();
};
QTCOMMERCIALCHART_END_NAMESPACE
diff --git a/src/barchart/horizontal/bar/qhorizontalbarseries.cpp b/src/barchart/horizontal/bar/qhorizontalbarseries.cpp
index 54a8d74d..a2341670 100644
--- a/src/barchart/horizontal/bar/qhorizontalbarseries.cpp
+++ b/src/barchart/horizontal/bar/qhorizontalbarseries.cpp
@@ -21,7 +21,6 @@
#include "qhorizontalbarseries.h"
#include "qhorizontalbarseries_p.h"
#include "horizontalbarchartitem_p.h"
-#include "horizontalbaranimation_p.h"
#include "qbarcategoryaxis.h"
#include "chartdataset_p.h"
@@ -116,18 +115,6 @@ void QHorizontalBarSeriesPrivate::initializeGraphics(QGraphicsItem* parent)
QAbstractSeriesPrivate::initializeGraphics(parent);
}
-void QHorizontalBarSeriesPrivate::initializeAnimations(QtCommercialChart::QChart::AnimationOptions options)
-{
- HorizontalBarChartItem *bar = static_cast<HorizontalBarChartItem *>(m_item.data());
- Q_ASSERT(bar);
- if (options.testFlag(QChart::SeriesAnimations)) {
- bar->setAnimation(new HorizontalBarAnimation(bar));
- }else{
- bar->setAnimation(0);
- }
- QAbstractSeriesPrivate::initializeAnimations(options);
-}
-
#include "moc_qhorizontalbarseries.cpp"
QTCOMMERCIALCHART_END_NAMESPACE
diff --git a/src/barchart/horizontal/bar/qhorizontalbarseries_p.h b/src/barchart/horizontal/bar/qhorizontalbarseries_p.h
index 5fa0fdc7..b91a45f0 100644
--- a/src/barchart/horizontal/bar/qhorizontalbarseries_p.h
+++ b/src/barchart/horizontal/bar/qhorizontalbarseries_p.h
@@ -40,7 +40,6 @@ class QHorizontalBarSeriesPrivate: public QAbstractBarSeriesPrivate
public:
QHorizontalBarSeriesPrivate(QHorizontalBarSeries *q);
void initializeGraphics(QGraphicsItem* parent);
- void initializeAnimations(QtCommercialChart::QChart::AnimationOptions options);
void initializeDomain();
private:
Q_DECLARE_PUBLIC(QHorizontalBarSeries)
diff --git a/src/barchart/horizontal/percent/horizontalpercentbarchartitem.cpp b/src/barchart/horizontal/percent/horizontalpercentbarchartitem.cpp
index b36d5d64..af679d03 100644
--- a/src/barchart/horizontal/percent/horizontalpercentbarchartitem.cpp
+++ b/src/barchart/horizontal/percent/horizontalpercentbarchartitem.cpp
@@ -30,6 +30,33 @@ HorizontalPercentBarChartItem::HorizontalPercentBarChartItem(QAbstractBarSeries
{
}
+void HorizontalPercentBarChartItem::initializeLayout()
+{
+ qreal categoryCount = m_series->d_func()->categoryCount();
+ qreal setCount = m_series->count();
+ qreal barWidth = m_series->d_func()->barWidth();
+
+ m_layout.clear();
+ for(int category = 0; category < categoryCount; category++) {
+ for (int set = 0; set < setCount; set++) {
+ QRectF rect;
+ QPointF topLeft;
+ QPointF bottomRight;
+ if (domain()->type() == AbstractDomain::LogXYDomain || domain()->type() == AbstractDomain::LogXLogYDomain) {
+ topLeft = domain()->calculateGeometryPoint(QPointF(domain()->minX(), category - barWidth / 2));
+ bottomRight = domain()->calculateGeometryPoint(QPointF(domain()->minX(), category + barWidth / 2));
+ } else {
+ topLeft = domain()->calculateGeometryPoint(QPointF(0, category - barWidth / 2));
+ bottomRight = domain()->calculateGeometryPoint(QPointF(0, category + barWidth / 2));
+ }
+
+ rect.setTopLeft(topLeft);
+ rect.setBottomRight(bottomRight);
+ m_layout.append(rect.normalized());
+ }
+ }
+}
+
QVector<QRectF> HorizontalPercentBarChartItem::calculateLayout()
{
QVector<QRectF> layout;
@@ -47,13 +74,13 @@ QVector<QRectF> HorizontalPercentBarChartItem::calculateLayout()
QRectF rect;
QPointF topLeft;
if (domain()->type() == AbstractDomain::LogXYDomain || domain()->type() == AbstractDomain::LogXLogYDomain)
- topLeft = domain()->calculateGeometryPoint(QPointF(set ? 100 * sum/categorySum : domain()->minX(), category + barWidth/2));
+ topLeft = domain()->calculateGeometryPoint(QPointF(set ? 100 * sum/categorySum : domain()->minX(), category - barWidth/2));
else
- topLeft = domain()->calculateGeometryPoint(QPointF(set ? 100 * sum/categorySum : 0, category + barWidth/2));
- QPointF bottomRight = domain()->calculateGeometryPoint(QPointF(100 * (value + sum)/categorySum, category - barWidth/2));
+ topLeft = domain()->calculateGeometryPoint(QPointF(set ? 100 * sum/categorySum : 0, category - barWidth/2));
+ QPointF bottomRight = domain()->calculateGeometryPoint(QPointF(100 * (value + sum)/categorySum, category + barWidth/2));
rect.setTopLeft(topLeft);
rect.setBottomRight(bottomRight);
- layout.append(rect);
+ layout.append(rect.normalized());
sum +=value;
}
}
diff --git a/src/barchart/horizontal/percent/horizontalpercentbarchartitem_p.h b/src/barchart/horizontal/percent/horizontalpercentbarchartitem_p.h
index ead2f423..a2471f78 100644
--- a/src/barchart/horizontal/percent/horizontalpercentbarchartitem_p.h
+++ b/src/barchart/horizontal/percent/horizontalpercentbarchartitem_p.h
@@ -44,6 +44,7 @@ public:
private:
virtual QVector<QRectF> calculateLayout();
+ void initializeLayout();
};
QTCOMMERCIALCHART_END_NAMESPACE
diff --git a/src/barchart/horizontal/percent/qhorizontalpercentbarseries.cpp b/src/barchart/horizontal/percent/qhorizontalpercentbarseries.cpp
index 2fbf46a7..a601180f 100644
--- a/src/barchart/horizontal/percent/qhorizontalpercentbarseries.cpp
+++ b/src/barchart/horizontal/percent/qhorizontalpercentbarseries.cpp
@@ -20,7 +20,6 @@
#include "qhorizontalpercentbarseries.h"
#include "qhorizontalpercentbarseries_p.h"
#include "horizontalpercentbarchartitem_p.h"
-#include "horizontalpercentbaranimation_p.h"
#include "chartdataset_p.h"
#include "charttheme_p.h"
@@ -112,17 +111,6 @@ void QHorizontalPercentBarSeriesPrivate::initializeGraphics(QGraphicsItem* paren
QAbstractSeriesPrivate::initializeGraphics(parent);
}
-void QHorizontalPercentBarSeriesPrivate::initializeAnimations(QtCommercialChart::QChart::AnimationOptions options)
-{
- HorizontalPercentBarChartItem *bar = static_cast<HorizontalPercentBarChartItem *>(m_item.data());
- Q_ASSERT(bar);
- if (options.testFlag(QChart::SeriesAnimations)) {
- bar->setAnimation(new HorizontalPercentBarAnimation(bar));
- }else{
- bar->setAnimation(0);
- }
- QAbstractSeriesPrivate::initializeAnimations(options);
-}
#include "moc_qhorizontalpercentbarseries.cpp"
QTCOMMERCIALCHART_END_NAMESPACE
diff --git a/src/barchart/horizontal/percent/qhorizontalpercentbarseries_p.h b/src/barchart/horizontal/percent/qhorizontalpercentbarseries_p.h
index a7c33a53..7a514469 100644
--- a/src/barchart/horizontal/percent/qhorizontalpercentbarseries_p.h
+++ b/src/barchart/horizontal/percent/qhorizontalpercentbarseries_p.h
@@ -40,7 +40,6 @@ class QHorizontalPercentBarSeriesPrivate: public QAbstractBarSeriesPrivate
public:
QHorizontalPercentBarSeriesPrivate(QHorizontalPercentBarSeries *q);
void initializeGraphics(QGraphicsItem* parent);
- void initializeAnimations(QtCommercialChart::QChart::AnimationOptions options);
void initializeDomain();
private:
Q_DECLARE_PUBLIC(QHorizontalPercentBarSeries)
diff --git a/src/barchart/horizontal/stacked/horizontalstackedbarchartitem.cpp b/src/barchart/horizontal/stacked/horizontalstackedbarchartitem.cpp
index eb614f4d..e603d04a 100644
--- a/src/barchart/horizontal/stacked/horizontalstackedbarchartitem.cpp
+++ b/src/barchart/horizontal/stacked/horizontalstackedbarchartitem.cpp
@@ -30,6 +30,33 @@ HorizontalStackedBarChartItem::HorizontalStackedBarChartItem(QAbstractBarSeries
{
}
+void HorizontalStackedBarChartItem::initializeLayout()
+{
+ qreal categoryCount = m_series->d_func()->categoryCount();
+ qreal setCount = m_series->count();
+ qreal barWidth = m_series->d_func()->barWidth();
+
+ m_layout.clear();
+ for(int category = 0; category < categoryCount; category++) {
+ for (int set = 0; set < setCount; set++) {
+ QRectF rect;
+ QPointF topLeft;
+ QPointF bottomRight;
+ if (domain()->type() == AbstractDomain::LogXYDomain || domain()->type() == AbstractDomain::LogXLogYDomain) {
+ topLeft = domain()->calculateGeometryPoint(QPointF(domain()->minX(), category - barWidth / 2));
+ bottomRight = domain()->calculateGeometryPoint(QPointF(domain()->minX(), category + barWidth / 2));
+ } else {
+ topLeft = domain()->calculateGeometryPoint(QPointF(0, category - barWidth / 2));
+ bottomRight = domain()->calculateGeometryPoint(QPointF(0, category + barWidth / 2));
+ }
+
+ rect.setTopLeft(topLeft);
+ rect.setBottomRight(bottomRight);
+ m_layout.append(rect.normalized());
+ }
+ }
+}
+
QVector<QRectF> HorizontalStackedBarChartItem::calculateLayout()
{
QVector<QRectF> layout;
@@ -64,7 +91,7 @@ QVector<QRectF> HorizontalStackedBarChartItem::calculateLayout()
}
rect.setTopLeft(topLeft);
rect.setBottomRight(bottomRight);
- layout.append(rect);
+ layout.append(rect.normalized());
}
}
return layout;
diff --git a/src/barchart/horizontal/stacked/horizontalstackedbarchartitem_p.h b/src/barchart/horizontal/stacked/horizontalstackedbarchartitem_p.h
index 25ecab4a..e79f155a 100644
--- a/src/barchart/horizontal/stacked/horizontalstackedbarchartitem_p.h
+++ b/src/barchart/horizontal/stacked/horizontalstackedbarchartitem_p.h
@@ -43,6 +43,7 @@ public:
private:
virtual QVector<QRectF> calculateLayout();
+ void initializeLayout();
};
QTCOMMERCIALCHART_END_NAMESPACE
diff --git a/src/barchart/horizontal/stacked/qhorizontalstackedbarseries.cpp b/src/barchart/horizontal/stacked/qhorizontalstackedbarseries.cpp
index d4789081..1535020a 100644
--- a/src/barchart/horizontal/stacked/qhorizontalstackedbarseries.cpp
+++ b/src/barchart/horizontal/stacked/qhorizontalstackedbarseries.cpp
@@ -20,7 +20,6 @@
#include "qhorizontalstackedbarseries.h"
#include "qhorizontalstackedbarseries_p.h"
#include "horizontalstackedbarchartitem_p.h"
-#include "horizontalstackedbaranimation_p.h"
#include "chartdataset_p.h"
#include "charttheme_p.h"
@@ -111,17 +110,6 @@ void QHorizontalStackedBarSeriesPrivate::initializeGraphics(QGraphicsItem *paren
QAbstractSeriesPrivate::initializeGraphics(parent);
}
-void QHorizontalStackedBarSeriesPrivate::initializeAnimations(QtCommercialChart::QChart::AnimationOptions options)
-{
- HorizontalStackedBarChartItem *bar = static_cast<HorizontalStackedBarChartItem *>(m_item.data());
- Q_ASSERT(bar);
- if (options.testFlag(QChart::SeriesAnimations)) {
- bar->setAnimation(new HorizontalStackedBarAnimation(bar));
- }else{
- bar->setAnimation(0);
- }
- QAbstractSeriesPrivate::initializeAnimations(options);
-}
#include "moc_qhorizontalstackedbarseries.cpp"
QTCOMMERCIALCHART_END_NAMESPACE
diff --git a/src/barchart/horizontal/stacked/qhorizontalstackedbarseries_p.h b/src/barchart/horizontal/stacked/qhorizontalstackedbarseries_p.h
index b593bc36..261849ff 100644
--- a/src/barchart/horizontal/stacked/qhorizontalstackedbarseries_p.h
+++ b/src/barchart/horizontal/stacked/qhorizontalstackedbarseries_p.h
@@ -40,7 +40,6 @@ class QHorizontalStackedBarSeriesPrivate: public QAbstractBarSeriesPrivate
public:
QHorizontalStackedBarSeriesPrivate(QHorizontalStackedBarSeries *q);
void initializeGraphics(QGraphicsItem* parent);
- void initializeAnimations(QtCommercialChart::QChart::AnimationOptions options);
void initializeDomain();
private:
Q_DECLARE_PUBLIC(QHorizontalStackedBarSeries)
diff --git a/src/barchart/qabstractbarseries.cpp b/src/barchart/qabstractbarseries.cpp
index 64f98a60..0275a41f 100644
--- a/src/barchart/qabstractbarseries.cpp
+++ b/src/barchart/qabstractbarseries.cpp
@@ -28,6 +28,8 @@
#include "qvalueaxis.h"
#include "qbarcategoryaxis.h"
#include "qbarlegendmarker.h"
+#include "baranimation_p.h"
+#include "abstractbarchartitem_p.h"
QTCOMMERCIALCHART_BEGIN_NAMESPACE
@@ -853,6 +855,18 @@ void QAbstractBarSeriesPrivate::initializeTheme(int index, ChartTheme* theme, bo
}
}
+void QAbstractBarSeriesPrivate::initializeAnimations(QChart::AnimationOptions options)
+{
+ AbstractBarChartItem *bar = static_cast<AbstractBarChartItem *>(m_item.data());
+ Q_ASSERT(bar);
+ if (options.testFlag(QChart::SeriesAnimations)) {
+ bar->setAnimation(new BarAnimation(bar));
+ }else{
+ bar->setAnimation(0);
+ }
+ QAbstractSeriesPrivate::initializeAnimations(options);
+}
+
#include "moc_qabstractbarseries.cpp"
#include "moc_qabstractbarseries_p.cpp"
diff --git a/src/barchart/qabstractbarseries_p.h b/src/barchart/qabstractbarseries_p.h
index 021751a0..72d74950 100644
--- a/src/barchart/qabstractbarseries_p.h
+++ b/src/barchart/qabstractbarseries_p.h
@@ -56,6 +56,7 @@ public:
void initializeDomain();
void initializeAxes();
+ void initializeAnimations(QChart::AnimationOptions options);
void initializeTheme(int index, ChartTheme* theme, bool forced = false);
QList<QLegendMarker*> createLegendMarkers(QLegend *legend);
diff --git a/src/barchart/vertical/bar/barchartitem.cpp b/src/barchart/vertical/bar/barchartitem.cpp
index 0df2e79d..d58ca357 100644
--- a/src/barchart/vertical/bar/barchartitem.cpp
+++ b/src/barchart/vertical/bar/barchartitem.cpp
@@ -31,6 +31,34 @@ BarChartItem::BarChartItem(QAbstractBarSeries *series, QGraphicsItem* item) :
{
}
+void BarChartItem::initializeLayout()
+{
+ qreal categoryCount = m_series->d_func()->categoryCount();
+ qreal setCount = m_series->count();
+ qreal barWidth = m_series->d_func()->barWidth();
+
+ m_layout.clear();
+ for(int category = 0; category < categoryCount; category++) {
+ for (int set = 0; set < setCount; set++) {
+ QRectF rect;
+ QPointF topLeft;
+ QPointF bottomRight;
+
+ if (domain()->type() == AbstractDomain::XLogYDomain || domain()->type() == AbstractDomain::LogXLogYDomain) {
+ topLeft = domain()->calculateGeometryPoint(QPointF(category - barWidth / 2 + set/setCount * barWidth, domain()->minY()));
+ bottomRight = domain()->calculateGeometryPoint(QPointF(category + barWidth / 2 + (set + 1)/setCount * barWidth, domain()->minY()));
+ } else {
+ topLeft = domain()->calculateGeometryPoint(QPointF(category - barWidth / 2 + set/setCount * barWidth, 0));
+ bottomRight = domain()->calculateGeometryPoint(QPointF(category - barWidth / 2 + (set + 1)/setCount * barWidth, 0));
+ }
+
+ rect.setTopLeft(topLeft);
+ rect.setBottomRight(bottomRight);
+ m_layout.append(rect.normalized());
+ }
+ }
+}
+
QVector<QRectF> BarChartItem::calculateLayout()
{
QVector<QRectF> layout;
@@ -52,7 +80,7 @@ QVector<QRectF> BarChartItem::calculateLayout()
bottomRight = domain()->calculateGeometryPoint(QPointF(category - barWidth / 2 + (set + 1)/(setCount) * barWidth, 0));
rect.setTopLeft(topLeft);
rect.setBottomRight(bottomRight);
- layout.append(rect);
+ layout.append(rect.normalized());
}
}
return layout;
diff --git a/src/barchart/vertical/bar/barchartitem_p.h b/src/barchart/vertical/bar/barchartitem_p.h
index 9eb3988e..3a3c74a5 100644
--- a/src/barchart/vertical/bar/barchartitem_p.h
+++ b/src/barchart/vertical/bar/barchartitem_p.h
@@ -45,6 +45,7 @@ public:
private:
virtual QVector<QRectF> calculateLayout();
+ void initializeLayout();
};
QTCOMMERCIALCHART_END_NAMESPACE
diff --git a/src/barchart/vertical/bar/qbarseries.cpp b/src/barchart/vertical/bar/qbarseries.cpp
index 93ad662f..819969bd 100644
--- a/src/barchart/vertical/bar/qbarseries.cpp
+++ b/src/barchart/vertical/bar/qbarseries.cpp
@@ -23,7 +23,6 @@
#include "barchartitem_p.h"
#include "chartdataset_p.h"
#include "charttheme_p.h"
-#include "baranimation_p.h"
#include "qvalueaxis.h"
#include "qbarcategoryaxis.h"
@@ -114,18 +113,6 @@ void QBarSeriesPrivate::initializeGraphics(QGraphicsItem* parent)
QAbstractSeriesPrivate::initializeGraphics(parent);
}
-void QBarSeriesPrivate::initializeAnimations(QtCommercialChart::QChart::AnimationOptions options)
-{
- BarChartItem *bar = static_cast<BarChartItem *>(m_item.data());
- Q_ASSERT(bar);
- if (options.testFlag(QChart::SeriesAnimations)) {
- bar->setAnimation(new BarAnimation(bar));
- }else{
- bar->setAnimation(0);
- }
- QAbstractSeriesPrivate::initializeAnimations(options);
-}
-
#include "moc_qbarseries.cpp"
QTCOMMERCIALCHART_END_NAMESPACE
diff --git a/src/barchart/vertical/bar/qbarseries_p.h b/src/barchart/vertical/bar/qbarseries_p.h
index bc30974c..3f1fec13 100644
--- a/src/barchart/vertical/bar/qbarseries_p.h
+++ b/src/barchart/vertical/bar/qbarseries_p.h
@@ -41,7 +41,6 @@ class QBarSeriesPrivate: public QAbstractBarSeriesPrivate
public:
QBarSeriesPrivate(QBarSeries *q);
void initializeGraphics(QGraphicsItem* parent);
- void initializeAnimations(QtCommercialChart::QChart::AnimationOptions options);
void initializeDomain();
private:
diff --git a/src/barchart/vertical/percent/percentbarchartitem.cpp b/src/barchart/vertical/percent/percentbarchartitem.cpp
index 1c12044f..a7e952ed 100644
--- a/src/barchart/vertical/percent/percentbarchartitem.cpp
+++ b/src/barchart/vertical/percent/percentbarchartitem.cpp
@@ -31,6 +31,34 @@ PercentBarChartItem::PercentBarChartItem(QAbstractBarSeries *series, QGraphicsIt
{
}
+void PercentBarChartItem::initializeLayout()
+{
+ qreal categoryCount = m_series->d_func()->categoryCount();
+ qreal setCount = m_series->count();
+ qreal barWidth = m_series->d_func()->barWidth();
+
+ m_layout.clear();
+ for(int category = 0; category < categoryCount; category++) {
+ for (int set = 0; set < setCount; set++) {
+ QRectF rect;
+ QPointF topLeft;
+ QPointF bottomRight;
+
+ if (domain()->type() == AbstractDomain::XLogYDomain || domain()->type() == AbstractDomain::LogXLogYDomain) {
+ topLeft = domain()->calculateGeometryPoint(QPointF(category - barWidth / 2, domain()->minY()));
+ bottomRight = domain()->calculateGeometryPoint(QPointF(category + barWidth / 2, domain()->minY()));
+ } else {
+ topLeft = domain()->calculateGeometryPoint(QPointF(category - barWidth / 2, 0));
+ bottomRight = domain()->calculateGeometryPoint(QPointF(category + barWidth / 2, 0));
+ }
+
+ rect.setTopLeft(topLeft);
+ rect.setBottomRight(bottomRight);
+ m_layout.append(rect.normalized());
+ }
+ }
+}
+
QVector<QRectF> PercentBarChartItem::calculateLayout()
{
QVector<QRectF> layout;
@@ -54,7 +82,7 @@ QVector<QRectF> PercentBarChartItem::calculateLayout()
bottomRight = domain()->calculateGeometryPoint(QPointF(category + barWidth/2, set ? 100 * sum/categorySum : 0));
rect.setTopLeft(topLeft);
rect.setBottomRight(bottomRight);
- layout.append(rect);
+ layout.append(rect.normalized());
sum +=value;
}
}
diff --git a/src/barchart/vertical/percent/percentbarchartitem_p.h b/src/barchart/vertical/percent/percentbarchartitem_p.h
index d0ceb649..ab729b79 100644
--- a/src/barchart/vertical/percent/percentbarchartitem_p.h
+++ b/src/barchart/vertical/percent/percentbarchartitem_p.h
@@ -46,7 +46,8 @@ public:
void handleUpdatedBars();
private:
- virtual QVector<QRectF> calculateLayout();
+ virtual QVector<QRectF> calculateLayout();
+ void initializeLayout();
};
QTCOMMERCIALCHART_END_NAMESPACE
diff --git a/src/barchart/vertical/percent/qpercentbarseries.cpp b/src/barchart/vertical/percent/qpercentbarseries.cpp
index 758105e2..985edb1d 100644
--- a/src/barchart/vertical/percent/qpercentbarseries.cpp
+++ b/src/barchart/vertical/percent/qpercentbarseries.cpp
@@ -24,7 +24,6 @@
#include "chartdataset_p.h"
#include "charttheme_p.h"
#include "qvalueaxis.h"
-#include "percentbaranimation_p.h"
QTCOMMERCIALCHART_BEGIN_NAMESPACE
@@ -113,17 +112,6 @@ void QPercentBarSeriesPrivate::initializeGraphics(QGraphicsItem* parent)
QAbstractSeriesPrivate::initializeGraphics(parent);
}
-void QPercentBarSeriesPrivate::initializeAnimations(QtCommercialChart::QChart::AnimationOptions options)
-{
- PercentBarChartItem *bar = static_cast<PercentBarChartItem *>(m_item.data());
- Q_ASSERT(bar);
- if (options.testFlag(QChart::SeriesAnimations)) {
- bar->setAnimation(new PercentBarAnimation(bar));
- }else{
- bar->setAnimation(0);
- }
- QAbstractSeriesPrivate::initializeAnimations(options);
-}
#include "moc_qpercentbarseries.cpp"
QTCOMMERCIALCHART_END_NAMESPACE
diff --git a/src/barchart/vertical/percent/qpercentbarseries_p.h b/src/barchart/vertical/percent/qpercentbarseries_p.h
index d888b731..882eb752 100644
--- a/src/barchart/vertical/percent/qpercentbarseries_p.h
+++ b/src/barchart/vertical/percent/qpercentbarseries_p.h
@@ -42,7 +42,6 @@ public:
QPercentBarSeriesPrivate(QPercentBarSeries *q);
void initializeDomain();
void initializeGraphics(QGraphicsItem* parent);
- void initializeAnimations(QtCommercialChart::QChart::AnimationOptions options);
private:
Q_DECLARE_PUBLIC(QPercentBarSeries)
};
diff --git a/src/barchart/vertical/stacked/qstackedbarseries.cpp b/src/barchart/vertical/stacked/qstackedbarseries.cpp
index 8db96128..e9cbc888 100644
--- a/src/barchart/vertical/stacked/qstackedbarseries.cpp
+++ b/src/barchart/vertical/stacked/qstackedbarseries.cpp
@@ -24,7 +24,6 @@
#include "chartdataset_p.h"
#include "charttheme_p.h"
#include "qvalueaxis.h"
-#include "stackedbaranimation_p.h"
QTCOMMERCIALCHART_BEGIN_NAMESPACE
@@ -112,17 +111,6 @@ void QStackedBarSeriesPrivate::initializeGraphics(QGraphicsItem* parent)
QAbstractSeriesPrivate::initializeGraphics(parent);
}
-void QStackedBarSeriesPrivate::initializeAnimations(QtCommercialChart::QChart::AnimationOptions options)
-{
- StackedBarChartItem *bar = static_cast<StackedBarChartItem *>(m_item.data());
- Q_ASSERT(bar);
- if (options.testFlag(QChart::SeriesAnimations)) {
- bar->setAnimation(new StackedBarAnimation(bar));
- }else{
- bar->setAnimation(0);
- }
- QAbstractSeriesPrivate::initializeAnimations(options);
-}
#include "moc_qstackedbarseries.cpp"
QTCOMMERCIALCHART_END_NAMESPACE
diff --git a/src/barchart/vertical/stacked/qstackedbarseries_p.h b/src/barchart/vertical/stacked/qstackedbarseries_p.h
index 1a32c405..c51a8b5c 100644
--- a/src/barchart/vertical/stacked/qstackedbarseries_p.h
+++ b/src/barchart/vertical/stacked/qstackedbarseries_p.h
@@ -41,7 +41,6 @@ class QStackedBarSeriesPrivate: public QAbstractBarSeriesPrivate
public:
QStackedBarSeriesPrivate(QStackedBarSeries *q);
void initializeGraphics(QGraphicsItem* parent);
- void initializeAnimations(QtCommercialChart::QChart::AnimationOptions options);
void initializeDomain();
private:
Q_DECLARE_PUBLIC(QStackedBarSeries)
diff --git a/src/barchart/vertical/stacked/stackedbarchartitem.cpp b/src/barchart/vertical/stacked/stackedbarchartitem.cpp
index 732c220f..377bd5da 100644
--- a/src/barchart/vertical/stacked/stackedbarchartitem.cpp
+++ b/src/barchart/vertical/stacked/stackedbarchartitem.cpp
@@ -31,6 +31,34 @@ StackedBarChartItem::StackedBarChartItem(QAbstractBarSeries *series, QGraphicsIt
{
}
+void StackedBarChartItem::initializeLayout()
+{
+ qreal categoryCount = m_series->d_func()->categoryCount();
+ qreal setCount = m_series->count();
+ qreal barWidth = m_series->d_func()->barWidth();
+
+ m_layout.clear();
+ for(int category = 0; category < categoryCount; category++) {
+ for (int set = 0; set < setCount; set++) {
+ QRectF rect;
+ QPointF topLeft;
+ QPointF bottomRight;
+
+ if (domain()->type() == AbstractDomain::XLogYDomain || domain()->type() == AbstractDomain::LogXLogYDomain) {
+ topLeft = domain()->calculateGeometryPoint(QPointF(category - barWidth / 2, domain()->minY()));
+ bottomRight = domain()->calculateGeometryPoint(QPointF(category + barWidth / 2, domain()->minY()));
+ } else {
+ topLeft = domain()->calculateGeometryPoint(QPointF(category - barWidth / 2, 0));
+ bottomRight = domain()->calculateGeometryPoint(QPointF(category + barWidth / 2, 0));
+ }
+
+ rect.setTopLeft(topLeft);
+ rect.setBottomRight(bottomRight);
+ m_layout.append(rect.normalized());
+ }
+ }
+}
+
QVector<QRectF> StackedBarChartItem::calculateLayout()
{
QVector<QRectF> layout;
@@ -55,16 +83,16 @@ QVector<QRectF> StackedBarChartItem::calculateLayout()
topLeft = domain()->calculateGeometryPoint(QPointF(category + barWidth / 2, set ? negativeSum : 0));
negativeSum += value;
} else {
- bottomRight = domain()->calculateGeometryPoint(QPointF(category - barWidth / 2, value + positiveSum));
+ topLeft = domain()->calculateGeometryPoint(QPointF(category - barWidth / 2, value + positiveSum));
if (domain()->type() == AbstractDomain::XLogYDomain || domain()->type() == AbstractDomain::LogXLogYDomain)
- topLeft = domain()->calculateGeometryPoint(QPointF(category + barWidth / 2, set ? positiveSum : domain()->minY()));
+ bottomRight = domain()->calculateGeometryPoint(QPointF(category + barWidth / 2, set ? positiveSum : domain()->minY()));
else
- topLeft = domain()->calculateGeometryPoint(QPointF(category + barWidth / 2, set ? positiveSum : 0));
+ bottomRight = domain()->calculateGeometryPoint(QPointF(category + barWidth / 2, set ? positiveSum : 0));
positiveSum += value;
}
rect.setTopLeft(topLeft);
rect.setBottomRight(bottomRight);
- layout.append(rect);
+ layout.append(rect.normalized());
}
}
return layout;
diff --git a/src/barchart/vertical/stacked/stackedbarchartitem_p.h b/src/barchart/vertical/stacked/stackedbarchartitem_p.h
index 4a24b9a1..9f22987f 100644
--- a/src/barchart/vertical/stacked/stackedbarchartitem_p.h
+++ b/src/barchart/vertical/stacked/stackedbarchartitem_p.h
@@ -45,6 +45,8 @@ public:
private:
virtual QVector<QRectF> calculateLayout();
+ void initializeLayout();
+
};
QTCOMMERCIALCHART_END_NAMESPACE