@@ -0,0 +1,61 | |||
|
1 | /**************************************************************************** | |
|
2 | ** | |
|
3 | ** Copyright (C) 2012 Digia Plc | |
|
4 | ** All rights reserved. | |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
|
6 | ** | |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
|
8 | ** | |
|
9 | ** $QT_BEGIN_LICENSE$ | |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
|
13 | ** a written agreement between you and Digia. | |
|
14 | ** | |
|
15 | ** If you have questions regarding the use of this file, please use | |
|
16 | ** contact form at http://qt.digia.com | |
|
17 | ** $QT_END_LICENSE$ | |
|
18 | ** | |
|
19 | ****************************************************************************/ | |
|
20 | ||
|
21 | #include "declarativeaxes.h" | |
|
22 | #include "qabstractaxis.h" | |
|
23 | ||
|
24 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
|
25 | ||
|
26 | DeclarativeAxes::DeclarativeAxes(QObject *parent) : | |
|
27 | QObject(parent), | |
|
28 | m_axisX(0), | |
|
29 | m_axisY(0), | |
|
30 | m_axisXTop(0), | |
|
31 | m_axisYRight(0) | |
|
32 | { | |
|
33 | } | |
|
34 | ||
|
35 | void DeclarativeAxes::setAxisX(QAbstractAxis *axis) | |
|
36 | { | |
|
37 | m_axisX = axis; | |
|
38 | emit axisXChanged(axis); | |
|
39 | } | |
|
40 | ||
|
41 | void DeclarativeAxes::setAxisY(QAbstractAxis *axis) | |
|
42 | { | |
|
43 | m_axisY = axis; | |
|
44 | emit axisYChanged(axis); | |
|
45 | } | |
|
46 | ||
|
47 | void DeclarativeAxes::setAxisXTop(QAbstractAxis *axis) | |
|
48 | { | |
|
49 | m_axisXTop = axis; | |
|
50 | emit axisXTopChanged(axis); | |
|
51 | } | |
|
52 | ||
|
53 | void DeclarativeAxes::setAxisYRight(QAbstractAxis *axis) | |
|
54 | { | |
|
55 | m_axisYRight = axis; | |
|
56 | emit axisYRightChanged(axis); | |
|
57 | } | |
|
58 | ||
|
59 | #include "moc_declarativeaxes.cpp" | |
|
60 | ||
|
61 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -0,0 +1,72 | |||
|
1 | /**************************************************************************** | |
|
2 | ** | |
|
3 | ** Copyright (C) 2012 Digia Plc | |
|
4 | ** All rights reserved. | |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
|
6 | ** | |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
|
8 | ** | |
|
9 | ** $QT_BEGIN_LICENSE$ | |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
|
13 | ** a written agreement between you and Digia. | |
|
14 | ** | |
|
15 | ** If you have questions regarding the use of this file, please use | |
|
16 | ** contact form at http://qt.digia.com | |
|
17 | ** $QT_END_LICENSE$ | |
|
18 | ** | |
|
19 | ****************************************************************************/ | |
|
20 | ||
|
21 | #ifndef DECLARATIVEAXES_H | |
|
22 | #define DECLARATIVEAXES_H | |
|
23 | ||
|
24 | #include "qchartglobal.h" | |
|
25 | #include <QObject> | |
|
26 | ||
|
27 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
|
28 | ||
|
29 | class QAbstractAxis; | |
|
30 | ||
|
31 | class DeclarativeAxes : public QObject | |
|
32 | { | |
|
33 | Q_OBJECT | |
|
34 | Q_PROPERTY(QAbstractAxis *axisX READ axisX WRITE setAxisX NOTIFY axisXChanged) | |
|
35 | Q_PROPERTY(QAbstractAxis *axisY READ axisY WRITE setAxisY NOTIFY axisYChanged) | |
|
36 | Q_PROPERTY(QAbstractAxis *axisXTop READ axisXTop WRITE setAxisXTop NOTIFY axisXTopChanged) | |
|
37 | Q_PROPERTY(QAbstractAxis *axisYRight READ axisYRight WRITE setAxisYRight NOTIFY axisYRightChanged) | |
|
38 | ||
|
39 | public: | |
|
40 | explicit DeclarativeAxes(QObject *parent = 0); | |
|
41 | ||
|
42 | QAbstractAxis *axisX() { return m_axisX; } | |
|
43 | void setAxisX(QAbstractAxis *axis); | |
|
44 | QAbstractAxis *axisY() { return m_axisY; } | |
|
45 | void setAxisY(QAbstractAxis *axis); | |
|
46 | QAbstractAxis *axisXTop() { return m_axisXTop; } | |
|
47 | void setAxisXTop(QAbstractAxis *axis); | |
|
48 | QAbstractAxis *axisYRight() { return m_axisYRight; } | |
|
49 | void setAxisYRight(QAbstractAxis *axis); | |
|
50 | ||
|
51 | public: | |
|
52 | void emitAxisXChanged() { emit axisXChanged(m_axisX); } | |
|
53 | void emitAxisYChanged() { emit axisYChanged(m_axisY); } | |
|
54 | void emitAxisXTopChanged() { emit axisXTopChanged(m_axisXTop); } | |
|
55 | void emitAxisYRightChanged() { emit axisYRightChanged(m_axisYRight); } | |
|
56 | ||
|
57 | signals: | |
|
58 | void axisXChanged(QAbstractAxis *axis); | |
|
59 | void axisYChanged(QAbstractAxis *axis); | |
|
60 | void axisXTopChanged(QAbstractAxis *axis); | |
|
61 | void axisYRightChanged(QAbstractAxis *axis); | |
|
62 | ||
|
63 | private: | |
|
64 | QAbstractAxis *m_axisX; | |
|
65 | QAbstractAxis *m_axisY; | |
|
66 | QAbstractAxis *m_axisXTop; | |
|
67 | QAbstractAxis *m_axisYRight; | |
|
68 | }; | |
|
69 | ||
|
70 | QTCOMMERCIALCHART_END_NAMESPACE | |
|
71 | ||
|
72 | #endif // DECLARATIVEAXES_H |
@@ -37,14 +37,14 Rectangle { | |||
|
37 | 37 | categories: ["2007", "2008", "2009", "2010", "2011", "2012", "2013", "2014" ] |
|
38 | 38 | min: "2007" |
|
39 | 39 | max: "2014" |
|
40 | title: "Year" | |
|
40 | titleText: "Year" | |
|
41 | 41 | } |
|
42 | 42 | |
|
43 | 43 | ValueAxis { |
|
44 | 44 | id: valueAxis |
|
45 | 45 | min: 0 |
|
46 | 46 | max: 60 |
|
47 | title: "Sales count [ku]" | |
|
47 | titleText: "Sales count [ku]" | |
|
48 | 48 | } |
|
49 | 49 | // ... |
|
50 | 50 | //![1] |
@@ -19,7 +19,7 | |||
|
19 | 19 | ****************************************************************************/ |
|
20 | 20 | |
|
21 | 21 | import QtQuick 1.1 |
|
22 |
import QtCommercial.Chart 1. |
|
|
22 | import QtCommercial.Chart 1.2 | |
|
23 | 23 | |
|
24 | 24 | Rectangle { |
|
25 | 25 | width: 360 |
@@ -43,21 +43,20 Rectangle { | |||
|
43 | 43 | //![2] |
|
44 | 44 | BarCategoriesAxis { |
|
45 | 45 | id: barCategoriesAxis |
|
46 | title: "Date" | |
|
46 | titleText: "Date" | |
|
47 | 47 | } |
|
48 | 48 | |
|
49 | 49 | ValueAxis{ |
|
50 | 50 | id: valueAxisY2 |
|
51 | 51 | min: 0 |
|
52 | 52 | max: 10 |
|
53 | title: "Rainfall [mm]" | |
|
54 | alignment: Qt.AlignRight | |
|
53 | titleText: "Rainfall [mm]" | |
|
55 | 54 | } |
|
56 | 55 | |
|
57 | 56 | BarSeries { |
|
58 | 57 | id: myBarSeries |
|
59 | 58 | axisX: barCategoriesAxis |
|
60 | axisY: valueAxisY2 | |
|
59 | axisYRight: valueAxisY2 | |
|
61 | 60 | BarSet { |
|
62 | 61 | id: rainfallSet |
|
63 | 62 | label: "Rainfall" |
@@ -76,7 +75,7 Rectangle { | |||
|
76 | 75 | id: valueAxisY |
|
77 | 76 | min: 0 |
|
78 | 77 | max: 15 |
|
79 | title: "Temperature [\u00B0C]" | |
|
78 | titleText: "Temperature [\u00B0C]" | |
|
80 | 79 | } |
|
81 | 80 | |
|
82 | 81 | LineSeries { |
@@ -24,7 +24,8 SOURCES += \ | |||
|
24 | 24 | declarativepieseries.cpp \ |
|
25 | 25 | declarativebarseries.cpp \ |
|
26 | 26 | declarativecategoryaxis.cpp \ |
|
27 | declarativemargins.cpp | |
|
27 | declarativemargins.cpp \ | |
|
28 | declarativeaxes.cpp | |
|
28 | 29 | |
|
29 | 30 | HEADERS += \ |
|
30 | 31 | declarativechart.h \ |
@@ -37,7 +38,8 HEADERS += \ | |||
|
37 | 38 | declarativepieseries.h \ |
|
38 | 39 | declarativebarseries.h \ |
|
39 | 40 | declarativecategoryaxis.h \ |
|
40 | declarativemargins.h | |
|
41 | declarativemargins.h \ | |
|
42 | declarativeaxes.h | |
|
41 | 43 | |
|
42 | 44 | TARGETPATH = QtCommercial/Chart |
|
43 | 45 | target.path = $$[QT_INSTALL_IMPORTS]/$$TARGETPATH |
@@ -25,9 +25,12 QTCOMMERCIALCHART_BEGIN_NAMESPACE | |||
|
25 | 25 | |
|
26 | 26 | DeclarativeAreaSeries::DeclarativeAreaSeries(QObject *parent) : |
|
27 | 27 | QAreaSeries(parent), |
|
28 | m_axisX(0), | |
|
29 | m_axisY(0) | |
|
28 | m_axes(new DeclarativeAxes(this)) | |
|
30 | 29 | { |
|
30 | connect(m_axes, SIGNAL(axisXChanged(QAbstractAxis*)), this, SIGNAL(axisXChanged(QAbstractAxis*))); | |
|
31 | connect(m_axes, SIGNAL(axisYChanged(QAbstractAxis*)), this, SIGNAL(axisYChanged(QAbstractAxis*))); | |
|
32 | connect(m_axes, SIGNAL(axisXTopChanged(QAbstractAxis*)), this, SIGNAL(axisXTopChanged(QAbstractAxis*))); | |
|
33 | connect(m_axes, SIGNAL(axisYRightChanged(QAbstractAxis*)), this, SIGNAL(axisYRightChanged(QAbstractAxis*))); | |
|
31 | 34 | } |
|
32 | 35 | |
|
33 | 36 | void DeclarativeAreaSeries::setUpperSeries(DeclarativeLineSeries *series) |
@@ -22,6 +22,7 | |||
|
22 | 22 | #define DECLARATIVEAREASERIES_H |
|
23 | 23 | |
|
24 | 24 | #include "qareaseries.h" |
|
25 | #include "declarativeaxes.h" | |
|
25 | 26 | |
|
26 | 27 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
27 | 28 | class DeclarativeLineSeries; |
@@ -33,6 +34,8 class DeclarativeAreaSeries : public QAreaSeries | |||
|
33 | 34 | Q_PROPERTY(DeclarativeLineSeries *lowerSeries READ lowerSeries WRITE setLowerSeries) |
|
34 | 35 | Q_PROPERTY(QAbstractAxis *axisX READ axisX WRITE setAxisX NOTIFY axisXChanged REVISION 1) |
|
35 | 36 | Q_PROPERTY(QAbstractAxis *axisY READ axisY WRITE setAxisY NOTIFY axisYChanged REVISION 1) |
|
37 | Q_PROPERTY(QAbstractAxis *axisXTop READ axisXTop WRITE setAxisXTop NOTIFY axisXTopChanged REVISION 2) | |
|
38 | Q_PROPERTY(QAbstractAxis *axisYRight READ axisYRight WRITE setAxisYRight NOTIFY axisYRightChanged REVISION 2) | |
|
36 | 39 | Q_PROPERTY(qreal borderWidth READ borderWidth WRITE setBorderWidth NOTIFY borderWidthChanged REVISION 1) |
|
37 | 40 | |
|
38 | 41 | public: |
@@ -41,10 +44,14 public: | |||
|
41 | 44 | DeclarativeLineSeries *upperSeries() const; |
|
42 | 45 | void setLowerSeries(DeclarativeLineSeries *series); |
|
43 | 46 | DeclarativeLineSeries *lowerSeries() const; |
|
44 | QAbstractAxis *axisX() { return m_axisX; } | |
|
45 |
void setAxisX(QAbstractAxis *axis) { m_ax |
|
|
46 | QAbstractAxis *axisY() { return m_axisY; } | |
|
47 |
void setAxisY(QAbstractAxis *axis) { m_ax |
|
|
47 | QAbstractAxis *axisX() { return m_axes->axisX(); } | |
|
48 | void setAxisX(QAbstractAxis *axis) { m_axes->setAxisX(axis); } | |
|
49 | QAbstractAxis *axisY() { return m_axes->axisY(); } | |
|
50 | void setAxisY(QAbstractAxis *axis) { m_axes->setAxisY(axis); } | |
|
51 | Q_REVISION(2) QAbstractAxis *axisXTop() { return m_axes->axisXTop(); } | |
|
52 | Q_REVISION(2) void setAxisXTop(QAbstractAxis *axis) { m_axes->setAxisXTop(axis); } | |
|
53 | Q_REVISION(2) QAbstractAxis *axisYRight() { return m_axes->axisYRight(); } | |
|
54 | Q_REVISION(2) void setAxisYRight(QAbstractAxis *axis) { m_axes->setAxisYRight(axis); } | |
|
48 | 55 | qreal borderWidth() const; |
|
49 | 56 | void setBorderWidth(qreal borderWidth); |
|
50 | 57 | |
@@ -52,10 +59,11 Q_SIGNALS: | |||
|
52 | 59 | Q_REVISION(1) void axisXChanged(QAbstractAxis *axis); |
|
53 | 60 | Q_REVISION(1) void axisYChanged(QAbstractAxis *axis); |
|
54 | 61 | Q_REVISION(1) void borderWidthChanged(qreal width); |
|
62 | Q_REVISION(2) void axisXTopChanged(QAbstractAxis *axis); | |
|
63 | Q_REVISION(2) void axisYRightChanged(QAbstractAxis *axis); | |
|
55 | 64 | |
|
56 | private: | |
|
57 |
|
|
|
58 | QAbstractAxis *m_axisY; | |
|
65 | public: | |
|
66 | DeclarativeAxes *m_axes; | |
|
59 | 67 | }; |
|
60 | 68 | |
|
61 | 69 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -76,9 +76,12 void DeclarativeBarSet::setValues(QVariantList values) | |||
|
76 | 76 | // Declarative bar series ====================================================================================== |
|
77 | 77 | DeclarativeBarSeries::DeclarativeBarSeries(QDeclarativeItem *parent) : |
|
78 | 78 | QBarSeries(parent), |
|
79 | m_axisX(0), | |
|
80 | m_axisY(0) | |
|
79 | m_axes(new DeclarativeAxes(this)) | |
|
81 | 80 | { |
|
81 | connect(m_axes, SIGNAL(axisXChanged(QAbstractAxis*)), this, SIGNAL(axisXChanged(QAbstractAxis*))); | |
|
82 | connect(m_axes, SIGNAL(axisYChanged(QAbstractAxis*)), this, SIGNAL(axisYChanged(QAbstractAxis*))); | |
|
83 | connect(m_axes, SIGNAL(axisXTopChanged(QAbstractAxis*)), this, SIGNAL(axisXTopChanged(QAbstractAxis*))); | |
|
84 | connect(m_axes, SIGNAL(axisYRightChanged(QAbstractAxis*)), this, SIGNAL(axisYRightChanged(QAbstractAxis*))); | |
|
82 | 85 | } |
|
83 | 86 | |
|
84 | 87 | void DeclarativeBarSeries::classBegin() |
@@ -135,9 +138,13 DeclarativeBarSet *DeclarativeBarSeries::insert(int index, QString label, QVaria | |||
|
135 | 138 | // Declarative stacked bar series ============================================================================== |
|
136 | 139 | DeclarativeStackedBarSeries::DeclarativeStackedBarSeries(QDeclarativeItem *parent) : |
|
137 | 140 | QStackedBarSeries(parent), |
|
138 |
m_ax |
|
|
139 | m_axisY(0) | |
|
141 | m_axes(0) | |
|
140 | 142 | { |
|
143 | m_axes = new DeclarativeAxes(this); | |
|
144 | connect(m_axes, SIGNAL(axisXChanged(QAbstractAxis*)), this, SIGNAL(axisXChanged(QAbstractAxis*))); | |
|
145 | connect(m_axes, SIGNAL(axisYChanged(QAbstractAxis*)), this, SIGNAL(axisYChanged(QAbstractAxis*))); | |
|
146 | connect(m_axes, SIGNAL(axisXTopChanged(QAbstractAxis*)), this, SIGNAL(axisXTopChanged(QAbstractAxis*))); | |
|
147 | connect(m_axes, SIGNAL(axisYRightChanged(QAbstractAxis*)), this, SIGNAL(axisYRightChanged(QAbstractAxis*))); | |
|
141 | 148 | } |
|
142 | 149 | |
|
143 | 150 | void DeclarativeStackedBarSeries::classBegin() |
@@ -195,9 +202,13 DeclarativeBarSet *DeclarativeStackedBarSeries::insert(int index, QString label, | |||
|
195 | 202 | // Declarative percent bar series ============================================================================== |
|
196 | 203 | DeclarativePercentBarSeries::DeclarativePercentBarSeries(QDeclarativeItem *parent) : |
|
197 | 204 | QPercentBarSeries(parent), |
|
198 |
m_ax |
|
|
199 | m_axisY(0) | |
|
205 | m_axes(0) | |
|
200 | 206 | { |
|
207 | m_axes = new DeclarativeAxes(this); | |
|
208 | connect(m_axes, SIGNAL(axisXChanged(QAbstractAxis*)), this, SIGNAL(axisXChanged(QAbstractAxis*))); | |
|
209 | connect(m_axes, SIGNAL(axisYChanged(QAbstractAxis*)), this, SIGNAL(axisYChanged(QAbstractAxis*))); | |
|
210 | connect(m_axes, SIGNAL(axisXTopChanged(QAbstractAxis*)), this, SIGNAL(axisXTopChanged(QAbstractAxis*))); | |
|
211 | connect(m_axes, SIGNAL(axisYRightChanged(QAbstractAxis*)), this, SIGNAL(axisYRightChanged(QAbstractAxis*))); | |
|
201 | 212 | } |
|
202 | 213 | |
|
203 | 214 | void DeclarativePercentBarSeries::classBegin() |
@@ -254,9 +265,13 DeclarativeBarSet *DeclarativePercentBarSeries::insert(int index, QString label, | |||
|
254 | 265 | // Declarative horizontal bar series =========================================================================== |
|
255 | 266 | DeclarativeHorizontalBarSeries::DeclarativeHorizontalBarSeries(QDeclarativeItem *parent) : |
|
256 | 267 | QHorizontalBarSeries(parent), |
|
257 |
m_ax |
|
|
258 | m_axisY(0) | |
|
268 | m_axes(0) | |
|
259 | 269 | { |
|
270 | m_axes = new DeclarativeAxes(this); | |
|
271 | connect(m_axes, SIGNAL(axisXChanged(QAbstractAxis*)), this, SIGNAL(axisXChanged(QAbstractAxis*))); | |
|
272 | connect(m_axes, SIGNAL(axisYChanged(QAbstractAxis*)), this, SIGNAL(axisYChanged(QAbstractAxis*))); | |
|
273 | connect(m_axes, SIGNAL(axisXTopChanged(QAbstractAxis*)), this, SIGNAL(axisXTopChanged(QAbstractAxis*))); | |
|
274 | connect(m_axes, SIGNAL(axisYRightChanged(QAbstractAxis*)), this, SIGNAL(axisYRightChanged(QAbstractAxis*))); | |
|
260 | 275 | } |
|
261 | 276 | |
|
262 | 277 | void DeclarativeHorizontalBarSeries::classBegin() |
@@ -313,9 +328,13 DeclarativeBarSet *DeclarativeHorizontalBarSeries::insert(int index, QString lab | |||
|
313 | 328 | // Declarative horizontal stacked bar series =================================================================== |
|
314 | 329 | DeclarativeHorizontalStackedBarSeries::DeclarativeHorizontalStackedBarSeries(QDeclarativeItem *parent) : |
|
315 | 330 | QHorizontalStackedBarSeries(parent), |
|
316 |
m_ax |
|
|
317 | m_axisY(0) | |
|
331 | m_axes(0) | |
|
318 | 332 | { |
|
333 | m_axes = new DeclarativeAxes(this); | |
|
334 | connect(m_axes, SIGNAL(axisXChanged(QAbstractAxis*)), this, SIGNAL(axisXChanged(QAbstractAxis*))); | |
|
335 | connect(m_axes, SIGNAL(axisYChanged(QAbstractAxis*)), this, SIGNAL(axisYChanged(QAbstractAxis*))); | |
|
336 | connect(m_axes, SIGNAL(axisXTopChanged(QAbstractAxis*)), this, SIGNAL(axisXTopChanged(QAbstractAxis*))); | |
|
337 | connect(m_axes, SIGNAL(axisYRightChanged(QAbstractAxis*)), this, SIGNAL(axisYRightChanged(QAbstractAxis*))); | |
|
319 | 338 | } |
|
320 | 339 | |
|
321 | 340 | void DeclarativeHorizontalStackedBarSeries::classBegin() |
@@ -372,9 +391,13 DeclarativeBarSet *DeclarativeHorizontalStackedBarSeries::insert(int index, QStr | |||
|
372 | 391 | // Declarative horizontal percent bar series =================================================================== |
|
373 | 392 | DeclarativeHorizontalPercentBarSeries::DeclarativeHorizontalPercentBarSeries(QDeclarativeItem *parent) : |
|
374 | 393 | QHorizontalPercentBarSeries(parent), |
|
375 |
m_ax |
|
|
376 | m_axisY(0) | |
|
394 | m_axes(0) | |
|
377 | 395 | { |
|
396 | m_axes = new DeclarativeAxes(this); | |
|
397 | connect(m_axes, SIGNAL(axisXChanged(QAbstractAxis*)), this, SIGNAL(axisXChanged(QAbstractAxis*))); | |
|
398 | connect(m_axes, SIGNAL(axisYChanged(QAbstractAxis*)), this, SIGNAL(axisYChanged(QAbstractAxis*))); | |
|
399 | connect(m_axes, SIGNAL(axisXTopChanged(QAbstractAxis*)), this, SIGNAL(axisXTopChanged(QAbstractAxis*))); | |
|
400 | connect(m_axes, SIGNAL(axisYRightChanged(QAbstractAxis*)), this, SIGNAL(axisYRightChanged(QAbstractAxis*))); | |
|
378 | 401 | } |
|
379 | 402 | |
|
380 | 403 | void DeclarativeHorizontalPercentBarSeries::classBegin() |
@@ -28,6 +28,7 | |||
|
28 | 28 | #include "qhorizontalstackedbarseries.h" |
|
29 | 29 | #include "qhorizontalpercentbarseries.h" |
|
30 | 30 | #include "qbarset.h" |
|
31 | #include "declarativeaxes.h" | |
|
31 | 32 | #include <QtDeclarative/QDeclarativeItem> |
|
32 | 33 | #include <QtDeclarative/QDeclarativeParserStatus> |
|
33 | 34 | |
@@ -69,15 +70,21 class DeclarativeBarSeries : public QBarSeries, public QDeclarativeParserStatus | |||
|
69 | 70 | Q_INTERFACES(QDeclarativeParserStatus) |
|
70 | 71 | Q_PROPERTY(QAbstractAxis *axisX READ axisX WRITE setAxisX NOTIFY axisXChanged REVISION 1) |
|
71 | 72 | Q_PROPERTY(QAbstractAxis *axisY READ axisY WRITE setAxisY NOTIFY axisYChanged REVISION 1) |
|
73 | Q_PROPERTY(QAbstractAxis *axisXTop READ axisXTop WRITE setAxisXTop NOTIFY axisXTopChanged REVISION 2) | |
|
74 | Q_PROPERTY(QAbstractAxis *axisYRight READ axisYRight WRITE setAxisYRight NOTIFY axisYRightChanged REVISION 2) | |
|
72 | 75 | Q_PROPERTY(QDeclarativeListProperty<QObject> seriesChildren READ seriesChildren) |
|
73 | 76 | Q_CLASSINFO("DefaultProperty", "seriesChildren") |
|
74 | 77 | |
|
75 | 78 | public: |
|
76 | 79 | explicit DeclarativeBarSeries(QDeclarativeItem *parent = 0); |
|
77 | QAbstractAxis *axisX() { return m_axisX; } | |
|
78 |
void setAxisX(QAbstractAxis *axis) { m_ax |
|
|
79 | QAbstractAxis *axisY() { return m_axisY; } | |
|
80 |
void setAxisY(QAbstractAxis *axis) { m_ax |
|
|
80 | QAbstractAxis *axisX() { return m_axes->axisX(); } | |
|
81 | void setAxisX(QAbstractAxis *axis) { m_axes->setAxisX(axis); } | |
|
82 | QAbstractAxis *axisY() { return m_axes->axisY(); } | |
|
83 | void setAxisY(QAbstractAxis *axis) { m_axes->setAxisY(axis); } | |
|
84 | Q_REVISION(2) QAbstractAxis *axisXTop() { return m_axes->axisXTop(); } | |
|
85 | Q_REVISION(2) void setAxisXTop(QAbstractAxis *axis) { m_axes->setAxisXTop(axis); } | |
|
86 | Q_REVISION(2) QAbstractAxis *axisYRight() { return m_axes->axisYRight(); } | |
|
87 | Q_REVISION(2) void setAxisYRight(QAbstractAxis *axis) { m_axes->setAxisYRight(axis); } | |
|
81 | 88 | QDeclarativeListProperty<QObject> seriesChildren(); |
|
82 | 89 | |
|
83 | 90 | public: |
@@ -94,13 +101,14 public: // from QDeclarativeParserStatus | |||
|
94 | 101 | Q_SIGNALS: |
|
95 | 102 | Q_REVISION(1) void axisXChanged(QAbstractAxis *axis); |
|
96 | 103 | Q_REVISION(1) void axisYChanged(QAbstractAxis *axis); |
|
104 | Q_REVISION(2) void axisXTopChanged(QAbstractAxis *axis); | |
|
105 | Q_REVISION(2) void axisYRightChanged(QAbstractAxis *axis); | |
|
97 | 106 | |
|
98 | 107 | public Q_SLOTS: |
|
99 | 108 | static void appendSeriesChildren(QDeclarativeListProperty<QObject> *list, QObject *element); |
|
100 | 109 | |
|
101 | private: | |
|
102 |
|
|
|
103 | QAbstractAxis *m_axisY; | |
|
110 | public: | |
|
111 | DeclarativeAxes *m_axes; | |
|
104 | 112 | }; |
|
105 | 113 | |
|
106 | 114 | class DeclarativeStackedBarSeries : public QStackedBarSeries, public QDeclarativeParserStatus |
@@ -109,15 +117,21 class DeclarativeStackedBarSeries : public QStackedBarSeries, public QDeclarativ | |||
|
109 | 117 | Q_INTERFACES(QDeclarativeParserStatus) |
|
110 | 118 | Q_PROPERTY(QAbstractAxis *axisX READ axisX WRITE setAxisX NOTIFY axisXChanged REVISION 1) |
|
111 | 119 | Q_PROPERTY(QAbstractAxis *axisY READ axisY WRITE setAxisY NOTIFY axisYChanged REVISION 1) |
|
120 | Q_PROPERTY(QAbstractAxis *axisXTop READ axisXTop WRITE setAxisXTop NOTIFY axisXTopChanged REVISION 2) | |
|
121 | Q_PROPERTY(QAbstractAxis *axisYRight READ axisYRight WRITE setAxisYRight NOTIFY axisYRightChanged REVISION 2) | |
|
112 | 122 | Q_PROPERTY(QDeclarativeListProperty<QObject> seriesChildren READ seriesChildren) |
|
113 | 123 | Q_CLASSINFO("DefaultProperty", "seriesChildren") |
|
114 | 124 | |
|
115 | 125 | public: |
|
116 | 126 | explicit DeclarativeStackedBarSeries(QDeclarativeItem *parent = 0); |
|
117 | QAbstractAxis *axisX() { return m_axisX; } | |
|
118 |
void setAxisX(QAbstractAxis *axis) { m_ax |
|
|
119 | QAbstractAxis *axisY() { return m_axisY; } | |
|
120 |
void setAxisY(QAbstractAxis *axis) { m_ax |
|
|
127 | QAbstractAxis *axisX() { return m_axes->axisX(); } | |
|
128 | void setAxisX(QAbstractAxis *axis) { m_axes->setAxisX(axis); } | |
|
129 | QAbstractAxis *axisY() { return m_axes->axisY(); } | |
|
130 | void setAxisY(QAbstractAxis *axis) { m_axes->setAxisY(axis); } | |
|
131 | Q_REVISION(2) QAbstractAxis *axisXTop() { return m_axes->axisXTop(); } | |
|
132 | Q_REVISION(2) void setAxisXTop(QAbstractAxis *axis) { m_axes->setAxisXTop(axis); } | |
|
133 | Q_REVISION(2) QAbstractAxis *axisYRight() { return m_axes->axisYRight(); } | |
|
134 | Q_REVISION(2) void setAxisYRight(QAbstractAxis *axis) { m_axes->setAxisYRight(axis); } | |
|
121 | 135 | QDeclarativeListProperty<QObject> seriesChildren(); |
|
122 | 136 | |
|
123 | 137 | public: |
@@ -134,13 +148,14 public: // from QDeclarativeParserStatus | |||
|
134 | 148 | Q_SIGNALS: |
|
135 | 149 | Q_REVISION(1) void axisXChanged(QAbstractAxis *axis); |
|
136 | 150 | Q_REVISION(1) void axisYChanged(QAbstractAxis *axis); |
|
151 | Q_REVISION(2) void axisXTopChanged(QAbstractAxis *axis); | |
|
152 | Q_REVISION(2) void axisYRightChanged(QAbstractAxis *axis); | |
|
137 | 153 | |
|
138 | 154 | public Q_SLOTS: |
|
139 | 155 | static void appendSeriesChildren(QDeclarativeListProperty<QObject> *list, QObject *element); |
|
140 | 156 | |
|
141 | private: | |
|
142 |
|
|
|
143 | QAbstractAxis *m_axisY; | |
|
157 | public: | |
|
158 | DeclarativeAxes *m_axes; | |
|
144 | 159 | }; |
|
145 | 160 | |
|
146 | 161 | class DeclarativePercentBarSeries : public QPercentBarSeries, public QDeclarativeParserStatus |
@@ -149,15 +164,21 class DeclarativePercentBarSeries : public QPercentBarSeries, public QDeclarativ | |||
|
149 | 164 | Q_INTERFACES(QDeclarativeParserStatus) |
|
150 | 165 | Q_PROPERTY(QAbstractAxis *axisX READ axisX WRITE setAxisX NOTIFY axisXChanged REVISION 1) |
|
151 | 166 | Q_PROPERTY(QAbstractAxis *axisY READ axisY WRITE setAxisY NOTIFY axisYChanged REVISION 1) |
|
167 | Q_PROPERTY(QAbstractAxis *axisXTop READ axisXTop WRITE setAxisXTop NOTIFY axisXTopChanged REVISION 2) | |
|
168 | Q_PROPERTY(QAbstractAxis *axisYRight READ axisYRight WRITE setAxisYRight NOTIFY axisYRightChanged REVISION 2) | |
|
152 | 169 | Q_PROPERTY(QDeclarativeListProperty<QObject> seriesChildren READ seriesChildren) |
|
153 | 170 | Q_CLASSINFO("DefaultProperty", "seriesChildren") |
|
154 | 171 | |
|
155 | 172 | public: |
|
156 | 173 | explicit DeclarativePercentBarSeries(QDeclarativeItem *parent = 0); |
|
157 | QAbstractAxis *axisX() { return m_axisX; } | |
|
158 |
void setAxisX(QAbstractAxis *axis) { m_ax |
|
|
159 | QAbstractAxis *axisY() { return m_axisY; } | |
|
160 |
void setAxisY(QAbstractAxis *axis) { m_ax |
|
|
174 | QAbstractAxis *axisX() { return m_axes->axisX(); } | |
|
175 | void setAxisX(QAbstractAxis *axis) { m_axes->setAxisX(axis); } | |
|
176 | QAbstractAxis *axisY() { return m_axes->axisY(); } | |
|
177 | void setAxisY(QAbstractAxis *axis) { m_axes->setAxisY(axis); } | |
|
178 | Q_REVISION(2) QAbstractAxis *axisXTop() { return m_axes->axisXTop(); } | |
|
179 | Q_REVISION(2) void setAxisXTop(QAbstractAxis *axis) { m_axes->setAxisXTop(axis); } | |
|
180 | Q_REVISION(2) QAbstractAxis *axisYRight() { return m_axes->axisYRight(); } | |
|
181 | Q_REVISION(2) void setAxisYRight(QAbstractAxis *axis) { m_axes->setAxisYRight(axis); } | |
|
161 | 182 | QDeclarativeListProperty<QObject> seriesChildren(); |
|
162 | 183 | |
|
163 | 184 | public: |
@@ -174,13 +195,14 public: // from QDeclarativeParserStatus | |||
|
174 | 195 | Q_SIGNALS: |
|
175 | 196 | Q_REVISION(1) void axisXChanged(QAbstractAxis *axis); |
|
176 | 197 | Q_REVISION(1) void axisYChanged(QAbstractAxis *axis); |
|
198 | Q_REVISION(2) void axisXTopChanged(QAbstractAxis *axis); | |
|
199 | Q_REVISION(2) void axisYRightChanged(QAbstractAxis *axis); | |
|
177 | 200 | |
|
178 | 201 | public Q_SLOTS: |
|
179 | 202 | static void appendSeriesChildren(QDeclarativeListProperty<QObject> *list, QObject *element); |
|
180 | 203 | |
|
181 | private: | |
|
182 |
|
|
|
183 | QAbstractAxis *m_axisY; | |
|
204 | public: | |
|
205 | DeclarativeAxes *m_axes; | |
|
184 | 206 | }; |
|
185 | 207 | |
|
186 | 208 | class DeclarativeHorizontalBarSeries : public QHorizontalBarSeries, public QDeclarativeParserStatus |
@@ -189,15 +211,21 class DeclarativeHorizontalBarSeries : public QHorizontalBarSeries, public QDecl | |||
|
189 | 211 | Q_INTERFACES(QDeclarativeParserStatus) |
|
190 | 212 | Q_PROPERTY(QAbstractAxis *axisX READ axisX WRITE setAxisX NOTIFY axisXChanged REVISION 1) |
|
191 | 213 | Q_PROPERTY(QAbstractAxis *axisY READ axisY WRITE setAxisY NOTIFY axisYChanged REVISION 1) |
|
214 | Q_PROPERTY(QAbstractAxis *axisXTop READ axisXTop WRITE setAxisXTop NOTIFY axisXTopChanged REVISION 2) | |
|
215 | Q_PROPERTY(QAbstractAxis *axisYRight READ axisYRight WRITE setAxisYRight NOTIFY axisYRightChanged REVISION 2) | |
|
192 | 216 | Q_PROPERTY(QDeclarativeListProperty<QObject> seriesChildren READ seriesChildren) |
|
193 | 217 | Q_CLASSINFO("DefaultProperty", "seriesChildren") |
|
194 | 218 | |
|
195 | 219 | public: |
|
196 | 220 | explicit DeclarativeHorizontalBarSeries(QDeclarativeItem *parent = 0); |
|
197 | QAbstractAxis *axisX() { return m_axisX; } | |
|
198 |
void setAxisX(QAbstractAxis *axis) { m_ax |
|
|
199 | QAbstractAxis *axisY() { return m_axisY; } | |
|
200 |
void setAxisY(QAbstractAxis *axis) { m_ax |
|
|
221 | QAbstractAxis *axisX() { return m_axes->axisX(); } | |
|
222 | void setAxisX(QAbstractAxis *axis) { m_axes->setAxisX(axis); } | |
|
223 | QAbstractAxis *axisY() { return m_axes->axisY(); } | |
|
224 | void setAxisY(QAbstractAxis *axis) { m_axes->setAxisY(axis); } | |
|
225 | Q_REVISION(2) QAbstractAxis *axisXTop() { return m_axes->axisXTop(); } | |
|
226 | Q_REVISION(2) void setAxisXTop(QAbstractAxis *axis) { m_axes->setAxisXTop(axis); } | |
|
227 | Q_REVISION(2) QAbstractAxis *axisYRight() { return m_axes->axisYRight(); } | |
|
228 | Q_REVISION(2) void setAxisYRight(QAbstractAxis *axis) { m_axes->setAxisYRight(axis); } | |
|
201 | 229 | QDeclarativeListProperty<QObject> seriesChildren(); |
|
202 | 230 | |
|
203 | 231 | public: |
@@ -214,13 +242,14 public: // from QDeclarativeParserStatus | |||
|
214 | 242 | Q_SIGNALS: |
|
215 | 243 | Q_REVISION(1) void axisXChanged(QAbstractAxis *axis); |
|
216 | 244 | Q_REVISION(1) void axisYChanged(QAbstractAxis *axis); |
|
245 | Q_REVISION(2) void axisXTopChanged(QAbstractAxis *axis); | |
|
246 | Q_REVISION(2) void axisYRightChanged(QAbstractAxis *axis); | |
|
217 | 247 | |
|
218 | 248 | public Q_SLOTS: |
|
219 | 249 | static void appendSeriesChildren(QDeclarativeListProperty<QObject> *list, QObject *element); |
|
220 | 250 | |
|
221 | private: | |
|
222 |
|
|
|
223 | QAbstractAxis *m_axisY; | |
|
251 | public: | |
|
252 | DeclarativeAxes *m_axes; | |
|
224 | 253 | }; |
|
225 | 254 | |
|
226 | 255 | class DeclarativeHorizontalStackedBarSeries : public QHorizontalStackedBarSeries, public QDeclarativeParserStatus |
@@ -229,15 +258,21 class DeclarativeHorizontalStackedBarSeries : public QHorizontalStackedBarSeries | |||
|
229 | 258 | Q_INTERFACES(QDeclarativeParserStatus) |
|
230 | 259 | Q_PROPERTY(QAbstractAxis *axisX READ axisX WRITE setAxisX NOTIFY axisXChanged REVISION 1) |
|
231 | 260 | Q_PROPERTY(QAbstractAxis *axisY READ axisY WRITE setAxisY NOTIFY axisYChanged REVISION 1) |
|
261 | Q_PROPERTY(QAbstractAxis *axisXTop READ axisXTop WRITE setAxisXTop NOTIFY axisXTopChanged REVISION 2) | |
|
262 | Q_PROPERTY(QAbstractAxis *axisYRight READ axisYRight WRITE setAxisYRight NOTIFY axisYRightChanged REVISION 2) | |
|
232 | 263 | Q_PROPERTY(QDeclarativeListProperty<QObject> seriesChildren READ seriesChildren) |
|
233 | 264 | Q_CLASSINFO("DefaultProperty", "seriesChildren") |
|
234 | 265 | |
|
235 | 266 | public: |
|
236 | 267 | explicit DeclarativeHorizontalStackedBarSeries(QDeclarativeItem *parent = 0); |
|
237 | QAbstractAxis *axisX() { return m_axisX; } | |
|
238 |
void setAxisX(QAbstractAxis *axis) { m_ax |
|
|
239 | QAbstractAxis *axisY() { return m_axisY; } | |
|
240 |
void setAxisY(QAbstractAxis *axis) { m_ax |
|
|
268 | QAbstractAxis *axisX() { return m_axes->axisX(); } | |
|
269 | void setAxisX(QAbstractAxis *axis) { m_axes->setAxisX(axis); } | |
|
270 | QAbstractAxis *axisY() { return m_axes->axisY(); } | |
|
271 | void setAxisY(QAbstractAxis *axis) { m_axes->setAxisY(axis); } | |
|
272 | Q_REVISION(2) QAbstractAxis *axisXTop() { return m_axes->axisXTop(); } | |
|
273 | Q_REVISION(2) void setAxisXTop(QAbstractAxis *axis) { m_axes->setAxisXTop(axis); } | |
|
274 | Q_REVISION(2) QAbstractAxis *axisYRight() { return m_axes->axisYRight(); } | |
|
275 | Q_REVISION(2) void setAxisYRight(QAbstractAxis *axis) { m_axes->setAxisYRight(axis); } | |
|
241 | 276 | QDeclarativeListProperty<QObject> seriesChildren(); |
|
242 | 277 | |
|
243 | 278 | public: |
@@ -254,13 +289,14 public: // from QDeclarativeParserStatus | |||
|
254 | 289 | Q_SIGNALS: |
|
255 | 290 | Q_REVISION(1) void axisXChanged(QAbstractAxis *axis); |
|
256 | 291 | Q_REVISION(1) void axisYChanged(QAbstractAxis *axis); |
|
292 | Q_REVISION(2) void axisXTopChanged(QAbstractAxis *axis); | |
|
293 | Q_REVISION(2) void axisYRightChanged(QAbstractAxis *axis); | |
|
257 | 294 | |
|
258 | 295 | public Q_SLOTS: |
|
259 | 296 | static void appendSeriesChildren(QDeclarativeListProperty<QObject> *list, QObject *element); |
|
260 | 297 | |
|
261 | private: | |
|
262 |
|
|
|
263 | QAbstractAxis *m_axisY; | |
|
298 | public: | |
|
299 | DeclarativeAxes *m_axes; | |
|
264 | 300 | }; |
|
265 | 301 | |
|
266 | 302 | class DeclarativeHorizontalPercentBarSeries : public QHorizontalPercentBarSeries, public QDeclarativeParserStatus |
@@ -269,15 +305,21 class DeclarativeHorizontalPercentBarSeries : public QHorizontalPercentBarSeries | |||
|
269 | 305 | Q_INTERFACES(QDeclarativeParserStatus) |
|
270 | 306 | Q_PROPERTY(QAbstractAxis *axisX READ axisX WRITE setAxisX NOTIFY axisXChanged REVISION 1) |
|
271 | 307 | Q_PROPERTY(QAbstractAxis *axisY READ axisY WRITE setAxisY NOTIFY axisYChanged REVISION 1) |
|
308 | Q_PROPERTY(QAbstractAxis *axisXTop READ axisXTop WRITE setAxisXTop NOTIFY axisXTopChanged REVISION 2) | |
|
309 | Q_PROPERTY(QAbstractAxis *axisYRight READ axisYRight WRITE setAxisYRight NOTIFY axisYRightChanged REVISION 2) | |
|
272 | 310 | Q_PROPERTY(QDeclarativeListProperty<QObject> seriesChildren READ seriesChildren) |
|
273 | 311 | Q_CLASSINFO("DefaultProperty", "seriesChildren") |
|
274 | 312 | |
|
275 | 313 | public: |
|
276 | 314 | explicit DeclarativeHorizontalPercentBarSeries(QDeclarativeItem *parent = 0); |
|
277 | QAbstractAxis *axisX() { return m_axisX; } | |
|
278 |
void setAxisX(QAbstractAxis *axis) { m_ax |
|
|
279 | QAbstractAxis *axisY() { return m_axisY; } | |
|
280 |
void setAxisY(QAbstractAxis *axis) { m_ax |
|
|
315 | QAbstractAxis *axisX() { return m_axes->axisX(); } | |
|
316 | void setAxisX(QAbstractAxis *axis) { m_axes->setAxisX(axis); } | |
|
317 | QAbstractAxis *axisY() { return m_axes->axisY(); } | |
|
318 | void setAxisY(QAbstractAxis *axis) { m_axes->setAxisY(axis); } | |
|
319 | Q_REVISION(2) QAbstractAxis *axisXTop() { return m_axes->axisXTop(); } | |
|
320 | Q_REVISION(2) void setAxisXTop(QAbstractAxis *axis) { m_axes->setAxisXTop(axis); } | |
|
321 | Q_REVISION(2) QAbstractAxis *axisYRight() { return m_axes->axisYRight(); } | |
|
322 | Q_REVISION(2) void setAxisYRight(QAbstractAxis *axis) { m_axes->setAxisYRight(axis); } | |
|
281 | 323 | QDeclarativeListProperty<QObject> seriesChildren(); |
|
282 | 324 | |
|
283 | 325 | public: |
@@ -294,13 +336,14 public: // from QDeclarativeParserStatus | |||
|
294 | 336 | Q_SIGNALS: |
|
295 | 337 | Q_REVISION(1) void axisXChanged(QAbstractAxis *axis); |
|
296 | 338 | Q_REVISION(1) void axisYChanged(QAbstractAxis *axis); |
|
339 | Q_REVISION(2) void axisXTopChanged(QAbstractAxis *axis); | |
|
340 | Q_REVISION(2) void axisYRightChanged(QAbstractAxis *axis); | |
|
297 | 341 | |
|
298 | 342 | public Q_SLOTS: |
|
299 | 343 | static void appendSeriesChildren(QDeclarativeListProperty<QObject> *list, QObject *element); |
|
300 | 344 | |
|
301 | private: | |
|
302 |
|
|
|
303 | QAbstractAxis *m_axisY; | |
|
345 | public: | |
|
346 | DeclarativeAxes *m_axes; | |
|
304 | 347 | }; |
|
305 | 348 | |
|
306 | 349 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -33,6 +33,7 | |||
|
33 | 33 | #include "qabstractseries_p.h" |
|
34 | 34 | #include "declarativemargins.h" |
|
35 | 35 | #include "chartdataset_p.h" |
|
36 | #include "declarativeaxes.h" | |
|
36 | 37 | #include "qchart_p.h" |
|
37 | 38 | |
|
38 | 39 | #ifndef QT_ON_ARM |
@@ -286,95 +287,72 void DeclarativeChart::componentComplete() | |||
|
286 | 287 | QAbstractSeries *series = qobject_cast<QAbstractSeries *>(child); |
|
287 | 288 | m_chart->addSeries(series); |
|
288 | 289 | |
|
289 | // Set optional user defined axes for the series and connect axis related signals | |
|
290 |
if (qobject_cast<Declarative |
|
|
291 | DeclarativeLineSeries *s = qobject_cast<DeclarativeLineSeries *>(child); | |
|
292 | connect(s, SIGNAL(axisXChanged(QAbstractAxis*)), this, SLOT(handleAxisXSet(QAbstractAxis*))); | |
|
293 | connect(s, SIGNAL(axisYChanged(QAbstractAxis*)), this, SLOT(handleAxisYSet(QAbstractAxis*))); | |
|
294 | setAxisX(s->axisX(), s); | |
|
295 | setAxisY(s->axisY(), s); | |
|
296 | } else if (qobject_cast<DeclarativeSplineSeries *>(child)) { | |
|
297 | DeclarativeSplineSeries *s = qobject_cast<DeclarativeSplineSeries *>(child); | |
|
298 | connect(s, SIGNAL(axisXChanged(QAbstractAxis*)), this, SLOT(handleAxisXSet(QAbstractAxis*))); | |
|
299 | connect(s, SIGNAL(axisYChanged(QAbstractAxis*)), this, SLOT(handleAxisYSet(QAbstractAxis*))); | |
|
300 | setAxisX(s->axisX(), s); | |
|
301 | setAxisY(s->axisY(), s); | |
|
302 | } else if (qobject_cast<DeclarativeScatterSeries *>(child)) { | |
|
303 | DeclarativeScatterSeries *s = qobject_cast<DeclarativeScatterSeries *>(child); | |
|
304 | connect(s, SIGNAL(axisXChanged(QAbstractAxis*)), this, SLOT(handleAxisXSet(QAbstractAxis*))); | |
|
305 | connect(s, SIGNAL(axisYChanged(QAbstractAxis*)), this, SLOT(handleAxisYSet(QAbstractAxis*))); | |
|
306 | setAxisX(s->axisX(), s); | |
|
307 | setAxisY(s->axisY(), s); | |
|
308 | } else if (qobject_cast<DeclarativeAreaSeries *>(child)) { | |
|
309 | DeclarativeAreaSeries *s = qobject_cast<DeclarativeAreaSeries *>(child); | |
|
310 | connect(s, SIGNAL(axisXChanged(QAbstractAxis*)), this, SLOT(handleAxisXSet(QAbstractAxis*))); | |
|
311 | connect(s, SIGNAL(axisYChanged(QAbstractAxis*)), this, SLOT(handleAxisYSet(QAbstractAxis*))); | |
|
312 | setAxisX(s->axisX(), s); | |
|
313 | setAxisY(s->axisY(), s); | |
|
314 | } else if (qobject_cast<DeclarativeBarSeries *>(child)) { | |
|
315 | DeclarativeBarSeries *s = qobject_cast<DeclarativeBarSeries *>(child); | |
|
316 | connect(s, SIGNAL(axisXChanged(QAbstractAxis*)), this, SLOT(handleAxisXSet(QAbstractAxis*))); | |
|
317 | connect(s, SIGNAL(axisYChanged(QAbstractAxis*)), this, SLOT(handleAxisYSet(QAbstractAxis*))); | |
|
318 | setAxisX(s->axisX(), s); | |
|
319 | setAxisY(s->axisY(), s); | |
|
320 | } else if (qobject_cast<DeclarativeStackedBarSeries *>(child)) { | |
|
321 | DeclarativeStackedBarSeries *s = qobject_cast<DeclarativeStackedBarSeries *>(child); | |
|
322 | connect(s, SIGNAL(axisXChanged(QAbstractAxis*)), this, SLOT(handleAxisXSet(QAbstractAxis*))); | |
|
323 | connect(s, SIGNAL(axisYChanged(QAbstractAxis*)), this, SLOT(handleAxisYSet(QAbstractAxis*))); | |
|
324 | setAxisX(s->axisX(), s); | |
|
325 | setAxisY(s->axisY(), s); | |
|
326 | } else if (qobject_cast<DeclarativePercentBarSeries *>(child)) { | |
|
327 | DeclarativePercentBarSeries *s = qobject_cast<DeclarativePercentBarSeries *>(child); | |
|
328 | connect(s, SIGNAL(axisXChanged(QAbstractAxis*)), this, SLOT(handleAxisXSet(QAbstractAxis*))); | |
|
329 | connect(s, SIGNAL(axisYChanged(QAbstractAxis*)), this, SLOT(handleAxisYSet(QAbstractAxis*))); | |
|
330 | setAxisX(s->axisX(), s); | |
|
331 | setAxisY(s->axisY(), s); | |
|
332 | } else if (qobject_cast<DeclarativeHorizontalBarSeries *>(child)) { | |
|
333 | DeclarativeHorizontalBarSeries *s = qobject_cast<DeclarativeHorizontalBarSeries *>(child); | |
|
334 | connect(s, SIGNAL(axisXChanged(QAbstractAxis*)), this, SLOT(handleAxisXSet(QAbstractAxis*))); | |
|
335 | connect(s, SIGNAL(axisYChanged(QAbstractAxis*)), this, SLOT(handleAxisYSet(QAbstractAxis*))); | |
|
336 | setAxisX(s->axisX(), s); | |
|
337 | setAxisY(s->axisY(), s); | |
|
338 | } else if (qobject_cast<DeclarativeHorizontalStackedBarSeries *>(child)) { | |
|
339 | DeclarativeHorizontalStackedBarSeries *s = qobject_cast<DeclarativeHorizontalStackedBarSeries *>(child); | |
|
340 | connect(s, SIGNAL(axisXChanged(QAbstractAxis*)), this, SLOT(handleAxisXSet(QAbstractAxis*))); | |
|
341 | connect(s, SIGNAL(axisYChanged(QAbstractAxis*)), this, SLOT(handleAxisYSet(QAbstractAxis*))); | |
|
342 | setAxisX(s->axisX(), s); | |
|
343 | setAxisY(s->axisY(), s); | |
|
344 | } else if (qobject_cast<DeclarativeHorizontalPercentBarSeries *>(child)) { | |
|
345 | DeclarativeHorizontalPercentBarSeries *s = qobject_cast<DeclarativeHorizontalPercentBarSeries *>(child); | |
|
346 | connect(s, SIGNAL(axisXChanged(QAbstractAxis*)), this, SLOT(handleAxisXSet(QAbstractAxis*))); | |
|
347 | connect(s, SIGNAL(axisYChanged(QAbstractAxis*)), this, SLOT(handleAxisYSet(QAbstractAxis*))); | |
|
348 | setAxisX(s->axisX(), s); | |
|
349 | setAxisY(s->axisY(), s); | |
|
350 | } | |
|
351 | } | |
|
352 | } | |
|
353 | ||
|
354 | // Create the missing axes for the series that cannot be painted without axes | |
|
355 | foreach (QAbstractSeries *chartSeries, m_chart->series()) | |
|
356 | createDefaultAxes(chartSeries); | |
|
290 | // Connect to axis changed signals (unless this is a pie series) | |
|
291 | if (!qobject_cast<DeclarativePieSeries *>(series)) { | |
|
292 | connect(series, SIGNAL(axisXChanged(QAbstractAxis*)), this, SLOT(handleAxisXSet(QAbstractAxis*))); | |
|
293 | connect(series, SIGNAL(axisXTopChanged(QAbstractAxis*)), this, SLOT(handleAxisXSet(QAbstractAxis*))); | |
|
294 | connect(series, SIGNAL(axisYChanged(QAbstractAxis*)), this, SLOT(handleAxisYSet(QAbstractAxis*))); | |
|
295 | connect(series, SIGNAL(axisYRightChanged(QAbstractAxis*)), this, SLOT(handleAxisYRightSet(QAbstractAxis*))); | |
|
296 | } | |
|
297 | ||
|
298 | initializeAxes(series); | |
|
299 | } | |
|
300 | } | |
|
357 | 301 | |
|
358 | 302 | QDeclarativeItem::componentComplete(); |
|
359 | 303 | } |
|
360 | 304 | |
|
361 | 305 | void DeclarativeChart::handleAxisXSet(QAbstractAxis *axis) |
|
362 | 306 | { |
|
363 | // qDebug() << "DeclarativeChart::handleAxisXSet" << sender() << axis; | |
|
364 | if (axis && qobject_cast<QAbstractSeries *>(sender())) | |
|
365 | m_chart->setAxisX(axis, qobject_cast<QAbstractSeries *>(sender())); | |
|
366 | else | |
|
307 | QAbstractSeries *s = qobject_cast<QAbstractSeries *>(sender()); | |
|
308 | if (axis && s) { | |
|
309 | if (!m_chart->axes(Qt::Horizontal).contains(axis)) | |
|
310 | m_chart->addAxis(axis, Qt::AlignBottom); | |
|
311 | if (!s->attachedAxes().contains(axis)) | |
|
312 | s->attachAxis(axis); | |
|
313 | } else { | |
|
367 | 314 | qWarning() << "Trying to set axisX to null."; |
|
368 | 315 | } |
|
316 | } | |
|
317 | ||
|
318 | void DeclarativeChart::handleAxisXTopSet(QAbstractAxis *axis) | |
|
319 | { | |
|
320 | QAbstractSeries *s = qobject_cast<QAbstractSeries *>(sender()); | |
|
321 | if (axis && s) { | |
|
322 | if (!m_chart->axes(Qt::Horizontal).contains(axis)) | |
|
323 | m_chart->addAxis(axis, Qt::AlignTop); | |
|
324 | if (!s->attachedAxes().contains(axis)) | |
|
325 | s->attachAxis(axis); | |
|
326 | } else { | |
|
327 | qWarning() << "Trying to set axisXTop to null."; | |
|
328 | } | |
|
329 | } | |
|
369 | 330 | |
|
370 | 331 | void DeclarativeChart::handleAxisYSet(QAbstractAxis *axis) |
|
371 | 332 | { |
|
372 | // qDebug() << "DeclarativeChart::handleAxisYSet" << sender() << axis; | |
|
373 | if (axis && qobject_cast<QAbstractSeries *>(sender())) | |
|
374 | m_chart->setAxisY(axis, qobject_cast<QAbstractSeries *>(sender())); | |
|
375 | else | |
|
333 | QAbstractSeries *s = qobject_cast<QAbstractSeries *>(sender()); | |
|
334 | if (axis && s) { | |
|
335 | if (!m_chart->axes(Qt::Vertical).contains(axis)) | |
|
336 | m_chart->addAxis(axis, Qt::AlignLeft); | |
|
337 | if (!s->attachedAxes().contains(axis)) | |
|
338 | s->attachAxis(axis); | |
|
339 | } else { | |
|
376 | 340 | qWarning() << "Trying to set axisY to null."; |
|
377 | 341 | } |
|
342 | } | |
|
343 | ||
|
344 | void DeclarativeChart::handleAxisYRightSet(QAbstractAxis *axis) | |
|
345 | { | |
|
346 | QAbstractSeries *s = qobject_cast<QAbstractSeries *>(sender()); | |
|
347 | if (axis && s) { | |
|
348 | if (!m_chart->axes(Qt::Vertical).contains(axis)) | |
|
349 | m_chart->addAxis(axis, Qt::AlignRight); | |
|
350 | if (!s->attachedAxes().contains(axis)) | |
|
351 | s->attachAxis(axis); | |
|
352 | } else { | |
|
353 | qWarning() << "Trying to set axisYRight to null."; | |
|
354 | } | |
|
355 | } | |
|
378 | 356 | |
|
379 | 357 | void DeclarativeChart::geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) |
|
380 | 358 | { |
@@ -435,12 +413,18 QString DeclarativeChart::title() | |||
|
435 | 413 | |
|
436 | 414 | QAbstractAxis *DeclarativeChart::axisX(QAbstractSeries *series) |
|
437 | 415 | { |
|
438 | return m_chart->axisX(series); | |
|
416 | QList<QAbstractAxis *> axes = m_chart->axes(Qt::Horizontal, series); | |
|
417 | if (axes.count()) | |
|
418 | return axes[0]; | |
|
419 | return 0; | |
|
439 | 420 | } |
|
440 | 421 | |
|
441 | 422 | QAbstractAxis *DeclarativeChart::axisY(QAbstractSeries *series) |
|
442 | 423 | { |
|
443 | return m_chart->axisY(series); | |
|
424 | QList<QAbstractAxis *> axes = m_chart->axes(Qt::Vertical, series); | |
|
425 | if (axes.count()) | |
|
426 | return axes[0]; | |
|
427 | return 0; | |
|
444 | 428 | } |
|
445 | 429 | |
|
446 | 430 | QLegend *DeclarativeChart::legend() |
@@ -557,6 +541,40 void DeclarativeChart::scrollDown(qreal pixels) | |||
|
557 | 541 | m_chart->scroll(0, -pixels); |
|
558 | 542 | } |
|
559 | 543 | |
|
544 | QDeclarativeListProperty<QAbstractAxis> DeclarativeChart::axes() | |
|
545 | { | |
|
546 | return QDeclarativeListProperty<QAbstractAxis>(this, 0, | |
|
547 | &DeclarativeChart::axesAppendFunc, | |
|
548 | &DeclarativeChart::axesCountFunc, | |
|
549 | &DeclarativeChart::axesAtFunc); | |
|
550 | } | |
|
551 | ||
|
552 | void DeclarativeChart::axesAppendFunc(QDeclarativeListProperty<QAbstractAxis> *list, QAbstractAxis *element) | |
|
553 | { | |
|
554 | // Empty implementation | |
|
555 | Q_UNUSED(list); | |
|
556 | Q_UNUSED(element); | |
|
557 | } | |
|
558 | ||
|
559 | int DeclarativeChart::axesCountFunc(QDeclarativeListProperty<QAbstractAxis> *list) | |
|
560 | { | |
|
561 | if (qobject_cast<DeclarativeChart *>(list->object)) { | |
|
562 | DeclarativeChart *chart = qobject_cast<DeclarativeChart *>(list->object); | |
|
563 | return chart->m_chart->axes(Qt::Horizontal | Qt::Vertical, chart->m_chart->series()[0]).count(); | |
|
564 | } | |
|
565 | return 0; | |
|
566 | } | |
|
567 | ||
|
568 | QAbstractAxis *DeclarativeChart::axesAtFunc(QDeclarativeListProperty<QAbstractAxis> *list, int index) | |
|
569 | { | |
|
570 | if (qobject_cast<DeclarativeChart *>(list->object)) { | |
|
571 | DeclarativeChart *chart = qobject_cast<DeclarativeChart *>(list->object); | |
|
572 | QList<QAbstractAxis *> axes = chart->m_chart->axes(Qt::Horizontal | Qt::Vertical, chart->m_chart->series()[0]); | |
|
573 | return axes.at(index); | |
|
574 | } | |
|
575 | return 0; | |
|
576 | } | |
|
577 | ||
|
560 | 578 | QAbstractSeries *DeclarativeChart::series(int index) |
|
561 | 579 | { |
|
562 | 580 | if (index < m_chart->series().count()) { |
@@ -625,13 +643,24 QAbstractSeries *DeclarativeChart::createSeries(DeclarativeChart::SeriesType typ | |||
|
625 | 643 | } |
|
626 | 644 | |
|
627 | 645 | if (series) { |
|
646 | // Connect to axis changed signals (unless this is a pie series) | |
|
647 | if (!qobject_cast<DeclarativePieSeries *>(series)) { | |
|
648 | connect(series, SIGNAL(axisXChanged(QAbstractAxis*)), this, SLOT(handleAxisXSet(QAbstractAxis*))); | |
|
649 | connect(series, SIGNAL(axisXTopChanged(QAbstractAxis*)), this, SLOT(handleAxisXSet(QAbstractAxis*))); | |
|
650 | connect(series, SIGNAL(axisYChanged(QAbstractAxis*)), this, SLOT(handleAxisYSet(QAbstractAxis*))); | |
|
651 | connect(series, SIGNAL(axisYRightChanged(QAbstractAxis*)), this, SLOT(handleAxisYRightSet(QAbstractAxis*))); | |
|
652 | } | |
|
653 | ||
|
628 | 654 | series->setName(name); |
|
629 | 655 | m_chart->addSeries(series); |
|
630 | // Set possible user defined axes | |
|
656 | ||
|
657 | if (axisX) | |
|
631 | 658 | setAxisX(axisX, series); |
|
659 | if (axisY) | |
|
632 | 660 | setAxisY(axisY, series); |
|
633 | // Then create the missing axes | |
|
634 | createDefaultAxes(series); | |
|
661 | ||
|
662 | if (series->attachedAxes().count() < 2) | |
|
663 | initializeAxes(series); | |
|
635 | 664 | } |
|
636 | 665 | |
|
637 | 666 | return series; |
@@ -662,67 +691,77 void DeclarativeChart::createDefaultAxes() | |||
|
662 | 691 | qWarning() << "ChartView.createDefaultAxes() is deprecated. Axes are created automatically."; |
|
663 | 692 | } |
|
664 | 693 | |
|
665 |
|
|
|
694 | QAbstractAxis *DeclarativeChart::defaultAxis(Qt::Orientation orientation, QAbstractSeries *series) | |
|
666 | 695 | { |
|
667 | foreach (QAbstractSeries *s, m_chart->series()) { | |
|
668 | // If there is already an x axis of the correct type, re-use it | |
|
669 | if (!m_chart->axisX(series) && s != series && m_chart->axisX(s) | |
|
670 | && m_chart->axisX(s)->type() == series->d_ptr->defaultAxisType(Qt::Horizontal)) | |
|
671 | m_chart->setAxisX(m_chart->axisX(s), series); | |
|
672 | ||
|
673 | // If there is already a y axis of the correct type, re-use it | |
|
674 | if (!m_chart->axisY(series) && s != series && m_chart->axisY(s) | |
|
675 | && m_chart->axisY(s)->type() == series->d_ptr->defaultAxisType(Qt::Vertical)) | |
|
676 | m_chart->setAxisY(m_chart->axisY(s), series); | |
|
696 | if (!series) { | |
|
697 | qWarning() << "No axis type defined for null series"; | |
|
698 | return 0; | |
|
677 | 699 | } |
|
678 | 700 | |
|
679 | // If no x axis of correct type was found, create a new x axis based of default axis type | |
|
680 | if (!m_chart->axisX(series)) { | |
|
681 | switch (series->d_ptr->defaultAxisType(Qt::Horizontal)) { | |
|
682 | case QAbstractAxis::AxisTypeValue: | |
|
683 | m_chart->setAxisX(new QValueAxis(this), series); | |
|
684 | break; | |
|
685 | case QAbstractAxis::AxisTypeBarCategory: | |
|
686 | m_chart->setAxisX(new QBarCategoryAxis(this), series); | |
|
687 | break; | |
|
688 | case QAbstractAxis::AxisTypeCategory: | |
|
689 | m_chart->setAxisX(new QCategoryAxis(this), series); | |
|
690 | break; | |
|
691 | #ifndef QT_ON_ARM | |
|
692 | case QAbstractAxis::AxisTypeDateTime: | |
|
693 | m_chart->setAxisX(new QDateTimeAxis(this), series); | |
|
694 | break; | |
|
695 | #endif | |
|
696 | default: | |
|
697 | // Do nothing, assume AxisTypeNoAxis | |
|
698 | break; | |
|
699 | } | |
|
701 | foreach (QAbstractAxis *existingAxis, m_chart->axes(orientation)) { | |
|
702 | if (existingAxis->type() == series->d_ptr->defaultAxisType(orientation)) | |
|
703 | return existingAxis; | |
|
700 | 704 | } |
|
701 | 705 | |
|
702 | // If no y axis of correct type was found, create a new y axis based of default axis type | |
|
703 | if (!m_chart->axisY(series)) { | |
|
704 | switch (series->d_ptr->defaultAxisType(Qt::Vertical)) { | |
|
706 | switch (series->d_ptr->defaultAxisType(orientation)) { | |
|
705 | 707 |
|
|
706 |
|
|
|
707 | break; | |
|
708 | return new QValueAxis(this); | |
|
708 | 709 |
|
|
709 |
|
|
|
710 | break; | |
|
710 | return new QBarCategoryAxis(this); | |
|
711 | 711 |
|
|
712 |
|
|
|
713 | break; | |
|
712 | return new QCategoryAxis(this); | |
|
714 | 713 | #ifndef QT_ON_ARM |
|
715 | 714 |
|
|
716 |
|
|
|
717 | break; | |
|
715 | return new QDateTimeAxis(this); | |
|
718 | 716 | #endif |
|
719 | 717 |
|
|
720 |
|
|
|
721 |
|
|
|
718 | // assume AxisTypeNoAxis | |
|
719 | return 0; | |
|
722 | 720 |
|
|
723 | 721 | } |
|
724 | 722 | |
|
725 | //qDebug() << "axis for series" << series << "x:" << m_chart->axisX(series) << "y:" << m_chart->axisY(series); | |
|
723 | void DeclarativeChart::initializeAxes(QAbstractSeries *series) | |
|
724 | { | |
|
725 | if (qobject_cast<DeclarativeLineSeries *>(series)) | |
|
726 | doInitializeAxes(series, qobject_cast<DeclarativeLineSeries *>(series)->m_axes); | |
|
727 | else if (qobject_cast<DeclarativeScatterSeries *>(series)) | |
|
728 | doInitializeAxes(series, qobject_cast<DeclarativeScatterSeries *>(series)->m_axes); | |
|
729 | else if (qobject_cast<DeclarativeSplineSeries *>(series)) | |
|
730 | doInitializeAxes(series, qobject_cast<DeclarativeSplineSeries *>(series)->m_axes); | |
|
731 | else if (qobject_cast<DeclarativeAreaSeries *>(series)) | |
|
732 | doInitializeAxes(series, qobject_cast<DeclarativeAreaSeries *>(series)->m_axes); | |
|
733 | else if (qobject_cast<DeclarativeBarSeries *>(series)) | |
|
734 | doInitializeAxes(series, qobject_cast<DeclarativeBarSeries *>(series)->m_axes); | |
|
735 | else if (qobject_cast<DeclarativeStackedBarSeries *>(series)) | |
|
736 | doInitializeAxes(series, qobject_cast<DeclarativeStackedBarSeries *>(series)->m_axes); | |
|
737 | else if (qobject_cast<DeclarativePercentBarSeries *>(series)) | |
|
738 | doInitializeAxes(series, qobject_cast<DeclarativePercentBarSeries *>(series)->m_axes); | |
|
739 | else if (qobject_cast<DeclarativeHorizontalBarSeries *>(series)) | |
|
740 | doInitializeAxes(series, qobject_cast<DeclarativeHorizontalBarSeries *>(series)->m_axes); | |
|
741 | else if (qobject_cast<DeclarativeHorizontalStackedBarSeries *>(series)) | |
|
742 | doInitializeAxes(series, qobject_cast<DeclarativeHorizontalStackedBarSeries *>(series)->m_axes); | |
|
743 | else if (qobject_cast<DeclarativeHorizontalPercentBarSeries *>(series)) | |
|
744 | doInitializeAxes(series, qobject_cast<DeclarativeHorizontalPercentBarSeries *>(series)->m_axes); | |
|
745 | // else: do nothing | |
|
746 | } | |
|
747 | ||
|
748 | void DeclarativeChart::doInitializeAxes(QAbstractSeries *series, DeclarativeAxes *axes) | |
|
749 | { | |
|
750 | // Initialize axis X | |
|
751 | if (axes->axisX()) | |
|
752 | axes->emitAxisXChanged(); | |
|
753 | else if (axes->axisXTop()) | |
|
754 | axes->emitAxisXTopChanged(); | |
|
755 | else | |
|
756 | axes->setAxisX(defaultAxis(Qt::Horizontal, series)); | |
|
757 | ||
|
758 | // Initialize axis Y | |
|
759 | if (axes->axisY()) | |
|
760 | axes->emitAxisYChanged(); | |
|
761 | else if (axes->axisYRight()) | |
|
762 | axes->emitAxisYRightChanged(); | |
|
763 | else | |
|
764 | axes->setAxisY(defaultAxis(Qt::Vertical, series)); | |
|
726 | 765 | } |
|
727 | 766 | |
|
728 | 767 | #include "moc_declarativechart.cpp" |
@@ -29,7 +29,8 | |||
|
29 | 29 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
30 | 30 | |
|
31 | 31 | class DeclarativeMargins; |
|
32 |
class |
|
|
32 | class Domain; | |
|
33 | class DeclarativeAxes; | |
|
33 | 34 | |
|
34 | 35 | class DeclarativeChart : public QDeclarativeItem |
|
35 | 36 | { |
@@ -50,6 +51,7 class DeclarativeChart : public QDeclarativeItem | |||
|
50 | 51 | Q_PROPERTY(DeclarativeMargins *minimumMargins READ minimumMargins NOTIFY minimumMarginsChanged REVISION 1) |
|
51 | 52 | Q_PROPERTY(DeclarativeMargins *margins READ margins NOTIFY marginsChanged REVISION 2) |
|
52 | 53 | Q_PROPERTY(QRectF plotArea READ plotArea NOTIFY plotAreaChanged REVISION 1) |
|
54 | Q_PROPERTY(QDeclarativeListProperty<QAbstractAxis> axes READ axes REVISION 2) | |
|
53 | 55 | Q_ENUMS(Animation) |
|
54 | 56 | Q_ENUMS(Theme) |
|
55 | 57 | Q_ENUMS(SeriesType) |
@@ -117,13 +119,21 public: | |||
|
117 | 119 | qreal bottomMargin(); |
|
118 | 120 | qreal leftMargin(); |
|
119 | 121 | qreal rightMargin(); |
|
120 | void createDefaultAxes(QAbstractSeries *series); | |
|
122 | QAbstractAxis *defaultAxis(Qt::Orientation orientation, QAbstractSeries *series); | |
|
123 | void initializeAxes(QAbstractSeries *series); | |
|
124 | void doInitializeAxes(QAbstractSeries *series, DeclarativeAxes *axes); | |
|
121 | 125 | //TODO this is deprecated: |
|
122 | 126 | DeclarativeMargins *minimumMargins() { return m_margins; } |
|
123 | 127 | |
|
124 | 128 | Q_REVISION(2) DeclarativeMargins *margins() { return m_margins; } |
|
125 | 129 | QRectF plotArea() { return m_chart->plotArea(); } |
|
126 | 130 | |
|
131 | // Axis list property methods | |
|
132 | QDeclarativeListProperty<QAbstractAxis> axes(); | |
|
133 | static void axesAppendFunc(QDeclarativeListProperty<QAbstractAxis> *list, QAbstractAxis *element); | |
|
134 | static int axesCountFunc(QDeclarativeListProperty<QAbstractAxis> *list); | |
|
135 | static QAbstractAxis *axesAtFunc(QDeclarativeListProperty<QAbstractAxis> *list, int index); | |
|
136 | ||
|
127 | 137 | public: |
|
128 | 138 | Q_INVOKABLE QAbstractSeries *series(int index); |
|
129 | 139 | Q_INVOKABLE QAbstractSeries *series(QString seriesName); |
@@ -153,10 +163,12 Q_SIGNALS: | |||
|
153 | 163 | void seriesAdded(QAbstractSeries *series); |
|
154 | 164 | void seriesRemoved(QAbstractSeries *series); |
|
155 | 165 | |
|
156 |
p |
|
|
166 | private Q_SLOTS: | |
|
157 | 167 | void changeMinimumMargins(int top, int bottom, int left, int right); |
|
158 | 168 | void handleAxisXSet(QAbstractAxis *axis); |
|
159 | 169 | void handleAxisYSet(QAbstractAxis *axis); |
|
170 | void handleAxisXTopSet(QAbstractAxis *axis); | |
|
171 | void handleAxisYRightSet(QAbstractAxis *axis); | |
|
160 | 172 | void handleSeriesAdded(QAbstractSeries *series); |
|
161 | 173 | |
|
162 | 174 | private: |
@@ -24,9 +24,12 QTCOMMERCIALCHART_BEGIN_NAMESPACE | |||
|
24 | 24 | |
|
25 | 25 | DeclarativeLineSeries::DeclarativeLineSeries(QObject *parent) : |
|
26 | 26 | QLineSeries(parent), |
|
27 | m_axisX(0), | |
|
28 | m_axisY(0) | |
|
27 | m_axes(new DeclarativeAxes(this)) | |
|
29 | 28 | { |
|
29 | connect(m_axes, SIGNAL(axisXChanged(QAbstractAxis*)), this, SIGNAL(axisXChanged(QAbstractAxis*))); | |
|
30 | connect(m_axes, SIGNAL(axisYChanged(QAbstractAxis*)), this, SIGNAL(axisYChanged(QAbstractAxis*))); | |
|
31 | connect(m_axes, SIGNAL(axisXTopChanged(QAbstractAxis*)), this, SIGNAL(axisXTopChanged(QAbstractAxis*))); | |
|
32 | connect(m_axes, SIGNAL(axisYRightChanged(QAbstractAxis*)), this, SIGNAL(axisYRightChanged(QAbstractAxis*))); | |
|
30 | 33 | connect(this, SIGNAL(pointAdded(int)), this, SLOT(handleCountChanged(int))); |
|
31 | 34 | connect(this, SIGNAL(pointRemoved(int)), this, SLOT(handleCountChanged(int))); |
|
32 | 35 | } |
@@ -23,6 +23,7 | |||
|
23 | 23 | |
|
24 | 24 | #include "qlineseries.h" |
|
25 | 25 | #include "declarativexyseries.h" |
|
26 | #include "declarativeaxes.h" | |
|
26 | 27 | #include <QtDeclarative/QDeclarativeListProperty> |
|
27 | 28 | #include <QtDeclarative/QDeclarativeParserStatus> |
|
28 | 29 | |
@@ -35,6 +36,8 class DeclarativeLineSeries : public QLineSeries, public DeclarativeXySeries, pu | |||
|
35 | 36 | Q_PROPERTY(int count READ count NOTIFY countChanged) |
|
36 | 37 | Q_PROPERTY(QAbstractAxis *axisX READ axisX WRITE setAxisX NOTIFY axisXChanged REVISION 1) |
|
37 | 38 | Q_PROPERTY(QAbstractAxis *axisY READ axisY WRITE setAxisY NOTIFY axisYChanged REVISION 1) |
|
39 | Q_PROPERTY(QAbstractAxis *axisXTop READ axisXTop WRITE setAxisXTop NOTIFY axisXTopChanged REVISION 2) | |
|
40 | Q_PROPERTY(QAbstractAxis *axisYRight READ axisYRight WRITE setAxisYRight NOTIFY axisYRightChanged REVISION 2) | |
|
38 | 41 | Q_PROPERTY(qreal width READ width WRITE setWidth NOTIFY widthChanged REVISION 1) |
|
39 | 42 | Q_PROPERTY(Qt::PenStyle style READ style WRITE setStyle NOTIFY styleChanged REVISION 1) |
|
40 | 43 | Q_PROPERTY(Qt::PenCapStyle capStyle READ capStyle WRITE setCapStyle NOTIFY capStyleChanged REVISION 1) |
@@ -44,10 +47,14 class DeclarativeLineSeries : public QLineSeries, public DeclarativeXySeries, pu | |||
|
44 | 47 | public: |
|
45 | 48 | explicit DeclarativeLineSeries(QObject *parent = 0); |
|
46 | 49 | QXYSeries *xySeries() { return this; } |
|
47 | QAbstractAxis *axisX() { return m_axisX; } | |
|
48 |
void setAxisX(QAbstractAxis *axis) { m_ax |
|
|
49 | QAbstractAxis *axisY() { return m_axisY; } | |
|
50 |
void setAxisY(QAbstractAxis *axis) { m_ax |
|
|
50 | QAbstractAxis *axisX() { return m_axes->axisX(); } | |
|
51 | void setAxisX(QAbstractAxis *axis) { m_axes->setAxisX(axis); } | |
|
52 | QAbstractAxis *axisY() { return m_axes->axisY(); } | |
|
53 | void setAxisY(QAbstractAxis *axis) { m_axes->setAxisY(axis); } | |
|
54 | Q_REVISION(2) QAbstractAxis *axisXTop() { return m_axes->axisXTop(); } | |
|
55 | Q_REVISION(2) void setAxisXTop(QAbstractAxis *axis) { m_axes->setAxisXTop(axis); } | |
|
56 | Q_REVISION(2) QAbstractAxis *axisYRight() { return m_axes->axisYRight(); } | |
|
57 | Q_REVISION(2) void setAxisYRight(QAbstractAxis *axis) { m_axes->setAxisYRight(axis); } | |
|
51 | 58 | qreal width() const; |
|
52 | 59 | void setWidth(qreal width); |
|
53 | 60 | Qt::PenStyle style() const; |
@@ -72,6 +79,8 Q_SIGNALS: | |||
|
72 | 79 | void countChanged(int count); |
|
73 | 80 | Q_REVISION(1) void axisXChanged(QAbstractAxis *axis); |
|
74 | 81 | Q_REVISION(1) void axisYChanged(QAbstractAxis *axis); |
|
82 | Q_REVISION(2) void axisXTopChanged(QAbstractAxis *axis); | |
|
83 | Q_REVISION(2) void axisYRightChanged(QAbstractAxis *axis); | |
|
75 | 84 | Q_REVISION(1) void widthChanged(qreal width); |
|
76 | 85 | Q_REVISION(1) void styleChanged(Qt::PenStyle style); |
|
77 | 86 | Q_REVISION(1) void capStyleChanged(Qt::PenCapStyle capStyle); |
@@ -80,9 +89,8 public Q_SLOTS: | |||
|
80 | 89 | static void appendDeclarativeChildren(QDeclarativeListProperty<QObject> *list, QObject *element); |
|
81 | 90 | void handleCountChanged(int index); |
|
82 | 91 | |
|
83 | private: | |
|
84 |
|
|
|
85 | QAbstractAxis *m_axisY; | |
|
92 | public: | |
|
93 | DeclarativeAxes *m_axes; | |
|
86 | 94 | }; |
|
87 | 95 | |
|
88 | 96 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -24,9 +24,12 QTCOMMERCIALCHART_BEGIN_NAMESPACE | |||
|
24 | 24 | |
|
25 | 25 | DeclarativeScatterSeries::DeclarativeScatterSeries(QObject *parent) : |
|
26 | 26 | QScatterSeries(parent), |
|
27 | m_axisX(0), | |
|
28 | m_axisY(0) | |
|
27 | m_axes(new DeclarativeAxes(this)) | |
|
29 | 28 | { |
|
29 | connect(m_axes, SIGNAL(axisXChanged(QAbstractAxis*)), this, SIGNAL(axisXChanged(QAbstractAxis*))); | |
|
30 | connect(m_axes, SIGNAL(axisYChanged(QAbstractAxis*)), this, SIGNAL(axisYChanged(QAbstractAxis*))); | |
|
31 | connect(m_axes, SIGNAL(axisXTopChanged(QAbstractAxis*)), this, SIGNAL(axisXTopChanged(QAbstractAxis*))); | |
|
32 | connect(m_axes, SIGNAL(axisYRightChanged(QAbstractAxis*)), this, SIGNAL(axisYRightChanged(QAbstractAxis*))); | |
|
30 | 33 | connect(this, SIGNAL(pointAdded(int)), this, SLOT(handleCountChanged(int))); |
|
31 | 34 | connect(this, SIGNAL(pointRemoved(int)), this, SLOT(handleCountChanged(int))); |
|
32 | 35 | } |
@@ -23,6 +23,7 | |||
|
23 | 23 | |
|
24 | 24 | #include "qscatterseries.h" |
|
25 | 25 | #include "declarativexyseries.h" |
|
26 | #include "declarativeaxes.h" | |
|
26 | 27 | #include <QtDeclarative/QDeclarativeListProperty> |
|
27 | 28 | #include <QtDeclarative/QDeclarativeParserStatus> |
|
28 | 29 | |
@@ -35,6 +36,8 class DeclarativeScatterSeries : public QScatterSeries, public DeclarativeXySeri | |||
|
35 | 36 | Q_PROPERTY(int count READ count NOTIFY countChanged) |
|
36 | 37 | Q_PROPERTY(QAbstractAxis *axisX READ axisX WRITE setAxisX NOTIFY axisXChanged REVISION 1) |
|
37 | 38 | Q_PROPERTY(QAbstractAxis *axisY READ axisY WRITE setAxisY NOTIFY axisYChanged REVISION 1) |
|
39 | Q_PROPERTY(QAbstractAxis *axisXTop READ axisXTop WRITE setAxisXTop NOTIFY axisXTopChanged REVISION 2) | |
|
40 | Q_PROPERTY(QAbstractAxis *axisYRight READ axisYRight WRITE setAxisYRight NOTIFY axisYRightChanged REVISION 2) | |
|
38 | 41 | Q_PROPERTY(qreal borderWidth READ borderWidth WRITE setBorderWidth NOTIFY borderWidthChanged REVISION 1) |
|
39 | 42 | Q_PROPERTY(QDeclarativeListProperty<QObject> declarativeChildren READ declarativeChildren) |
|
40 | 43 | Q_CLASSINFO("DefaultProperty", "declarativeChildren") |
@@ -42,10 +45,14 class DeclarativeScatterSeries : public QScatterSeries, public DeclarativeXySeri | |||
|
42 | 45 | public: |
|
43 | 46 | explicit DeclarativeScatterSeries(QObject *parent = 0); |
|
44 | 47 | QXYSeries *xySeries() { return this; } |
|
45 | QAbstractAxis *axisX() { return m_axisX; } | |
|
46 |
void setAxisX(QAbstractAxis *axis) { m_ax |
|
|
47 | QAbstractAxis *axisY() { return m_axisY; } | |
|
48 |
void setAxisY(QAbstractAxis *axis) { m_ax |
|
|
48 | QAbstractAxis *axisX() { return m_axes->axisX(); } | |
|
49 | void setAxisX(QAbstractAxis *axis) { m_axes->setAxisX(axis); } | |
|
50 | QAbstractAxis *axisY() { return m_axes->axisY(); } | |
|
51 | void setAxisY(QAbstractAxis *axis) { m_axes->setAxisY(axis); } | |
|
52 | Q_REVISION(2) QAbstractAxis *axisXTop() { return m_axes->axisXTop(); } | |
|
53 | Q_REVISION(2) void setAxisXTop(QAbstractAxis *axis) { m_axes->setAxisXTop(axis); } | |
|
54 | Q_REVISION(2) QAbstractAxis *axisYRight() { return m_axes->axisYRight(); } | |
|
55 | Q_REVISION(2) void setAxisYRight(QAbstractAxis *axis) { m_axes->setAxisYRight(axis); } | |
|
49 | 56 | qreal borderWidth() const; |
|
50 | 57 | void setBorderWidth(qreal borderWidth); |
|
51 | 58 | QDeclarativeListProperty<QObject> declarativeChildren(); |
@@ -67,14 +74,15 Q_SIGNALS: | |||
|
67 | 74 | Q_REVISION(1) void axisXChanged(QAbstractAxis *axis); |
|
68 | 75 | Q_REVISION(1) void axisYChanged(QAbstractAxis *axis); |
|
69 | 76 | Q_REVISION(1) void borderWidthChanged(qreal width); |
|
77 | Q_REVISION(2) void axisXTopChanged(QAbstractAxis *axis); | |
|
78 | Q_REVISION(2) void axisYRightChanged(QAbstractAxis *axis); | |
|
70 | 79 | |
|
71 | 80 | public Q_SLOTS: |
|
72 | 81 | static void appendDeclarativeChildren(QDeclarativeListProperty<QObject> *list, QObject *element); |
|
73 | 82 | void handleCountChanged(int index); |
|
74 | 83 | |
|
75 | private: | |
|
76 |
|
|
|
77 | QAbstractAxis *m_axisY; | |
|
84 | public: | |
|
85 | DeclarativeAxes *m_axes; | |
|
78 | 86 | }; |
|
79 | 87 | |
|
80 | 88 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -24,9 +24,12 QTCOMMERCIALCHART_BEGIN_NAMESPACE | |||
|
24 | 24 | |
|
25 | 25 | DeclarativeSplineSeries::DeclarativeSplineSeries(QObject *parent) : |
|
26 | 26 | QSplineSeries(parent), |
|
27 | m_axisX(0), | |
|
28 | m_axisY(0) | |
|
27 | m_axes(new DeclarativeAxes(this)) | |
|
29 | 28 | { |
|
29 | connect(m_axes, SIGNAL(axisXChanged(QAbstractAxis*)), this, SIGNAL(axisXChanged(QAbstractAxis*))); | |
|
30 | connect(m_axes, SIGNAL(axisYChanged(QAbstractAxis*)), this, SIGNAL(axisYChanged(QAbstractAxis*))); | |
|
31 | connect(m_axes, SIGNAL(axisXTopChanged(QAbstractAxis*)), this, SIGNAL(axisXTopChanged(QAbstractAxis*))); | |
|
32 | connect(m_axes, SIGNAL(axisYRightChanged(QAbstractAxis*)), this, SIGNAL(axisYRightChanged(QAbstractAxis*))); | |
|
30 | 33 | connect(this, SIGNAL(pointAdded(int)), this, SLOT(handleCountChanged(int))); |
|
31 | 34 | connect(this, SIGNAL(pointRemoved(int)), this, SLOT(handleCountChanged(int))); |
|
32 | 35 | } |
@@ -23,6 +23,7 | |||
|
23 | 23 | |
|
24 | 24 | #include "qsplineseries.h" |
|
25 | 25 | #include "declarativexyseries.h" |
|
26 | #include "declarativeaxes.h" | |
|
26 | 27 | #include <QtDeclarative/QDeclarativeListProperty> |
|
27 | 28 | #include <QtDeclarative/QDeclarativeParserStatus> |
|
28 | 29 | |
@@ -35,6 +36,8 class DeclarativeSplineSeries : public QSplineSeries, public DeclarativeXySeries | |||
|
35 | 36 | Q_PROPERTY(int count READ count NOTIFY countChanged) |
|
36 | 37 | Q_PROPERTY(QAbstractAxis *axisX READ axisX WRITE setAxisX NOTIFY axisXChanged REVISION 1) |
|
37 | 38 | Q_PROPERTY(QAbstractAxis *axisY READ axisY WRITE setAxisY NOTIFY axisYChanged REVISION 1) |
|
39 | Q_PROPERTY(QAbstractAxis *axisXTop READ axisXTop WRITE setAxisXTop NOTIFY axisXTopChanged REVISION 2) | |
|
40 | Q_PROPERTY(QAbstractAxis *axisYRight READ axisYRight WRITE setAxisYRight NOTIFY axisYRightChanged REVISION 2) | |
|
38 | 41 | Q_PROPERTY(qreal width READ width WRITE setWidth NOTIFY widthChanged REVISION 1) |
|
39 | 42 | Q_PROPERTY(Qt::PenStyle style READ style WRITE setStyle NOTIFY styleChanged REVISION 1) |
|
40 | 43 | Q_PROPERTY(Qt::PenCapStyle capStyle READ capStyle WRITE setCapStyle NOTIFY capStyleChanged REVISION 1) |
@@ -44,10 +47,14 class DeclarativeSplineSeries : public QSplineSeries, public DeclarativeXySeries | |||
|
44 | 47 | public: |
|
45 | 48 | explicit DeclarativeSplineSeries(QObject *parent = 0); |
|
46 | 49 | QXYSeries *xySeries() { return this; } |
|
47 | QAbstractAxis *axisX() { return m_axisX; } | |
|
48 |
void setAxisX(QAbstractAxis *axis) { m_ax |
|
|
49 | QAbstractAxis *axisY() { return m_axisY; } | |
|
50 |
void setAxisY(QAbstractAxis *axis) { m_ax |
|
|
50 | QAbstractAxis *axisX() { return m_axes->axisX(); } | |
|
51 | void setAxisX(QAbstractAxis *axis) { m_axes->setAxisX(axis); } | |
|
52 | QAbstractAxis *axisY() { return m_axes->axisY(); } | |
|
53 | void setAxisY(QAbstractAxis *axis) { m_axes->setAxisY(axis); } | |
|
54 | Q_REVISION(2) QAbstractAxis *axisXTop() { return m_axes->axisXTop(); } | |
|
55 | Q_REVISION(2) void setAxisXTop(QAbstractAxis *axis) { m_axes->setAxisXTop(axis); } | |
|
56 | Q_REVISION(2) QAbstractAxis *axisYRight() { return m_axes->axisYRight(); } | |
|
57 | Q_REVISION(2) void setAxisYRight(QAbstractAxis *axis) { m_axes->setAxisYRight(axis); } | |
|
51 | 58 | qreal width() const; |
|
52 | 59 | void setWidth(qreal width); |
|
53 | 60 | Qt::PenStyle style() const; |
@@ -72,6 +79,8 Q_SIGNALS: | |||
|
72 | 79 | void countChanged(int count); |
|
73 | 80 | Q_REVISION(1) void axisXChanged(QAbstractAxis *axis); |
|
74 | 81 | Q_REVISION(1) void axisYChanged(QAbstractAxis *axis); |
|
82 | Q_REVISION(2) void axisXTopChanged(QAbstractAxis *axis); | |
|
83 | Q_REVISION(2) void axisYRightChanged(QAbstractAxis *axis); | |
|
75 | 84 | Q_REVISION(1) void widthChanged(qreal width); |
|
76 | 85 | Q_REVISION(1) void styleChanged(Qt::PenStyle style); |
|
77 | 86 | Q_REVISION(1) void capStyleChanged(Qt::PenCapStyle capStyle); |
@@ -81,8 +90,7 public Q_SLOTS: | |||
|
81 | 90 | void handleCountChanged(int index); |
|
82 | 91 | |
|
83 | 92 | public: |
|
84 |
|
|
|
85 | QAbstractAxis *m_axisY; | |
|
93 | DeclarativeAxes *m_axes; | |
|
86 | 94 | }; |
|
87 | 95 | |
|
88 | 96 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -31,6 +31,7 | |||
|
31 | 31 | #include "declarativescatterseries.h" |
|
32 | 32 | #include "declarativebarseries.h" |
|
33 | 33 | #include "declarativepieseries.h" |
|
34 | #include "declarativeaxes.h" | |
|
34 | 35 | #include "qvxymodelmapper.h" |
|
35 | 36 | #include "qhxymodelmapper.h" |
|
36 | 37 | #include "qhpiemodelmapper.h" |
@@ -53,6 +54,7 QTCOMMERCIALCHART_USE_NAMESPACE | |||
|
53 | 54 | |
|
54 | 55 | Q_DECLARE_METATYPE(QList<QPieSlice *>) |
|
55 | 56 | Q_DECLARE_METATYPE(QList<QBarSet *>) |
|
57 | Q_DECLARE_METATYPE(QList<QAbstractAxis *>) | |
|
56 | 58 | |
|
57 | 59 | #if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)) |
|
58 | 60 | |
@@ -127,6 +129,7 public: | |||
|
127 | 129 | |
|
128 | 130 | qRegisterMetaType<QList<QPieSlice *> >(); |
|
129 | 131 | qRegisterMetaType<QList<QBarSet *> >(); |
|
132 | qRegisterMetaType<QList<QAbstractAxis *> >(); | |
|
130 | 133 | #if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)) |
|
131 | 134 | qRegisterMetaType<DeclarativeChart::SeriesType>(); |
|
132 | 135 | #endif |
@@ -174,6 +177,8 public: | |||
|
174 | 177 | QLatin1String("Trying to create uncreatable: BarsetBase.")); |
|
175 | 178 | qmlRegisterUncreatableType<QPieSeries>(uri, 1, 0, "QPieSeries", |
|
176 | 179 | QLatin1String("Trying to create uncreatable: QPieSeries. Use PieSeries instead.")); |
|
180 | qmlRegisterUncreatableType<DeclarativeAxes>(uri, 1, 0, "DeclarativeAxes", | |
|
181 | QLatin1String("Trying to create uncreatable: DeclarativeAxes.")); | |
|
177 | 182 | |
|
178 | 183 | // QtCommercial.Chart 1.1 |
|
179 | 184 | qmlRegisterType<DeclarativeChart, 1>(uri, 1, 1, "ChartView"); |
@@ -201,6 +206,16 public: | |||
|
201 | 206 | |
|
202 | 207 | // QtCommercial.Chart 1.2 |
|
203 | 208 | qmlRegisterType<DeclarativeChart, 2>(uri, 1, 2, "ChartView"); |
|
209 | qmlRegisterType<DeclarativeScatterSeries, 2>(uri, 1, 2, "ScatterSeries"); | |
|
210 | qmlRegisterType<DeclarativeLineSeries, 2>(uri, 1, 2, "LineSeries"); | |
|
211 | qmlRegisterType<DeclarativeSplineSeries, 2>(uri, 1, 2, "SplineSeries"); | |
|
212 | qmlRegisterType<DeclarativeAreaSeries, 2>(uri, 1, 2, "AreaSeries"); | |
|
213 | qmlRegisterType<DeclarativeBarSeries, 2>(uri, 1, 2, "BarSeries"); | |
|
214 | qmlRegisterType<DeclarativeStackedBarSeries, 2>(uri, 1, 2, "StackedBarSeries"); | |
|
215 | qmlRegisterType<DeclarativePercentBarSeries, 2>(uri, 1, 2, "PercentBarSeries"); | |
|
216 | qmlRegisterType<DeclarativeHorizontalBarSeries, 2>(uri, 1, 2, "HorizontalBarSeries"); | |
|
217 | qmlRegisterType<DeclarativeHorizontalStackedBarSeries, 2>(uri, 1, 2, "HorizontalStackedBarSeries"); | |
|
218 | qmlRegisterType<DeclarativeHorizontalPercentBarSeries, 2>(uri, 1, 2, "HorizontalPercentBarSeries"); | |
|
204 | 219 | } |
|
205 | 220 | }; |
|
206 | 221 |
@@ -358,15 +358,23 QAbstractAxis *QChart::axisY(QAbstractSeries *series) const | |||
|
358 | 358 | return left?left:right; |
|
359 | 359 | } |
|
360 | 360 | |
|
361 | ||
|
362 | 361 | QList<QAbstractAxis *> QChart::axes(Qt::Orientations orientation, QAbstractSeries *series) const |
|
363 | 362 | { |
|
364 | 363 | QList<QAbstractAxis *> result ; |
|
365 | 364 | |
|
365 | if (series) { | |
|
366 | 366 |
foreach(QAbstractAxis* |
|
367 | 367 | if(orientation.testFlag(axis->orientation())) |
|
368 | 368 | result << axis; |
|
369 | 369 | } |
|
370 | } else { | |
|
371 | foreach (QAbstractSeries *s, QChart::series()) { | |
|
372 | foreach (QAbstractAxis *axis, s->attachedAxes()){ | |
|
373 | if (orientation.testFlag(axis->orientation())) | |
|
374 | result << axis; | |
|
375 | } | |
|
376 | } | |
|
377 | } | |
|
370 | 378 | |
|
371 | 379 | return result; |
|
372 | 380 | } |
@@ -80,7 +80,7 public: | |||
|
80 | 80 | m_seriesColors.append(ChartThemeManager::colorAt(g, 0.5)); |
|
81 | 81 | |
|
82 | 82 | // Generate gradients from the base colors |
|
83 | ChartThemeManager::generateSeriesGradients(m_seriesColors); | |
|
83 | m_seriesGradients = ChartThemeManager::generateSeriesGradients(m_seriesColors); | |
|
84 | 84 | |
|
85 | 85 | // Background fill color from COLOR_WINDOW |
|
86 | 86 | QLinearGradient backgroundGradient; |
@@ -129,7 +129,7 public: | |||
|
129 | 129 | m_seriesColors << QRgb(0x92ca66); |
|
130 | 130 | m_seriesColors << QRgb(0xeba85f); |
|
131 | 131 | m_seriesColors << QRgb(0xfc5751); |
|
132 | generateSeriesGradients(); | |
|
132 | m_seriesGradients = ChartThemeManager::generateSeriesGradients(m_seriesColors); | |
|
133 | 133 | |
|
134 | 134 | // Background |
|
135 | 135 | QLinearGradient backgroundGradient; |
@@ -36,6 +36,18 Rectangle { | |||
|
36 | 36 | compare(barSeries.labelsVisible, false); |
|
37 | 37 | } |
|
38 | 38 | |
|
39 | function test_axes() { | |
|
40 | compare(chartView.axes.length, 2); | |
|
41 | verify(chartView.axes[0] == barSeries.axisX || chartView.axes[1] == barSeries.axisX); | |
|
42 | verify(chartView.axes[0] == barSeries.axisY || chartView.axes[1] == barSeries.axisY); | |
|
43 | ||
|
44 | compare(barSeries.axisX, stackedBarSeries.axisX); | |
|
45 | compare(barSeries.axisY, stackedBarSeries.axisY); | |
|
46 | ||
|
47 | compare(barSeries.axisX, percentBarSeries.axisX); | |
|
48 | compare(barSeries.axisY, percentBarSeries.axisY); | |
|
49 | } | |
|
50 | ||
|
39 | 51 | function test_append() { |
|
40 | 52 | var setCount = 5; |
|
41 | 53 | var valueCount = 50; |
@@ -105,10 +117,10 Rectangle { | |||
|
105 | 117 | anchors.fill: parent |
|
106 | 118 | |
|
107 | 119 | BarSeries { |
|
108 | axisX: BarCategoriesAxis {} | |
|
109 | axisY: ValuesAxis { min: 0; max: 10 } | |
|
110 | 120 | id: barSeries |
|
111 | 121 | name: "bar" |
|
122 | axisX: BarCategoryAxis {} | |
|
123 | axisY: ValueAxis { min: 0; max: 10 } | |
|
112 | 124 | |
|
113 | 125 | SignalSpy { |
|
114 | 126 | id: addedSpy |
@@ -121,5 +133,15 Rectangle { | |||
|
121 | 133 | signalName: "barsetsRemoved" |
|
122 | 134 | } |
|
123 | 135 | } |
|
136 | ||
|
137 | StackedBarSeries { | |
|
138 | id: stackedBarSeries | |
|
139 | name: "stackedBar" | |
|
140 | } | |
|
141 | ||
|
142 | PercentBarSeries { | |
|
143 | id: percentBarSeries | |
|
144 | name: "percentBar" | |
|
145 | } | |
|
124 | 146 | } |
|
125 | 147 | } |
@@ -34,26 +34,17 Rectangle { | |||
|
34 | 34 | function test_properties() { |
|
35 | 35 | verify(lineSeries.color != undefined); |
|
36 | 36 | compare(lineSeries.pointsVisible, false); |
|
37 | // TODO: Should the properties be set or not? | |
|
38 | // verify(lineSeries.axisX != null); | |
|
39 | // verify(lineSeries.axisY != null); | |
|
40 | 37 |
|
|
41 | 38 | compare(lineSeries.style, Qt.SolidLine); |
|
42 | 39 | compare(lineSeries.width, 2.0); |
|
43 | 40 | |
|
44 | 41 | verify(splineSeries.color != undefined); |
|
45 | 42 | compare(splineSeries.pointsVisible, false); |
|
46 | // TODO: Should the properties be set or not? | |
|
47 | // verify(splineSeries.axisX != null); | |
|
48 | // verify(splineSeries.axisY != null); | |
|
49 | 43 |
|
|
50 | 44 | compare(splineSeries.style, Qt.SolidLine); |
|
51 | 45 | compare(splineSeries.width, 2.0); |
|
52 | 46 | |
|
53 | 47 | verify(scatterSeries.color != undefined); |
|
54 | // TODO: Should the properties be set or not? | |
|
55 | // verify(scatterSeries.axisX != null); | |
|
56 | // verify(scatterSeries.axisY != null); | |
|
57 | 48 |
|
|
58 | 49 | compare(scatterSeries.borderWidth, 2.0); |
|
59 | 50 | compare(scatterSeries.markerShape, ScatterSeries.MarkerShapeCircle); |
@@ -64,6 +55,20 Rectangle { | |||
|
64 | 55 | compare(areaSeries.borderWidth, 2.0); |
|
65 | 56 | } |
|
66 | 57 | |
|
58 | function test_axes() { | |
|
59 | compare(chartView.axes.length, 2); | |
|
60 | console.log("chart.axes[0] " + chartView.axes[0]); | |
|
61 | console.log("chart.axes[1] " + chartView.axes[1]); | |
|
62 | console.log("lineSeries.axisX " + lineSeries.axisX); | |
|
63 | console.log("lineSeries.axisY " + lineSeries.axisY); | |
|
64 | verify(chartView.axes[0] == lineSeries.axisX || chartView.axes[1] == lineSeries.axisX); | |
|
65 | verify(chartView.axes[0] == lineSeries.axisY || chartView.axes[1] == lineSeries.axisY); | |
|
66 | verify(lineSeries.axisX == splineSeries.axisX); | |
|
67 | verify(lineSeries.axisY == splineSeries.axisY); | |
|
68 | verify(lineSeries.axisX == areaSeries.axisX); | |
|
69 | verify(lineSeries.axisY == areaSeries.axisY); | |
|
70 | } | |
|
71 | ||
|
67 | 72 | function test_append() { |
|
68 | 73 | lineSeriesPointAddedSpy.clear(); |
|
69 | 74 | splineSeriesPointAddedSpy.clear(); |
@@ -33,12 +33,12 ChartView { | |||
|
33 | 33 | onTriggered: { |
|
34 | 34 | switch (index) { |
|
35 | 35 | case 0: |
|
36 |
|
|
|
37 |
|
|
|
36 | lineSeries.axisX.max = 6; | |
|
37 | lineSeries.axisY.max = 6; | |
|
38 | 38 | break; |
|
39 | 39 | case 1: |
|
40 |
|
|
|
41 |
|
|
|
40 | scatterSeries.axisX.max = 10; | |
|
41 | scatterSeries.axisY.max = 10; | |
|
42 | 42 | break; |
|
43 | 43 | default: |
|
44 | 44 | chartView.axisX().max = 4; |
General Comments 0
You need to be logged in to leave comments.
Login now