@@ -7,13 +7,7 SOURCES += \ | |||
|
7 | 7 | $$PWD/pieanimation.cpp \ |
|
8 | 8 | $$PWD/piesliceanimation.cpp \ |
|
9 | 9 | $$PWD/splineanimation.cpp \ |
|
10 |
$$PWD/baranimation.cpp |
|
|
11 | $$PWD/stackedbaranimation.cpp \ | |
|
12 | $$PWD/percentbaranimation.cpp \ | |
|
13 | $$PWD/abstractbaranimation.cpp \ | |
|
14 | $$PWD/horizontalbaranimation.cpp \ | |
|
15 | $$PWD/horizontalstackedbaranimation.cpp \ | |
|
16 | $$PWD/horizontalpercentbaranimation.cpp | |
|
10 | $$PWD/baranimation.cpp | |
|
17 | 11 | |
|
18 | 12 | PRIVATE_HEADERS += \ |
|
19 | 13 | $$PWD/axisanimation_p.h \ |
@@ -22,10 +16,4 PRIVATE_HEADERS += \ | |||
|
22 | 16 | $$PWD/pieanimation_p.h \ |
|
23 | 17 | $$PWD/piesliceanimation_p.h \ |
|
24 | 18 | $$PWD/splineanimation_p.h \ |
|
25 |
$$PWD/baranimation_p.h |
|
|
26 | $$PWD/stackedbaranimation_p.h \ | |
|
27 | $$PWD/percentbaranimation_p.h \ | |
|
28 | $$PWD/abstractbaranimation_p.h \ | |
|
29 | $$PWD/horizontalbaranimation_p.h \ | |
|
30 | $$PWD/horizontalstackedbaranimation_p.h \ | |
|
31 | $$PWD/horizontalpercentbaranimation_p.h | |
|
19 | $$PWD/baranimation_p.h |
@@ -27,9 +27,11 Q_DECLARE_METATYPE(QVector<QRectF>) | |||
|
27 | 27 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
28 | 28 | |
|
29 | 29 | BarAnimation::BarAnimation(AbstractBarChartItem *item) |
|
30 |
: |
|
|
30 | : ChartAnimation(item), | |
|
31 | m_item(item) | |
|
31 | 32 | { |
|
32 | ||
|
33 | setDuration(ChartAnimationDuration); | |
|
34 | setEasingCurve(QEasingCurve::OutQuart); | |
|
33 | 35 | } |
|
34 | 36 | |
|
35 | 37 | BarAnimation::~BarAnimation() |
@@ -47,27 +49,32 QVariant BarAnimation::interpolated(const QVariant &from, const QVariant &to, qr | |||
|
47 | 49 | for (int i = 0; i < startVector.count(); i++) { |
|
48 | 50 | QRectF start = startVector[i].normalized(); |
|
49 | 51 | QRectF end = endVector[i].normalized(); |
|
52 | qreal x1 = start.left() + progress * (end.left() - start.left()); | |
|
53 | qreal x2 = start.right() + progress * (end.right() - start.right()); | |
|
54 | qreal y1 = start.top() + progress * (end.top() - start.top()); | |
|
55 | qreal y2 = start.bottom() + progress * (end.bottom() - start.bottom()); | |
|
50 | 56 | |
|
51 | qreal x = end.left(); | |
|
52 | qreal y; | |
|
53 | qreal w = end.width(); | |
|
54 | qreal h; | |
|
55 | ||
|
56 | if (endVector[i].height() < 0) { | |
|
57 | // Negative bar | |
|
58 | y = end.top(); | |
|
59 | h = start.height() + ((end.height() - start.height()) * progress); | |
|
60 | } else { | |
|
61 | h = startVector[i].height() + ((endVector[i].height() - startVector[i].height()) * progress); | |
|
62 | y = endVector[i].top() + endVector[i].height() - h; | |
|
63 | } | |
|
64 | ||
|
65 | QRectF value(x, y, w, h); | |
|
57 | QRectF value(QPointF(x1, y1), QPointF(x2, y2)); | |
|
66 | 58 | result << value.normalized(); |
|
67 | 59 | } |
|
68 | 60 | return qVariantFromValue(result); |
|
69 | 61 | } |
|
70 | 62 | |
|
63 | void BarAnimation::updateCurrentValue(const QVariant &value) | |
|
64 | { | |
|
65 | QVector<QRectF> layout = qvariant_cast<QVector<QRectF> >(value); | |
|
66 | m_item->setLayout(layout); | |
|
67 | } | |
|
68 | ||
|
69 | void BarAnimation::setup(const QVector<QRectF> &oldLayout, const QVector<QRectF> &newLayout) | |
|
70 | { | |
|
71 | QVariantAnimation::KeyValues value; | |
|
72 | setKeyValues(value); //workaround for wrong interpolation call | |
|
73 | setKeyValueAt(0.0, qVariantFromValue(oldLayout)); | |
|
74 | setKeyValueAt(1.0, qVariantFromValue(newLayout)); | |
|
75 | } | |
|
76 | ||
|
71 | 77 | #include "moc_baranimation_p.cpp" |
|
72 | 78 | |
|
73 | 79 | QTCOMMERCIALCHART_END_NAMESPACE |
|
80 |
@@ -27,18 +27,16 | |||
|
27 | 27 | // |
|
28 | 28 | // We mean it. |
|
29 | 29 | |
|
30 | #ifndef BARANIMATION_P_H | |
|
31 | #define BARANIMATION_P_H | |
|
30 | #ifndef ABSTRACTBARANIMATION_P_H | |
|
31 | #define ABSTRACTBARANIMATION_P_H | |
|
32 | 32 | |
|
33 | #include "abstractbaranimation_p.h" | |
|
34 | 33 | #include "chartanimation_p.h" |
|
35 | #include "abstractbarchartitem_p.h" | |
|
36 | 34 | |
|
37 | 35 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
38 | 36 | |
|
39 | 37 | class AbstractBarChartItem; |
|
40 | 38 | |
|
41 |
class BarAnimation : public |
|
|
39 | class BarAnimation : public ChartAnimation | |
|
42 | 40 | { |
|
43 | 41 | Q_OBJECT |
|
44 | 42 | |
@@ -48,8 +46,14 public: | |||
|
48 | 46 | |
|
49 | 47 | public: // from QVariantAnimation |
|
50 | 48 | virtual QVariant interpolated(const QVariant &from, const QVariant &to, qreal progress) const; |
|
49 | virtual void updateCurrentValue(const QVariant &value); | |
|
50 | ||
|
51 | void setup(const QVector<QRectF> &oldLayout, const QVector<QRectF> &newLayout); | |
|
52 | ||
|
53 | protected: | |
|
54 | AbstractBarChartItem *m_item; | |
|
51 | 55 | }; |
|
52 | 56 | |
|
53 | 57 | QTCOMMERCIALCHART_END_NAMESPACE |
|
54 | 58 | |
|
55 | #endif | |
|
59 | #endif // ABSTRACTBARANIMATION_P_H |
@@ -27,7 +27,7 | |||
|
27 | 27 | #include "qchart.h" |
|
28 | 28 | #include "chartpresenter_p.h" |
|
29 | 29 | #include "charttheme_p.h" |
|
30 |
#include " |
|
|
30 | #include "baranimation_p.h" | |
|
31 | 31 | #include "chartdataset_p.h" |
|
32 | 32 | #include <QPainter> |
|
33 | 33 | |
@@ -46,7 +46,7 AbstractBarChartItem::AbstractBarChartItem(QAbstractBarSeries *series, QGraphics | |||
|
46 | 46 | connect(series->d_func(), SIGNAL(restructuredBars()), this, SLOT(handleDataStructureChanged())); |
|
47 | 47 | connect(series, SIGNAL(visibleChanged()), this, SLOT(handleVisibleChanged())); |
|
48 | 48 | connect(series, SIGNAL(opacityChanged()), this, SLOT(handleOpacityChanged())); |
|
49 |
setZValue(ChartPresenter::BarSeriesZValue); |
|
|
49 | setZValue(ChartPresenter::BarSeriesZValue); | |
|
50 | 50 | handleDataStructureChanged(); |
|
51 | 51 | handleVisibleChanged(); |
|
52 | 52 | handleUpdatedBars(); |
@@ -70,16 +70,23 QRectF AbstractBarChartItem::boundingRect() const | |||
|
70 | 70 | |
|
71 | 71 | void AbstractBarChartItem::applyLayout(const QVector<QRectF> &layout) |
|
72 | 72 | { |
|
73 | if (m_animation) { | |
|
74 | m_animation->setup(m_layout, layout); | |
|
75 | presenter()->startAnimation(m_animation); | |
|
76 | } else { | |
|
77 | setLayout(layout); | |
|
78 | update(); | |
|
73 | QSizeF size = geometry().size(); | |
|
74 | if (geometry().size().isValid()) { | |
|
75 | if (m_animation) { | |
|
76 | if (m_layout.count() == 0 || m_oldSize != size) { | |
|
77 | initializeLayout(); | |
|
78 | m_oldSize = size; | |
|
79 | } | |
|
80 | m_animation->setup(m_layout, layout); | |
|
81 | presenter()->startAnimation(m_animation); | |
|
82 | } else { | |
|
83 | setLayout(layout); | |
|
84 | update(); | |
|
85 | } | |
|
79 | 86 | } |
|
80 | 87 | } |
|
81 | 88 | |
|
82 |
void AbstractBarChartItem::setAnimation( |
|
|
89 | void AbstractBarChartItem::setAnimation(BarAnimation *animation) | |
|
83 | 90 | { |
|
84 | 91 | m_animation = animation; |
|
85 | 92 | } |
@@ -154,7 +161,7 void AbstractBarChartItem::handleDataStructureChanged() | |||
|
154 | 161 | connect(bar, SIGNAL(hovered(bool,QBarSet*)), m_series, SIGNAL(hovered(bool,QBarSet*))); |
|
155 | 162 | connect(bar, SIGNAL(clicked(int,QBarSet*)), set, SIGNAL(clicked(int))); |
|
156 | 163 | connect(bar, SIGNAL(hovered(bool,QBarSet*)), set, SIGNAL(hovered(bool))); |
|
157 |
m_layout.append(QRectF(0, 0, |
|
|
164 | // m_layout.append(QRectF(0, 0, 1, 1)); | |
|
158 | 165 | |
|
159 | 166 | // Labels |
|
160 | 167 | m_labels.append(new QGraphicsSimpleTextItem(this)); |
@@ -41,7 +41,7 QTCOMMERCIALCHART_BEGIN_NAMESPACE | |||
|
41 | 41 | class Bar; |
|
42 | 42 | class QAxisCategories; |
|
43 | 43 | class QChart; |
|
44 |
class |
|
|
44 | class BarAnimation; | |
|
45 | 45 | |
|
46 | 46 | class AbstractBarChartItem : public ChartItem |
|
47 | 47 | { |
@@ -55,8 +55,9 public: | |||
|
55 | 55 | QRectF boundingRect() const; |
|
56 | 56 | |
|
57 | 57 | virtual QVector<QRectF> calculateLayout() = 0; |
|
58 | virtual void initializeLayout() = 0; | |
|
58 | 59 | virtual void applyLayout(const QVector<QRectF> &layout); |
|
59 |
virtual void setAnimation( |
|
|
60 | virtual void setAnimation(BarAnimation *animation); | |
|
60 | 61 | void setLayout(const QVector<QRectF> &layout); |
|
61 | 62 | void updateLayout(const QVector<QRectF> &layout); |
|
62 | 63 | QRectF geometry() const { return m_rect;} |
@@ -80,11 +81,12 protected: | |||
|
80 | 81 | QRectF m_rect; |
|
81 | 82 | QVector<QRectF> m_layout; |
|
82 | 83 | |
|
83 |
|
|
|
84 | BarAnimation *m_animation; | |
|
84 | 85 | |
|
85 | 86 | QAbstractBarSeries *m_series; // Not owned. |
|
86 | 87 | QList<Bar *> m_bars; |
|
87 | 88 | QList<QGraphicsSimpleTextItem *> m_labels; |
|
89 | QSizeF m_oldSize; | |
|
88 | 90 | }; |
|
89 | 91 | |
|
90 | 92 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -30,6 +30,33 HorizontalBarChartItem::HorizontalBarChartItem(QAbstractBarSeries *series, QGrap | |||
|
30 | 30 | { |
|
31 | 31 | } |
|
32 | 32 | |
|
33 | void HorizontalBarChartItem::initializeLayout() | |
|
34 | { | |
|
35 | qreal categoryCount = m_series->d_func()->categoryCount(); | |
|
36 | qreal setCount = m_series->count(); | |
|
37 | qreal barWidth = m_series->d_func()->barWidth(); | |
|
38 | ||
|
39 | m_layout.clear(); | |
|
40 | for(int category = 0; category < categoryCount; category++) { | |
|
41 | for (int set = 0; set < setCount; set++) { | |
|
42 | QRectF rect; | |
|
43 | QPointF topLeft; | |
|
44 | QPointF bottomRight; | |
|
45 | if (domain()->type() == AbstractDomain::LogXYDomain || domain()->type() == AbstractDomain::LogXLogYDomain) { | |
|
46 | topLeft = domain()->calculateGeometryPoint(QPointF(domain()->minX(), category - barWidth / 2 + set/setCount * barWidth)); | |
|
47 | bottomRight = domain()->calculateGeometryPoint(QPointF(domain()->minX(), category + barWidth / 2 + (set + 1)/setCount * barWidth)); | |
|
48 | } else { | |
|
49 | topLeft = domain()->calculateGeometryPoint(QPointF(0, category - barWidth / 2 + set/setCount * barWidth)); | |
|
50 | bottomRight = domain()->calculateGeometryPoint(QPointF(0, category - barWidth / 2 + (set + 1)/setCount * barWidth)); | |
|
51 | } | |
|
52 | ||
|
53 | rect.setTopLeft(topLeft); | |
|
54 | rect.setBottomRight(bottomRight); | |
|
55 | m_layout.append(rect.normalized()); | |
|
56 | } | |
|
57 | } | |
|
58 | } | |
|
59 | ||
|
33 | 60 | QVector<QRectF> HorizontalBarChartItem::calculateLayout() |
|
34 | 61 | { |
|
35 | 62 | QVector<QRectF> layout; |
@@ -39,27 +66,20 QVector<QRectF> HorizontalBarChartItem::calculateLayout() | |||
|
39 | 66 | qreal setCount = m_series->count(); |
|
40 | 67 | qreal barWidth = m_series->d_func()->barWidth(); |
|
41 | 68 | |
|
42 | int itemIndex(0); | |
|
43 | 69 | for(int category = 0; category < categoryCount; category++) { |
|
44 | 70 | for (int set = 0; set < setCount; set++) { |
|
45 | 71 | qreal value = m_series->barSets().at(set)->at(category); |
|
46 | 72 | QRectF rect; |
|
47 | 73 | QPointF topLeft; |
|
48 | 74 | if (domain()->type() == AbstractDomain::LogXYDomain || domain()->type() == AbstractDomain::LogXLogYDomain) |
|
49 |
topLeft = domain()->calculateGeometryPoint(QPointF(domain()->minX(), category - barWidth / 2 + |
|
|
75 | topLeft = domain()->calculateGeometryPoint(QPointF(domain()->minX(), category - barWidth / 2 + set/setCount * barWidth)); | |
|
50 | 76 | else |
|
51 |
topLeft = domain()->calculateGeometryPoint(QPointF(0, category - barWidth / 2 + |
|
|
77 | topLeft = domain()->calculateGeometryPoint(QPointF(0, category - barWidth / 2 + set/setCount * barWidth)); | |
|
52 | 78 | |
|
53 |
QPointF bottomRight = domain()->calculateGeometryPoint(QPointF(value, category - barWidth / 2 + (set)/ |
|
|
79 | QPointF bottomRight = domain()->calculateGeometryPoint(QPointF(value, category - barWidth / 2 + (set + 1)/setCount * barWidth)); | |
|
54 | 80 | rect.setTopLeft(topLeft); |
|
55 | 81 | rect.setBottomRight(bottomRight); |
|
56 | layout.append(rect); | |
|
57 | ||
|
58 | QGraphicsSimpleTextItem *label = m_labels.at(itemIndex); | |
|
59 | label->setPos(rect.center() - label->boundingRect().center()); | |
|
60 | label->setZValue(200); | |
|
61 | itemIndex++; | |
|
62 | label->setBrush(Qt::black); | |
|
82 | layout.append(rect.normalized()); | |
|
63 | 83 | } |
|
64 | 84 | } |
|
65 | 85 | return layout; |
@@ -43,6 +43,7 public: | |||
|
43 | 43 | |
|
44 | 44 | private: |
|
45 | 45 | virtual QVector<QRectF> calculateLayout(); |
|
46 | void initializeLayout(); | |
|
46 | 47 | }; |
|
47 | 48 | |
|
48 | 49 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -21,7 +21,6 | |||
|
21 | 21 | #include "qhorizontalbarseries.h" |
|
22 | 22 | #include "qhorizontalbarseries_p.h" |
|
23 | 23 | #include "horizontalbarchartitem_p.h" |
|
24 | #include "horizontalbaranimation_p.h" | |
|
25 | 24 | #include "qbarcategoryaxis.h" |
|
26 | 25 | |
|
27 | 26 | #include "chartdataset_p.h" |
@@ -116,18 +115,6 void QHorizontalBarSeriesPrivate::initializeGraphics(QGraphicsItem* parent) | |||
|
116 | 115 | QAbstractSeriesPrivate::initializeGraphics(parent); |
|
117 | 116 | } |
|
118 | 117 | |
|
119 | void QHorizontalBarSeriesPrivate::initializeAnimations(QtCommercialChart::QChart::AnimationOptions options) | |
|
120 | { | |
|
121 | HorizontalBarChartItem *bar = static_cast<HorizontalBarChartItem *>(m_item.data()); | |
|
122 | Q_ASSERT(bar); | |
|
123 | if (options.testFlag(QChart::SeriesAnimations)) { | |
|
124 | bar->setAnimation(new HorizontalBarAnimation(bar)); | |
|
125 | }else{ | |
|
126 | bar->setAnimation(0); | |
|
127 | } | |
|
128 | QAbstractSeriesPrivate::initializeAnimations(options); | |
|
129 | } | |
|
130 | ||
|
131 | 118 | #include "moc_qhorizontalbarseries.cpp" |
|
132 | 119 | |
|
133 | 120 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -40,7 +40,6 class QHorizontalBarSeriesPrivate: public QAbstractBarSeriesPrivate | |||
|
40 | 40 | public: |
|
41 | 41 | QHorizontalBarSeriesPrivate(QHorizontalBarSeries *q); |
|
42 | 42 | void initializeGraphics(QGraphicsItem* parent); |
|
43 | void initializeAnimations(QtCommercialChart::QChart::AnimationOptions options); | |
|
44 | 43 | void initializeDomain(); |
|
45 | 44 | private: |
|
46 | 45 | Q_DECLARE_PUBLIC(QHorizontalBarSeries) |
@@ -30,6 +30,33 HorizontalPercentBarChartItem::HorizontalPercentBarChartItem(QAbstractBarSeries | |||
|
30 | 30 | { |
|
31 | 31 | } |
|
32 | 32 | |
|
33 | void HorizontalPercentBarChartItem::initializeLayout() | |
|
34 | { | |
|
35 | qreal categoryCount = m_series->d_func()->categoryCount(); | |
|
36 | qreal setCount = m_series->count(); | |
|
37 | qreal barWidth = m_series->d_func()->barWidth(); | |
|
38 | ||
|
39 | m_layout.clear(); | |
|
40 | for(int category = 0; category < categoryCount; category++) { | |
|
41 | for (int set = 0; set < setCount; set++) { | |
|
42 | QRectF rect; | |
|
43 | QPointF topLeft; | |
|
44 | QPointF bottomRight; | |
|
45 | if (domain()->type() == AbstractDomain::LogXYDomain || domain()->type() == AbstractDomain::LogXLogYDomain) { | |
|
46 | topLeft = domain()->calculateGeometryPoint(QPointF(domain()->minX(), category - barWidth / 2)); | |
|
47 | bottomRight = domain()->calculateGeometryPoint(QPointF(domain()->minX(), category + barWidth / 2)); | |
|
48 | } else { | |
|
49 | topLeft = domain()->calculateGeometryPoint(QPointF(0, category - barWidth / 2)); | |
|
50 | bottomRight = domain()->calculateGeometryPoint(QPointF(0, category + barWidth / 2)); | |
|
51 | } | |
|
52 | ||
|
53 | rect.setTopLeft(topLeft); | |
|
54 | rect.setBottomRight(bottomRight); | |
|
55 | m_layout.append(rect.normalized()); | |
|
56 | } | |
|
57 | } | |
|
58 | } | |
|
59 | ||
|
33 | 60 | QVector<QRectF> HorizontalPercentBarChartItem::calculateLayout() |
|
34 | 61 | { |
|
35 | 62 | QVector<QRectF> layout; |
@@ -47,13 +74,13 QVector<QRectF> HorizontalPercentBarChartItem::calculateLayout() | |||
|
47 | 74 | QRectF rect; |
|
48 | 75 | QPointF topLeft; |
|
49 | 76 | if (domain()->type() == AbstractDomain::LogXYDomain || domain()->type() == AbstractDomain::LogXLogYDomain) |
|
50 |
topLeft = domain()->calculateGeometryPoint(QPointF(set ? 100 * sum/categorySum : domain()->minX(), category |
|
|
77 | topLeft = domain()->calculateGeometryPoint(QPointF(set ? 100 * sum/categorySum : domain()->minX(), category - barWidth/2)); | |
|
51 | 78 | else |
|
52 |
topLeft = domain()->calculateGeometryPoint(QPointF(set ? 100 * sum/categorySum : 0, category |
|
|
53 |
QPointF bottomRight = domain()->calculateGeometryPoint(QPointF(100 * (value + sum)/categorySum, category |
|
|
79 | topLeft = domain()->calculateGeometryPoint(QPointF(set ? 100 * sum/categorySum : 0, category - barWidth/2)); | |
|
80 | QPointF bottomRight = domain()->calculateGeometryPoint(QPointF(100 * (value + sum)/categorySum, category + barWidth/2)); | |
|
54 | 81 | rect.setTopLeft(topLeft); |
|
55 | 82 | rect.setBottomRight(bottomRight); |
|
56 | layout.append(rect); | |
|
83 | layout.append(rect.normalized()); | |
|
57 | 84 | sum +=value; |
|
58 | 85 | } |
|
59 | 86 | } |
@@ -44,6 +44,7 public: | |||
|
44 | 44 | |
|
45 | 45 | private: |
|
46 | 46 | virtual QVector<QRectF> calculateLayout(); |
|
47 | void initializeLayout(); | |
|
47 | 48 | }; |
|
48 | 49 | |
|
49 | 50 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -20,7 +20,6 | |||
|
20 | 20 | #include "qhorizontalpercentbarseries.h" |
|
21 | 21 | #include "qhorizontalpercentbarseries_p.h" |
|
22 | 22 | #include "horizontalpercentbarchartitem_p.h" |
|
23 | #include "horizontalpercentbaranimation_p.h" | |
|
24 | 23 | |
|
25 | 24 | #include "chartdataset_p.h" |
|
26 | 25 | #include "charttheme_p.h" |
@@ -112,17 +111,6 void QHorizontalPercentBarSeriesPrivate::initializeGraphics(QGraphicsItem* paren | |||
|
112 | 111 | QAbstractSeriesPrivate::initializeGraphics(parent); |
|
113 | 112 | } |
|
114 | 113 | |
|
115 | void QHorizontalPercentBarSeriesPrivate::initializeAnimations(QtCommercialChart::QChart::AnimationOptions options) | |
|
116 | { | |
|
117 | HorizontalPercentBarChartItem *bar = static_cast<HorizontalPercentBarChartItem *>(m_item.data()); | |
|
118 | Q_ASSERT(bar); | |
|
119 | if (options.testFlag(QChart::SeriesAnimations)) { | |
|
120 | bar->setAnimation(new HorizontalPercentBarAnimation(bar)); | |
|
121 | }else{ | |
|
122 | bar->setAnimation(0); | |
|
123 | } | |
|
124 | QAbstractSeriesPrivate::initializeAnimations(options); | |
|
125 | } | |
|
126 | 114 | #include "moc_qhorizontalpercentbarseries.cpp" |
|
127 | 115 | |
|
128 | 116 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -40,7 +40,6 class QHorizontalPercentBarSeriesPrivate: public QAbstractBarSeriesPrivate | |||
|
40 | 40 | public: |
|
41 | 41 | QHorizontalPercentBarSeriesPrivate(QHorizontalPercentBarSeries *q); |
|
42 | 42 | void initializeGraphics(QGraphicsItem* parent); |
|
43 | void initializeAnimations(QtCommercialChart::QChart::AnimationOptions options); | |
|
44 | 43 | void initializeDomain(); |
|
45 | 44 | private: |
|
46 | 45 | Q_DECLARE_PUBLIC(QHorizontalPercentBarSeries) |
@@ -30,6 +30,33 HorizontalStackedBarChartItem::HorizontalStackedBarChartItem(QAbstractBarSeries | |||
|
30 | 30 | { |
|
31 | 31 | } |
|
32 | 32 | |
|
33 | void HorizontalStackedBarChartItem::initializeLayout() | |
|
34 | { | |
|
35 | qreal categoryCount = m_series->d_func()->categoryCount(); | |
|
36 | qreal setCount = m_series->count(); | |
|
37 | qreal barWidth = m_series->d_func()->barWidth(); | |
|
38 | ||
|
39 | m_layout.clear(); | |
|
40 | for(int category = 0; category < categoryCount; category++) { | |
|
41 | for (int set = 0; set < setCount; set++) { | |
|
42 | QRectF rect; | |
|
43 | QPointF topLeft; | |
|
44 | QPointF bottomRight; | |
|
45 | if (domain()->type() == AbstractDomain::LogXYDomain || domain()->type() == AbstractDomain::LogXLogYDomain) { | |
|
46 | topLeft = domain()->calculateGeometryPoint(QPointF(domain()->minX(), category - barWidth / 2)); | |
|
47 | bottomRight = domain()->calculateGeometryPoint(QPointF(domain()->minX(), category + barWidth / 2)); | |
|
48 | } else { | |
|
49 | topLeft = domain()->calculateGeometryPoint(QPointF(0, category - barWidth / 2)); | |
|
50 | bottomRight = domain()->calculateGeometryPoint(QPointF(0, category + barWidth / 2)); | |
|
51 | } | |
|
52 | ||
|
53 | rect.setTopLeft(topLeft); | |
|
54 | rect.setBottomRight(bottomRight); | |
|
55 | m_layout.append(rect.normalized()); | |
|
56 | } | |
|
57 | } | |
|
58 | } | |
|
59 | ||
|
33 | 60 | QVector<QRectF> HorizontalStackedBarChartItem::calculateLayout() |
|
34 | 61 | { |
|
35 | 62 | QVector<QRectF> layout; |
@@ -64,7 +91,7 QVector<QRectF> HorizontalStackedBarChartItem::calculateLayout() | |||
|
64 | 91 | } |
|
65 | 92 | rect.setTopLeft(topLeft); |
|
66 | 93 | rect.setBottomRight(bottomRight); |
|
67 | layout.append(rect); | |
|
94 | layout.append(rect.normalized()); | |
|
68 | 95 | } |
|
69 | 96 | } |
|
70 | 97 | return layout; |
@@ -43,6 +43,7 public: | |||
|
43 | 43 | |
|
44 | 44 | private: |
|
45 | 45 | virtual QVector<QRectF> calculateLayout(); |
|
46 | void initializeLayout(); | |
|
46 | 47 | }; |
|
47 | 48 | |
|
48 | 49 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -20,7 +20,6 | |||
|
20 | 20 | #include "qhorizontalstackedbarseries.h" |
|
21 | 21 | #include "qhorizontalstackedbarseries_p.h" |
|
22 | 22 | #include "horizontalstackedbarchartitem_p.h" |
|
23 | #include "horizontalstackedbaranimation_p.h" | |
|
24 | 23 | |
|
25 | 24 | #include "chartdataset_p.h" |
|
26 | 25 | #include "charttheme_p.h" |
@@ -111,17 +110,6 void QHorizontalStackedBarSeriesPrivate::initializeGraphics(QGraphicsItem *paren | |||
|
111 | 110 | QAbstractSeriesPrivate::initializeGraphics(parent); |
|
112 | 111 | } |
|
113 | 112 | |
|
114 | void QHorizontalStackedBarSeriesPrivate::initializeAnimations(QtCommercialChart::QChart::AnimationOptions options) | |
|
115 | { | |
|
116 | HorizontalStackedBarChartItem *bar = static_cast<HorizontalStackedBarChartItem *>(m_item.data()); | |
|
117 | Q_ASSERT(bar); | |
|
118 | if (options.testFlag(QChart::SeriesAnimations)) { | |
|
119 | bar->setAnimation(new HorizontalStackedBarAnimation(bar)); | |
|
120 | }else{ | |
|
121 | bar->setAnimation(0); | |
|
122 | } | |
|
123 | QAbstractSeriesPrivate::initializeAnimations(options); | |
|
124 | } | |
|
125 | 113 | #include "moc_qhorizontalstackedbarseries.cpp" |
|
126 | 114 | |
|
127 | 115 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -40,7 +40,6 class QHorizontalStackedBarSeriesPrivate: public QAbstractBarSeriesPrivate | |||
|
40 | 40 | public: |
|
41 | 41 | QHorizontalStackedBarSeriesPrivate(QHorizontalStackedBarSeries *q); |
|
42 | 42 | void initializeGraphics(QGraphicsItem* parent); |
|
43 | void initializeAnimations(QtCommercialChart::QChart::AnimationOptions options); | |
|
44 | 43 | void initializeDomain(); |
|
45 | 44 | private: |
|
46 | 45 | Q_DECLARE_PUBLIC(QHorizontalStackedBarSeries) |
@@ -28,6 +28,8 | |||
|
28 | 28 | #include "qvalueaxis.h" |
|
29 | 29 | #include "qbarcategoryaxis.h" |
|
30 | 30 | #include "qbarlegendmarker.h" |
|
31 | #include "baranimation_p.h" | |
|
32 | #include "abstractbarchartitem_p.h" | |
|
31 | 33 | |
|
32 | 34 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
33 | 35 | |
@@ -853,6 +855,18 void QAbstractBarSeriesPrivate::initializeTheme(int index, ChartTheme* theme, bo | |||
|
853 | 855 | } |
|
854 | 856 | } |
|
855 | 857 | |
|
858 | void QAbstractBarSeriesPrivate::initializeAnimations(QChart::AnimationOptions options) | |
|
859 | { | |
|
860 | AbstractBarChartItem *bar = static_cast<AbstractBarChartItem *>(m_item.data()); | |
|
861 | Q_ASSERT(bar); | |
|
862 | if (options.testFlag(QChart::SeriesAnimations)) { | |
|
863 | bar->setAnimation(new BarAnimation(bar)); | |
|
864 | }else{ | |
|
865 | bar->setAnimation(0); | |
|
866 | } | |
|
867 | QAbstractSeriesPrivate::initializeAnimations(options); | |
|
868 | } | |
|
869 | ||
|
856 | 870 | #include "moc_qabstractbarseries.cpp" |
|
857 | 871 | #include "moc_qabstractbarseries_p.cpp" |
|
858 | 872 |
@@ -56,6 +56,7 public: | |||
|
56 | 56 | |
|
57 | 57 | void initializeDomain(); |
|
58 | 58 | void initializeAxes(); |
|
59 | void initializeAnimations(QChart::AnimationOptions options); | |
|
59 | 60 | void initializeTheme(int index, ChartTheme* theme, bool forced = false); |
|
60 | 61 | |
|
61 | 62 | QList<QLegendMarker*> createLegendMarkers(QLegend *legend); |
@@ -31,6 +31,34 BarChartItem::BarChartItem(QAbstractBarSeries *series, QGraphicsItem* item) : | |||
|
31 | 31 | { |
|
32 | 32 | } |
|
33 | 33 | |
|
34 | void BarChartItem::initializeLayout() | |
|
35 | { | |
|
36 | qreal categoryCount = m_series->d_func()->categoryCount(); | |
|
37 | qreal setCount = m_series->count(); | |
|
38 | qreal barWidth = m_series->d_func()->barWidth(); | |
|
39 | ||
|
40 | m_layout.clear(); | |
|
41 | for(int category = 0; category < categoryCount; category++) { | |
|
42 | for (int set = 0; set < setCount; set++) { | |
|
43 | QRectF rect; | |
|
44 | QPointF topLeft; | |
|
45 | QPointF bottomRight; | |
|
46 | ||
|
47 | if (domain()->type() == AbstractDomain::XLogYDomain || domain()->type() == AbstractDomain::LogXLogYDomain) { | |
|
48 | topLeft = domain()->calculateGeometryPoint(QPointF(category - barWidth / 2 + set/setCount * barWidth, domain()->minY())); | |
|
49 | bottomRight = domain()->calculateGeometryPoint(QPointF(category + barWidth / 2 + (set + 1)/setCount * barWidth, domain()->minY())); | |
|
50 | } else { | |
|
51 | topLeft = domain()->calculateGeometryPoint(QPointF(category - barWidth / 2 + set/setCount * barWidth, 0)); | |
|
52 | bottomRight = domain()->calculateGeometryPoint(QPointF(category - barWidth / 2 + (set + 1)/setCount * barWidth, 0)); | |
|
53 | } | |
|
54 | ||
|
55 | rect.setTopLeft(topLeft); | |
|
56 | rect.setBottomRight(bottomRight); | |
|
57 | m_layout.append(rect.normalized()); | |
|
58 | } | |
|
59 | } | |
|
60 | } | |
|
61 | ||
|
34 | 62 | QVector<QRectF> BarChartItem::calculateLayout() |
|
35 | 63 | { |
|
36 | 64 | QVector<QRectF> layout; |
@@ -52,7 +80,7 QVector<QRectF> BarChartItem::calculateLayout() | |||
|
52 | 80 | bottomRight = domain()->calculateGeometryPoint(QPointF(category - barWidth / 2 + (set + 1)/(setCount) * barWidth, 0)); |
|
53 | 81 | rect.setTopLeft(topLeft); |
|
54 | 82 | rect.setBottomRight(bottomRight); |
|
55 | layout.append(rect); | |
|
83 | layout.append(rect.normalized()); | |
|
56 | 84 | } |
|
57 | 85 | } |
|
58 | 86 | return layout; |
@@ -45,6 +45,7 public: | |||
|
45 | 45 | |
|
46 | 46 | private: |
|
47 | 47 | virtual QVector<QRectF> calculateLayout(); |
|
48 | void initializeLayout(); | |
|
48 | 49 | }; |
|
49 | 50 | |
|
50 | 51 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -23,7 +23,6 | |||
|
23 | 23 | #include "barchartitem_p.h" |
|
24 | 24 | #include "chartdataset_p.h" |
|
25 | 25 | #include "charttheme_p.h" |
|
26 | #include "baranimation_p.h" | |
|
27 | 26 | #include "qvalueaxis.h" |
|
28 | 27 | #include "qbarcategoryaxis.h" |
|
29 | 28 | |
@@ -114,18 +113,6 void QBarSeriesPrivate::initializeGraphics(QGraphicsItem* parent) | |||
|
114 | 113 | QAbstractSeriesPrivate::initializeGraphics(parent); |
|
115 | 114 | } |
|
116 | 115 | |
|
117 | void QBarSeriesPrivate::initializeAnimations(QtCommercialChart::QChart::AnimationOptions options) | |
|
118 | { | |
|
119 | BarChartItem *bar = static_cast<BarChartItem *>(m_item.data()); | |
|
120 | Q_ASSERT(bar); | |
|
121 | if (options.testFlag(QChart::SeriesAnimations)) { | |
|
122 | bar->setAnimation(new BarAnimation(bar)); | |
|
123 | }else{ | |
|
124 | bar->setAnimation(0); | |
|
125 | } | |
|
126 | QAbstractSeriesPrivate::initializeAnimations(options); | |
|
127 | } | |
|
128 | ||
|
129 | 116 | #include "moc_qbarseries.cpp" |
|
130 | 117 | |
|
131 | 118 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -41,7 +41,6 class QBarSeriesPrivate: public QAbstractBarSeriesPrivate | |||
|
41 | 41 | public: |
|
42 | 42 | QBarSeriesPrivate(QBarSeries *q); |
|
43 | 43 | void initializeGraphics(QGraphicsItem* parent); |
|
44 | void initializeAnimations(QtCommercialChart::QChart::AnimationOptions options); | |
|
45 | 44 | void initializeDomain(); |
|
46 | 45 | |
|
47 | 46 | private: |
@@ -31,6 +31,34 PercentBarChartItem::PercentBarChartItem(QAbstractBarSeries *series, QGraphicsIt | |||
|
31 | 31 | { |
|
32 | 32 | } |
|
33 | 33 | |
|
34 | void PercentBarChartItem::initializeLayout() | |
|
35 | { | |
|
36 | qreal categoryCount = m_series->d_func()->categoryCount(); | |
|
37 | qreal setCount = m_series->count(); | |
|
38 | qreal barWidth = m_series->d_func()->barWidth(); | |
|
39 | ||
|
40 | m_layout.clear(); | |
|
41 | for(int category = 0; category < categoryCount; category++) { | |
|
42 | for (int set = 0; set < setCount; set++) { | |
|
43 | QRectF rect; | |
|
44 | QPointF topLeft; | |
|
45 | QPointF bottomRight; | |
|
46 | ||
|
47 | if (domain()->type() == AbstractDomain::XLogYDomain || domain()->type() == AbstractDomain::LogXLogYDomain) { | |
|
48 | topLeft = domain()->calculateGeometryPoint(QPointF(category - barWidth / 2, domain()->minY())); | |
|
49 | bottomRight = domain()->calculateGeometryPoint(QPointF(category + barWidth / 2, domain()->minY())); | |
|
50 | } else { | |
|
51 | topLeft = domain()->calculateGeometryPoint(QPointF(category - barWidth / 2, 0)); | |
|
52 | bottomRight = domain()->calculateGeometryPoint(QPointF(category + barWidth / 2, 0)); | |
|
53 | } | |
|
54 | ||
|
55 | rect.setTopLeft(topLeft); | |
|
56 | rect.setBottomRight(bottomRight); | |
|
57 | m_layout.append(rect.normalized()); | |
|
58 | } | |
|
59 | } | |
|
60 | } | |
|
61 | ||
|
34 | 62 | QVector<QRectF> PercentBarChartItem::calculateLayout() |
|
35 | 63 | { |
|
36 | 64 | QVector<QRectF> layout; |
@@ -54,7 +82,7 QVector<QRectF> PercentBarChartItem::calculateLayout() | |||
|
54 | 82 | bottomRight = domain()->calculateGeometryPoint(QPointF(category + barWidth/2, set ? 100 * sum/categorySum : 0)); |
|
55 | 83 | rect.setTopLeft(topLeft); |
|
56 | 84 | rect.setBottomRight(bottomRight); |
|
57 | layout.append(rect); | |
|
85 | layout.append(rect.normalized()); | |
|
58 | 86 | sum +=value; |
|
59 | 87 | } |
|
60 | 88 | } |
@@ -46,7 +46,8 public: | |||
|
46 | 46 | void handleUpdatedBars(); |
|
47 | 47 | |
|
48 | 48 | private: |
|
49 |
virtual QVector<QRectF> calculateLayout(); |
|
|
49 | virtual QVector<QRectF> calculateLayout(); | |
|
50 | void initializeLayout(); | |
|
50 | 51 | }; |
|
51 | 52 | |
|
52 | 53 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -24,7 +24,6 | |||
|
24 | 24 | #include "chartdataset_p.h" |
|
25 | 25 | #include "charttheme_p.h" |
|
26 | 26 | #include "qvalueaxis.h" |
|
27 | #include "percentbaranimation_p.h" | |
|
28 | 27 | |
|
29 | 28 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
30 | 29 | |
@@ -113,17 +112,6 void QPercentBarSeriesPrivate::initializeGraphics(QGraphicsItem* parent) | |||
|
113 | 112 | QAbstractSeriesPrivate::initializeGraphics(parent); |
|
114 | 113 | } |
|
115 | 114 | |
|
116 | void QPercentBarSeriesPrivate::initializeAnimations(QtCommercialChart::QChart::AnimationOptions options) | |
|
117 | { | |
|
118 | PercentBarChartItem *bar = static_cast<PercentBarChartItem *>(m_item.data()); | |
|
119 | Q_ASSERT(bar); | |
|
120 | if (options.testFlag(QChart::SeriesAnimations)) { | |
|
121 | bar->setAnimation(new PercentBarAnimation(bar)); | |
|
122 | }else{ | |
|
123 | bar->setAnimation(0); | |
|
124 | } | |
|
125 | QAbstractSeriesPrivate::initializeAnimations(options); | |
|
126 | } | |
|
127 | 115 | #include "moc_qpercentbarseries.cpp" |
|
128 | 116 | |
|
129 | 117 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -42,7 +42,6 public: | |||
|
42 | 42 | QPercentBarSeriesPrivate(QPercentBarSeries *q); |
|
43 | 43 | void initializeDomain(); |
|
44 | 44 | void initializeGraphics(QGraphicsItem* parent); |
|
45 | void initializeAnimations(QtCommercialChart::QChart::AnimationOptions options); | |
|
46 | 45 | private: |
|
47 | 46 | Q_DECLARE_PUBLIC(QPercentBarSeries) |
|
48 | 47 | }; |
@@ -24,7 +24,6 | |||
|
24 | 24 | #include "chartdataset_p.h" |
|
25 | 25 | #include "charttheme_p.h" |
|
26 | 26 | #include "qvalueaxis.h" |
|
27 | #include "stackedbaranimation_p.h" | |
|
28 | 27 | |
|
29 | 28 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
30 | 29 | |
@@ -112,17 +111,6 void QStackedBarSeriesPrivate::initializeGraphics(QGraphicsItem* parent) | |||
|
112 | 111 | QAbstractSeriesPrivate::initializeGraphics(parent); |
|
113 | 112 | } |
|
114 | 113 | |
|
115 | void QStackedBarSeriesPrivate::initializeAnimations(QtCommercialChart::QChart::AnimationOptions options) | |
|
116 | { | |
|
117 | StackedBarChartItem *bar = static_cast<StackedBarChartItem *>(m_item.data()); | |
|
118 | Q_ASSERT(bar); | |
|
119 | if (options.testFlag(QChart::SeriesAnimations)) { | |
|
120 | bar->setAnimation(new StackedBarAnimation(bar)); | |
|
121 | }else{ | |
|
122 | bar->setAnimation(0); | |
|
123 | } | |
|
124 | QAbstractSeriesPrivate::initializeAnimations(options); | |
|
125 | } | |
|
126 | 114 | #include "moc_qstackedbarseries.cpp" |
|
127 | 115 | |
|
128 | 116 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -41,7 +41,6 class QStackedBarSeriesPrivate: public QAbstractBarSeriesPrivate | |||
|
41 | 41 | public: |
|
42 | 42 | QStackedBarSeriesPrivate(QStackedBarSeries *q); |
|
43 | 43 | void initializeGraphics(QGraphicsItem* parent); |
|
44 | void initializeAnimations(QtCommercialChart::QChart::AnimationOptions options); | |
|
45 | 44 | void initializeDomain(); |
|
46 | 45 | private: |
|
47 | 46 | Q_DECLARE_PUBLIC(QStackedBarSeries) |
@@ -31,6 +31,34 StackedBarChartItem::StackedBarChartItem(QAbstractBarSeries *series, QGraphicsIt | |||
|
31 | 31 | { |
|
32 | 32 | } |
|
33 | 33 | |
|
34 | void StackedBarChartItem::initializeLayout() | |
|
35 | { | |
|
36 | qreal categoryCount = m_series->d_func()->categoryCount(); | |
|
37 | qreal setCount = m_series->count(); | |
|
38 | qreal barWidth = m_series->d_func()->barWidth(); | |
|
39 | ||
|
40 | m_layout.clear(); | |
|
41 | for(int category = 0; category < categoryCount; category++) { | |
|
42 | for (int set = 0; set < setCount; set++) { | |
|
43 | QRectF rect; | |
|
44 | QPointF topLeft; | |
|
45 | QPointF bottomRight; | |
|
46 | ||
|
47 | if (domain()->type() == AbstractDomain::XLogYDomain || domain()->type() == AbstractDomain::LogXLogYDomain) { | |
|
48 | topLeft = domain()->calculateGeometryPoint(QPointF(category - barWidth / 2, domain()->minY())); | |
|
49 | bottomRight = domain()->calculateGeometryPoint(QPointF(category + barWidth / 2, domain()->minY())); | |
|
50 | } else { | |
|
51 | topLeft = domain()->calculateGeometryPoint(QPointF(category - barWidth / 2, 0)); | |
|
52 | bottomRight = domain()->calculateGeometryPoint(QPointF(category + barWidth / 2, 0)); | |
|
53 | } | |
|
54 | ||
|
55 | rect.setTopLeft(topLeft); | |
|
56 | rect.setBottomRight(bottomRight); | |
|
57 | m_layout.append(rect.normalized()); | |
|
58 | } | |
|
59 | } | |
|
60 | } | |
|
61 | ||
|
34 | 62 | QVector<QRectF> StackedBarChartItem::calculateLayout() |
|
35 | 63 | { |
|
36 | 64 | QVector<QRectF> layout; |
@@ -55,16 +83,16 QVector<QRectF> StackedBarChartItem::calculateLayout() | |||
|
55 | 83 | topLeft = domain()->calculateGeometryPoint(QPointF(category + barWidth / 2, set ? negativeSum : 0)); |
|
56 | 84 | negativeSum += value; |
|
57 | 85 | } else { |
|
58 |
|
|
|
86 | topLeft = domain()->calculateGeometryPoint(QPointF(category - barWidth / 2, value + positiveSum)); | |
|
59 | 87 | if (domain()->type() == AbstractDomain::XLogYDomain || domain()->type() == AbstractDomain::LogXLogYDomain) |
|
60 |
|
|
|
88 | bottomRight = domain()->calculateGeometryPoint(QPointF(category + barWidth / 2, set ? positiveSum : domain()->minY())); | |
|
61 | 89 | else |
|
62 |
|
|
|
90 | bottomRight = domain()->calculateGeometryPoint(QPointF(category + barWidth / 2, set ? positiveSum : 0)); | |
|
63 | 91 | positiveSum += value; |
|
64 | 92 | } |
|
65 | 93 | rect.setTopLeft(topLeft); |
|
66 | 94 | rect.setBottomRight(bottomRight); |
|
67 | layout.append(rect); | |
|
95 | layout.append(rect.normalized()); | |
|
68 | 96 | } |
|
69 | 97 | } |
|
70 | 98 | return layout; |
@@ -45,6 +45,8 public: | |||
|
45 | 45 | |
|
46 | 46 | private: |
|
47 | 47 | virtual QVector<QRectF> calculateLayout(); |
|
48 | void initializeLayout(); | |
|
49 | ||
|
48 | 50 | }; |
|
49 | 51 | |
|
50 | 52 | QTCOMMERCIALCHART_END_NAMESPACE |
|
1 | NO CONTENT: file was removed |
|
1 | NO CONTENT: file was removed |
|
1 | NO CONTENT: file was removed |
|
1 | NO CONTENT: file was removed |
|
1 | NO CONTENT: file was removed |
|
1 | NO CONTENT: file was removed |
|
1 | NO CONTENT: file was removed |
|
1 | NO CONTENT: file was removed |
|
1 | NO CONTENT: file was removed |
|
1 | NO CONTENT: file was removed |
|
1 | NO CONTENT: file was removed |
|
1 | NO CONTENT: file was removed |
General Comments 0
You need to be logged in to leave comments.
Login now