@@ -39,6 +39,10 Rectangle { | |||||
39 | XYPoint { x: 3.4; y: 3.0 } |
|
39 | XYPoint { x: 3.4; y: 3.0 } | |
40 | XYPoint { x: 4.1; y: 3.3 } |
|
40 | XYPoint { x: 4.1; y: 3.3 } | |
41 | } |
|
41 | } | |
|
42 | ||||
|
43 | Component.onCompleted: { | |||
|
44 | createDefaultAxes(); | |||
|
45 | } | |||
42 | } |
|
46 | } | |
43 | //![1] |
|
47 | //![1] | |
44 | } |
|
48 | } |
@@ -39,6 +39,10 Rectangle { | |||||
39 | XYPoint { x: 3.4; y: 2.3 } |
|
39 | XYPoint { x: 3.4; y: 2.3 } | |
40 | XYPoint { x: 4.1; y: 3.1 } |
|
40 | XYPoint { x: 4.1; y: 3.1 } | |
41 | } |
|
41 | } | |
|
42 | ||||
|
43 | Component.onCompleted: { | |||
|
44 | createDefaultAxes(); | |||
|
45 | } | |||
42 | } |
|
46 | } | |
43 | //![1] |
|
47 | //![1] | |
44 | } |
|
48 | } |
@@ -30,11 +30,12 Rectangle { | |||||
30 | anchors.fill: parent |
|
30 | anchors.fill: parent | |
31 |
|
31 | |||
32 | AreaSeries { |
|
32 | AreaSeries { | |
33 | axisX: CategoriesAxis { |
|
33 | //TODO: obsolate | |
34 |
|
|
34 | //axisX: CategoriesAxis { | |
35 | categories: ["2000", "2001", "2002", "2003", "2004", "2005", "2006", "2007", |
|
35 | // id: categoriesAxis | |
36 | "2008", "2009", "2010", "2011" ] |
|
36 | // categories: ["2000", "2001", "2002", "2003", "2004", "2005", "2006", "2007", | |
37 | } |
|
37 | // "2008", "2009", "2010", "2011" ] | |
|
38 | //} | |||
38 |
|
39 | |||
39 | name: "Russian" |
|
40 | name: "Russian" | |
40 | upperSeries: LineSeries { |
|
41 | upperSeries: LineSeries { | |
@@ -141,5 +142,8 Rectangle { | |||||
141 | borderColor = "blue"; |
|
142 | borderColor = "blue"; | |
142 | } |
|
143 | } | |
143 | } |
|
144 | } | |
|
145 | Component.onCompleted: { | |||
|
146 | createDefaultAxes(); | |||
|
147 | } | |||
144 | } |
|
148 | } | |
145 | } |
|
149 | } |
@@ -53,6 +53,11 Rectangle { | |||||
53 | XYPoint { x: 2.67; y: 2.65 } |
|
53 | XYPoint { x: 2.67; y: 2.65 } | |
54 | //![2] |
|
54 | //![2] | |
55 | } |
|
55 | } | |
|
56 | ||||
|
57 | Component.onCompleted: { | |||
|
58 | createDefaultAxes(); | |||
|
59 | } | |||
|
60 | ||||
56 | } |
|
61 | } | |
57 | //![2] |
|
62 | //![2] | |
58 | } |
|
63 | } |
@@ -29,13 +29,20 Rectangle { | |||||
29 | title: "Bar series" |
|
29 | title: "Bar series" | |
30 | anchors.fill: parent |
|
30 | anchors.fill: parent | |
31 | legend.alignment: Qt.AlignBottom |
|
31 | legend.alignment: Qt.AlignBottom | |
32 |
|
32 | CategoriesAxis { | ||
|
33 | id:myAxis | |||
|
34 | categories: ["2007", "2008", "2009", "2010", "2011", "2012" ] | |||
|
35 | } | |||
33 | BarSeries { |
|
36 | BarSeries { | |
34 | axisX: CategoriesAxis { categories: ["2007", "2008", "2009", "2010", "2011", "2012" ] } |
|
37 | id: mySeries | |
35 | BarSet { label: "Bob"; values: [2, 2, 3, 4, 5, 6] } |
|
38 | BarSet { label: "Bob"; values: [2, 2, 3, 4, 5, 6] } | |
36 | BarSet { label: "Susan"; values: [5, 1, 2, 4, 1, 7] } |
|
39 | BarSet { label: "Susan"; values: [5, 1, 2, 4, 1, 7] } | |
37 | BarSet { label: "James"; values: [3, 5, 8, 13, 5, 8] } |
|
40 | BarSet { label: "James"; values: [3, 5, 8, 13, 5, 8] } | |
38 | } |
|
41 | } | |
|
42 | Component.onCompleted: { | |||
|
43 | createDefaultAxes(); | |||
|
44 | setAxisX(myAxis,mySeries); | |||
|
45 | } | |||
39 | } |
|
46 | } | |
40 | //![1] |
|
47 | //![1] | |
41 | } |
|
48 | } |
@@ -26,16 +26,23 Rectangle { | |||||
26 |
|
26 | |||
27 | //![1] |
|
27 | //![1] | |
28 | ChartView { |
|
28 | ChartView { | |
29 |
title: " |
|
29 | title: "Stacked Bar series" | |
30 | anchors.fill: parent |
|
30 | anchors.fill: parent | |
31 | legend.alignment: Qt.AlignBottom |
|
31 | legend.alignment: Qt.AlignBottom | |
32 |
|
32 | CategoriesAxis { | ||
33 | GroupedBarSeries { |
|
33 | id: myAxis; | |
34 |
|
|
34 | categories: ["2007", "2008", "2009", "2010", "2011", "2012" ] | |
|
35 | } | |||
|
36 | StackedBarSeries { | |||
|
37 | id: mySeries; | |||
35 | BarSet { label: "Bob"; values: [2, 2, 3, 4, 5, 6] } |
|
38 | BarSet { label: "Bob"; values: [2, 2, 3, 4, 5, 6] } | |
36 | BarSet { label: "Susan"; values: [5, 1, 2, 4, 1, 7] } |
|
39 | BarSet { label: "Susan"; values: [5, 1, 2, 4, 1, 7] } | |
37 | BarSet { label: "James"; values: [3, 5, 8, 13, 5, 8] } |
|
40 | BarSet { label: "James"; values: [3, 5, 8, 13, 5, 8] } | |
38 | } |
|
41 | } | |
|
42 | Component.onCompleted: { | |||
|
43 | createDefaultAxes(); | |||
|
44 | setAxisX(myAxis,mySeries); | |||
|
45 | } | |||
39 | } |
|
46 | } | |
40 | //![1] |
|
47 | //![1] | |
41 | } |
|
48 | } |
@@ -26,16 +26,24 Rectangle { | |||||
26 |
|
26 | |||
27 | //![1] |
|
27 | //![1] | |
28 | ChartView { |
|
28 | ChartView { | |
29 |
title: " |
|
29 | title: "Percent Bar series" | |
30 | anchors.fill: parent |
|
30 | anchors.fill: parent | |
31 | legend.alignment: Qt.AlignBottom |
|
31 | legend.alignment: Qt.AlignBottom | |
32 |
|
32 | CategoriesAxis { | ||
33 | StackedBarSeries { |
|
33 | id: myAxis | |
34 |
|
|
34 | categories: ["2007", "2008", "2009", "2010", "2011", "2012" ] | |
|
35 | } | |||
|
36 | PercentBarSeries { | |||
|
37 | id: mySeries | |||
35 | BarSet { label: "Bob"; values: [2, 2, 3, 4, 5, 6] } |
|
38 | BarSet { label: "Bob"; values: [2, 2, 3, 4, 5, 6] } | |
36 | BarSet { label: "Susan"; values: [5, 1, 2, 4, 1, 7] } |
|
39 | BarSet { label: "Susan"; values: [5, 1, 2, 4, 1, 7] } | |
37 | BarSet { label: "James"; values: [3, 5, 8, 13, 5, 8] } |
|
40 | BarSet { label: "James"; values: [3, 5, 8, 13, 5, 8] } | |
38 | } |
|
41 | } | |
|
42 | Component.onCompleted: { | |||
|
43 | createDefaultAxes(); | |||
|
44 | setAxisX(myAxis,mySeries); | |||
|
45 | } | |||
39 | } |
|
46 | } | |
40 | //![1] |
|
47 | //![1] | |
41 | } |
|
48 | } | |
|
49 |
@@ -74,7 +74,7 Rectangle { | |||||
74 |
|
74 | |||
75 | function nextView() { |
|
75 | function nextView() { | |
76 | var i = viewNumber + 1; |
|
76 | var i = viewNumber + 1; | |
77 |
if (i > |
|
77 | if (i > 8) | |
78 | viewNumber = 1; |
|
78 | viewNumber = 1; | |
79 | else |
|
79 | else | |
80 | viewNumber = i; |
|
80 | viewNumber = i; | |
@@ -83,7 +83,7 Rectangle { | |||||
83 | function previousView() { |
|
83 | function previousView() { | |
84 | var i = viewNumber - 1; |
|
84 | var i = viewNumber - 1; | |
85 | if (i <= 0) |
|
85 | if (i <= 0) | |
86 |
viewNumber = |
|
86 | viewNumber = 8; | |
87 | else |
|
87 | else | |
88 | viewNumber = i; |
|
88 | viewNumber = i; | |
89 | } |
|
89 | } |
@@ -10,6 +10,5 | |||||
10 | <file>qml/qmlchart/View6.qml</file> |
|
10 | <file>qml/qmlchart/View6.qml</file> | |
11 | <file>qml/qmlchart/View7.qml</file> |
|
11 | <file>qml/qmlchart/View7.qml</file> | |
12 | <file>qml/qmlchart/View8.qml</file> |
|
12 | <file>qml/qmlchart/View8.qml</file> | |
13 | <file>qml/qmlchart/View9.qml</file> |
|
|||
14 | </qresource> |
|
13 | </qresource> | |
15 | </RCC> |
|
14 | </RCC> |
@@ -60,106 +60,6 void DeclarativeBarSet::setValues(QVariantList values) | |||||
60 | } |
|
60 | } | |
61 | } |
|
61 | } | |
62 |
|
62 | |||
63 | DeclarativeAbstractBarSeries::DeclarativeAbstractBarSeries(QDeclarativeItem *parent) : |
|
|||
64 | QAbstractBarSeries(parent) |
|
|||
65 | { |
|
|||
66 | connect(this, SIGNAL(barsetsAdded(QList<QBarSet*>)), this, SLOT(handleAdded(QList<QBarSet*>))); |
|
|||
67 | connect(this, SIGNAL(barsetsRemoved(QList<QBarSet*>)), this, SLOT(handleRemoved(QList<QBarSet*>))); |
|
|||
68 | } |
|
|||
69 |
|
||||
70 | void DeclarativeAbstractBarSeries::handleAdded(QList<QBarSet* > barsets) |
|
|||
71 | { |
|
|||
72 | foreach(QBarSet *b, barsets) { |
|
|||
73 | DeclarativeBarSet *barset = qobject_cast<DeclarativeBarSet *>(b); |
|
|||
74 | emit added(barset); |
|
|||
75 | } |
|
|||
76 | } |
|
|||
77 |
|
||||
78 | void DeclarativeAbstractBarSeries::handleRemoved(QList<QBarSet* > barsets) |
|
|||
79 | { |
|
|||
80 | foreach(QBarSet *b, barsets) { |
|
|||
81 | DeclarativeBarSet *barset = qobject_cast<DeclarativeBarSet *>(b); |
|
|||
82 | emit removed(barset); |
|
|||
83 | } |
|
|||
84 | } |
|
|||
85 |
|
||||
86 | void DeclarativeAbstractBarSeries::classBegin() |
|
|||
87 | { |
|
|||
88 | } |
|
|||
89 |
|
||||
90 | void DeclarativeAbstractBarSeries::componentComplete() |
|
|||
91 | { |
|
|||
92 | foreach(QObject *child, children()) { |
|
|||
93 | if (qobject_cast<DeclarativeBarSet *>(child)) { |
|
|||
94 | QAbstractBarSeries::append(qobject_cast<DeclarativeBarSet *>(child)); |
|
|||
95 | } else if (qobject_cast<QVBarModelMapper *>(child)) { |
|
|||
96 | QVBarModelMapper *mapper = qobject_cast<QVBarModelMapper *>(child); |
|
|||
97 | mapper->setSeries(this); |
|
|||
98 | } else if (qobject_cast<QHBarModelMapper *>(child)) { |
|
|||
99 | QHBarModelMapper *mapper = qobject_cast<QHBarModelMapper *>(child); |
|
|||
100 | mapper->setSeries(this); |
|
|||
101 | } |
|
|||
102 | } |
|
|||
103 | } |
|
|||
104 |
|
||||
105 | void DeclarativeAbstractBarSeries::setAxisX(QAbstractAxis *axis) |
|
|||
106 | { |
|
|||
107 | chart()->setAxisX(axis, this); |
|
|||
108 | } |
|
|||
109 |
|
||||
110 | QAbstractAxis *DeclarativeAbstractBarSeries::axisX() |
|
|||
111 | { |
|
|||
112 | return chart()->axisX(this); |
|
|||
113 | } |
|
|||
114 |
|
||||
115 | void DeclarativeAbstractBarSeries::setAxisY(QAbstractAxis *axis) |
|
|||
116 | { |
|
|||
117 | chart()->setAxisY(axis, this); |
|
|||
118 | } |
|
|||
119 |
|
||||
120 | QAbstractAxis *DeclarativeAbstractBarSeries::axisY() |
|
|||
121 | { |
|
|||
122 | return chart()->axisY(this); |
|
|||
123 | } |
|
|||
124 |
|
||||
125 | QDeclarativeListProperty<QObject> DeclarativeAbstractBarSeries::seriesChildren() |
|
|||
126 | { |
|
|||
127 | return QDeclarativeListProperty<QObject>(this, 0, &DeclarativeAbstractBarSeries::appendSeriesChildren); |
|
|||
128 | } |
|
|||
129 |
|
||||
130 | void DeclarativeAbstractBarSeries::appendSeriesChildren(QDeclarativeListProperty<QObject> * list, QObject *element) |
|
|||
131 | { |
|
|||
132 | // Empty implementation; the children are parsed in componentComplete instead |
|
|||
133 | Q_UNUSED(list); |
|
|||
134 | Q_UNUSED(element); |
|
|||
135 | } |
|
|||
136 |
|
||||
137 | DeclarativeBarSet *DeclarativeAbstractBarSeries::at(int index) |
|
|||
138 | { |
|
|||
139 | QList<QBarSet*> setList = barSets(); |
|
|||
140 | if (index >= 0 && index < setList.count()) |
|
|||
141 | return qobject_cast<DeclarativeBarSet *>(setList[index]); |
|
|||
142 |
|
||||
143 | return 0; |
|
|||
144 | } |
|
|||
145 |
|
||||
146 | DeclarativeBarSet *DeclarativeAbstractBarSeries::insert(int index, QString label, QVariantList values) |
|
|||
147 | { |
|
|||
148 | int insertIndex = index; |
|
|||
149 | if (insertIndex < 0) |
|
|||
150 | insertIndex = 0; |
|
|||
151 | else if (insertIndex > count()) |
|
|||
152 | insertIndex = count(); |
|
|||
153 |
|
||||
154 | DeclarativeBarSet *barset = new DeclarativeBarSet(this); |
|
|||
155 | barset->setLabel(label); |
|
|||
156 | barset->setValues(values); |
|
|||
157 | if (QAbstractBarSeries::insert(insertIndex, barset)) |
|
|||
158 | return barset; |
|
|||
159 | delete barset; |
|
|||
160 | return 0; |
|
|||
161 | } |
|
|||
162 |
|
||||
163 | DeclarativeBarSeries::DeclarativeBarSeries(QDeclarativeItem *parent) : |
|
63 | DeclarativeBarSeries::DeclarativeBarSeries(QDeclarativeItem *parent) : | |
164 | QBarSeries(parent) |
|
64 | QBarSeries(parent) | |
165 | { |
|
65 | { | |
@@ -184,29 +84,9 void DeclarativeBarSeries::componentComplete() | |||||
184 | } |
|
84 | } | |
185 | } |
|
85 | } | |
186 |
|
86 | |||
187 | void DeclarativeBarSeries::setAxisX(QAbstractAxis *axis) |
|
|||
188 | { |
|
|||
189 | chart()->setAxisX(axis, this); |
|
|||
190 | } |
|
|||
191 |
|
||||
192 | QAbstractAxis *DeclarativeBarSeries::axisX() |
|
|||
193 | { |
|
|||
194 | return chart()->axisX(this); |
|
|||
195 | } |
|
|||
196 |
|
||||
197 | void DeclarativeBarSeries::setAxisY(QAbstractAxis *axis) |
|
|||
198 | { |
|
|||
199 | chart()->setAxisY(axis, this); |
|
|||
200 | } |
|
|||
201 |
|
||||
202 | QAbstractAxis *DeclarativeBarSeries::axisY() |
|
|||
203 | { |
|
|||
204 | return chart()->axisY(this); |
|
|||
205 | } |
|
|||
206 |
|
||||
207 | QDeclarativeListProperty<QObject> DeclarativeBarSeries::seriesChildren() |
|
87 | QDeclarativeListProperty<QObject> DeclarativeBarSeries::seriesChildren() | |
208 | { |
|
88 | { | |
209 |
return QDeclarativeListProperty<QObject>(this, 0, &Declarative |
|
89 | return QDeclarativeListProperty<QObject>(this, 0, &DeclarativeBarSeries::appendSeriesChildren); | |
210 | } |
|
90 | } | |
211 |
|
91 | |||
212 | void DeclarativeBarSeries::appendSeriesChildren(QDeclarativeListProperty<QObject> * list, QObject *element) |
|
92 | void DeclarativeBarSeries::appendSeriesChildren(QDeclarativeListProperty<QObject> * list, QObject *element) | |
@@ -260,29 +140,10 void DeclarativeStackedBarSeries::componentComplete() | |||||
260 | } |
|
140 | } | |
261 | } |
|
141 | } | |
262 |
|
142 | |||
263 | void DeclarativeStackedBarSeries::setAxisX(QAbstractAxis *axis) |
|
|||
264 | { |
|
|||
265 | chart()->setAxisX(axis, this); |
|
|||
266 | } |
|
|||
267 |
|
||||
268 | QAbstractAxis *DeclarativeStackedBarSeries::axisX() |
|
|||
269 | { |
|
|||
270 | return chart()->axisX(this); |
|
|||
271 | } |
|
|||
272 |
|
||||
273 | void DeclarativeStackedBarSeries::setAxisY(QAbstractAxis *axis) |
|
|||
274 | { |
|
|||
275 | chart()->setAxisY(axis, this); |
|
|||
276 | } |
|
|||
277 |
|
||||
278 | QAbstractAxis *DeclarativeStackedBarSeries::axisY() |
|
|||
279 | { |
|
|||
280 | return chart()->axisY(this); |
|
|||
281 | } |
|
|||
282 |
|
143 | |||
283 | QDeclarativeListProperty<QObject> DeclarativeStackedBarSeries::seriesChildren() |
|
144 | QDeclarativeListProperty<QObject> DeclarativeStackedBarSeries::seriesChildren() | |
284 | { |
|
145 | { | |
285 |
return QDeclarativeListProperty<QObject>(this, 0, &Declarative |
|
146 | return QDeclarativeListProperty<QObject>(this, 0, &DeclarativeBarSeries::appendSeriesChildren); | |
286 | } |
|
147 | } | |
287 |
|
148 | |||
288 | void DeclarativeStackedBarSeries::appendSeriesChildren(QDeclarativeListProperty<QObject> * list, QObject *element) |
|
149 | void DeclarativeStackedBarSeries::appendSeriesChildren(QDeclarativeListProperty<QObject> * list, QObject *element) | |
@@ -336,29 +197,9 void DeclarativePercentBarSeries::componentComplete() | |||||
336 | } |
|
197 | } | |
337 | } |
|
198 | } | |
338 |
|
199 | |||
339 | void DeclarativePercentBarSeries::setAxisX(QAbstractAxis *axis) |
|
|||
340 | { |
|
|||
341 | chart()->setAxisX(axis, this); |
|
|||
342 | } |
|
|||
343 |
|
||||
344 | QAbstractAxis *DeclarativePercentBarSeries::axisX() |
|
|||
345 | { |
|
|||
346 | return chart()->axisX(this); |
|
|||
347 | } |
|
|||
348 |
|
||||
349 | void DeclarativePercentBarSeries::setAxisY(QAbstractAxis *axis) |
|
|||
350 | { |
|
|||
351 | chart()->setAxisY(axis, this); |
|
|||
352 | } |
|
|||
353 |
|
||||
354 | QAbstractAxis *DeclarativePercentBarSeries::axisY() |
|
|||
355 | { |
|
|||
356 | return chart()->axisY(this); |
|
|||
357 | } |
|
|||
358 |
|
||||
359 | QDeclarativeListProperty<QObject> DeclarativePercentBarSeries::seriesChildren() |
|
200 | QDeclarativeListProperty<QObject> DeclarativePercentBarSeries::seriesChildren() | |
360 | { |
|
201 | { | |
361 |
return QDeclarativeListProperty<QObject>(this, 0, &Declarative |
|
202 | return QDeclarativeListProperty<QObject>(this, 0, &DeclarativeBarSeries::appendSeriesChildren); | |
362 | } |
|
203 | } | |
363 |
|
204 | |||
364 | void DeclarativePercentBarSeries::appendSeriesChildren(QDeclarativeListProperty<QObject> * list, QObject *element) |
|
205 | void DeclarativePercentBarSeries::appendSeriesChildren(QDeclarativeListProperty<QObject> * list, QObject *element) |
@@ -59,48 +59,10 private Q_SLOTS: | |||||
59 | void handleCountChanged(int index, int count); |
|
59 | void handleCountChanged(int index, int count); | |
60 | }; |
|
60 | }; | |
61 |
|
61 | |||
62 | class DeclarativeAbstractBarSeries : public QAbstractBarSeries, public QDeclarativeParserStatus |
|
|||
63 | { |
|
|||
64 | Q_OBJECT |
|
|||
65 | Q_INTERFACES(QDeclarativeParserStatus) |
|
|||
66 | Q_PROPERTY(QDeclarativeListProperty<QObject> seriesChildren READ seriesChildren) |
|
|||
67 | Q_PROPERTY(QAbstractAxis *axisX READ axisX WRITE setAxisX) |
|
|||
68 | Q_PROPERTY(QAbstractAxis *axisY READ axisY WRITE setAxisY) |
|
|||
69 | Q_CLASSINFO("DefaultProperty", "seriesChildren") |
|
|||
70 |
|
||||
71 | public: |
|
|||
72 | explicit DeclarativeAbstractBarSeries(QDeclarativeItem *parent = 0); |
|
|||
73 | void setAxisX(QAbstractAxis *axis); |
|
|||
74 | QAbstractAxis *axisX(); |
|
|||
75 | void setAxisY(QAbstractAxis *axis); |
|
|||
76 | QAbstractAxis *axisY(); |
|
|||
77 | QDeclarativeListProperty<QObject> seriesChildren(); |
|
|||
78 | Q_INVOKABLE DeclarativeBarSet *at(int index); |
|
|||
79 | Q_INVOKABLE DeclarativeBarSet *append(QString label, QVariantList values) { return insert(count(), label, values); } |
|
|||
80 | Q_INVOKABLE DeclarativeBarSet *insert(int index, QString label, QVariantList values); |
|
|||
81 | Q_INVOKABLE bool remove(QBarSet *barset) { return QAbstractBarSeries::remove(barset); } |
|
|||
82 | Q_INVOKABLE void clear() { return QAbstractBarSeries::clear(); } |
|
|||
83 |
|
||||
84 | public: // from QDeclarativeParserStatus |
|
|||
85 | void classBegin(); |
|
|||
86 | void componentComplete(); |
|
|||
87 |
|
||||
88 | Q_SIGNALS: |
|
|||
89 | void added(DeclarativeBarSet *barset); |
|
|||
90 | void removed(DeclarativeBarSet *barset); |
|
|||
91 |
|
||||
92 | public Q_SLOTS: |
|
|||
93 | static void appendSeriesChildren(QDeclarativeListProperty<QObject> *list, QObject *element); |
|
|||
94 | void handleAdded(QList<QBarSet* > barsets); |
|
|||
95 | void handleRemoved(QList<QBarSet* > barsets); |
|
|||
96 | }; |
|
|||
97 |
|
||||
98 | class DeclarativeBarSeries : public QBarSeries, public QDeclarativeParserStatus |
|
62 | class DeclarativeBarSeries : public QBarSeries, public QDeclarativeParserStatus | |
99 | { |
|
63 | { | |
100 | Q_OBJECT |
|
64 | Q_OBJECT | |
101 | Q_INTERFACES(QDeclarativeParserStatus) |
|
65 | Q_INTERFACES(QDeclarativeParserStatus) | |
102 | Q_PROPERTY(QAbstractAxis *axisX READ axisX WRITE setAxisX) |
|
|||
103 | Q_PROPERTY(QAbstractAxis *axisY READ axisY WRITE setAxisY) |
|
|||
104 | Q_PROPERTY(QDeclarativeListProperty<QObject> seriesChildren READ seriesChildren) |
|
66 | Q_PROPERTY(QDeclarativeListProperty<QObject> seriesChildren READ seriesChildren) | |
105 | Q_CLASSINFO("DefaultProperty", "seriesChildren") |
|
67 | Q_CLASSINFO("DefaultProperty", "seriesChildren") | |
106 |
|
68 | |||
@@ -123,23 +85,21 public: // from QDeclarativeParserStatus | |||||
123 |
|
85 | |||
124 | public Q_SLOTS: |
|
86 | public Q_SLOTS: | |
125 | static void appendSeriesChildren(QDeclarativeListProperty<QObject> *list, QObject *element); |
|
87 | static void appendSeriesChildren(QDeclarativeListProperty<QObject> *list, QObject *element); | |
|
88 | ||||
|
89 | private: | |||
|
90 | QAbstractAxis* m_axisX; | |||
|
91 | QAbstractAxis* m_axisY; | |||
126 | }; |
|
92 | }; | |
127 |
|
93 | |||
128 | class DeclarativeStackedBarSeries : public QStackedBarSeries, public QDeclarativeParserStatus |
|
94 | class DeclarativeStackedBarSeries : public QStackedBarSeries, public QDeclarativeParserStatus | |
129 | { |
|
95 | { | |
130 | Q_OBJECT |
|
96 | Q_OBJECT | |
131 | Q_INTERFACES(QDeclarativeParserStatus) |
|
97 | Q_INTERFACES(QDeclarativeParserStatus) | |
132 | Q_PROPERTY(QAbstractAxis *axisX READ axisX WRITE setAxisX) |
|
|||
133 | Q_PROPERTY(QAbstractAxis *axisY READ axisY WRITE setAxisY) |
|
|||
134 | Q_PROPERTY(QDeclarativeListProperty<QObject> seriesChildren READ seriesChildren) |
|
98 | Q_PROPERTY(QDeclarativeListProperty<QObject> seriesChildren READ seriesChildren) | |
135 | Q_CLASSINFO("DefaultProperty", "seriesChildren") |
|
99 | Q_CLASSINFO("DefaultProperty", "seriesChildren") | |
136 |
|
100 | |||
137 | public: |
|
101 | public: | |
138 | explicit DeclarativeStackedBarSeries(QDeclarativeItem *parent = 0); |
|
102 | explicit DeclarativeStackedBarSeries(QDeclarativeItem *parent = 0); | |
139 | void setAxisX(QAbstractAxis *axis); |
|
|||
140 | QAbstractAxis *axisX(); |
|
|||
141 | void setAxisY(QAbstractAxis *axis); |
|
|||
142 | QAbstractAxis *axisY(); |
|
|||
143 | QDeclarativeListProperty<QObject> seriesChildren(); |
|
103 | QDeclarativeListProperty<QObject> seriesChildren(); | |
144 | Q_INVOKABLE DeclarativeBarSet *at(int index); |
|
104 | Q_INVOKABLE DeclarativeBarSet *at(int index); | |
145 | Q_INVOKABLE DeclarativeBarSet *append(QString label, QVariantList values) { return insert(count(), label, values); } |
|
105 | Q_INVOKABLE DeclarativeBarSet *append(QString label, QVariantList values) { return insert(count(), label, values); } | |
@@ -153,23 +113,18 public: // from QDeclarativeParserStatus | |||||
153 |
|
113 | |||
154 | public Q_SLOTS: |
|
114 | public Q_SLOTS: | |
155 | static void appendSeriesChildren(QDeclarativeListProperty<QObject> *list, QObject *element); |
|
115 | static void appendSeriesChildren(QDeclarativeListProperty<QObject> *list, QObject *element); | |
|
116 | ||||
156 | }; |
|
117 | }; | |
157 |
|
118 | |||
158 | class DeclarativePercentBarSeries : public QPercentBarSeries, public QDeclarativeParserStatus |
|
119 | class DeclarativePercentBarSeries : public QPercentBarSeries, public QDeclarativeParserStatus | |
159 | { |
|
120 | { | |
160 | Q_OBJECT |
|
121 | Q_OBJECT | |
161 | Q_INTERFACES(QDeclarativeParserStatus) |
|
122 | Q_INTERFACES(QDeclarativeParserStatus) | |
162 | Q_PROPERTY(QAbstractAxis *axisX READ axisX WRITE setAxisX) |
|
|||
163 | Q_PROPERTY(QAbstractAxis *axisY READ axisY WRITE setAxisY) |
|
|||
164 | Q_PROPERTY(QDeclarativeListProperty<QObject> seriesChildren READ seriesChildren) |
|
123 | Q_PROPERTY(QDeclarativeListProperty<QObject> seriesChildren READ seriesChildren) | |
165 | Q_CLASSINFO("DefaultProperty", "seriesChildren") |
|
124 | Q_CLASSINFO("DefaultProperty", "seriesChildren") | |
166 |
|
125 | |||
167 | public: |
|
126 | public: | |
168 | explicit DeclarativePercentBarSeries(QDeclarativeItem *parent = 0); |
|
127 | explicit DeclarativePercentBarSeries(QDeclarativeItem *parent = 0); | |
169 | void setAxisX(QAbstractAxis *axis); |
|
|||
170 | QAbstractAxis *axisX(); |
|
|||
171 | void setAxisY(QAbstractAxis *axis); |
|
|||
172 | QAbstractAxis *axisY(); |
|
|||
173 | QDeclarativeListProperty<QObject> seriesChildren(); |
|
128 | QDeclarativeListProperty<QObject> seriesChildren(); | |
174 | Q_INVOKABLE DeclarativeBarSet *at(int index); |
|
129 | Q_INVOKABLE DeclarativeBarSet *at(int index); | |
175 | Q_INVOKABLE DeclarativeBarSet *append(QString label, QVariantList values) { return insert(count(), label, values); } |
|
130 | Q_INVOKABLE DeclarativeBarSet *append(QString label, QVariantList values) { return insert(count(), label, values); } |
@@ -250,19 +250,15 void DeclarativeChart::childEvent(QChildEvent *event) | |||||
250 |
|
250 | |||
251 | void DeclarativeChart::componentComplete() |
|
251 | void DeclarativeChart::componentComplete() | |
252 | { |
|
252 | { | |
253 | bool createAxis = true; |
|
|||
254 | foreach(QObject *child, children()) { |
|
253 | foreach(QObject *child, children()) { | |
255 | if (qobject_cast<QAbstractSeries *>(child)) { |
|
254 | if (qobject_cast<QAbstractSeries *>(child)) { | |
256 | // qDebug() << "DeclarativeChart::componentComplete(), add: " << child; |
|
255 | // qDebug() << "DeclarativeChart::componentComplete(), add: " << child; | |
257 | // TODO: how about optional y-axis? |
|
256 | // TODO: how about optional y-axis? | |
258 | m_chart->addSeries(qobject_cast<QAbstractSeries *>(child)); |
|
257 | m_chart->addSeries(qobject_cast<QAbstractSeries *>(child)); | |
259 | }else if(qobject_cast<QAbstractAxis *>(child)){ |
|
258 | }else if(qobject_cast<QAbstractAxis *>(child)){ | |
260 | createAxis = false; |
|
259 | ||
261 | } |
|
260 | } | |
262 | } |
|
261 | } | |
263 |
|
||||
264 | if(createAxis) m_chart->createDefaultAxes(); |
|
|||
265 |
|
||||
266 | QDeclarativeItem::componentComplete(); |
|
262 | QDeclarativeItem::componentComplete(); | |
267 | } |
|
263 | } | |
268 |
|
264 | |||
@@ -499,6 +495,21 QAbstractSeries *DeclarativeChart::createSeries(DeclarativeChart::SeriesType typ | |||||
499 | return series; |
|
495 | return series; | |
500 | } |
|
496 | } | |
501 |
|
497 | |||
|
498 | void DeclarativeChart::setAxisX(QAbstractAxis* axis, QAbstractSeries *series) | |||
|
499 | { | |||
|
500 | m_chart->setAxisX(axis,series); | |||
|
501 | } | |||
|
502 | ||||
|
503 | void DeclarativeChart::setAxisY(QAbstractAxis* axis, QAbstractSeries *series) | |||
|
504 | { | |||
|
505 | m_chart->setAxisY(axis,series); | |||
|
506 | } | |||
|
507 | ||||
|
508 | void DeclarativeChart::createDefaultAxes() | |||
|
509 | { | |||
|
510 | m_chart->createDefaultAxes(); | |||
|
511 | } | |||
|
512 | ||||
502 | #include "moc_declarativechart.cpp" |
|
513 | #include "moc_declarativechart.cpp" | |
503 |
|
514 | |||
504 | QTCOMMERCIALCHART_END_NAMESPACE |
|
515 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -114,12 +114,17 public: | |||||
114 | qreal leftMargin(); |
|
114 | qreal leftMargin(); | |
115 | qreal rightMargin(); |
|
115 | qreal rightMargin(); | |
116 |
|
116 | |||
|
117 | QAbstractAxis *axisX(QAbstractSeries *series = 0); | |||
|
118 | QAbstractAxis *axisY(QAbstractSeries *series = 0); | |||
|
119 | ||||
117 | public: |
|
120 | public: | |
118 | Q_INVOKABLE QAbstractSeries *series(int index); |
|
121 | Q_INVOKABLE QAbstractSeries *series(int index); | |
119 | Q_INVOKABLE QAbstractSeries *series(QString seriesName); |
|
122 | Q_INVOKABLE QAbstractSeries *series(QString seriesName); | |
120 | Q_INVOKABLE QAbstractSeries *createSeries(DeclarativeChart::SeriesType type, QString name = ""); |
|
123 | Q_INVOKABLE QAbstractSeries *createSeries(DeclarativeChart::SeriesType type, QString name = ""); | |
121 |
Q_INVOKABLE QAbstractAxis |
|
124 | Q_INVOKABLE void setAxisX(QAbstractAxis* axis, QAbstractSeries *series = 0); | |
122 |
Q_INVOKABLE QAbstractAxis |
|
125 | Q_INVOKABLE void setAxisY(QAbstractAxis* axis, QAbstractSeries *series = 0); | |
|
126 | Q_INVOKABLE void createDefaultAxes(); | |||
|
127 | ||||
123 | Q_INVOKABLE void zoom(qreal factor); |
|
128 | Q_INVOKABLE void zoom(qreal factor); | |
124 | Q_INVOKABLE void scrollLeft(qreal pixels); |
|
129 | Q_INVOKABLE void scrollLeft(qreal pixels); | |
125 | Q_INVOKABLE void scrollRight(qreal pixels); |
|
130 | Q_INVOKABLE void scrollRight(qreal pixels); |
@@ -74,12 +74,6 public: | |||||
74 | QLatin1String("Trying to create uncreatable: Legend.")); |
|
74 | QLatin1String("Trying to create uncreatable: Legend.")); | |
75 | qmlRegisterUncreatableType<QXYSeries>(uri, 1, 0, "XYSeries", |
|
75 | qmlRegisterUncreatableType<QXYSeries>(uri, 1, 0, "XYSeries", | |
76 | QLatin1String("Trying to create uncreatable: XYSeries.")); |
|
76 | QLatin1String("Trying to create uncreatable: XYSeries.")); | |
77 | qmlRegisterUncreatableType<QScatterSeries>(uri, 1, 0, "QScatterSeries", |
|
|||
78 | QLatin1String("Trying to create uncreatable: QScatterSeries.")); |
|
|||
79 | qmlRegisterUncreatableType<QPieSeries>(uri, 1, 0, "QPieSeries", |
|
|||
80 | QLatin1String("Trying to create uncreatable: QPieSeries.")); |
|
|||
81 | qmlRegisterUncreatableType<QBarSet>(uri, 1, 0, "QBarSet", |
|
|||
82 | QLatin1String("Trying to create uncreatable: QBarSet.")); |
|
|||
83 | qmlRegisterUncreatableType<QAbstractItemModel>(uri, 1, 0, "AbstractItemModel", |
|
77 | qmlRegisterUncreatableType<QAbstractItemModel>(uri, 1, 0, "AbstractItemModel", | |
84 | QLatin1String("Trying to create uncreatable: AbstractItemModel.")); |
|
78 | QLatin1String("Trying to create uncreatable: AbstractItemModel.")); | |
85 | qmlRegisterUncreatableType<QXYModelMapper>(uri, 1, 0, "XYModelMapper", |
|
79 | qmlRegisterUncreatableType<QXYModelMapper>(uri, 1, 0, "XYModelMapper", | |
@@ -90,6 +84,8 public: | |||||
90 | QLatin1String("Trying to create uncreatable: BarModelMapper.")); |
|
84 | QLatin1String("Trying to create uncreatable: BarModelMapper.")); | |
91 | qmlRegisterUncreatableType<QAbstractSeries>(uri, 1, 0, "AbstractSeries", |
|
85 | qmlRegisterUncreatableType<QAbstractSeries>(uri, 1, 0, "AbstractSeries", | |
92 | QLatin1String("Trying to create uncreatable: AbstractSeries.")); |
|
86 | QLatin1String("Trying to create uncreatable: AbstractSeries.")); | |
|
87 | qmlRegisterUncreatableType<QAbstractBarSeries>(uri, 1, 0, "AbstractBarSeries", | |||
|
88 | QLatin1String("Trying to create uncreatable: AbstractBarSeries.")); | |||
93 | qmlRegisterUncreatableType<QAbstractAxis>(uri, 1, 0, "AbstractAxis", |
|
89 | qmlRegisterUncreatableType<QAbstractAxis>(uri, 1, 0, "AbstractAxis", | |
94 | QLatin1String("Trying to create uncreatable: AbstractAxis.")); |
|
90 | QLatin1String("Trying to create uncreatable: AbstractAxis.")); | |
95 | qmlRegisterUncreatableType<QPieModelMapper>(uri, 1, 0, "PieModelMapper", |
|
91 | qmlRegisterUncreatableType<QPieModelMapper>(uri, 1, 0, "PieModelMapper", |
1 | NO CONTENT: file was removed |
|
NO CONTENT: file was removed |
General Comments 0
You need to be logged in to leave comments.
Login now