@@ -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 | categories: ["2007", "2008", "2009", "2010", "2011", "2012", "2013", "2014" ] |
|
37 | categories: ["2007", "2008", "2009", "2010", "2011", "2012", "2013", "2014" ] | |
38 | min: "2007" |
|
38 | min: "2007" | |
39 | max: "2014" |
|
39 | max: "2014" | |
40 | title: "Year" |
|
40 | titleText: "Year" | |
41 | } |
|
41 | } | |
42 |
|
42 | |||
43 | ValueAxis { |
|
43 | ValueAxis { | |
44 | id: valueAxis |
|
44 | id: valueAxis | |
45 | min: 0 |
|
45 | min: 0 | |
46 | max: 60 |
|
46 | max: 60 | |
47 | title: "Sales count [ku]" |
|
47 | titleText: "Sales count [ku]" | |
48 | } |
|
48 | } | |
49 | // ... |
|
49 | // ... | |
50 | //![1] |
|
50 | //![1] |
@@ -19,7 +19,7 | |||||
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 | import QtQuick 1.1 |
|
21 | import QtQuick 1.1 | |
22 |
import QtCommercial.Chart 1. |
|
22 | import QtCommercial.Chart 1.2 | |
23 |
|
23 | |||
24 | Rectangle { |
|
24 | Rectangle { | |
25 | width: 360 |
|
25 | width: 360 | |
@@ -43,21 +43,20 Rectangle { | |||||
43 | //![2] |
|
43 | //![2] | |
44 | BarCategoriesAxis { |
|
44 | BarCategoriesAxis { | |
45 | id: barCategoriesAxis |
|
45 | id: barCategoriesAxis | |
46 | title: "Date" |
|
46 | titleText: "Date" | |
47 | } |
|
47 | } | |
48 |
|
48 | |||
49 | ValueAxis{ |
|
49 | ValueAxis{ | |
50 | id: valueAxisY2 |
|
50 | id: valueAxisY2 | |
51 | min: 0 |
|
51 | min: 0 | |
52 | max: 10 |
|
52 | max: 10 | |
53 | title: "Rainfall [mm]" |
|
53 | titleText: "Rainfall [mm]" | |
54 | alignment: Qt.AlignRight |
|
|||
55 | } |
|
54 | } | |
56 |
|
55 | |||
57 | BarSeries { |
|
56 | BarSeries { | |
58 | id: myBarSeries |
|
57 | id: myBarSeries | |
59 | axisX: barCategoriesAxis |
|
58 | axisX: barCategoriesAxis | |
60 | axisY: valueAxisY2 |
|
59 | axisYRight: valueAxisY2 | |
61 | BarSet { |
|
60 | BarSet { | |
62 | id: rainfallSet |
|
61 | id: rainfallSet | |
63 | label: "Rainfall" |
|
62 | label: "Rainfall" | |
@@ -76,7 +75,7 Rectangle { | |||||
76 | id: valueAxisY |
|
75 | id: valueAxisY | |
77 | min: 0 |
|
76 | min: 0 | |
78 | max: 15 |
|
77 | max: 15 | |
79 | title: "Temperature [\u00B0C]" |
|
78 | titleText: "Temperature [\u00B0C]" | |
80 | } |
|
79 | } | |
81 |
|
80 | |||
82 | LineSeries { |
|
81 | LineSeries { |
@@ -24,7 +24,8 SOURCES += \ | |||||
24 | declarativepieseries.cpp \ |
|
24 | declarativepieseries.cpp \ | |
25 | declarativebarseries.cpp \ |
|
25 | declarativebarseries.cpp \ | |
26 | declarativecategoryaxis.cpp \ |
|
26 | declarativecategoryaxis.cpp \ | |
27 | declarativemargins.cpp |
|
27 | declarativemargins.cpp \ | |
|
28 | declarativeaxes.cpp | |||
28 |
|
29 | |||
29 | HEADERS += \ |
|
30 | HEADERS += \ | |
30 | declarativechart.h \ |
|
31 | declarativechart.h \ | |
@@ -37,7 +38,8 HEADERS += \ | |||||
37 | declarativepieseries.h \ |
|
38 | declarativepieseries.h \ | |
38 | declarativebarseries.h \ |
|
39 | declarativebarseries.h \ | |
39 | declarativecategoryaxis.h \ |
|
40 | declarativecategoryaxis.h \ | |
40 | declarativemargins.h |
|
41 | declarativemargins.h \ | |
|
42 | declarativeaxes.h | |||
41 |
|
43 | |||
42 | TARGETPATH = QtCommercial/Chart |
|
44 | TARGETPATH = QtCommercial/Chart | |
43 | target.path = $$[QT_INSTALL_IMPORTS]/$$TARGETPATH |
|
45 | target.path = $$[QT_INSTALL_IMPORTS]/$$TARGETPATH |
@@ -25,9 +25,12 QTCOMMERCIALCHART_BEGIN_NAMESPACE | |||||
25 |
|
25 | |||
26 | DeclarativeAreaSeries::DeclarativeAreaSeries(QObject *parent) : |
|
26 | DeclarativeAreaSeries::DeclarativeAreaSeries(QObject *parent) : | |
27 | QAreaSeries(parent), |
|
27 | QAreaSeries(parent), | |
28 | m_axisX(0), |
|
28 | m_axes(new DeclarativeAxes(this)) | |
29 | m_axisY(0) |
|
|||
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 | void DeclarativeAreaSeries::setUpperSeries(DeclarativeLineSeries *series) |
|
36 | void DeclarativeAreaSeries::setUpperSeries(DeclarativeLineSeries *series) |
@@ -22,6 +22,7 | |||||
22 | #define DECLARATIVEAREASERIES_H |
|
22 | #define DECLARATIVEAREASERIES_H | |
23 |
|
23 | |||
24 | #include "qareaseries.h" |
|
24 | #include "qareaseries.h" | |
|
25 | #include "declarativeaxes.h" | |||
25 |
|
26 | |||
26 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
27 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
27 | class DeclarativeLineSeries; |
|
28 | class DeclarativeLineSeries; | |
@@ -33,6 +34,8 class DeclarativeAreaSeries : public QAreaSeries | |||||
33 | Q_PROPERTY(DeclarativeLineSeries *lowerSeries READ lowerSeries WRITE setLowerSeries) |
|
34 | Q_PROPERTY(DeclarativeLineSeries *lowerSeries READ lowerSeries WRITE setLowerSeries) | |
34 | Q_PROPERTY(QAbstractAxis *axisX READ axisX WRITE setAxisX NOTIFY axisXChanged REVISION 1) |
|
35 | Q_PROPERTY(QAbstractAxis *axisX READ axisX WRITE setAxisX NOTIFY axisXChanged REVISION 1) | |
35 | Q_PROPERTY(QAbstractAxis *axisY READ axisY WRITE setAxisY NOTIFY axisYChanged REVISION 1) |
|
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 | Q_PROPERTY(qreal borderWidth READ borderWidth WRITE setBorderWidth NOTIFY borderWidthChanged REVISION 1) |
|
39 | Q_PROPERTY(qreal borderWidth READ borderWidth WRITE setBorderWidth NOTIFY borderWidthChanged REVISION 1) | |
37 |
|
40 | |||
38 | public: |
|
41 | public: | |
@@ -41,10 +44,14 public: | |||||
41 | DeclarativeLineSeries *upperSeries() const; |
|
44 | DeclarativeLineSeries *upperSeries() const; | |
42 | void setLowerSeries(DeclarativeLineSeries *series); |
|
45 | void setLowerSeries(DeclarativeLineSeries *series); | |
43 | DeclarativeLineSeries *lowerSeries() const; |
|
46 | DeclarativeLineSeries *lowerSeries() const; | |
44 | QAbstractAxis *axisX() { return m_axisX; } |
|
47 | QAbstractAxis *axisX() { return m_axes->axisX(); } | |
45 |
void setAxisX(QAbstractAxis *axis) { m_ax |
|
48 | void setAxisX(QAbstractAxis *axis) { m_axes->setAxisX(axis); } | |
46 | QAbstractAxis *axisY() { return m_axisY; } |
|
49 | QAbstractAxis *axisY() { return m_axes->axisY(); } | |
47 |
void setAxisY(QAbstractAxis *axis) { m_ax |
|
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 | qreal borderWidth() const; |
|
55 | qreal borderWidth() const; | |
49 | void setBorderWidth(qreal borderWidth); |
|
56 | void setBorderWidth(qreal borderWidth); | |
50 |
|
57 | |||
@@ -52,10 +59,11 Q_SIGNALS: | |||||
52 | Q_REVISION(1) void axisXChanged(QAbstractAxis *axis); |
|
59 | Q_REVISION(1) void axisXChanged(QAbstractAxis *axis); | |
53 | Q_REVISION(1) void axisYChanged(QAbstractAxis *axis); |
|
60 | Q_REVISION(1) void axisYChanged(QAbstractAxis *axis); | |
54 | Q_REVISION(1) void borderWidthChanged(qreal width); |
|
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: |
|
65 | public: | |
57 |
|
|
66 | DeclarativeAxes *m_axes; | |
58 | QAbstractAxis *m_axisY; |
|
|||
59 | }; |
|
67 | }; | |
60 |
|
68 | |||
61 | QTCOMMERCIALCHART_END_NAMESPACE |
|
69 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -76,9 +76,12 void DeclarativeBarSet::setValues(QVariantList values) | |||||
76 | // Declarative bar series ====================================================================================== |
|
76 | // Declarative bar series ====================================================================================== | |
77 | DeclarativeBarSeries::DeclarativeBarSeries(QDeclarativeItem *parent) : |
|
77 | DeclarativeBarSeries::DeclarativeBarSeries(QDeclarativeItem *parent) : | |
78 | QBarSeries(parent), |
|
78 | QBarSeries(parent), | |
79 | m_axisX(0), |
|
79 | m_axes(new DeclarativeAxes(this)) | |
80 | m_axisY(0) |
|
|||
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 | void DeclarativeBarSeries::classBegin() |
|
87 | void DeclarativeBarSeries::classBegin() | |
@@ -135,9 +138,13 DeclarativeBarSet *DeclarativeBarSeries::insert(int index, QString label, QVaria | |||||
135 | // Declarative stacked bar series ============================================================================== |
|
138 | // Declarative stacked bar series ============================================================================== | |
136 | DeclarativeStackedBarSeries::DeclarativeStackedBarSeries(QDeclarativeItem *parent) : |
|
139 | DeclarativeStackedBarSeries::DeclarativeStackedBarSeries(QDeclarativeItem *parent) : | |
137 | QStackedBarSeries(parent), |
|
140 | QStackedBarSeries(parent), | |
138 |
m_ax |
|
141 | m_axes(0) | |
139 | m_axisY(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 | void DeclarativeStackedBarSeries::classBegin() |
|
150 | void DeclarativeStackedBarSeries::classBegin() | |
@@ -195,9 +202,13 DeclarativeBarSet *DeclarativeStackedBarSeries::insert(int index, QString label, | |||||
195 | // Declarative percent bar series ============================================================================== |
|
202 | // Declarative percent bar series ============================================================================== | |
196 | DeclarativePercentBarSeries::DeclarativePercentBarSeries(QDeclarativeItem *parent) : |
|
203 | DeclarativePercentBarSeries::DeclarativePercentBarSeries(QDeclarativeItem *parent) : | |
197 | QPercentBarSeries(parent), |
|
204 | QPercentBarSeries(parent), | |
198 |
m_ax |
|
205 | m_axes(0) | |
199 | m_axisY(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 | void DeclarativePercentBarSeries::classBegin() |
|
214 | void DeclarativePercentBarSeries::classBegin() | |
@@ -254,9 +265,13 DeclarativeBarSet *DeclarativePercentBarSeries::insert(int index, QString label, | |||||
254 | // Declarative horizontal bar series =========================================================================== |
|
265 | // Declarative horizontal bar series =========================================================================== | |
255 | DeclarativeHorizontalBarSeries::DeclarativeHorizontalBarSeries(QDeclarativeItem *parent) : |
|
266 | DeclarativeHorizontalBarSeries::DeclarativeHorizontalBarSeries(QDeclarativeItem *parent) : | |
256 | QHorizontalBarSeries(parent), |
|
267 | QHorizontalBarSeries(parent), | |
257 |
m_ax |
|
268 | m_axes(0) | |
258 | m_axisY(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 | void DeclarativeHorizontalBarSeries::classBegin() |
|
277 | void DeclarativeHorizontalBarSeries::classBegin() | |
@@ -313,9 +328,13 DeclarativeBarSet *DeclarativeHorizontalBarSeries::insert(int index, QString lab | |||||
313 | // Declarative horizontal stacked bar series =================================================================== |
|
328 | // Declarative horizontal stacked bar series =================================================================== | |
314 | DeclarativeHorizontalStackedBarSeries::DeclarativeHorizontalStackedBarSeries(QDeclarativeItem *parent) : |
|
329 | DeclarativeHorizontalStackedBarSeries::DeclarativeHorizontalStackedBarSeries(QDeclarativeItem *parent) : | |
315 | QHorizontalStackedBarSeries(parent), |
|
330 | QHorizontalStackedBarSeries(parent), | |
316 |
m_ax |
|
331 | m_axes(0) | |
317 | m_axisY(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 | void DeclarativeHorizontalStackedBarSeries::classBegin() |
|
340 | void DeclarativeHorizontalStackedBarSeries::classBegin() | |
@@ -372,9 +391,13 DeclarativeBarSet *DeclarativeHorizontalStackedBarSeries::insert(int index, QStr | |||||
372 | // Declarative horizontal percent bar series =================================================================== |
|
391 | // Declarative horizontal percent bar series =================================================================== | |
373 | DeclarativeHorizontalPercentBarSeries::DeclarativeHorizontalPercentBarSeries(QDeclarativeItem *parent) : |
|
392 | DeclarativeHorizontalPercentBarSeries::DeclarativeHorizontalPercentBarSeries(QDeclarativeItem *parent) : | |
374 | QHorizontalPercentBarSeries(parent), |
|
393 | QHorizontalPercentBarSeries(parent), | |
375 |
m_ax |
|
394 | m_axes(0) | |
376 | m_axisY(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 | void DeclarativeHorizontalPercentBarSeries::classBegin() |
|
403 | void DeclarativeHorizontalPercentBarSeries::classBegin() |
@@ -28,6 +28,7 | |||||
28 | #include "qhorizontalstackedbarseries.h" |
|
28 | #include "qhorizontalstackedbarseries.h" | |
29 | #include "qhorizontalpercentbarseries.h" |
|
29 | #include "qhorizontalpercentbarseries.h" | |
30 | #include "qbarset.h" |
|
30 | #include "qbarset.h" | |
|
31 | #include "declarativeaxes.h" | |||
31 | #include <QtDeclarative/QDeclarativeItem> |
|
32 | #include <QtDeclarative/QDeclarativeItem> | |
32 | #include <QtDeclarative/QDeclarativeParserStatus> |
|
33 | #include <QtDeclarative/QDeclarativeParserStatus> | |
33 |
|
34 | |||
@@ -69,15 +70,21 class DeclarativeBarSeries : public QBarSeries, public QDeclarativeParserStatus | |||||
69 | Q_INTERFACES(QDeclarativeParserStatus) |
|
70 | Q_INTERFACES(QDeclarativeParserStatus) | |
70 | Q_PROPERTY(QAbstractAxis *axisX READ axisX WRITE setAxisX NOTIFY axisXChanged REVISION 1) |
|
71 | Q_PROPERTY(QAbstractAxis *axisX READ axisX WRITE setAxisX NOTIFY axisXChanged REVISION 1) | |
71 | Q_PROPERTY(QAbstractAxis *axisY READ axisY WRITE setAxisY NOTIFY axisYChanged REVISION 1) |
|
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 | Q_PROPERTY(QDeclarativeListProperty<QObject> seriesChildren READ seriesChildren) |
|
75 | Q_PROPERTY(QDeclarativeListProperty<QObject> seriesChildren READ seriesChildren) | |
73 | Q_CLASSINFO("DefaultProperty", "seriesChildren") |
|
76 | Q_CLASSINFO("DefaultProperty", "seriesChildren") | |
74 |
|
77 | |||
75 | public: |
|
78 | public: | |
76 | explicit DeclarativeBarSeries(QDeclarativeItem *parent = 0); |
|
79 | explicit DeclarativeBarSeries(QDeclarativeItem *parent = 0); | |
77 | QAbstractAxis *axisX() { return m_axisX; } |
|
80 | QAbstractAxis *axisX() { return m_axes->axisX(); } | |
78 |
void setAxisX(QAbstractAxis *axis) { m_ax |
|
81 | void setAxisX(QAbstractAxis *axis) { m_axes->setAxisX(axis); } | |
79 | QAbstractAxis *axisY() { return m_axisY; } |
|
82 | QAbstractAxis *axisY() { return m_axes->axisY(); } | |
80 |
void setAxisY(QAbstractAxis *axis) { m_ax |
|
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 | QDeclarativeListProperty<QObject> seriesChildren(); |
|
88 | QDeclarativeListProperty<QObject> seriesChildren(); | |
82 |
|
89 | |||
83 | public: |
|
90 | public: | |
@@ -94,13 +101,14 public: // from QDeclarativeParserStatus | |||||
94 | Q_SIGNALS: |
|
101 | Q_SIGNALS: | |
95 | Q_REVISION(1) void axisXChanged(QAbstractAxis *axis); |
|
102 | Q_REVISION(1) void axisXChanged(QAbstractAxis *axis); | |
96 | Q_REVISION(1) void axisYChanged(QAbstractAxis *axis); |
|
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 | public Q_SLOTS: |
|
107 | public Q_SLOTS: | |
99 | static void appendSeriesChildren(QDeclarativeListProperty<QObject> *list, QObject *element); |
|
108 | static void appendSeriesChildren(QDeclarativeListProperty<QObject> *list, QObject *element); | |
100 |
|
109 | |||
101 | private: |
|
110 | public: | |
102 |
|
|
111 | DeclarativeAxes *m_axes; | |
103 | QAbstractAxis *m_axisY; |
|
|||
104 | }; |
|
112 | }; | |
105 |
|
113 | |||
106 | class DeclarativeStackedBarSeries : public QStackedBarSeries, public QDeclarativeParserStatus |
|
114 | class DeclarativeStackedBarSeries : public QStackedBarSeries, public QDeclarativeParserStatus | |
@@ -109,15 +117,21 class DeclarativeStackedBarSeries : public QStackedBarSeries, public QDeclarativ | |||||
109 | Q_INTERFACES(QDeclarativeParserStatus) |
|
117 | Q_INTERFACES(QDeclarativeParserStatus) | |
110 | Q_PROPERTY(QAbstractAxis *axisX READ axisX WRITE setAxisX NOTIFY axisXChanged REVISION 1) |
|
118 | Q_PROPERTY(QAbstractAxis *axisX READ axisX WRITE setAxisX NOTIFY axisXChanged REVISION 1) | |
111 | Q_PROPERTY(QAbstractAxis *axisY READ axisY WRITE setAxisY NOTIFY axisYChanged REVISION 1) |
|
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 | Q_PROPERTY(QDeclarativeListProperty<QObject> seriesChildren READ seriesChildren) |
|
122 | Q_PROPERTY(QDeclarativeListProperty<QObject> seriesChildren READ seriesChildren) | |
113 | Q_CLASSINFO("DefaultProperty", "seriesChildren") |
|
123 | Q_CLASSINFO("DefaultProperty", "seriesChildren") | |
114 |
|
124 | |||
115 | public: |
|
125 | public: | |
116 | explicit DeclarativeStackedBarSeries(QDeclarativeItem *parent = 0); |
|
126 | explicit DeclarativeStackedBarSeries(QDeclarativeItem *parent = 0); | |
117 | QAbstractAxis *axisX() { return m_axisX; } |
|
127 | QAbstractAxis *axisX() { return m_axes->axisX(); } | |
118 |
void setAxisX(QAbstractAxis *axis) { m_ax |
|
128 | void setAxisX(QAbstractAxis *axis) { m_axes->setAxisX(axis); } | |
119 | QAbstractAxis *axisY() { return m_axisY; } |
|
129 | QAbstractAxis *axisY() { return m_axes->axisY(); } | |
120 |
void setAxisY(QAbstractAxis *axis) { m_ax |
|
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 | QDeclarativeListProperty<QObject> seriesChildren(); |
|
135 | QDeclarativeListProperty<QObject> seriesChildren(); | |
122 |
|
136 | |||
123 | public: |
|
137 | public: | |
@@ -134,13 +148,14 public: // from QDeclarativeParserStatus | |||||
134 | Q_SIGNALS: |
|
148 | Q_SIGNALS: | |
135 | Q_REVISION(1) void axisXChanged(QAbstractAxis *axis); |
|
149 | Q_REVISION(1) void axisXChanged(QAbstractAxis *axis); | |
136 | Q_REVISION(1) void axisYChanged(QAbstractAxis *axis); |
|
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 | public Q_SLOTS: |
|
154 | public Q_SLOTS: | |
139 | static void appendSeriesChildren(QDeclarativeListProperty<QObject> *list, QObject *element); |
|
155 | static void appendSeriesChildren(QDeclarativeListProperty<QObject> *list, QObject *element); | |
140 |
|
156 | |||
141 | private: |
|
157 | public: | |
142 |
|
|
158 | DeclarativeAxes *m_axes; | |
143 | QAbstractAxis *m_axisY; |
|
|||
144 | }; |
|
159 | }; | |
145 |
|
160 | |||
146 | class DeclarativePercentBarSeries : public QPercentBarSeries, public QDeclarativeParserStatus |
|
161 | class DeclarativePercentBarSeries : public QPercentBarSeries, public QDeclarativeParserStatus | |
@@ -149,15 +164,21 class DeclarativePercentBarSeries : public QPercentBarSeries, public QDeclarativ | |||||
149 | Q_INTERFACES(QDeclarativeParserStatus) |
|
164 | Q_INTERFACES(QDeclarativeParserStatus) | |
150 | Q_PROPERTY(QAbstractAxis *axisX READ axisX WRITE setAxisX NOTIFY axisXChanged REVISION 1) |
|
165 | Q_PROPERTY(QAbstractAxis *axisX READ axisX WRITE setAxisX NOTIFY axisXChanged REVISION 1) | |
151 | Q_PROPERTY(QAbstractAxis *axisY READ axisY WRITE setAxisY NOTIFY axisYChanged REVISION 1) |
|
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 | Q_PROPERTY(QDeclarativeListProperty<QObject> seriesChildren READ seriesChildren) |
|
169 | Q_PROPERTY(QDeclarativeListProperty<QObject> seriesChildren READ seriesChildren) | |
153 | Q_CLASSINFO("DefaultProperty", "seriesChildren") |
|
170 | Q_CLASSINFO("DefaultProperty", "seriesChildren") | |
154 |
|
171 | |||
155 | public: |
|
172 | public: | |
156 | explicit DeclarativePercentBarSeries(QDeclarativeItem *parent = 0); |
|
173 | explicit DeclarativePercentBarSeries(QDeclarativeItem *parent = 0); | |
157 | QAbstractAxis *axisX() { return m_axisX; } |
|
174 | QAbstractAxis *axisX() { return m_axes->axisX(); } | |
158 |
void setAxisX(QAbstractAxis *axis) { m_ax |
|
175 | void setAxisX(QAbstractAxis *axis) { m_axes->setAxisX(axis); } | |
159 | QAbstractAxis *axisY() { return m_axisY; } |
|
176 | QAbstractAxis *axisY() { return m_axes->axisY(); } | |
160 |
void setAxisY(QAbstractAxis *axis) { m_ax |
|
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 | QDeclarativeListProperty<QObject> seriesChildren(); |
|
182 | QDeclarativeListProperty<QObject> seriesChildren(); | |
162 |
|
183 | |||
163 | public: |
|
184 | public: | |
@@ -174,13 +195,14 public: // from QDeclarativeParserStatus | |||||
174 | Q_SIGNALS: |
|
195 | Q_SIGNALS: | |
175 | Q_REVISION(1) void axisXChanged(QAbstractAxis *axis); |
|
196 | Q_REVISION(1) void axisXChanged(QAbstractAxis *axis); | |
176 | Q_REVISION(1) void axisYChanged(QAbstractAxis *axis); |
|
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 | public Q_SLOTS: |
|
201 | public Q_SLOTS: | |
179 | static void appendSeriesChildren(QDeclarativeListProperty<QObject> *list, QObject *element); |
|
202 | static void appendSeriesChildren(QDeclarativeListProperty<QObject> *list, QObject *element); | |
180 |
|
203 | |||
181 | private: |
|
204 | public: | |
182 |
|
|
205 | DeclarativeAxes *m_axes; | |
183 | QAbstractAxis *m_axisY; |
|
|||
184 | }; |
|
206 | }; | |
185 |
|
207 | |||
186 | class DeclarativeHorizontalBarSeries : public QHorizontalBarSeries, public QDeclarativeParserStatus |
|
208 | class DeclarativeHorizontalBarSeries : public QHorizontalBarSeries, public QDeclarativeParserStatus | |
@@ -189,15 +211,21 class DeclarativeHorizontalBarSeries : public QHorizontalBarSeries, public QDecl | |||||
189 | Q_INTERFACES(QDeclarativeParserStatus) |
|
211 | Q_INTERFACES(QDeclarativeParserStatus) | |
190 | Q_PROPERTY(QAbstractAxis *axisX READ axisX WRITE setAxisX NOTIFY axisXChanged REVISION 1) |
|
212 | Q_PROPERTY(QAbstractAxis *axisX READ axisX WRITE setAxisX NOTIFY axisXChanged REVISION 1) | |
191 | Q_PROPERTY(QAbstractAxis *axisY READ axisY WRITE setAxisY NOTIFY axisYChanged REVISION 1) |
|
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 | Q_PROPERTY(QDeclarativeListProperty<QObject> seriesChildren READ seriesChildren) |
|
216 | Q_PROPERTY(QDeclarativeListProperty<QObject> seriesChildren READ seriesChildren) | |
193 | Q_CLASSINFO("DefaultProperty", "seriesChildren") |
|
217 | Q_CLASSINFO("DefaultProperty", "seriesChildren") | |
194 |
|
218 | |||
195 | public: |
|
219 | public: | |
196 | explicit DeclarativeHorizontalBarSeries(QDeclarativeItem *parent = 0); |
|
220 | explicit DeclarativeHorizontalBarSeries(QDeclarativeItem *parent = 0); | |
197 | QAbstractAxis *axisX() { return m_axisX; } |
|
221 | QAbstractAxis *axisX() { return m_axes->axisX(); } | |
198 |
void setAxisX(QAbstractAxis *axis) { m_ax |
|
222 | void setAxisX(QAbstractAxis *axis) { m_axes->setAxisX(axis); } | |
199 | QAbstractAxis *axisY() { return m_axisY; } |
|
223 | QAbstractAxis *axisY() { return m_axes->axisY(); } | |
200 |
void setAxisY(QAbstractAxis *axis) { m_ax |
|
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 | QDeclarativeListProperty<QObject> seriesChildren(); |
|
229 | QDeclarativeListProperty<QObject> seriesChildren(); | |
202 |
|
230 | |||
203 | public: |
|
231 | public: | |
@@ -214,13 +242,14 public: // from QDeclarativeParserStatus | |||||
214 | Q_SIGNALS: |
|
242 | Q_SIGNALS: | |
215 | Q_REVISION(1) void axisXChanged(QAbstractAxis *axis); |
|
243 | Q_REVISION(1) void axisXChanged(QAbstractAxis *axis); | |
216 | Q_REVISION(1) void axisYChanged(QAbstractAxis *axis); |
|
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 | public Q_SLOTS: |
|
248 | public Q_SLOTS: | |
219 | static void appendSeriesChildren(QDeclarativeListProperty<QObject> *list, QObject *element); |
|
249 | static void appendSeriesChildren(QDeclarativeListProperty<QObject> *list, QObject *element); | |
220 |
|
250 | |||
221 | private: |
|
251 | public: | |
222 |
|
|
252 | DeclarativeAxes *m_axes; | |
223 | QAbstractAxis *m_axisY; |
|
|||
224 | }; |
|
253 | }; | |
225 |
|
254 | |||
226 | class DeclarativeHorizontalStackedBarSeries : public QHorizontalStackedBarSeries, public QDeclarativeParserStatus |
|
255 | class DeclarativeHorizontalStackedBarSeries : public QHorizontalStackedBarSeries, public QDeclarativeParserStatus | |
@@ -229,15 +258,21 class DeclarativeHorizontalStackedBarSeries : public QHorizontalStackedBarSeries | |||||
229 | Q_INTERFACES(QDeclarativeParserStatus) |
|
258 | Q_INTERFACES(QDeclarativeParserStatus) | |
230 | Q_PROPERTY(QAbstractAxis *axisX READ axisX WRITE setAxisX NOTIFY axisXChanged REVISION 1) |
|
259 | Q_PROPERTY(QAbstractAxis *axisX READ axisX WRITE setAxisX NOTIFY axisXChanged REVISION 1) | |
231 | Q_PROPERTY(QAbstractAxis *axisY READ axisY WRITE setAxisY NOTIFY axisYChanged REVISION 1) |
|
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 | Q_PROPERTY(QDeclarativeListProperty<QObject> seriesChildren READ seriesChildren) |
|
263 | Q_PROPERTY(QDeclarativeListProperty<QObject> seriesChildren READ seriesChildren) | |
233 | Q_CLASSINFO("DefaultProperty", "seriesChildren") |
|
264 | Q_CLASSINFO("DefaultProperty", "seriesChildren") | |
234 |
|
265 | |||
235 | public: |
|
266 | public: | |
236 | explicit DeclarativeHorizontalStackedBarSeries(QDeclarativeItem *parent = 0); |
|
267 | explicit DeclarativeHorizontalStackedBarSeries(QDeclarativeItem *parent = 0); | |
237 | QAbstractAxis *axisX() { return m_axisX; } |
|
268 | QAbstractAxis *axisX() { return m_axes->axisX(); } | |
238 |
void setAxisX(QAbstractAxis *axis) { m_ax |
|
269 | void setAxisX(QAbstractAxis *axis) { m_axes->setAxisX(axis); } | |
239 | QAbstractAxis *axisY() { return m_axisY; } |
|
270 | QAbstractAxis *axisY() { return m_axes->axisY(); } | |
240 |
void setAxisY(QAbstractAxis *axis) { m_ax |
|
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 | QDeclarativeListProperty<QObject> seriesChildren(); |
|
276 | QDeclarativeListProperty<QObject> seriesChildren(); | |
242 |
|
277 | |||
243 | public: |
|
278 | public: | |
@@ -254,13 +289,14 public: // from QDeclarativeParserStatus | |||||
254 | Q_SIGNALS: |
|
289 | Q_SIGNALS: | |
255 | Q_REVISION(1) void axisXChanged(QAbstractAxis *axis); |
|
290 | Q_REVISION(1) void axisXChanged(QAbstractAxis *axis); | |
256 | Q_REVISION(1) void axisYChanged(QAbstractAxis *axis); |
|
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 | public Q_SLOTS: |
|
295 | public Q_SLOTS: | |
259 | static void appendSeriesChildren(QDeclarativeListProperty<QObject> *list, QObject *element); |
|
296 | static void appendSeriesChildren(QDeclarativeListProperty<QObject> *list, QObject *element); | |
260 |
|
297 | |||
261 | private: |
|
298 | public: | |
262 |
|
|
299 | DeclarativeAxes *m_axes; | |
263 | QAbstractAxis *m_axisY; |
|
|||
264 | }; |
|
300 | }; | |
265 |
|
301 | |||
266 | class DeclarativeHorizontalPercentBarSeries : public QHorizontalPercentBarSeries, public QDeclarativeParserStatus |
|
302 | class DeclarativeHorizontalPercentBarSeries : public QHorizontalPercentBarSeries, public QDeclarativeParserStatus | |
@@ -269,15 +305,21 class DeclarativeHorizontalPercentBarSeries : public QHorizontalPercentBarSeries | |||||
269 | Q_INTERFACES(QDeclarativeParserStatus) |
|
305 | Q_INTERFACES(QDeclarativeParserStatus) | |
270 | Q_PROPERTY(QAbstractAxis *axisX READ axisX WRITE setAxisX NOTIFY axisXChanged REVISION 1) |
|
306 | Q_PROPERTY(QAbstractAxis *axisX READ axisX WRITE setAxisX NOTIFY axisXChanged REVISION 1) | |
271 | Q_PROPERTY(QAbstractAxis *axisY READ axisY WRITE setAxisY NOTIFY axisYChanged REVISION 1) |
|
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 | Q_PROPERTY(QDeclarativeListProperty<QObject> seriesChildren READ seriesChildren) |
|
310 | Q_PROPERTY(QDeclarativeListProperty<QObject> seriesChildren READ seriesChildren) | |
273 | Q_CLASSINFO("DefaultProperty", "seriesChildren") |
|
311 | Q_CLASSINFO("DefaultProperty", "seriesChildren") | |
274 |
|
312 | |||
275 | public: |
|
313 | public: | |
276 | explicit DeclarativeHorizontalPercentBarSeries(QDeclarativeItem *parent = 0); |
|
314 | explicit DeclarativeHorizontalPercentBarSeries(QDeclarativeItem *parent = 0); | |
277 | QAbstractAxis *axisX() { return m_axisX; } |
|
315 | QAbstractAxis *axisX() { return m_axes->axisX(); } | |
278 |
void setAxisX(QAbstractAxis *axis) { m_ax |
|
316 | void setAxisX(QAbstractAxis *axis) { m_axes->setAxisX(axis); } | |
279 | QAbstractAxis *axisY() { return m_axisY; } |
|
317 | QAbstractAxis *axisY() { return m_axes->axisY(); } | |
280 |
void setAxisY(QAbstractAxis *axis) { m_ax |
|
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 | QDeclarativeListProperty<QObject> seriesChildren(); |
|
323 | QDeclarativeListProperty<QObject> seriesChildren(); | |
282 |
|
324 | |||
283 | public: |
|
325 | public: | |
@@ -294,13 +336,14 public: // from QDeclarativeParserStatus | |||||
294 | Q_SIGNALS: |
|
336 | Q_SIGNALS: | |
295 | Q_REVISION(1) void axisXChanged(QAbstractAxis *axis); |
|
337 | Q_REVISION(1) void axisXChanged(QAbstractAxis *axis); | |
296 | Q_REVISION(1) void axisYChanged(QAbstractAxis *axis); |
|
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 | public Q_SLOTS: |
|
342 | public Q_SLOTS: | |
299 | static void appendSeriesChildren(QDeclarativeListProperty<QObject> *list, QObject *element); |
|
343 | static void appendSeriesChildren(QDeclarativeListProperty<QObject> *list, QObject *element); | |
300 |
|
344 | |||
301 | private: |
|
345 | public: | |
302 |
|
|
346 | DeclarativeAxes *m_axes; | |
303 | QAbstractAxis *m_axisY; |
|
|||
304 | }; |
|
347 | }; | |
305 |
|
348 | |||
306 | QTCOMMERCIALCHART_END_NAMESPACE |
|
349 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -33,6 +33,7 | |||||
33 | #include "qabstractseries_p.h" |
|
33 | #include "qabstractseries_p.h" | |
34 | #include "declarativemargins.h" |
|
34 | #include "declarativemargins.h" | |
35 | #include "chartdataset_p.h" |
|
35 | #include "chartdataset_p.h" | |
|
36 | #include "declarativeaxes.h" | |||
36 | #include "qchart_p.h" |
|
37 | #include "qchart_p.h" | |
37 |
|
38 | |||
38 | #ifndef QT_ON_ARM |
|
39 | #ifndef QT_ON_ARM | |
@@ -286,94 +287,71 void DeclarativeChart::componentComplete() | |||||
286 | QAbstractSeries *series = qobject_cast<QAbstractSeries *>(child); |
|
287 | QAbstractSeries *series = qobject_cast<QAbstractSeries *>(child); | |
287 | m_chart->addSeries(series); |
|
288 | m_chart->addSeries(series); | |
288 |
|
289 | |||
289 | // Set optional user defined axes for the series and connect axis related signals |
|
290 | // Connect to axis changed signals (unless this is a pie series) | |
290 |
if (qobject_cast<Declarative |
|
291 | if (!qobject_cast<DeclarativePieSeries *>(series)) { | |
291 | DeclarativeLineSeries *s = qobject_cast<DeclarativeLineSeries *>(child); |
|
292 | connect(series, SIGNAL(axisXChanged(QAbstractAxis*)), this, SLOT(handleAxisXSet(QAbstractAxis*))); | |
292 | connect(s, SIGNAL(axisXChanged(QAbstractAxis*)), this, SLOT(handleAxisXSet(QAbstractAxis*))); |
|
293 | connect(series, SIGNAL(axisXTopChanged(QAbstractAxis*)), this, SLOT(handleAxisXSet(QAbstractAxis*))); | |
293 | connect(s, SIGNAL(axisYChanged(QAbstractAxis*)), this, SLOT(handleAxisYSet(QAbstractAxis*))); |
|
294 | connect(series, SIGNAL(axisYChanged(QAbstractAxis*)), this, SLOT(handleAxisYSet(QAbstractAxis*))); | |
294 | setAxisX(s->axisX(), s); |
|
295 | connect(series, SIGNAL(axisYRightChanged(QAbstractAxis*)), this, SLOT(handleAxisYRightSet(QAbstractAxis*))); | |
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 | } |
|
296 | } | |
|
297 | ||||
|
298 | initializeAxes(series); | |||
351 | } |
|
299 | } | |
352 | } |
|
300 | } | |
353 |
|
301 | |||
354 | // Create the missing axes for the series that cannot be painted without axes |
|
|||
355 | foreach (QAbstractSeries *chartSeries, m_chart->series()) |
|
|||
356 | createDefaultAxes(chartSeries); |
|
|||
357 |
|
||||
358 | QDeclarativeItem::componentComplete(); |
|
302 | QDeclarativeItem::componentComplete(); | |
359 | } |
|
303 | } | |
360 |
|
304 | |||
361 | void DeclarativeChart::handleAxisXSet(QAbstractAxis *axis) |
|
305 | void DeclarativeChart::handleAxisXSet(QAbstractAxis *axis) | |
362 | { |
|
306 | { | |
363 | // qDebug() << "DeclarativeChart::handleAxisXSet" << sender() << axis; |
|
307 | QAbstractSeries *s = qobject_cast<QAbstractSeries *>(sender()); | |
364 | if (axis && qobject_cast<QAbstractSeries *>(sender())) |
|
308 | if (axis && s) { | |
365 | m_chart->setAxisX(axis, qobject_cast<QAbstractSeries *>(sender())); |
|
309 | if (!m_chart->axes(Qt::Horizontal).contains(axis)) | |
366 | else |
|
310 | m_chart->addAxis(axis, Qt::AlignBottom); | |
|
311 | if (!s->attachedAxes().contains(axis)) | |||
|
312 | s->attachAxis(axis); | |||
|
313 | } else { | |||
367 | qWarning() << "Trying to set axisX to null."; |
|
314 | qWarning() << "Trying to set axisX to null."; | |
|
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 | } | |||
368 | } |
|
329 | } | |
369 |
|
330 | |||
370 | void DeclarativeChart::handleAxisYSet(QAbstractAxis *axis) |
|
331 | void DeclarativeChart::handleAxisYSet(QAbstractAxis *axis) | |
371 | { |
|
332 | { | |
372 | // qDebug() << "DeclarativeChart::handleAxisYSet" << sender() << axis; |
|
333 | QAbstractSeries *s = qobject_cast<QAbstractSeries *>(sender()); | |
373 | if (axis && qobject_cast<QAbstractSeries *>(sender())) |
|
334 | if (axis && s) { | |
374 | m_chart->setAxisY(axis, qobject_cast<QAbstractSeries *>(sender())); |
|
335 | if (!m_chart->axes(Qt::Vertical).contains(axis)) | |
375 | else |
|
336 | m_chart->addAxis(axis, Qt::AlignLeft); | |
|
337 | if (!s->attachedAxes().contains(axis)) | |||
|
338 | s->attachAxis(axis); | |||
|
339 | } else { | |||
376 | qWarning() << "Trying to set axisY to null."; |
|
340 | qWarning() << "Trying to set axisY to null."; | |
|
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 | } | |||
377 | } |
|
355 | } | |
378 |
|
356 | |||
379 | void DeclarativeChart::geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) |
|
357 | void DeclarativeChart::geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) | |
@@ -435,12 +413,18 QString DeclarativeChart::title() | |||||
435 |
|
413 | |||
436 | QAbstractAxis *DeclarativeChart::axisX(QAbstractSeries *series) |
|
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 | QAbstractAxis *DeclarativeChart::axisY(QAbstractSeries *series) |
|
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 | QLegend *DeclarativeChart::legend() |
|
430 | QLegend *DeclarativeChart::legend() | |
@@ -557,6 +541,40 void DeclarativeChart::scrollDown(qreal pixels) | |||||
557 | m_chart->scroll(0, -pixels); |
|
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 | QAbstractSeries *DeclarativeChart::series(int index) |
|
578 | QAbstractSeries *DeclarativeChart::series(int index) | |
561 | { |
|
579 | { | |
562 | if (index < m_chart->series().count()) { |
|
580 | if (index < m_chart->series().count()) { | |
@@ -625,13 +643,24 QAbstractSeries *DeclarativeChart::createSeries(DeclarativeChart::SeriesType typ | |||||
625 | } |
|
643 | } | |
626 |
|
644 | |||
627 | if (series) { |
|
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 | series->setName(name); |
|
654 | series->setName(name); | |
629 | m_chart->addSeries(series); |
|
655 | m_chart->addSeries(series); | |
630 | // Set possible user defined axes |
|
656 | ||
631 |
|
|
657 | if (axisX) | |
632 |
setAxis |
|
658 | setAxisX(axisX, series); | |
633 | // Then create the missing axes |
|
659 | if (axisY) | |
634 |
|
|
660 | setAxisY(axisY, series); | |
|
661 | ||||
|
662 | if (series->attachedAxes().count() < 2) | |||
|
663 | initializeAxes(series); | |||
635 | } |
|
664 | } | |
636 |
|
665 | |||
637 | return series; |
|
666 | return series; | |
@@ -662,67 +691,77 void DeclarativeChart::createDefaultAxes() | |||||
662 | qWarning() << "ChartView.createDefaultAxes() is deprecated. Axes are created automatically."; |
|
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()) { |
|
696 | if (!series) { | |
668 | // If there is already an x axis of the correct type, re-use it |
|
697 | qWarning() << "No axis type defined for null series"; | |
669 | if (!m_chart->axisX(series) && s != series && m_chart->axisX(s) |
|
698 | return 0; | |
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); |
|
|||
677 | } |
|
699 | } | |
678 |
|
700 | |||
679 | // If no x axis of correct type was found, create a new x axis based of default axis type |
|
701 | foreach (QAbstractAxis *existingAxis, m_chart->axes(orientation)) { | |
680 | if (!m_chart->axisX(series)) { |
|
702 | if (existingAxis->type() == series->d_ptr->defaultAxisType(orientation)) | |
681 | switch (series->d_ptr->defaultAxisType(Qt::Horizontal)) { |
|
703 | return existingAxis; | |
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 | } |
|
|||
700 | } |
|
704 | } | |
701 |
|
705 | |||
702 | // If no y axis of correct type was found, create a new y axis based of default axis type |
|
706 | switch (series->d_ptr->defaultAxisType(orientation)) { | |
703 | if (!m_chart->axisY(series)) { |
|
707 | case QAbstractAxis::AxisTypeValue: | |
704 | switch (series->d_ptr->defaultAxisType(Qt::Vertical)) { |
|
708 | return new QValueAxis(this); | |
705 |
|
|
709 | case QAbstractAxis::AxisTypeBarCategory: | |
706 | m_chart->setAxisY(new QValueAxis(this), series); |
|
710 | return new QBarCategoryAxis(this); | |
707 | break; |
|
711 | case QAbstractAxis::AxisTypeCategory: | |
708 | case QAbstractAxis::AxisTypeBarCategory: |
|
712 | return new QCategoryAxis(this); | |
709 | m_chart->setAxisY(new QBarCategoryAxis(this), series); |
|
|||
710 | break; |
|
|||
711 | case QAbstractAxis::AxisTypeCategory: |
|
|||
712 | m_chart->setAxisY(new QCategoryAxis(this), series); |
|
|||
713 | break; |
|
|||
714 | #ifndef QT_ON_ARM |
|
713 | #ifndef QT_ON_ARM | |
715 |
|
|
714 | case QAbstractAxis::AxisTypeDateTime: | |
716 |
|
|
715 | return new QDateTimeAxis(this); | |
717 | break; |
|
|||
718 | #endif |
|
716 | #endif | |
719 |
|
|
717 | default: | |
720 |
|
|
718 | // assume AxisTypeNoAxis | |
721 |
|
|
719 | return 0; | |
722 | } |
|
|||
723 | } |
|
720 | } | |
|
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 | #include "moc_declarativechart.cpp" |
|
767 | #include "moc_declarativechart.cpp" |
@@ -29,7 +29,8 | |||||
29 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
29 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
30 |
|
30 | |||
31 | class DeclarativeMargins; |
|
31 | class DeclarativeMargins; | |
32 |
class |
|
32 | class Domain; | |
|
33 | class DeclarativeAxes; | |||
33 |
|
34 | |||
34 | class DeclarativeChart : public QDeclarativeItem |
|
35 | class DeclarativeChart : public QDeclarativeItem | |
35 | { |
|
36 | { | |
@@ -50,6 +51,7 class DeclarativeChart : public QDeclarativeItem | |||||
50 | Q_PROPERTY(DeclarativeMargins *minimumMargins READ minimumMargins NOTIFY minimumMarginsChanged REVISION 1) |
|
51 | Q_PROPERTY(DeclarativeMargins *minimumMargins READ minimumMargins NOTIFY minimumMarginsChanged REVISION 1) | |
51 | Q_PROPERTY(DeclarativeMargins *margins READ margins NOTIFY marginsChanged REVISION 2) |
|
52 | Q_PROPERTY(DeclarativeMargins *margins READ margins NOTIFY marginsChanged REVISION 2) | |
52 | Q_PROPERTY(QRectF plotArea READ plotArea NOTIFY plotAreaChanged REVISION 1) |
|
53 | Q_PROPERTY(QRectF plotArea READ plotArea NOTIFY plotAreaChanged REVISION 1) | |
|
54 | Q_PROPERTY(QDeclarativeListProperty<QAbstractAxis> axes READ axes REVISION 2) | |||
53 | Q_ENUMS(Animation) |
|
55 | Q_ENUMS(Animation) | |
54 | Q_ENUMS(Theme) |
|
56 | Q_ENUMS(Theme) | |
55 | Q_ENUMS(SeriesType) |
|
57 | Q_ENUMS(SeriesType) | |
@@ -117,13 +119,21 public: | |||||
117 | qreal bottomMargin(); |
|
119 | qreal bottomMargin(); | |
118 | qreal leftMargin(); |
|
120 | qreal leftMargin(); | |
119 | qreal rightMargin(); |
|
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 | //TODO this is deprecated: |
|
125 | //TODO this is deprecated: | |
122 | DeclarativeMargins *minimumMargins() { return m_margins; } |
|
126 | DeclarativeMargins *minimumMargins() { return m_margins; } | |
123 |
|
127 | |||
124 | Q_REVISION(2) DeclarativeMargins *margins() { return m_margins; } |
|
128 | Q_REVISION(2) DeclarativeMargins *margins() { return m_margins; } | |
125 | QRectF plotArea() { return m_chart->plotArea(); } |
|
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 | public: |
|
137 | public: | |
128 | Q_INVOKABLE QAbstractSeries *series(int index); |
|
138 | Q_INVOKABLE QAbstractSeries *series(int index); | |
129 | Q_INVOKABLE QAbstractSeries *series(QString seriesName); |
|
139 | Q_INVOKABLE QAbstractSeries *series(QString seriesName); | |
@@ -153,10 +163,12 Q_SIGNALS: | |||||
153 | void seriesAdded(QAbstractSeries *series); |
|
163 | void seriesAdded(QAbstractSeries *series); | |
154 | void seriesRemoved(QAbstractSeries *series); |
|
164 | void seriesRemoved(QAbstractSeries *series); | |
155 |
|
165 | |||
156 |
p |
|
166 | private Q_SLOTS: | |
157 | void changeMinimumMargins(int top, int bottom, int left, int right); |
|
167 | void changeMinimumMargins(int top, int bottom, int left, int right); | |
158 | void handleAxisXSet(QAbstractAxis *axis); |
|
168 | void handleAxisXSet(QAbstractAxis *axis); | |
159 | void handleAxisYSet(QAbstractAxis *axis); |
|
169 | void handleAxisYSet(QAbstractAxis *axis); | |
|
170 | void handleAxisXTopSet(QAbstractAxis *axis); | |||
|
171 | void handleAxisYRightSet(QAbstractAxis *axis); | |||
160 | void handleSeriesAdded(QAbstractSeries *series); |
|
172 | void handleSeriesAdded(QAbstractSeries *series); | |
161 |
|
173 | |||
162 | private: |
|
174 | private: |
@@ -24,9 +24,12 QTCOMMERCIALCHART_BEGIN_NAMESPACE | |||||
24 |
|
24 | |||
25 | DeclarativeLineSeries::DeclarativeLineSeries(QObject *parent) : |
|
25 | DeclarativeLineSeries::DeclarativeLineSeries(QObject *parent) : | |
26 | QLineSeries(parent), |
|
26 | QLineSeries(parent), | |
27 | m_axisX(0), |
|
27 | m_axes(new DeclarativeAxes(this)) | |
28 | m_axisY(0) |
|
|||
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 | connect(this, SIGNAL(pointAdded(int)), this, SLOT(handleCountChanged(int))); |
|
33 | connect(this, SIGNAL(pointAdded(int)), this, SLOT(handleCountChanged(int))); | |
31 | connect(this, SIGNAL(pointRemoved(int)), this, SLOT(handleCountChanged(int))); |
|
34 | connect(this, SIGNAL(pointRemoved(int)), this, SLOT(handleCountChanged(int))); | |
32 | } |
|
35 | } |
@@ -23,6 +23,7 | |||||
23 |
|
23 | |||
24 | #include "qlineseries.h" |
|
24 | #include "qlineseries.h" | |
25 | #include "declarativexyseries.h" |
|
25 | #include "declarativexyseries.h" | |
|
26 | #include "declarativeaxes.h" | |||
26 | #include <QtDeclarative/QDeclarativeListProperty> |
|
27 | #include <QtDeclarative/QDeclarativeListProperty> | |
27 | #include <QtDeclarative/QDeclarativeParserStatus> |
|
28 | #include <QtDeclarative/QDeclarativeParserStatus> | |
28 |
|
29 | |||
@@ -35,6 +36,8 class DeclarativeLineSeries : public QLineSeries, public DeclarativeXySeries, pu | |||||
35 | Q_PROPERTY(int count READ count NOTIFY countChanged) |
|
36 | Q_PROPERTY(int count READ count NOTIFY countChanged) | |
36 | Q_PROPERTY(QAbstractAxis *axisX READ axisX WRITE setAxisX NOTIFY axisXChanged REVISION 1) |
|
37 | Q_PROPERTY(QAbstractAxis *axisX READ axisX WRITE setAxisX NOTIFY axisXChanged REVISION 1) | |
37 | Q_PROPERTY(QAbstractAxis *axisY READ axisY WRITE setAxisY NOTIFY axisYChanged REVISION 1) |
|
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 | Q_PROPERTY(qreal width READ width WRITE setWidth NOTIFY widthChanged REVISION 1) |
|
41 | Q_PROPERTY(qreal width READ width WRITE setWidth NOTIFY widthChanged REVISION 1) | |
39 | Q_PROPERTY(Qt::PenStyle style READ style WRITE setStyle NOTIFY styleChanged REVISION 1) |
|
42 | Q_PROPERTY(Qt::PenStyle style READ style WRITE setStyle NOTIFY styleChanged REVISION 1) | |
40 | Q_PROPERTY(Qt::PenCapStyle capStyle READ capStyle WRITE setCapStyle NOTIFY capStyleChanged REVISION 1) |
|
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 | public: |
|
47 | public: | |
45 | explicit DeclarativeLineSeries(QObject *parent = 0); |
|
48 | explicit DeclarativeLineSeries(QObject *parent = 0); | |
46 | QXYSeries *xySeries() { return this; } |
|
49 | QXYSeries *xySeries() { return this; } | |
47 | QAbstractAxis *axisX() { return m_axisX; } |
|
50 | QAbstractAxis *axisX() { return m_axes->axisX(); } | |
48 |
void setAxisX(QAbstractAxis *axis) { m_ax |
|
51 | void setAxisX(QAbstractAxis *axis) { m_axes->setAxisX(axis); } | |
49 | QAbstractAxis *axisY() { return m_axisY; } |
|
52 | QAbstractAxis *axisY() { return m_axes->axisY(); } | |
50 |
void setAxisY(QAbstractAxis *axis) { m_ax |
|
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 | qreal width() const; |
|
58 | qreal width() const; | |
52 | void setWidth(qreal width); |
|
59 | void setWidth(qreal width); | |
53 | Qt::PenStyle style() const; |
|
60 | Qt::PenStyle style() const; | |
@@ -72,6 +79,8 Q_SIGNALS: | |||||
72 | void countChanged(int count); |
|
79 | void countChanged(int count); | |
73 | Q_REVISION(1) void axisXChanged(QAbstractAxis *axis); |
|
80 | Q_REVISION(1) void axisXChanged(QAbstractAxis *axis); | |
74 | Q_REVISION(1) void axisYChanged(QAbstractAxis *axis); |
|
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 | Q_REVISION(1) void widthChanged(qreal width); |
|
84 | Q_REVISION(1) void widthChanged(qreal width); | |
76 | Q_REVISION(1) void styleChanged(Qt::PenStyle style); |
|
85 | Q_REVISION(1) void styleChanged(Qt::PenStyle style); | |
77 | Q_REVISION(1) void capStyleChanged(Qt::PenCapStyle capStyle); |
|
86 | Q_REVISION(1) void capStyleChanged(Qt::PenCapStyle capStyle); | |
@@ -80,9 +89,8 public Q_SLOTS: | |||||
80 | static void appendDeclarativeChildren(QDeclarativeListProperty<QObject> *list, QObject *element); |
|
89 | static void appendDeclarativeChildren(QDeclarativeListProperty<QObject> *list, QObject *element); | |
81 | void handleCountChanged(int index); |
|
90 | void handleCountChanged(int index); | |
82 |
|
91 | |||
83 | private: |
|
92 | public: | |
84 |
|
|
93 | DeclarativeAxes *m_axes; | |
85 | QAbstractAxis *m_axisY; |
|
|||
86 | }; |
|
94 | }; | |
87 |
|
95 | |||
88 | QTCOMMERCIALCHART_END_NAMESPACE |
|
96 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -24,9 +24,12 QTCOMMERCIALCHART_BEGIN_NAMESPACE | |||||
24 |
|
24 | |||
25 | DeclarativeScatterSeries::DeclarativeScatterSeries(QObject *parent) : |
|
25 | DeclarativeScatterSeries::DeclarativeScatterSeries(QObject *parent) : | |
26 | QScatterSeries(parent), |
|
26 | QScatterSeries(parent), | |
27 | m_axisX(0), |
|
27 | m_axes(new DeclarativeAxes(this)) | |
28 | m_axisY(0) |
|
|||
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 | connect(this, SIGNAL(pointAdded(int)), this, SLOT(handleCountChanged(int))); |
|
33 | connect(this, SIGNAL(pointAdded(int)), this, SLOT(handleCountChanged(int))); | |
31 | connect(this, SIGNAL(pointRemoved(int)), this, SLOT(handleCountChanged(int))); |
|
34 | connect(this, SIGNAL(pointRemoved(int)), this, SLOT(handleCountChanged(int))); | |
32 | } |
|
35 | } |
@@ -23,6 +23,7 | |||||
23 |
|
23 | |||
24 | #include "qscatterseries.h" |
|
24 | #include "qscatterseries.h" | |
25 | #include "declarativexyseries.h" |
|
25 | #include "declarativexyseries.h" | |
|
26 | #include "declarativeaxes.h" | |||
26 | #include <QtDeclarative/QDeclarativeListProperty> |
|
27 | #include <QtDeclarative/QDeclarativeListProperty> | |
27 | #include <QtDeclarative/QDeclarativeParserStatus> |
|
28 | #include <QtDeclarative/QDeclarativeParserStatus> | |
28 |
|
29 | |||
@@ -35,6 +36,8 class DeclarativeScatterSeries : public QScatterSeries, public DeclarativeXySeri | |||||
35 | Q_PROPERTY(int count READ count NOTIFY countChanged) |
|
36 | Q_PROPERTY(int count READ count NOTIFY countChanged) | |
36 | Q_PROPERTY(QAbstractAxis *axisX READ axisX WRITE setAxisX NOTIFY axisXChanged REVISION 1) |
|
37 | Q_PROPERTY(QAbstractAxis *axisX READ axisX WRITE setAxisX NOTIFY axisXChanged REVISION 1) | |
37 | Q_PROPERTY(QAbstractAxis *axisY READ axisY WRITE setAxisY NOTIFY axisYChanged REVISION 1) |
|
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 | Q_PROPERTY(qreal borderWidth READ borderWidth WRITE setBorderWidth NOTIFY borderWidthChanged REVISION 1) |
|
41 | Q_PROPERTY(qreal borderWidth READ borderWidth WRITE setBorderWidth NOTIFY borderWidthChanged REVISION 1) | |
39 | Q_PROPERTY(QDeclarativeListProperty<QObject> declarativeChildren READ declarativeChildren) |
|
42 | Q_PROPERTY(QDeclarativeListProperty<QObject> declarativeChildren READ declarativeChildren) | |
40 | Q_CLASSINFO("DefaultProperty", "declarativeChildren") |
|
43 | Q_CLASSINFO("DefaultProperty", "declarativeChildren") | |
@@ -42,10 +45,14 class DeclarativeScatterSeries : public QScatterSeries, public DeclarativeXySeri | |||||
42 | public: |
|
45 | public: | |
43 | explicit DeclarativeScatterSeries(QObject *parent = 0); |
|
46 | explicit DeclarativeScatterSeries(QObject *parent = 0); | |
44 | QXYSeries *xySeries() { return this; } |
|
47 | QXYSeries *xySeries() { return this; } | |
45 | QAbstractAxis *axisX() { return m_axisX; } |
|
48 | QAbstractAxis *axisX() { return m_axes->axisX(); } | |
46 |
void setAxisX(QAbstractAxis *axis) { m_ax |
|
49 | void setAxisX(QAbstractAxis *axis) { m_axes->setAxisX(axis); } | |
47 | QAbstractAxis *axisY() { return m_axisY; } |
|
50 | QAbstractAxis *axisY() { return m_axes->axisY(); } | |
48 |
void setAxisY(QAbstractAxis *axis) { m_ax |
|
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 | qreal borderWidth() const; |
|
56 | qreal borderWidth() const; | |
50 | void setBorderWidth(qreal borderWidth); |
|
57 | void setBorderWidth(qreal borderWidth); | |
51 | QDeclarativeListProperty<QObject> declarativeChildren(); |
|
58 | QDeclarativeListProperty<QObject> declarativeChildren(); | |
@@ -67,14 +74,15 Q_SIGNALS: | |||||
67 | Q_REVISION(1) void axisXChanged(QAbstractAxis *axis); |
|
74 | Q_REVISION(1) void axisXChanged(QAbstractAxis *axis); | |
68 | Q_REVISION(1) void axisYChanged(QAbstractAxis *axis); |
|
75 | Q_REVISION(1) void axisYChanged(QAbstractAxis *axis); | |
69 | Q_REVISION(1) void borderWidthChanged(qreal width); |
|
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 | public Q_SLOTS: |
|
80 | public Q_SLOTS: | |
72 | static void appendDeclarativeChildren(QDeclarativeListProperty<QObject> *list, QObject *element); |
|
81 | static void appendDeclarativeChildren(QDeclarativeListProperty<QObject> *list, QObject *element); | |
73 | void handleCountChanged(int index); |
|
82 | void handleCountChanged(int index); | |
74 |
|
83 | |||
75 | private: |
|
84 | public: | |
76 |
|
|
85 | DeclarativeAxes *m_axes; | |
77 | QAbstractAxis *m_axisY; |
|
|||
78 | }; |
|
86 | }; | |
79 |
|
87 | |||
80 | QTCOMMERCIALCHART_END_NAMESPACE |
|
88 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -24,9 +24,12 QTCOMMERCIALCHART_BEGIN_NAMESPACE | |||||
24 |
|
24 | |||
25 | DeclarativeSplineSeries::DeclarativeSplineSeries(QObject *parent) : |
|
25 | DeclarativeSplineSeries::DeclarativeSplineSeries(QObject *parent) : | |
26 | QSplineSeries(parent), |
|
26 | QSplineSeries(parent), | |
27 | m_axisX(0), |
|
27 | m_axes(new DeclarativeAxes(this)) | |
28 | m_axisY(0) |
|
|||
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 | connect(this, SIGNAL(pointAdded(int)), this, SLOT(handleCountChanged(int))); |
|
33 | connect(this, SIGNAL(pointAdded(int)), this, SLOT(handleCountChanged(int))); | |
31 | connect(this, SIGNAL(pointRemoved(int)), this, SLOT(handleCountChanged(int))); |
|
34 | connect(this, SIGNAL(pointRemoved(int)), this, SLOT(handleCountChanged(int))); | |
32 | } |
|
35 | } |
@@ -23,6 +23,7 | |||||
23 |
|
23 | |||
24 | #include "qsplineseries.h" |
|
24 | #include "qsplineseries.h" | |
25 | #include "declarativexyseries.h" |
|
25 | #include "declarativexyseries.h" | |
|
26 | #include "declarativeaxes.h" | |||
26 | #include <QtDeclarative/QDeclarativeListProperty> |
|
27 | #include <QtDeclarative/QDeclarativeListProperty> | |
27 | #include <QtDeclarative/QDeclarativeParserStatus> |
|
28 | #include <QtDeclarative/QDeclarativeParserStatus> | |
28 |
|
29 | |||
@@ -35,6 +36,8 class DeclarativeSplineSeries : public QSplineSeries, public DeclarativeXySeries | |||||
35 | Q_PROPERTY(int count READ count NOTIFY countChanged) |
|
36 | Q_PROPERTY(int count READ count NOTIFY countChanged) | |
36 | Q_PROPERTY(QAbstractAxis *axisX READ axisX WRITE setAxisX NOTIFY axisXChanged REVISION 1) |
|
37 | Q_PROPERTY(QAbstractAxis *axisX READ axisX WRITE setAxisX NOTIFY axisXChanged REVISION 1) | |
37 | Q_PROPERTY(QAbstractAxis *axisY READ axisY WRITE setAxisY NOTIFY axisYChanged REVISION 1) |
|
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 | Q_PROPERTY(qreal width READ width WRITE setWidth NOTIFY widthChanged REVISION 1) |
|
41 | Q_PROPERTY(qreal width READ width WRITE setWidth NOTIFY widthChanged REVISION 1) | |
39 | Q_PROPERTY(Qt::PenStyle style READ style WRITE setStyle NOTIFY styleChanged REVISION 1) |
|
42 | Q_PROPERTY(Qt::PenStyle style READ style WRITE setStyle NOTIFY styleChanged REVISION 1) | |
40 | Q_PROPERTY(Qt::PenCapStyle capStyle READ capStyle WRITE setCapStyle NOTIFY capStyleChanged REVISION 1) |
|
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 | public: |
|
47 | public: | |
45 | explicit DeclarativeSplineSeries(QObject *parent = 0); |
|
48 | explicit DeclarativeSplineSeries(QObject *parent = 0); | |
46 | QXYSeries *xySeries() { return this; } |
|
49 | QXYSeries *xySeries() { return this; } | |
47 | QAbstractAxis *axisX() { return m_axisX; } |
|
50 | QAbstractAxis *axisX() { return m_axes->axisX(); } | |
48 |
void setAxisX(QAbstractAxis *axis) { m_ax |
|
51 | void setAxisX(QAbstractAxis *axis) { m_axes->setAxisX(axis); } | |
49 | QAbstractAxis *axisY() { return m_axisY; } |
|
52 | QAbstractAxis *axisY() { return m_axes->axisY(); } | |
50 |
void setAxisY(QAbstractAxis *axis) { m_ax |
|
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 | qreal width() const; |
|
58 | qreal width() const; | |
52 | void setWidth(qreal width); |
|
59 | void setWidth(qreal width); | |
53 | Qt::PenStyle style() const; |
|
60 | Qt::PenStyle style() const; | |
@@ -72,6 +79,8 Q_SIGNALS: | |||||
72 | void countChanged(int count); |
|
79 | void countChanged(int count); | |
73 | Q_REVISION(1) void axisXChanged(QAbstractAxis *axis); |
|
80 | Q_REVISION(1) void axisXChanged(QAbstractAxis *axis); | |
74 | Q_REVISION(1) void axisYChanged(QAbstractAxis *axis); |
|
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 | Q_REVISION(1) void widthChanged(qreal width); |
|
84 | Q_REVISION(1) void widthChanged(qreal width); | |
76 | Q_REVISION(1) void styleChanged(Qt::PenStyle style); |
|
85 | Q_REVISION(1) void styleChanged(Qt::PenStyle style); | |
77 | Q_REVISION(1) void capStyleChanged(Qt::PenCapStyle capStyle); |
|
86 | Q_REVISION(1) void capStyleChanged(Qt::PenCapStyle capStyle); | |
@@ -81,8 +90,7 public Q_SLOTS: | |||||
81 | void handleCountChanged(int index); |
|
90 | void handleCountChanged(int index); | |
82 |
|
91 | |||
83 | public: |
|
92 | public: | |
84 |
|
|
93 | DeclarativeAxes *m_axes; | |
85 | QAbstractAxis *m_axisY; |
|
|||
86 | }; |
|
94 | }; | |
87 |
|
95 | |||
88 | QTCOMMERCIALCHART_END_NAMESPACE |
|
96 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -31,6 +31,7 | |||||
31 | #include "declarativescatterseries.h" |
|
31 | #include "declarativescatterseries.h" | |
32 | #include "declarativebarseries.h" |
|
32 | #include "declarativebarseries.h" | |
33 | #include "declarativepieseries.h" |
|
33 | #include "declarativepieseries.h" | |
|
34 | #include "declarativeaxes.h" | |||
34 | #include "qvxymodelmapper.h" |
|
35 | #include "qvxymodelmapper.h" | |
35 | #include "qhxymodelmapper.h" |
|
36 | #include "qhxymodelmapper.h" | |
36 | #include "qhpiemodelmapper.h" |
|
37 | #include "qhpiemodelmapper.h" | |
@@ -53,6 +54,7 QTCOMMERCIALCHART_USE_NAMESPACE | |||||
53 |
|
54 | |||
54 | Q_DECLARE_METATYPE(QList<QPieSlice *>) |
|
55 | Q_DECLARE_METATYPE(QList<QPieSlice *>) | |
55 | Q_DECLARE_METATYPE(QList<QBarSet *>) |
|
56 | Q_DECLARE_METATYPE(QList<QBarSet *>) | |
|
57 | Q_DECLARE_METATYPE(QList<QAbstractAxis *>) | |||
56 |
|
58 | |||
57 | #if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)) |
|
59 | #if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)) | |
58 |
|
60 | |||
@@ -127,6 +129,7 public: | |||||
127 |
|
129 | |||
128 | qRegisterMetaType<QList<QPieSlice *> >(); |
|
130 | qRegisterMetaType<QList<QPieSlice *> >(); | |
129 | qRegisterMetaType<QList<QBarSet *> >(); |
|
131 | qRegisterMetaType<QList<QBarSet *> >(); | |
|
132 | qRegisterMetaType<QList<QAbstractAxis *> >(); | |||
130 | #if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)) |
|
133 | #if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)) | |
131 | qRegisterMetaType<DeclarativeChart::SeriesType>(); |
|
134 | qRegisterMetaType<DeclarativeChart::SeriesType>(); | |
132 | #endif |
|
135 | #endif | |
@@ -174,6 +177,8 public: | |||||
174 | QLatin1String("Trying to create uncreatable: BarsetBase.")); |
|
177 | QLatin1String("Trying to create uncreatable: BarsetBase.")); | |
175 | qmlRegisterUncreatableType<QPieSeries>(uri, 1, 0, "QPieSeries", |
|
178 | qmlRegisterUncreatableType<QPieSeries>(uri, 1, 0, "QPieSeries", | |
176 | QLatin1String("Trying to create uncreatable: QPieSeries. Use PieSeries instead.")); |
|
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 | // QtCommercial.Chart 1.1 |
|
183 | // QtCommercial.Chart 1.1 | |
179 | qmlRegisterType<DeclarativeChart, 1>(uri, 1, 1, "ChartView"); |
|
184 | qmlRegisterType<DeclarativeChart, 1>(uri, 1, 1, "ChartView"); | |
@@ -201,6 +206,16 public: | |||||
201 |
|
206 | |||
202 | // QtCommercial.Chart 1.2 |
|
207 | // QtCommercial.Chart 1.2 | |
203 | qmlRegisterType<DeclarativeChart, 2>(uri, 1, 2, "ChartView"); |
|
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,14 +358,22 QAbstractAxis *QChart::axisY(QAbstractSeries *series) const | |||||
358 | return left?left:right; |
|
358 | return left?left:right; | |
359 | } |
|
359 | } | |
360 |
|
360 | |||
361 |
|
||||
362 | QList<QAbstractAxis *> QChart::axes(Qt::Orientations orientation, QAbstractSeries *series) const |
|
361 | QList<QAbstractAxis *> QChart::axes(Qt::Orientations orientation, QAbstractSeries *series) const | |
363 | { |
|
362 | { | |
364 | QList<QAbstractAxis *> result ; |
|
363 | QList<QAbstractAxis *> result ; | |
365 |
|
364 | |||
366 | foreach(QAbstractAxis* axis,series->attachedAxes()){ |
|
365 | if (series) { | |
367 | if(orientation.testFlag(axis->orientation())) |
|
366 | foreach (QAbstractAxis *axis, series->attachedAxes()){ | |
368 | result << axis; |
|
367 | if (orientation.testFlag(axis->orientation())) | |
|
368 | result << axis; | |||
|
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 | } | |||
369 | } |
|
377 | } | |
370 |
|
378 | |||
371 | return result; |
|
379 | return result; |
@@ -80,7 +80,7 public: | |||||
80 | m_seriesColors.append(ChartThemeManager::colorAt(g, 0.5)); |
|
80 | m_seriesColors.append(ChartThemeManager::colorAt(g, 0.5)); | |
81 |
|
81 | |||
82 | // Generate gradients from the base colors |
|
82 | // Generate gradients from the base colors | |
83 | ChartThemeManager::generateSeriesGradients(m_seriesColors); |
|
83 | m_seriesGradients = ChartThemeManager::generateSeriesGradients(m_seriesColors); | |
84 |
|
84 | |||
85 | // Background fill color from COLOR_WINDOW |
|
85 | // Background fill color from COLOR_WINDOW | |
86 | QLinearGradient backgroundGradient; |
|
86 | QLinearGradient backgroundGradient; | |
@@ -129,7 +129,7 public: | |||||
129 | m_seriesColors << QRgb(0x92ca66); |
|
129 | m_seriesColors << QRgb(0x92ca66); | |
130 | m_seriesColors << QRgb(0xeba85f); |
|
130 | m_seriesColors << QRgb(0xeba85f); | |
131 | m_seriesColors << QRgb(0xfc5751); |
|
131 | m_seriesColors << QRgb(0xfc5751); | |
132 | generateSeriesGradients(); |
|
132 | m_seriesGradients = ChartThemeManager::generateSeriesGradients(m_seriesColors); | |
133 |
|
133 | |||
134 | // Background |
|
134 | // Background | |
135 | QLinearGradient backgroundGradient; |
|
135 | QLinearGradient backgroundGradient; |
@@ -36,6 +36,18 Rectangle { | |||||
36 | compare(barSeries.labelsVisible, false); |
|
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 | function test_append() { |
|
51 | function test_append() { | |
40 | var setCount = 5; |
|
52 | var setCount = 5; | |
41 | var valueCount = 50; |
|
53 | var valueCount = 50; | |
@@ -105,10 +117,10 Rectangle { | |||||
105 | anchors.fill: parent |
|
117 | anchors.fill: parent | |
106 |
|
118 | |||
107 | BarSeries { |
|
119 | BarSeries { | |
108 | axisX: BarCategoriesAxis {} |
|
|||
109 | axisY: ValuesAxis { min: 0; max: 10 } |
|
|||
110 | id: barSeries |
|
120 | id: barSeries | |
111 | name: "bar" |
|
121 | name: "bar" | |
|
122 | axisX: BarCategoryAxis {} | |||
|
123 | axisY: ValueAxis { min: 0; max: 10 } | |||
112 |
|
124 | |||
113 | SignalSpy { |
|
125 | SignalSpy { | |
114 | id: addedSpy |
|
126 | id: addedSpy | |
@@ -121,5 +133,15 Rectangle { | |||||
121 | signalName: "barsetsRemoved" |
|
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 | function test_properties() { |
|
34 | function test_properties() { | |
35 | verify(lineSeries.color != undefined); |
|
35 | verify(lineSeries.color != undefined); | |
36 | compare(lineSeries.pointsVisible, false); |
|
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 | compare(lineSeries.capStyle, Qt.SquareCap); | |
41 | compare(lineSeries.style, Qt.SolidLine); |
|
38 | compare(lineSeries.style, Qt.SolidLine); | |
42 | compare(lineSeries.width, 2.0); |
|
39 | compare(lineSeries.width, 2.0); | |
43 |
|
40 | |||
44 | verify(splineSeries.color != undefined); |
|
41 | verify(splineSeries.color != undefined); | |
45 | compare(splineSeries.pointsVisible, false); |
|
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 | compare(splineSeries.capStyle, Qt.SquareCap); | |
50 | compare(splineSeries.style, Qt.SolidLine); |
|
44 | compare(splineSeries.style, Qt.SolidLine); | |
51 | compare(splineSeries.width, 2.0); |
|
45 | compare(splineSeries.width, 2.0); | |
52 |
|
46 | |||
53 | verify(scatterSeries.color != undefined); |
|
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 | verify(scatterSeries.borderColor != undefined); | |
58 | compare(scatterSeries.borderWidth, 2.0); |
|
49 | compare(scatterSeries.borderWidth, 2.0); | |
59 | compare(scatterSeries.markerShape, ScatterSeries.MarkerShapeCircle); |
|
50 | compare(scatterSeries.markerShape, ScatterSeries.MarkerShapeCircle); | |
@@ -64,6 +55,20 Rectangle { | |||||
64 | compare(areaSeries.borderWidth, 2.0); |
|
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 | function test_append() { |
|
72 | function test_append() { | |
68 | lineSeriesPointAddedSpy.clear(); |
|
73 | lineSeriesPointAddedSpy.clear(); | |
69 | splineSeriesPointAddedSpy.clear(); |
|
74 | splineSeriesPointAddedSpy.clear(); |
@@ -33,12 +33,12 ChartView { | |||||
33 | onTriggered: { |
|
33 | onTriggered: { | |
34 | switch (index) { |
|
34 | switch (index) { | |
35 | case 0: |
|
35 | case 0: | |
36 |
|
|
36 | lineSeries.axisX.max = 6; | |
37 |
|
|
37 | lineSeries.axisY.max = 6; | |
38 | break; |
|
38 | break; | |
39 | case 1: |
|
39 | case 1: | |
40 |
|
|
40 | scatterSeries.axisX.max = 10; | |
41 |
|
|
41 | scatterSeries.axisY.max = 10; | |
42 | break; |
|
42 | break; | |
43 | default: |
|
43 | default: | |
44 | chartView.axisX().max = 4; |
|
44 | chartView.axisX().max = 4; |
General Comments 0
You need to be logged in to leave comments.
Login now