@@ -1,96 +1,123 | |||
|
1 | 1 | /**************************************************************************** |
|
2 | 2 | ** |
|
3 | 3 | ** Copyright (C) 2012 Digia Plc |
|
4 | 4 | ** All rights reserved. |
|
5 | 5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
6 | 6 | ** |
|
7 | 7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
8 | 8 | ** |
|
9 | 9 | ** $QT_BEGIN_LICENSE$ |
|
10 | 10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
11 | 11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
12 | 12 | ** Software or, alternatively, in accordance with the terms contained in |
|
13 | 13 | ** a written agreement between you and Digia. |
|
14 | 14 | ** |
|
15 | 15 | ** If you have questions regarding the use of this file, please use |
|
16 | 16 | ** contact form at http://qt.digia.com |
|
17 | 17 | ** $QT_END_LICENSE$ |
|
18 | 18 | ** |
|
19 | 19 | ****************************************************************************/ |
|
20 | 20 | |
|
21 | 21 | #include "declarativepieseries.h" |
|
22 | 22 | #include "declarativechart.h" |
|
23 | 23 | #include "qchart.h" |
|
24 | 24 | #include <qdeclarativelist.h> |
|
25 | 25 | #include <QVPieModelMapper> |
|
26 | 26 | #include <QHPieModelMapper> |
|
27 | 27 | |
|
28 | 28 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
29 | 29 | |
|
30 | 30 | DeclarativePieSeries::DeclarativePieSeries(QObject *parent) : |
|
31 | 31 | QPieSeries(parent) |
|
32 | 32 | { |
|
33 | connect(this, SIGNAL(added(QList<QPieSlice*>)), this, SLOT(handleAdded(QList<QPieSlice*>))); | |
|
34 | connect(this, SIGNAL(removed(QList<QPieSlice*>)), this, SLOT(handleRemoved(QList<QPieSlice*>))); | |
|
33 | 35 | } |
|
34 | 36 | |
|
35 | 37 | void DeclarativePieSeries::classBegin() |
|
36 | 38 | { |
|
37 | 39 | } |
|
38 | 40 | |
|
39 | 41 | void DeclarativePieSeries::componentComplete() |
|
40 | 42 | { |
|
41 | 43 | foreach(QObject *child, children()) { |
|
42 | 44 | if (qobject_cast<QPieSlice *>(child)) { |
|
43 | 45 | QPieSeries::append(qobject_cast<QPieSlice *>(child)); |
|
44 | 46 | } else if(qobject_cast<QVPieModelMapper *>(child)) { |
|
45 | 47 | QVPieModelMapper *mapper = qobject_cast<QVPieModelMapper *>(child); |
|
46 | 48 | mapper->setSeries(this); |
|
47 | 49 | } else if(qobject_cast<QHPieModelMapper *>(child)) { |
|
48 | 50 | QHPieModelMapper *mapper = qobject_cast<QHPieModelMapper *>(child); |
|
49 | 51 | mapper->setSeries(this); |
|
50 | 52 | } |
|
51 | 53 | } |
|
52 | 54 | } |
|
53 | 55 | |
|
54 | 56 | QDeclarativeListProperty<QObject> DeclarativePieSeries::seriesChildren() |
|
55 | 57 | { |
|
56 | 58 | return QDeclarativeListProperty<QObject>(this, 0, &DeclarativePieSeries::appendSeriesChildren); |
|
57 | 59 | } |
|
58 | 60 | |
|
59 | 61 | void DeclarativePieSeries::appendSeriesChildren(QDeclarativeListProperty<QObject> * list, QObject *element) |
|
60 | 62 | { |
|
61 | 63 | // Empty implementation; the children are parsed in componentComplete instead |
|
62 | 64 | Q_UNUSED(list); |
|
63 | 65 | Q_UNUSED(element); |
|
64 | 66 | } |
|
65 | 67 | |
|
66 | 68 | QPieSlice *DeclarativePieSeries::at(int index) |
|
67 | 69 | { |
|
68 | 70 | QList<QPieSlice*> sliceList = slices(); |
|
69 | if (index < sliceList.count()) | |
|
71 | if (index >= 0 && index < sliceList.count()) | |
|
70 | 72 | return sliceList[index]; |
|
71 | 73 | |
|
72 | 74 | return 0; |
|
73 | 75 | } |
|
74 | 76 | |
|
75 | 77 | QPieSlice* DeclarativePieSeries::find(QString label) |
|
76 | 78 | { |
|
77 | 79 | foreach (QPieSlice *slice, slices()) { |
|
78 | 80 | if (slice->label() == label) |
|
79 | 81 | return slice; |
|
80 | 82 | } |
|
81 | 83 | return 0; |
|
82 | 84 | } |
|
83 | 85 | |
|
84 | 86 | QPieSlice* DeclarativePieSeries::append(QString label, qreal value) |
|
85 | 87 | { |
|
86 | 88 | // TODO: parameter order is wrong, switch it: |
|
87 | 89 | QPieSlice *slice = new QPieSlice(this); |
|
88 | 90 | slice->setLabel(label); |
|
89 | 91 | slice->setValue(value); |
|
90 | 92 | QPieSeries::append(slice); |
|
91 | 93 | return slice; |
|
92 | 94 | } |
|
93 | 95 | |
|
96 | bool DeclarativePieSeries::remove(int index) | |
|
97 | { | |
|
98 | QPieSlice *slice = at(index); | |
|
99 | if (slice) | |
|
100 | return QPieSeries::remove(slice); | |
|
101 | return false; | |
|
102 | } | |
|
103 | ||
|
104 | void DeclarativePieSeries::clear() | |
|
105 | { | |
|
106 | QPieSeries::clear(); | |
|
107 | } | |
|
108 | ||
|
109 | void DeclarativePieSeries::handleAdded(QList<QPieSlice*> slices) | |
|
110 | { | |
|
111 | foreach(QPieSlice *slice, slices) | |
|
112 | emit sliceAdded(slice); | |
|
113 | } | |
|
114 | ||
|
115 | void DeclarativePieSeries::handleRemoved(QList<QPieSlice*> slices) | |
|
116 | { | |
|
117 | foreach(QPieSlice *slice, slices) | |
|
118 | emit sliceRemoved(slice); | |
|
119 | } | |
|
120 | ||
|
94 | 121 | #include "moc_declarativepieseries.cpp" |
|
95 | 122 | |
|
96 | 123 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -1,59 +1,67 | |||
|
1 | 1 | /**************************************************************************** |
|
2 | 2 | ** |
|
3 | 3 | ** Copyright (C) 2012 Digia Plc |
|
4 | 4 | ** All rights reserved. |
|
5 | 5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
6 | 6 | ** |
|
7 | 7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
8 | 8 | ** |
|
9 | 9 | ** $QT_BEGIN_LICENSE$ |
|
10 | 10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
11 | 11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
12 | 12 | ** Software or, alternatively, in accordance with the terms contained in |
|
13 | 13 | ** a written agreement between you and Digia. |
|
14 | 14 | ** |
|
15 | 15 | ** If you have questions regarding the use of this file, please use |
|
16 | 16 | ** contact form at http://qt.digia.com |
|
17 | 17 | ** $QT_END_LICENSE$ |
|
18 | 18 | ** |
|
19 | 19 | ****************************************************************************/ |
|
20 | 20 | |
|
21 | 21 | #ifndef DECLARATIVEPIESERIES_H |
|
22 | 22 | #define DECLARATIVEPIESERIES_H |
|
23 | 23 | |
|
24 | 24 | #include "qchartglobal.h" |
|
25 | 25 | #include <QPieSlice> |
|
26 | 26 | #include <QPieSeries> |
|
27 | 27 | #include <QDeclarativeParserStatus> |
|
28 | 28 | #include <QDeclarativeListProperty> |
|
29 | 29 | #include <QAbstractItemModel> |
|
30 | 30 | |
|
31 | 31 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
32 | 32 | |
|
33 | 33 | class QChart; |
|
34 | 34 | |
|
35 | 35 | class DeclarativePieSeries : public QPieSeries, public QDeclarativeParserStatus |
|
36 | 36 | { |
|
37 | 37 | Q_OBJECT |
|
38 | 38 | Q_INTERFACES(QDeclarativeParserStatus) |
|
39 | 39 | Q_PROPERTY(QDeclarativeListProperty<QObject> seriesChildren READ seriesChildren) |
|
40 | 40 | Q_CLASSINFO("DefaultProperty", "seriesChildren") |
|
41 | 41 | |
|
42 | 42 | public: |
|
43 | 43 | explicit DeclarativePieSeries(QObject *parent = 0); |
|
44 | 44 | QDeclarativeListProperty<QObject> seriesChildren(); |
|
45 | 45 | Q_INVOKABLE QPieSlice *at(int index); |
|
46 | 46 | Q_INVOKABLE QPieSlice *find(QString label); |
|
47 | 47 | Q_INVOKABLE QPieSlice *append(QString label, qreal value); |
|
48 | Q_INVOKABLE bool remove(int index); | |
|
49 | Q_INVOKABLE void clear(); | |
|
48 | 50 | |
|
49 | 51 | public: |
|
50 | 52 | void classBegin(); |
|
51 | 53 | void componentComplete(); |
|
52 | 54 | |
|
55 | Q_SIGNALS: | |
|
56 | void sliceAdded(QPieSlice* slice); | |
|
57 | void sliceRemoved(QPieSlice* slice); | |
|
58 | ||
|
53 | 59 | public Q_SLOTS: |
|
54 | 60 | static void appendSeriesChildren(QDeclarativeListProperty<QObject> *list, QObject *element); |
|
61 | void handleAdded(QList<QPieSlice*> slices); | |
|
62 | void handleRemoved(QList<QPieSlice*> slices); | |
|
55 | 63 | }; |
|
56 | 64 | |
|
57 | 65 | QTCOMMERCIALCHART_END_NAMESPACE |
|
58 | 66 | |
|
59 | 67 | #endif // DECLARATIVEPIESERIES_H |
@@ -1,654 +1,660 | |||
|
1 | 1 | /**************************************************************************** |
|
2 | 2 | ** |
|
3 | 3 | ** Copyright (C) 2012 Digia Plc |
|
4 | 4 | ** All rights reserved. |
|
5 | 5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
6 | 6 | ** |
|
7 | 7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
8 | 8 | ** |
|
9 | 9 | ** $QT_BEGIN_LICENSE$ |
|
10 | 10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
11 | 11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
12 | 12 | ** Software or, alternatively, in accordance with the terms contained in |
|
13 | 13 | ** a written agreement between you and Digia. |
|
14 | 14 | ** |
|
15 | 15 | ** If you have questions regarding the use of this file, please use |
|
16 | 16 | ** contact form at http://qt.digia.com |
|
17 | 17 | ** $QT_END_LICENSE$ |
|
18 | 18 | ** |
|
19 | 19 | ****************************************************************************/ |
|
20 | 20 | |
|
21 | 21 | #include "qpieseries.h" |
|
22 | 22 | #include "qpieseries_p.h" |
|
23 | 23 | #include "qpieslice.h" |
|
24 | 24 | #include "qpieslice_p.h" |
|
25 | 25 | #include "pieslicedata_p.h" |
|
26 | 26 | #include "chartdataset_p.h" |
|
27 | 27 | #include "charttheme_p.h" |
|
28 | 28 | #include "chartanimator_p.h" |
|
29 | 29 | #include "legendmarker_p.h" |
|
30 | 30 | |
|
31 | 31 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
32 | 32 | |
|
33 | 33 | /*! |
|
34 | 34 | \class QPieSeries |
|
35 | 35 | \brief Pie series API for QtCommercial Charts |
|
36 | 36 | |
|
37 | 37 | The pie series defines a pie chart which consists of pie slices which are defined as QPieSlice objects. |
|
38 | 38 | The slices can have any values as the QPieSeries will calculate its relative value to the sum of all slices. |
|
39 | 39 | The actual slice size is determined by that relative value. |
|
40 | 40 | |
|
41 | 41 | Pie size and position on the chart is controlled by using relative values which range from 0.0 to 1.0 |
|
42 | 42 | These relate to the actual chart rectangle. |
|
43 | 43 | |
|
44 | 44 | By default the pie is defined as a full pie but it can also be a partial pie. |
|
45 | 45 | This can be done by setting a starting angle and angle span to the series. |
|
46 | 46 | Full pie is 360 degrees where 0 is at 12 a'clock. |
|
47 | 47 | |
|
48 | 48 | See the \l {PieChart Example} {pie chart example} to learn how to create a simple pie chart. |
|
49 | 49 | \image examples_piechart.png |
|
50 | 50 | */ |
|
51 | 51 | /*! |
|
52 | 52 | \qmlclass PieSeries QPieSeries |
|
53 | 53 | |
|
54 | 54 | The following QML shows how to create a simple pie chart. |
|
55 | 55 | \snippet ../demos/qmlchart/qml/qmlchart/View1.qml 1 |
|
56 | 56 | \beginfloatleft |
|
57 | 57 | \image demos_qmlchart1.png |
|
58 | 58 | \endfloat |
|
59 | 59 | \clearfloat |
|
60 | 60 | */ |
|
61 | 61 | |
|
62 | 62 | /*! |
|
63 | 63 | \property QPieSeries::horizontalPosition |
|
64 | 64 | \brief Defines the horizontal position of the pie. |
|
65 | 65 | The value is a relative value to the chart rectangle where: |
|
66 | 66 | \list |
|
67 | 67 | \o 0.0 is the absolute left. |
|
68 | 68 | \o 1.0 is the absolute right. |
|
69 | 69 | \endlist |
|
70 | 70 | Default value is 0.5 (center). |
|
71 | 71 | \sa verticalPosition |
|
72 | 72 | */ |
|
73 | 73 | /*! |
|
74 | 74 | \qmlproperty real PieSeries::horizontalPosition |
|
75 | 75 | Defines the horizontal position of the pie. The value is a relative value to the chart rectangle where: |
|
76 | 76 | \list |
|
77 | 77 | \o 0.0 is the absolute left. |
|
78 | 78 | \o 1.0 is the absolute right. |
|
79 | 79 | \endlist |
|
80 | 80 | Default value is 0.5 (center). |
|
81 | 81 | \sa verticalPosition |
|
82 | 82 | */ |
|
83 | 83 | |
|
84 | 84 | /*! |
|
85 | 85 | \property QPieSeries::verticalPosition |
|
86 | 86 | \brief Defines the vertical position of the pie. |
|
87 | 87 | The value is a relative value to the chart rectangle where: |
|
88 | 88 | \list |
|
89 | 89 | \o 0.0 is the absolute top. |
|
90 | 90 | \o 1.0 is the absolute bottom. |
|
91 | 91 | \endlist |
|
92 | 92 | Default value is 0.5 (center). |
|
93 | 93 | \sa horizontalPosition |
|
94 | 94 | */ |
|
95 | 95 | /*! |
|
96 | 96 | \qmlproperty real PieSeries::verticalPosition |
|
97 | 97 | Defines the vertical position of the pie. The value is a relative value to the chart rectangle where: |
|
98 | 98 | \list |
|
99 | 99 | \o 0.0 is the absolute top. |
|
100 | 100 | \o 1.0 is the absolute bottom. |
|
101 | 101 | \endlist |
|
102 | 102 | Default value is 0.5 (center). |
|
103 | 103 | \sa horizontalPosition |
|
104 | 104 | */ |
|
105 | 105 | |
|
106 | 106 | /*! |
|
107 | 107 | \property QPieSeries::size |
|
108 | 108 | \brief Defines the pie size. |
|
109 | 109 | |
|
110 | 110 | The value is a relative value to the chart rectangle where: |
|
111 | 111 | |
|
112 | 112 | \list |
|
113 | 113 | \o 0.0 is the minimum size (pie not drawn). |
|
114 | 114 | \o 1.0 is the maximum size that can fit the chart. |
|
115 | 115 | \endlist |
|
116 | 116 | |
|
117 | 117 | Default value is 0.7. |
|
118 | 118 | */ |
|
119 | 119 | |
|
120 | 120 | /*! |
|
121 | 121 | \property QPieSeries::startAngle |
|
122 | 122 | \brief Defines the starting angle of the pie. |
|
123 | 123 | |
|
124 | 124 | Full pie is 360 degrees where 0 degrees is at 12 a'clock. |
|
125 | 125 | |
|
126 | 126 | Default is value is 0. |
|
127 | 127 | */ |
|
128 | 128 | |
|
129 | 129 | /*! |
|
130 | 130 | \property QPieSeries::endAngle |
|
131 | 131 | \brief Defines the ending angle of the pie. |
|
132 | 132 | |
|
133 | 133 | Full pie is 360 degrees where 0 degrees is at 12 a'clock. |
|
134 | 134 | |
|
135 | 135 | Default is value is 360. |
|
136 | 136 | */ |
|
137 | 137 | |
|
138 | 138 | /*! |
|
139 | 139 | \property QPieSeries::count |
|
140 | 140 | |
|
141 | 141 | Number of slices in the series. |
|
142 | 142 | */ |
|
143 | 143 | |
|
144 | 144 | /*! |
|
145 | 145 | \fn void QPieSeries::countChanged() |
|
146 | 146 | |
|
147 | 147 | Emitted when the slice count has changed. |
|
148 | 148 | |
|
149 | 149 | \sa count |
|
150 | 150 | */ |
|
151 | 151 | |
|
152 | 152 | /*! |
|
153 | 153 | \property QPieSeries::sum |
|
154 | 154 | |
|
155 | 155 | Sum of all slices. |
|
156 | 156 | |
|
157 | 157 | The series keeps track of the sum of all slices it holds. |
|
158 | 158 | */ |
|
159 | 159 | |
|
160 | 160 | /*! |
|
161 | 161 | \fn void QPieSeries::sumChanged() |
|
162 | 162 | |
|
163 | 163 | Emitted when the sum of all slices has changed. |
|
164 | 164 | |
|
165 | 165 | \sa sum |
|
166 | 166 | */ |
|
167 | 167 | |
|
168 | 168 | /*! |
|
169 | 169 | \fn void QPieSeries::added(QList<QPieSlice*> slices) |
|
170 | 170 | |
|
171 | 171 | This signal is emitted when \a slices have been added to the series. |
|
172 | 172 | |
|
173 | 173 | \sa append(), insert() |
|
174 | 174 | */ |
|
175 | /*! | |
|
176 | \qmlsignal PieSeries::added(PieSlice slice) | |
|
177 | Emitted when \a slice has been added to the series. | |
|
178 | */ | |
|
175 | 179 | |
|
176 | 180 | /*! |
|
177 | 181 | \fn void QPieSeries::removed(QList<QPieSlice*> slices) |
|
178 | ||
|
179 | 182 | This signal is emitted when \a slices have been removed from the series. |
|
180 | ||
|
181 | 183 | \sa remove() |
|
182 | 184 | */ |
|
185 | /*! | |
|
186 | \qmlsignal PieSeries::removed(PieSlice slice) | |
|
187 | Emitted when \a slice has been removed from the series. | |
|
188 | */ | |
|
183 | 189 | |
|
184 | 190 | /*! |
|
185 | 191 | \fn void QPieSeries::clicked(QPieSlice* slice) |
|
186 | 192 | |
|
187 | 193 | This signal is emitted when a \a slice has been clicked. |
|
188 | 194 | |
|
189 | 195 | \sa QPieSlice::clicked() |
|
190 | 196 | */ |
|
191 | 197 | |
|
192 | 198 | /*! |
|
193 | 199 | \fn void QPieSeries::hovered(QPieSlice* slice, bool state) |
|
194 | 200 | |
|
195 | 201 | This signal is emitted when user has hovered over or away from the \a slice. |
|
196 | 202 | |
|
197 | 203 | \a state is true when user has hovered over the slice and false when hover has moved away from the slice. |
|
198 | 204 | |
|
199 | 205 | \sa QPieSlice::hovered() |
|
200 | 206 | */ |
|
201 | 207 | |
|
202 | 208 | /*! |
|
203 | 209 | Constructs a series object which is a child of \a parent. |
|
204 | 210 | */ |
|
205 | 211 | QPieSeries::QPieSeries(QObject *parent) : |
|
206 | 212 | QAbstractSeries(*new QPieSeriesPrivate(this),parent) |
|
207 | 213 | { |
|
208 | 214 | |
|
209 | 215 | } |
|
210 | 216 | |
|
211 | 217 | /*! |
|
212 | 218 | Destroys the series and its slices. |
|
213 | 219 | */ |
|
214 | 220 | QPieSeries::~QPieSeries() |
|
215 | 221 | { |
|
216 | 222 | // NOTE: d_prt destroyed by QObject |
|
217 | 223 | } |
|
218 | 224 | |
|
219 | 225 | /*! |
|
220 | 226 | Returns QChartSeries::SeriesTypePie. |
|
221 | 227 | */ |
|
222 | 228 | QAbstractSeries::SeriesType QPieSeries::type() const |
|
223 | 229 | { |
|
224 | 230 | return QAbstractSeries::SeriesTypePie; |
|
225 | 231 | } |
|
226 | 232 | |
|
227 | 233 | /*! |
|
228 | 234 | Appends a single \a slice to the series. |
|
229 | 235 | Slice ownership is passed to the series. |
|
230 | 236 | |
|
231 | 237 | Returns true if append was succesfull. |
|
232 | 238 | */ |
|
233 | 239 | bool QPieSeries::append(QPieSlice* slice) |
|
234 | 240 | { |
|
235 | 241 | return append(QList<QPieSlice*>() << slice); |
|
236 | 242 | } |
|
237 | 243 | |
|
238 | 244 | /*! |
|
239 | 245 | Appends an array of \a slices to the series. |
|
240 | 246 | Slice ownership is passed to the series. |
|
241 | 247 | |
|
242 | 248 | Returns true if append was successfull. |
|
243 | 249 | */ |
|
244 | 250 | bool QPieSeries::append(QList<QPieSlice*> slices) |
|
245 | 251 | { |
|
246 | 252 | Q_D(QPieSeries); |
|
247 | 253 | |
|
248 | 254 | if (slices.count() == 0) |
|
249 | 255 | return false; |
|
250 | 256 | |
|
251 | 257 | foreach (QPieSlice* s, slices) { |
|
252 | 258 | if (!s || d->m_slices.contains(s)) |
|
253 | 259 | return false; |
|
254 | 260 | if (s->series()) // already added to some series |
|
255 | 261 | return false; |
|
256 | 262 | } |
|
257 | 263 | |
|
258 | 264 | foreach (QPieSlice* s, slices) { |
|
259 | 265 | s->setParent(this); |
|
260 | 266 | QPieSlicePrivate::fromSlice(s)->m_series = this; |
|
261 | 267 | d->m_slices << s; |
|
262 | 268 | } |
|
263 | 269 | |
|
264 | 270 | d->updateDerivativeData(); |
|
265 | 271 | |
|
266 | 272 | foreach (QPieSlice* s, slices) { |
|
267 | 273 | connect(s, SIGNAL(valueChanged()), d, SLOT(sliceValueChanged())); |
|
268 | 274 | connect(s, SIGNAL(clicked()), d, SLOT(sliceClicked())); |
|
269 | 275 | connect(s, SIGNAL(hovered(bool)), d, SLOT(sliceHovered(bool))); |
|
270 | 276 | } |
|
271 | 277 | |
|
272 | 278 | emit added(slices); |
|
273 | 279 | emit countChanged(); |
|
274 | 280 | |
|
275 | 281 | return true; |
|
276 | 282 | } |
|
277 | 283 | |
|
278 | 284 | /*! |
|
279 | 285 | Appends a single \a slice to the series and returns a reference to the series. |
|
280 | 286 | Slice ownership is passed to the series. |
|
281 | 287 | */ |
|
282 | 288 | QPieSeries& QPieSeries::operator << (QPieSlice* slice) |
|
283 | 289 | { |
|
284 | 290 | append(slice); |
|
285 | 291 | return *this; |
|
286 | 292 | } |
|
287 | 293 | |
|
288 | 294 | |
|
289 | 295 | /*! |
|
290 | 296 | Appends a single slice to the series with give \a value and \a label. |
|
291 | 297 | Slice ownership is passed to the series. |
|
292 | 298 | */ |
|
293 | 299 | QPieSlice* QPieSeries::append(QString label, qreal value) |
|
294 | 300 | { |
|
295 | 301 | QPieSlice* slice = new QPieSlice(label, value); |
|
296 | 302 | append(slice); |
|
297 | 303 | return slice; |
|
298 | 304 | } |
|
299 | 305 | |
|
300 | 306 | /*! |
|
301 | 307 | Inserts a single \a slice to the series before the slice at \a index position. |
|
302 | 308 | Slice ownership is passed to the series. |
|
303 | 309 | |
|
304 | 310 | Returns true if insert was successfull. |
|
305 | 311 | */ |
|
306 | 312 | bool QPieSeries::insert(int index, QPieSlice* slice) |
|
307 | 313 | { |
|
308 | 314 | Q_D(QPieSeries); |
|
309 | 315 | |
|
310 | 316 | if (index < 0 || index > d->m_slices.count()) |
|
311 | 317 | return false; |
|
312 | 318 | |
|
313 | 319 | if (!slice || d->m_slices.contains(slice)) |
|
314 | 320 | return false; |
|
315 | 321 | |
|
316 | 322 | if (slice->series()) // already added to some series |
|
317 | 323 | return false; |
|
318 | 324 | |
|
319 | 325 | slice->setParent(this); |
|
320 | 326 | QPieSlicePrivate::fromSlice(slice)->m_series = this; |
|
321 | 327 | d->m_slices.insert(index, slice); |
|
322 | 328 | |
|
323 | 329 | d->updateDerivativeData(); |
|
324 | 330 | |
|
325 | 331 | connect(slice, SIGNAL(valueChanged()), d, SLOT(sliceValueChanged())); |
|
326 | 332 | connect(slice, SIGNAL(clicked()), d, SLOT(sliceClicked())); |
|
327 | 333 | connect(slice, SIGNAL(hovered(bool)), d, SLOT(sliceHovered(bool))); |
|
328 | 334 | |
|
329 | 335 | emit added(QList<QPieSlice*>() << slice); |
|
330 | 336 | emit countChanged(); |
|
331 | 337 | |
|
332 | 338 | return true; |
|
333 | 339 | } |
|
334 | 340 | |
|
335 | 341 | /*! |
|
336 | 342 | Removes a single \a slice from the series and deletes the slice. |
|
337 | 343 | |
|
338 | 344 | Do not reference the pointer after this call. |
|
339 | 345 | |
|
340 | 346 | Returns true if remove was successfull. |
|
341 | 347 | */ |
|
342 | 348 | bool QPieSeries::remove(QPieSlice* slice) |
|
343 | 349 | { |
|
344 | 350 | Q_D(QPieSeries); |
|
345 | 351 | |
|
346 | 352 | if (!d->m_slices.removeOne(slice)) |
|
347 | 353 | return false; |
|
348 | 354 | |
|
349 | 355 | d->updateDerivativeData(); |
|
350 | 356 | |
|
351 | 357 | emit removed(QList<QPieSlice*>() << slice); |
|
352 | 358 | emit countChanged(); |
|
353 | 359 | |
|
354 | 360 | delete slice; |
|
355 | 361 | slice = 0; |
|
356 | 362 | |
|
357 | 363 | return true; |
|
358 | 364 | } |
|
359 | 365 | |
|
360 | 366 | /*! |
|
361 | 367 | Clears all slices from the series. |
|
362 | 368 | */ |
|
363 | 369 | void QPieSeries::clear() |
|
364 | 370 | { |
|
365 | 371 | Q_D(QPieSeries); |
|
366 | 372 | if (d->m_slices.count() == 0) |
|
367 | 373 | return; |
|
368 | 374 | |
|
369 | 375 | QList<QPieSlice*> slices = d->m_slices; |
|
370 | 376 | foreach (QPieSlice* s, d->m_slices) { |
|
371 | 377 | d->m_slices.removeOne(s); |
|
372 | 378 | delete s; |
|
373 | 379 | } |
|
374 | 380 | |
|
375 | 381 | d->updateDerivativeData(); |
|
376 | 382 | |
|
377 | 383 | emit removed(slices); |
|
378 | 384 | emit countChanged(); |
|
379 | 385 | } |
|
380 | 386 | |
|
381 | 387 | /*! |
|
382 | 388 | Returns a list of slices that belong to this series. |
|
383 | 389 | */ |
|
384 | 390 | QList<QPieSlice*> QPieSeries::slices() const |
|
385 | 391 | { |
|
386 | 392 | Q_D(const QPieSeries); |
|
387 | 393 | return d->m_slices; |
|
388 | 394 | } |
|
389 | 395 | |
|
390 | 396 | /*! |
|
391 | 397 | returns the number of the slices in this series. |
|
392 | 398 | */ |
|
393 | 399 | int QPieSeries::count() const |
|
394 | 400 | { |
|
395 | 401 | Q_D(const QPieSeries); |
|
396 | 402 | return d->m_slices.count(); |
|
397 | 403 | } |
|
398 | 404 | |
|
399 | 405 | /*! |
|
400 | 406 | Returns true is the series is empty. |
|
401 | 407 | */ |
|
402 | 408 | bool QPieSeries::isEmpty() const |
|
403 | 409 | { |
|
404 | 410 | Q_D(const QPieSeries); |
|
405 | 411 | return d->m_slices.isEmpty(); |
|
406 | 412 | } |
|
407 | 413 | |
|
408 | 414 | /*! |
|
409 | 415 | Returns the sum of all slice values in this series. |
|
410 | 416 | |
|
411 | 417 | \sa QPieSlice::value(), QPieSlice::setValue(), QPieSlice::percentage() |
|
412 | 418 | */ |
|
413 | 419 | qreal QPieSeries::sum() const |
|
414 | 420 | { |
|
415 | 421 | Q_D(const QPieSeries); |
|
416 | 422 | return d->m_sum; |
|
417 | 423 | } |
|
418 | 424 | |
|
419 | 425 | void QPieSeries::setHorizontalPosition(qreal relativePosition) |
|
420 | 426 | { |
|
421 | 427 | Q_D(QPieSeries); |
|
422 | 428 | |
|
423 | 429 | if (relativePosition < 0.0) |
|
424 | 430 | relativePosition = 0.0; |
|
425 | 431 | if (relativePosition > 1.0) |
|
426 | 432 | relativePosition = 1.0; |
|
427 | 433 | |
|
428 | 434 | if (!qFuzzyIsNull(d->m_pieRelativeHorPos - relativePosition)) { |
|
429 | 435 | d->m_pieRelativeHorPos = relativePosition; |
|
430 | 436 | emit d->horizontalPositionChanged(); |
|
431 | 437 | } |
|
432 | 438 | } |
|
433 | 439 | |
|
434 | 440 | qreal QPieSeries::horizontalPosition() const |
|
435 | 441 | { |
|
436 | 442 | Q_D(const QPieSeries); |
|
437 | 443 | return d->m_pieRelativeHorPos; |
|
438 | 444 | } |
|
439 | 445 | |
|
440 | 446 | void QPieSeries::setVerticalPosition(qreal relativePosition) |
|
441 | 447 | { |
|
442 | 448 | Q_D(QPieSeries); |
|
443 | 449 | |
|
444 | 450 | if (relativePosition < 0.0) |
|
445 | 451 | relativePosition = 0.0; |
|
446 | 452 | if (relativePosition > 1.0) |
|
447 | 453 | relativePosition = 1.0; |
|
448 | 454 | |
|
449 | 455 | if (!qFuzzyIsNull(d->m_pieRelativeVerPos - relativePosition)) { |
|
450 | 456 | d->m_pieRelativeVerPos = relativePosition; |
|
451 | 457 | emit d->verticalPositionChanged(); |
|
452 | 458 | } |
|
453 | 459 | } |
|
454 | 460 | |
|
455 | 461 | qreal QPieSeries::verticalPosition() const |
|
456 | 462 | { |
|
457 | 463 | Q_D(const QPieSeries); |
|
458 | 464 | return d->m_pieRelativeVerPos; |
|
459 | 465 | } |
|
460 | 466 | |
|
461 | 467 | void QPieSeries::setPieSize(qreal relativeSize) |
|
462 | 468 | { |
|
463 | 469 | Q_D(QPieSeries); |
|
464 | 470 | |
|
465 | 471 | if (relativeSize < 0.0) |
|
466 | 472 | relativeSize = 0.0; |
|
467 | 473 | if (relativeSize > 1.0) |
|
468 | 474 | relativeSize = 1.0; |
|
469 | 475 | |
|
470 | 476 | if (!qFuzzyIsNull(d->m_pieRelativeSize - relativeSize)) { |
|
471 | 477 | d->m_pieRelativeSize = relativeSize; |
|
472 | 478 | emit d->pieSizeChanged(); |
|
473 | 479 | } |
|
474 | 480 | } |
|
475 | 481 | |
|
476 | 482 | qreal QPieSeries::pieSize() const |
|
477 | 483 | { |
|
478 | 484 | Q_D(const QPieSeries); |
|
479 | 485 | return d->m_pieRelativeSize; |
|
480 | 486 | } |
|
481 | 487 | |
|
482 | 488 | |
|
483 | 489 | void QPieSeries::setPieStartAngle(qreal angle) |
|
484 | 490 | { |
|
485 | 491 | Q_D(QPieSeries); |
|
486 | 492 | if (qFuzzyIsNull(d->m_pieStartAngle - angle)) |
|
487 | 493 | return; |
|
488 | 494 | d->m_pieStartAngle = angle; |
|
489 | 495 | d->updateDerivativeData(); |
|
490 | 496 | emit d->pieStartAngleChanged(); |
|
491 | 497 | } |
|
492 | 498 | |
|
493 | 499 | qreal QPieSeries::pieStartAngle() const |
|
494 | 500 | { |
|
495 | 501 | Q_D(const QPieSeries); |
|
496 | 502 | return d->m_pieStartAngle; |
|
497 | 503 | } |
|
498 | 504 | |
|
499 | 505 | /*! |
|
500 | 506 | Sets the end angle of the pie. |
|
501 | 507 | |
|
502 | 508 | Full pie is 360 degrees where 0 degrees is at 12 a'clock. |
|
503 | 509 | |
|
504 | 510 | \a angle must be greater than start angle. |
|
505 | 511 | |
|
506 | 512 | \sa pieEndAngle(), pieStartAngle(), setPieStartAngle() |
|
507 | 513 | */ |
|
508 | 514 | void QPieSeries::setPieEndAngle(qreal angle) |
|
509 | 515 | { |
|
510 | 516 | Q_D(QPieSeries); |
|
511 | 517 | if (qFuzzyIsNull(d->m_pieEndAngle - angle)) |
|
512 | 518 | return; |
|
513 | 519 | d->m_pieEndAngle = angle; |
|
514 | 520 | d->updateDerivativeData(); |
|
515 | 521 | emit d->pieEndAngleChanged(); |
|
516 | 522 | } |
|
517 | 523 | |
|
518 | 524 | /*! |
|
519 | 525 | Returns the end angle of the pie. |
|
520 | 526 | |
|
521 | 527 | Full pie is 360 degrees where 0 degrees is at 12 a'clock. |
|
522 | 528 | |
|
523 | 529 | \sa setPieEndAngle(), pieStartAngle(), setPieStartAngle() |
|
524 | 530 | */ |
|
525 | 531 | qreal QPieSeries::pieEndAngle() const |
|
526 | 532 | { |
|
527 | 533 | Q_D(const QPieSeries); |
|
528 | 534 | return d->m_pieEndAngle; |
|
529 | 535 | } |
|
530 | 536 | |
|
531 | 537 | /*! |
|
532 | 538 | Sets the all the slice labels \a visible or invisible. |
|
533 | 539 | |
|
534 | 540 | Note that this affects only the current slices in the series. |
|
535 | 541 | If user adds a new slice the default label visibility is false. |
|
536 | 542 | |
|
537 | 543 | \sa QPieSlice::isLabelVisible(), QPieSlice::setLabelVisible() |
|
538 | 544 | */ |
|
539 | 545 | void QPieSeries::setLabelsVisible(bool visible) |
|
540 | 546 | { |
|
541 | 547 | Q_D(QPieSeries); |
|
542 | 548 | foreach (QPieSlice* s, d->m_slices) |
|
543 | 549 | s->setLabelVisible(visible); |
|
544 | 550 | } |
|
545 | 551 | |
|
546 | 552 | /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
|
547 | 553 | |
|
548 | 554 | |
|
549 | 555 | QPieSeriesPrivate::QPieSeriesPrivate(QPieSeries *parent) : |
|
550 | 556 | QAbstractSeriesPrivate(parent), |
|
551 | 557 | m_pieRelativeHorPos(0.5), |
|
552 | 558 | m_pieRelativeVerPos(0.5), |
|
553 | 559 | m_pieRelativeSize(0.7), |
|
554 | 560 | m_pieStartAngle(0), |
|
555 | 561 | m_pieEndAngle(360), |
|
556 | 562 | m_sum(0) |
|
557 | 563 | { |
|
558 | 564 | } |
|
559 | 565 | |
|
560 | 566 | QPieSeriesPrivate::~QPieSeriesPrivate() |
|
561 | 567 | { |
|
562 | 568 | } |
|
563 | 569 | |
|
564 | 570 | void QPieSeriesPrivate::updateDerivativeData() |
|
565 | 571 | { |
|
566 | 572 | // calculate sum of all slices |
|
567 | 573 | qreal sum = 0; |
|
568 | 574 | foreach (QPieSlice* s, m_slices) |
|
569 | 575 | sum += s->value(); |
|
570 | 576 | |
|
571 | 577 | if (!qFuzzyIsNull(m_sum - sum)) { |
|
572 | 578 | m_sum = sum; |
|
573 | 579 | emit q_func()->sumChanged(); |
|
574 | 580 | } |
|
575 | 581 | |
|
576 | 582 | // nothing to show.. |
|
577 | 583 | if (qFuzzyIsNull(m_sum)) |
|
578 | 584 | return; |
|
579 | 585 | |
|
580 | 586 | // update slice attributes |
|
581 | 587 | qreal sliceAngle = m_pieStartAngle; |
|
582 | 588 | qreal pieSpan = m_pieEndAngle - m_pieStartAngle; |
|
583 | 589 | QVector<QPieSlice*> changed; |
|
584 | 590 | foreach (QPieSlice* s, m_slices) { |
|
585 | 591 | QPieSlicePrivate *d = QPieSlicePrivate::fromSlice(s); |
|
586 | 592 | d->setPercentage(s->value() / m_sum); |
|
587 | 593 | d->setStartAngle(sliceAngle); |
|
588 | 594 | d->setAngleSpan(pieSpan * s->percentage()); |
|
589 | 595 | sliceAngle += s->angleSpan(); |
|
590 | 596 | } |
|
591 | 597 | |
|
592 | 598 | |
|
593 | 599 | emit calculatedDataChanged(); |
|
594 | 600 | } |
|
595 | 601 | |
|
596 | 602 | QPieSeriesPrivate* QPieSeriesPrivate::fromSeries(QPieSeries *series) |
|
597 | 603 | { |
|
598 | 604 | return series->d_func(); |
|
599 | 605 | } |
|
600 | 606 | |
|
601 | 607 | void QPieSeriesPrivate::sliceValueChanged() |
|
602 | 608 | { |
|
603 | 609 | Q_ASSERT(m_slices.contains(qobject_cast<QPieSlice *>(sender()))); |
|
604 | 610 | updateDerivativeData(); |
|
605 | 611 | } |
|
606 | 612 | |
|
607 | 613 | void QPieSeriesPrivate::sliceClicked() |
|
608 | 614 | { |
|
609 | 615 | QPieSlice* slice = qobject_cast<QPieSlice *>(sender()); |
|
610 | 616 | Q_ASSERT(m_slices.contains(slice)); |
|
611 | 617 | Q_Q(QPieSeries); |
|
612 | 618 | emit q->clicked(slice); |
|
613 | 619 | } |
|
614 | 620 | |
|
615 | 621 | void QPieSeriesPrivate::sliceHovered(bool state) |
|
616 | 622 | { |
|
617 | 623 | QPieSlice* slice = qobject_cast<QPieSlice *>(sender()); |
|
618 | 624 | Q_ASSERT(m_slices.contains(slice)); |
|
619 | 625 | Q_Q(QPieSeries); |
|
620 | 626 | emit q->hovered(slice, state); |
|
621 | 627 | } |
|
622 | 628 | |
|
623 | 629 | void QPieSeriesPrivate::scaleDomain(Domain& domain) |
|
624 | 630 | { |
|
625 | 631 | Q_UNUSED(domain); |
|
626 | 632 | // does not apply to pie |
|
627 | 633 | } |
|
628 | 634 | |
|
629 | 635 | Chart* QPieSeriesPrivate::createGraphics(ChartPresenter* presenter) |
|
630 | 636 | { |
|
631 | 637 | Q_Q(QPieSeries); |
|
632 | 638 | PieChartItem* pie = new PieChartItem(q,presenter); |
|
633 | 639 | if(presenter->animationOptions().testFlag(QChart::SeriesAnimations)) { |
|
634 | 640 | presenter->animator()->addAnimation(pie); |
|
635 | 641 | } |
|
636 | 642 | presenter->chartTheme()->decorate(q, presenter->dataSet()->seriesIndex(q)); |
|
637 | 643 | return pie; |
|
638 | 644 | } |
|
639 | 645 | |
|
640 | 646 | QList<LegendMarker*> QPieSeriesPrivate::createLegendMarker(QLegend* legend) |
|
641 | 647 | { |
|
642 | 648 | Q_Q(QPieSeries); |
|
643 | 649 | QList<LegendMarker*> markers; |
|
644 | 650 | foreach(QPieSlice* slice, q->slices()) { |
|
645 | 651 | PieLegendMarker* marker = new PieLegendMarker(q,slice,legend); |
|
646 | 652 | markers << marker; |
|
647 | 653 | } |
|
648 | 654 | return markers; |
|
649 | 655 | } |
|
650 | 656 | |
|
651 | 657 | #include "moc_qpieseries.cpp" |
|
652 | 658 | #include "moc_qpieseries_p.cpp" |
|
653 | 659 | |
|
654 | 660 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -1,66 +1,72 | |||
|
1 | 1 | /**************************************************************************** |
|
2 | 2 | ** |
|
3 | 3 | ** Copyright (C) 2012 Digia Plc |
|
4 | 4 | ** All rights reserved. |
|
5 | 5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
6 | 6 | ** |
|
7 | 7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
8 | 8 | ** |
|
9 | 9 | ** $QT_BEGIN_LICENSE$ |
|
10 | 10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
11 | 11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
12 | 12 | ** Software or, alternatively, in accordance with the terms contained in |
|
13 | 13 | ** a written agreement between you and Digia. |
|
14 | 14 | ** |
|
15 | 15 | ** If you have questions regarding the use of this file, please use |
|
16 | 16 | ** contact form at http://qt.digia.com |
|
17 | 17 | ** $QT_END_LICENSE$ |
|
18 | 18 | ** |
|
19 | 19 | ****************************************************************************/ |
|
20 | 20 | |
|
21 | 21 | import QtQuick 1.0 |
|
22 | 22 | import QtCommercial.Chart 1.0 |
|
23 | 23 | |
|
24 | 24 | ChartView { |
|
25 | 25 | title: "area series" |
|
26 | 26 | anchors.fill: parent |
|
27 | 27 | axisXLabels: ["0", "2000", "1", "2001", "2", "2002", "3", "2003", "4", "2004", "5", "2005", |
|
28 | 28 | "6", "2006", "7", "2007", "8", "2008", "9", "2009", "10", "2010", "11", "2011"] |
|
29 | 29 | |
|
30 |
property variant series: |
|
|
30 | property variant series: areaSeries | |
|
31 | 31 | |
|
32 | 32 | AreaSeries { |
|
33 |
id: |
|
|
33 | id: areaSeries | |
|
34 | 34 | name: "area 1" |
|
35 | onSelected: console.log("areaSeries.onSelected"); | |
|
36 | onClicked: console.log("areaSeries.onClicked: " + point.x + ", " + point.y); | |
|
37 | 35 | upperSeries: LineSeries { |
|
38 | 36 | XyPoint { x: 0; y: 1 } |
|
39 | 37 | XyPoint { x: 1; y: 1 } |
|
40 | 38 | XyPoint { x: 2; y: 3 } |
|
41 | 39 | XyPoint { x: 3; y: 3 } |
|
42 | 40 | XyPoint { x: 4; y: 2 } |
|
43 | 41 | XyPoint { x: 5; y: 0 } |
|
44 | 42 | XyPoint { x: 6; y: 2 } |
|
45 | 43 | XyPoint { x: 7; y: 1 } |
|
46 | 44 | XyPoint { x: 8; y: 2 } |
|
47 | 45 | XyPoint { x: 9; y: 1 } |
|
48 | 46 | XyPoint { x: 10; y: 3 } |
|
49 | 47 | XyPoint { x: 11; y: 3 } |
|
50 | 48 | } |
|
51 | 49 | lowerSeries: LineSeries { |
|
52 | 50 | XyPoint { x: 0; y: 0 } |
|
53 | 51 | XyPoint { x: 1; y: 0 } |
|
54 | 52 | XyPoint { x: 2; y: 0 } |
|
55 | 53 | XyPoint { x: 3; y: 0 } |
|
56 | 54 | XyPoint { x: 4; y: 0 } |
|
57 | 55 | XyPoint { x: 5; y: 0 } |
|
58 | 56 | XyPoint { x: 6; y: 0 } |
|
59 | 57 | XyPoint { x: 7; y: 0 } |
|
60 | 58 | XyPoint { x: 8; y: 0 } |
|
61 | 59 | XyPoint { x: 9; y: 0 } |
|
62 | 60 | XyPoint { x: 10; y: 0 } |
|
63 | 61 | XyPoint { x: 11; y: 0 } |
|
64 | 62 | } |
|
63 | ||
|
64 | onNameChanged: console.log("areaSeries.onNameChanged: " + name); | |
|
65 | onVisibleChanged: console.log("areaSeries.onVisibleChanged: " + visible); | |
|
66 | onClicked: console.log("areaSeries.onClicked: " + point.x + ", " + point.y); | |
|
67 | onSelected: console.log("areaSeries.onSelected"); | |
|
68 | onColorChanged: console.log("areaSeries.onColorChanged: " + color); | |
|
69 | onBorderColorChanged: console.log("areaSeries.onBorderColorChanged: " + borderColor); | |
|
70 | // onCountChanged: console.log("areaSeries.onCountChanged: " + count); | |
|
65 | 71 | } |
|
66 | 72 | } |
@@ -1,77 +1,59 | |||
|
1 | 1 | /**************************************************************************** |
|
2 | 2 | ** |
|
3 | 3 | ** Copyright (C) 2012 Digia Plc |
|
4 | 4 | ** All rights reserved. |
|
5 | 5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
6 | 6 | ** |
|
7 | 7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
8 | 8 | ** |
|
9 | 9 | ** $QT_BEGIN_LICENSE$ |
|
10 | 10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
11 | 11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
12 | 12 | ** Software or, alternatively, in accordance with the terms contained in |
|
13 | 13 | ** a written agreement between you and Digia. |
|
14 | 14 | ** |
|
15 | 15 | ** If you have questions regarding the use of this file, please use |
|
16 | 16 | ** contact form at http://qt.digia.com |
|
17 | 17 | ** $QT_END_LICENSE$ |
|
18 | 18 | ** |
|
19 | 19 | ****************************************************************************/ |
|
20 | 20 | |
|
21 | 21 | import QtQuick 1.0 |
|
22 | 22 | import QtCommercial.Chart 1.0 |
|
23 | 23 | |
|
24 | 24 | |
|
25 | 25 | Flow { |
|
26 | 26 | id: flow |
|
27 | 27 | spacing: 5 |
|
28 | 28 | flow: Flow.TopToBottom |
|
29 | 29 | property variant series |
|
30 | 30 | |
|
31 | onSeriesChanged: { | |
|
32 | if (series && series.name == "area 1") { | |
|
33 | seriesConnections.target = series; | |
|
34 | } else { | |
|
35 | seriesConnections.target = null; | |
|
36 | } | |
|
37 | } | |
|
38 | ||
|
39 | Connections { | |
|
40 | id: seriesConnections | |
|
41 | target: null | |
|
42 | onNameChanged: console.log("series.onNameChanged: " + series.name); | |
|
43 | onVisibleChanged: console.log("series.onVisibleChanged: " + series.visible); | |
|
44 | onColorChanged: console.log("series.onColorChanged: " + series.color); | |
|
45 | onBorderColorChanged: console.log("series.onBorderColorChanged: " + series.borderColor); | |
|
46 | onCountChanged: console.log("series.onCountChanged: " + series.count); | |
|
47 | } | |
|
48 | ||
|
49 | 31 | Button { |
|
50 | 32 | text: "visible" |
|
51 | 33 | onClicked: series.visible = !series.visible; |
|
52 | 34 | } |
|
53 | 35 | Button { |
|
54 | 36 | text: "color" |
|
55 | 37 | onClicked: series.color = main.nextColor(); |
|
56 | 38 | } |
|
57 | 39 | Button { |
|
58 | 40 | text: "borderColor" |
|
59 | 41 | onClicked: series.borderColor = main.nextColor(); |
|
60 | 42 | } |
|
61 | 43 | Button { |
|
62 | 44 | text: "upper color" |
|
63 | 45 | onClicked: series.upperSeries.color = main.nextColor(); |
|
64 | 46 | } |
|
65 | 47 | Button { |
|
66 | 48 | text: "lower color" |
|
67 | 49 | onClicked: series.lowerSeries.color = main.nextColor(); |
|
68 | 50 | } |
|
69 | 51 | Button { |
|
70 | 52 | text: "upper points visible" |
|
71 | 53 | onClicked: series.upperSeries.pointsVisible = !series.pointsVisible; |
|
72 | 54 | } |
|
73 | 55 | Button { |
|
74 | 56 | text: "lower points visible" |
|
75 | 57 | onClicked: series.lowerSeries.pointsVisible = !series.pointsVisible; |
|
76 | 58 | } |
|
77 | 59 | } |
@@ -1,45 +1,54 | |||
|
1 | 1 | /**************************************************************************** |
|
2 | 2 | ** |
|
3 | 3 | ** Copyright (C) 2012 Digia Plc |
|
4 | 4 | ** All rights reserved. |
|
5 | 5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
6 | 6 | ** |
|
7 | 7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
8 | 8 | ** |
|
9 | 9 | ** $QT_BEGIN_LICENSE$ |
|
10 | 10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
11 | 11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
12 | 12 | ** Software or, alternatively, in accordance with the terms contained in |
|
13 | 13 | ** a written agreement between you and Digia. |
|
14 | 14 | ** |
|
15 | 15 | ** If you have questions regarding the use of this file, please use |
|
16 | 16 | ** contact form at http://qt.digia.com |
|
17 | 17 | ** $QT_END_LICENSE$ |
|
18 | 18 | ** |
|
19 | 19 | ****************************************************************************/ |
|
20 | 20 | |
|
21 | 21 | import QtQuick 1.0 |
|
22 | 22 | import QtCommercial.Chart 1.0 |
|
23 | 23 | |
|
24 | 24 | ChartView { |
|
25 | 25 | title: "Bar series" |
|
26 | 26 | anchors.fill: parent |
|
27 | 27 | theme: ChartView.ChartThemeLight |
|
28 | 28 | legend.alignment: Qt.AlignBottom |
|
29 | 29 | axisXLabels: ["0", "2007", "1", "2008", "2", "2009", "3", "2010", "4", "2011", "5", "2012"] |
|
30 | 30 | |
|
31 |
property variant series: |
|
|
31 | property variant series: barSeries | |
|
32 | 32 | |
|
33 | 33 | BarSeries { |
|
34 |
id: |
|
|
34 | id: barSeries | |
|
35 | 35 | name: "bar" |
|
36 | onClicked: console.log("onClicked: " + barset + " " + index); | |
|
37 | onHovered: console.log("onHovered: " + barset + " " + status); | |
|
38 | 36 | BarSet { label: "Bob"; values: [4, 7, 3, 10, 5, 6] |
|
39 | onClicked: console.log("barset.onClicked: " + index); | |
|
40 | onHovered: console.log("barset.onHovered: " + status); | |
|
37 | onClicked: console.log("barset.onClicked: " + index); | |
|
38 | onHovered: console.log("barset.onHovered: " + status); | |
|
39 | onColorChanged: console.log("barset.onColorChanged: " + color); | |
|
40 | onBorderColorChanged: console.log("barset.onBorderColorChanged: " + color); | |
|
41 | onLabelColorChanged: console.log("barset.onLabelColorChanged: " + color); | |
|
42 | onCountChanged: console.log("barset.onCountChanged: " + count); | |
|
41 | 43 | } |
|
42 | 44 | BarSet { label: "Susan"; values: [5, 1, 2, 4, 1, 8] } |
|
43 | 45 | BarSet { label: "James"; values: [3, 5, 8, 5, 4, 7] } |
|
46 | ||
|
47 | onNameChanged: console.log("barSeries.onNameChanged: " + series.name); | |
|
48 | onVisibleChanged: console.log("barSeries.onVisibleChanged: " + series.visible); | |
|
49 | onClicked: console.log("barSeries.onClicked: " + barset + " " + index); | |
|
50 | onHovered: console.log("barSeries.onHovered: " + barset + " " + status); | |
|
51 | onLabelsVisibleChanged: console.log("barSeries.onLabelsVisibleChanged: " + series.labelsVisible); | |
|
52 | onCountChanged: console.log("barSeries.onCountChanged: " + count); | |
|
44 | 53 | } |
|
45 | 54 | } |
@@ -1,94 +1,66 | |||
|
1 | 1 | /**************************************************************************** |
|
2 | 2 | ** |
|
3 | 3 | ** Copyright (C) 2012 Digia Plc |
|
4 | 4 | ** All rights reserved. |
|
5 | 5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
6 | 6 | ** |
|
7 | 7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
8 | 8 | ** |
|
9 | 9 | ** $QT_BEGIN_LICENSE$ |
|
10 | 10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
11 | 11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
12 | 12 | ** Software or, alternatively, in accordance with the terms contained in |
|
13 | 13 | ** a written agreement between you and Digia. |
|
14 | 14 | ** |
|
15 | 15 | ** If you have questions regarding the use of this file, please use |
|
16 | 16 | ** contact form at http://qt.digia.com |
|
17 | 17 | ** $QT_END_LICENSE$ |
|
18 | 18 | ** |
|
19 | 19 | ****************************************************************************/ |
|
20 | 20 | |
|
21 | 21 | import QtQuick 1.0 |
|
22 | 22 | import QtCommercial.Chart 1.0 |
|
23 | 23 | |
|
24 | 24 | Flow { |
|
25 | 25 | id: flow |
|
26 | 26 | spacing: 5 |
|
27 | 27 | flow: Flow.TopToBottom |
|
28 | 28 | property variant series |
|
29 | 29 | |
|
30 | onSeriesChanged: { | |
|
31 | if (series && series.name == "bar") { | |
|
32 | seriesConnections.target = series; | |
|
33 | setConnections.target = series.at(0); | |
|
34 | } else { | |
|
35 | seriesConnections.target = null; | |
|
36 | setConnections.target = null; | |
|
37 | } | |
|
38 | } | |
|
39 | ||
|
40 | Connections { | |
|
41 | id: seriesConnections | |
|
42 | target: null | |
|
43 | onNameChanged: console.log("series.onNameChanged: " + series.name); | |
|
44 | onVisibleChanged: console.log("series.onVisibleChanged: " + series.visible); | |
|
45 | onLabelsVisibleChanged: console.log("series.onLabelsVisibleChanged: " + series.labelsVisible); | |
|
46 | onCountChanged: console.log("series.onCountChanged: " + count); | |
|
47 | } | |
|
48 | ||
|
49 | Connections { | |
|
50 | id: setConnections | |
|
51 | target: null | |
|
52 | onColorChanged: console.log("series.onColorChanged: " + color); | |
|
53 | onBorderColorChanged: console.log("series.onBorderColorChanged: " + color); | |
|
54 | onLabelColorChanged: console.log("series.onLabelColorChanged: " + color); | |
|
55 | onCountChanged: console.log("series.onCountChanged: " + count); | |
|
56 | } | |
|
57 | ||
|
58 | 30 | Button { |
|
59 | 31 | text: "visible" |
|
60 | 32 | onClicked: series.visible = !series.visible; |
|
61 | 33 | } |
|
62 | 34 | Button { |
|
63 | 35 | text: "labels visible" |
|
64 | 36 | onClicked: series.labelsVisible = !series.labelsVisible; |
|
65 | 37 | } |
|
66 | 38 | Button { |
|
67 | 39 | text: "bar width +" |
|
68 | 40 | onClicked: series.barWidth += 0.1; |
|
69 | 41 | } |
|
70 | 42 | Button { |
|
71 | 43 | text: "bar width -" |
|
72 | 44 | onClicked: series.barWidth -= 0.1; |
|
73 | 45 | } |
|
74 | 46 | Button { |
|
75 | 47 | text: "set 1 color" |
|
76 | 48 | onClicked: series.at(0).color = main.nextColor(); |
|
77 | 49 | } |
|
78 | 50 | Button { |
|
79 | 51 | text: "set 1 border color" |
|
80 | 52 | onClicked: series.at(0).borderColor = main.nextColor(); |
|
81 | 53 | } |
|
82 | 54 | Button { |
|
83 | 55 | text: "set 1 label color" |
|
84 | 56 | onClicked: series.at(0).labelColor = main.nextColor(); |
|
85 | 57 | } |
|
86 | 58 | Button { |
|
87 | 59 | text: "set 1 font size +" |
|
88 | 60 | onClicked: series.at(0).labelFont.pixelSize += 1; |
|
89 | 61 | } |
|
90 | 62 | Button { |
|
91 | 63 | text: "set 1 font size -" |
|
92 | 64 | onClicked: series.at(0).labelFont.pixelSize -= 1; |
|
93 | 65 | } |
|
94 | 66 | } |
@@ -1,40 +1,72 | |||
|
1 | 1 | /**************************************************************************** |
|
2 | 2 | ** |
|
3 | 3 | ** Copyright (C) 2012 Digia Plc |
|
4 | 4 | ** All rights reserved. |
|
5 | 5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
6 | 6 | ** |
|
7 | 7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
8 | 8 | ** |
|
9 | 9 | ** $QT_BEGIN_LICENSE$ |
|
10 | 10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
11 | 11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
12 | 12 | ** Software or, alternatively, in accordance with the terms contained in |
|
13 | 13 | ** a written agreement between you and Digia. |
|
14 | 14 | ** |
|
15 | 15 | ** If you have questions regarding the use of this file, please use |
|
16 | 16 | ** contact form at http://qt.digia.com |
|
17 | 17 | ** $QT_END_LICENSE$ |
|
18 | 18 | ** |
|
19 | 19 | ****************************************************************************/ |
|
20 | 20 | |
|
21 | 21 | import QtQuick 1.0 |
|
22 | 22 | import QtCommercial.Chart 1.0 |
|
23 | 23 | |
|
24 | 24 | ChartView { |
|
25 | 25 | id: chartView |
|
26 | 26 | title: "chart" |
|
27 | 27 | anchors.fill: parent |
|
28 | 28 | property variant series: chartView |
|
29 | 29 | |
|
30 | 30 | LineSeries { |
|
31 | 31 | name: "line" |
|
32 | 32 | XyPoint { x: 0; y: 0 } |
|
33 | 33 | XyPoint { x: 1.1; y: 2.1 } |
|
34 | 34 | XyPoint { x: 1.9; y: 3.3 } |
|
35 | 35 | XyPoint { x: 2.1; y: 2.1 } |
|
36 | 36 | XyPoint { x: 2.9; y: 4.9 } |
|
37 | 37 | XyPoint { x: 3.4; y: 3.0 } |
|
38 | 38 | XyPoint { x: 4.1; y: 3.3 } |
|
39 | 39 | } |
|
40 | ||
|
41 | onVisibleChanged: console.log("chart.onVisibleChanged: " + series.visible); | |
|
42 | onTitleColorChanged: console.log("chart.onTitleColorChanged: " + series.titleColor); | |
|
43 | onBackgroundColorChanged: console.log("chart.onBackgroundColorChanged: " + series.backgroundColor); | |
|
44 | onDropShadowEnabledChanged: console.log("chart.onDropShadowEnabledChanged: " + enabled); | |
|
45 | ||
|
46 | legend.onVisibleChanged: console.log("legend.onVisibleChanged: " + series.legend.visible); | |
|
47 | legend.onBackgroundVisibleChanged: console.log("legend.onBackgroundVisibleChanged: " + visible); | |
|
48 | legend.onColorChanged: console.log("legend.onColorChanged: " + color); | |
|
49 | legend.onBorderColorChanged: console.log("legend.onBorderColorChanged: " + color); | |
|
50 | ||
|
51 | axisX.onColorChanged: console.log("axisX.onColorChanged: " + color); | |
|
52 | axisX.onLabelsVisibleChanged: console.log("axisX.onLabelsVisibleChanged: " + visible); | |
|
53 | axisX.onLabelsColorChanged: console.log("axisX.onLabelsColorChanged: " + color); | |
|
54 | axisX.onVisibleChanged: console.log("axisX.onVisibleChanged: " + visible); | |
|
55 | axisX.onGridVisibleChanged: console.log("axisX.onGridVisibleChanged: " + visible); | |
|
56 | axisX.onShadesVisibleChanged: console.log("axisX.onShadesVisibleChanged: " + visible); | |
|
57 | axisX.onShadesColorChanged: console.log("axisX.onShadesColorChanged: " + color); | |
|
58 | axisX.onShadesBorderColorChanged: console.log("axisX.onShadesBorderColorChanged: " + color); | |
|
59 | axisX.onMinChanged: console.log("axisX.onMinChanged: " + min); | |
|
60 | axisX.onMaxChanged: console.log("axisX.onMaxChanged: " + max); | |
|
61 | ||
|
62 | axisY.onColorChanged: console.log("axisY.onColorChanged: " + color); | |
|
63 | axisY.onLabelsVisibleChanged: console.log("axisY.onLabelsVisibleChanged: " + visible); | |
|
64 | axisY.onLabelsColorChanged: console.log("axisY.onLabelsColorChanged: " + color); | |
|
65 | axisY.onVisibleChanged: console.log("axisY.onVisibleChanged: " + visible); | |
|
66 | axisY.onGridVisibleChanged: console.log("axisY.onGridVisibleChanged: " + visible); | |
|
67 | axisY.onShadesVisibleChanged: console.log("axisY.onShadesVisibleChanged: " + visible); | |
|
68 | axisY.onShadesColorChanged: console.log("axisY.onShadesColorChanged: " + color); | |
|
69 | axisY.onShadesBorderColorChanged: console.log("axisY.onShadesBorderColorChanged: " + color); | |
|
70 | axisY.onMinChanged: console.log("axisY.onMinChanged: " + min); | |
|
71 | axisY.onMaxChanged: console.log("axisY.onMaxChanged: " + max); | |
|
40 | 72 | } |
@@ -1,316 +1,255 | |||
|
1 | 1 | /**************************************************************************** |
|
2 | 2 | ** |
|
3 | 3 | ** Copyright (C) 2012 Digia Plc |
|
4 | 4 | ** All rights reserved. |
|
5 | 5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
6 | 6 | ** |
|
7 | 7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
8 | 8 | ** |
|
9 | 9 | ** $QT_BEGIN_LICENSE$ |
|
10 | 10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
11 | 11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
12 | 12 | ** Software or, alternatively, in accordance with the terms contained in |
|
13 | 13 | ** a written agreement between you and Digia. |
|
14 | 14 | ** |
|
15 | 15 | ** If you have questions regarding the use of this file, please use |
|
16 | 16 | ** contact form at http://qt.digia.com |
|
17 | 17 | ** $QT_END_LICENSE$ |
|
18 | 18 | ** |
|
19 | 19 | ****************************************************************************/ |
|
20 | 20 | |
|
21 | 21 | import QtQuick 1.0 |
|
22 | 22 | import QtCommercial.Chart 1.0 |
|
23 | 23 | |
|
24 | 24 | |
|
25 | 25 | Flow { |
|
26 | 26 | id: flow |
|
27 | 27 | spacing: 5 |
|
28 | 28 | flow: Flow.TopToBottom |
|
29 | 29 | property variant series // TODO: rename to chart |
|
30 | 30 | |
|
31 | onSeriesChanged: { | |
|
32 | if (series && series.name == "") { | |
|
33 | chartConnections.target = series; | |
|
34 | legendConnections.target = series.legend; | |
|
35 | axisXConnections.target = series.axisX; | |
|
36 | axisYConnections.target = series.axisY; | |
|
37 | } else { | |
|
38 | legendConnections.target = null; | |
|
39 | axisXConnections.target = null; | |
|
40 | axisYConnections.target = null; | |
|
41 | } | |
|
42 | } | |
|
43 | ||
|
44 | Connections { | |
|
45 | id: chartConnections | |
|
46 | target: null | |
|
47 | onVisibleChanged: console.log("chart.onVisibleChanged: " + series.visible); | |
|
48 | onTitleColorChanged: console.log("chart.onTitleColorChanged: " + series.titleColor); | |
|
49 | onBackgroundColorChanged: console.log("chart.onBackgroundColorChanged: " + series.backgroundColor); | |
|
50 | onDropShadowEnabledChanged: console.log("chart.onDropShadowEnabledChanged: " + enabled); | |
|
51 | } | |
|
52 | ||
|
53 | Connections { | |
|
54 | id: legendConnections | |
|
55 | target: null | |
|
56 | onVisibleChanged: console.log("legend.onVisibleChanged: " + series.legend.visible); | |
|
57 | onBackgroundVisibleChanged: console.log("legend.onBackgroundVisibleChanged: " + visible); | |
|
58 | onColorChanged: console.log("legend.onColorChanged: " + color); | |
|
59 | onBorderColorChanged: console.log("legend.onBorderColorChanged: " + color); | |
|
60 | } | |
|
61 | ||
|
62 | Connections { | |
|
63 | id: axisXConnections | |
|
64 | target: null | |
|
65 | onColorChanged: console.log("axisX.onColorChanged: " + color); | |
|
66 | onLabelsVisibleChanged: console.log("axisX.onLabelsVisibleChanged: " + visible); | |
|
67 | onLabelsColorChanged: console.log("axisX.onLabelsColorChanged: " + color); | |
|
68 | onVisibleChanged: console.log("axisX.onVisibleChanged: " + visible); | |
|
69 | onGridVisibleChanged: console.log("axisX.onGridVisibleChanged: " + visible); | |
|
70 | onShadesVisibleChanged: console.log("axisX.onShadesVisibleChanged: " + visible); | |
|
71 | onShadesColorChanged: console.log("axisX.onShadesColorChanged: " + color); | |
|
72 | onShadesBorderColorChanged: console.log("axisX.onShadesBorderColorChanged: " + color); | |
|
73 | onMinChanged: console.log("axisX.onMinChanged: " + min); | |
|
74 | onMaxChanged: console.log("axisX.onMaxChanged: " + max); | |
|
75 | } | |
|
76 | ||
|
77 | Connections { | |
|
78 | id: axisYConnections | |
|
79 | target: null | |
|
80 | onColorChanged: console.log("axisY.onColorChanged: " + color); | |
|
81 | onLabelsVisibleChanged: console.log("axisY.onLabelsVisibleChanged: " + visible); | |
|
82 | onLabelsColorChanged: console.log("axisY.onLabelsColorChanged: " + color); | |
|
83 | onVisibleChanged: console.log("axisY.onVisibleChanged: " + visible); | |
|
84 | onGridVisibleChanged: console.log("axisY.onGridVisibleChanged: " + visible); | |
|
85 | onShadesVisibleChanged: console.log("axisY.onShadesVisibleChanged: " + visible); | |
|
86 | onShadesColorChanged: console.log("axisY.onShadesColorChanged: " + color); | |
|
87 | onShadesBorderColorChanged: console.log("axisY.onShadesBorderColorChanged: " + color); | |
|
88 | onMinChanged: console.log("axisY.onMinChanged: " + min); | |
|
89 | onMaxChanged: console.log("axisY.onMaxChanged: " + max); | |
|
90 | } | |
|
91 | ||
|
92 | 31 | Button { |
|
93 | 32 | text: "visible" |
|
94 | 33 | onClicked: series.visible = !series.visible; |
|
95 | 34 | } |
|
96 | 35 | Button { |
|
97 | 36 | text: "theme +" |
|
98 | 37 | onClicked: series.theme++; |
|
99 | 38 | } |
|
100 | 39 | Button { |
|
101 | 40 | text: "theme -" |
|
102 | 41 | onClicked: series.theme--; |
|
103 | 42 | } |
|
104 | 43 | Button { |
|
105 | 44 | text: "animation opt +" |
|
106 | 45 | onClicked: series.animationOptions++; |
|
107 | 46 | } |
|
108 | 47 | Button { |
|
109 | 48 | text: "animation opt -" |
|
110 | 49 | onClicked: series.animationOptions--; |
|
111 | 50 | } |
|
112 | 51 | Button { |
|
113 | 52 | text: "title color" |
|
114 | 53 | onClicked: series.titleColor = main.nextColor(); |
|
115 | 54 | } |
|
116 | 55 | Button { |
|
117 | 56 | text: "background color" |
|
118 | 57 | onClicked: series.backgroundColor = main.nextColor(); |
|
119 | 58 | } |
|
120 | 59 | Button { |
|
121 | 60 | text: "drop shadow enabled" |
|
122 | 61 | onClicked: series.dropShadowEnabled = !series.dropShadowEnabled; |
|
123 | 62 | } |
|
124 | 63 | Button { |
|
125 | 64 | text: "zoom +" |
|
126 | 65 | onClicked: series.zoom(2); |
|
127 | 66 | } |
|
128 | 67 | Button { |
|
129 | 68 | text: "zoom -" |
|
130 | 69 | onClicked: series.zoom(0.5); |
|
131 | 70 | } |
|
132 | 71 | Button { |
|
133 | 72 | text: "scroll left" |
|
134 | 73 | onClicked: series.scrollLeft(10); |
|
135 | 74 | } |
|
136 | 75 | Button { |
|
137 | 76 | text: "scroll right" |
|
138 | 77 | onClicked: series.scrollRight(10); |
|
139 | 78 | } |
|
140 | 79 | Button { |
|
141 | 80 | text: "scroll up" |
|
142 | 81 | onClicked: series.scrollUp(10); |
|
143 | 82 | } |
|
144 | 83 | Button { |
|
145 | 84 | text: "scroll down" |
|
146 | 85 | onClicked: series.scrollDown(10); |
|
147 | 86 | } |
|
148 | 87 | Button { |
|
149 | 88 | text: "legend visible" |
|
150 | 89 | onClicked: series.legend.visible = !series.legend.visible; |
|
151 | 90 | } |
|
152 | 91 | Button { |
|
153 | 92 | text: "legend bckgrd visible" |
|
154 | 93 | onClicked: series.legend.backgroundVisible = !series.legend.backgroundVisible; |
|
155 | 94 | } |
|
156 | 95 | Button { |
|
157 | 96 | text: "legend color" |
|
158 | 97 | onClicked: series.legend.color = main.nextColor(); |
|
159 | 98 | } |
|
160 | 99 | Button { |
|
161 | 100 | text: "legend border color" |
|
162 | 101 | onClicked: series.legend.borderColor = main.nextColor(); |
|
163 | 102 | } |
|
164 | 103 | Button { |
|
165 | 104 | text: "legend top" |
|
166 | 105 | onClicked: series.legend.alignment ^= Qt.AlignTop; |
|
167 | 106 | } |
|
168 | 107 | Button { |
|
169 | 108 | text: "legend bottom" |
|
170 | 109 | onClicked: series.legend.alignment ^= Qt.AlignBottom; |
|
171 | 110 | } |
|
172 | 111 | Button { |
|
173 | 112 | text: "legend left" |
|
174 | 113 | onClicked: series.legend.alignment ^= Qt.AlignLeft; |
|
175 | 114 | } |
|
176 | 115 | Button { |
|
177 | 116 | text: "legend right" |
|
178 | 117 | onClicked: series.legend.alignment ^= Qt.AlignRight; |
|
179 | 118 | } |
|
180 | 119 | Button { |
|
181 | 120 | text: "axis X visible" |
|
182 | 121 | onClicked: series.axisX.visible = !series.axisX.visible; |
|
183 | 122 | } |
|
184 | 123 | Button { |
|
185 | 124 | text: "axis X grid visible" |
|
186 | 125 | onClicked: series.axisX.gridVisible = !series.axisX.gridVisible; |
|
187 | 126 | } |
|
188 | 127 | Button { |
|
189 | 128 | text: "axis X labels visible" |
|
190 | 129 | onClicked: series.axisX.labelsVisible = !series.axisX.labelsVisible; |
|
191 | 130 | } |
|
192 | 131 | Button { |
|
193 | 132 | text: "axis X color" |
|
194 | 133 | onClicked: series.axisX.color = main.nextColor(); |
|
195 | 134 | } |
|
196 | 135 | Button { |
|
197 | 136 | text: "axis X labels color" |
|
198 | 137 | onClicked: series.axisX.labelsColor = main.nextColor(); |
|
199 | 138 | } |
|
200 | 139 | Button { |
|
201 | 140 | text: "axis X labels angle +" |
|
202 | 141 | onClicked: series.axisX.labelsAngle += 5; |
|
203 | 142 | } |
|
204 | 143 | Button { |
|
205 | 144 | text: "axis X labels angle -" |
|
206 | 145 | onClicked: series.axisX.labelsAngle -= 5; |
|
207 | 146 | } |
|
208 | 147 | Button { |
|
209 | 148 | text: "axis X shades visible" |
|
210 | 149 | onClicked: series.axisX.shadesVisible = !series.axisX.shadesVisible; |
|
211 | 150 | } |
|
212 | 151 | Button { |
|
213 | 152 | text: "axis X shades color" |
|
214 | 153 | onClicked: series.axisX.shadesColor = main.nextColor(); |
|
215 | 154 | } |
|
216 | 155 | Button { |
|
217 | 156 | text: "axis X shades bcolor" |
|
218 | 157 | onClicked: series.axisX.shadesBorderColor = main.nextColor(); |
|
219 | 158 | } |
|
220 | 159 | Button { |
|
221 | 160 | text: "axis X max +" |
|
222 | 161 | onClicked: series.axisX.max += 0.1; |
|
223 | 162 | } |
|
224 | 163 | Button { |
|
225 | 164 | text: "axis X max -" |
|
226 | 165 | onClicked: series.axisX.max -= 0.1; |
|
227 | 166 | } |
|
228 | 167 | Button { |
|
229 | 168 | text: "axis X min +" |
|
230 | 169 | onClicked: series.axisX.min += 0.1; |
|
231 | 170 | } |
|
232 | 171 | Button { |
|
233 | 172 | text: "axis X min -" |
|
234 | 173 | onClicked: series.axisX.min -= 0.1; |
|
235 | 174 | } |
|
236 | 175 | Button { |
|
237 | 176 | text: "axis X ticks count +" |
|
238 | 177 | onClicked: series.axisX.ticksCount++; |
|
239 | 178 | } |
|
240 | 179 | Button { |
|
241 | 180 | text: "axis X ticks count -" |
|
242 | 181 | onClicked: series.axisX.ticksCount--; |
|
243 | 182 | } |
|
244 | 183 | Button { |
|
245 | 184 | text: "axis X nice nmb" |
|
246 | 185 | onClicked: series.axisX.niceNumbersEnabled = !series.axisX.niceNumbersEnabled; |
|
247 | 186 | } |
|
248 | 187 | Button { |
|
249 | 188 | text: "axis Y visible" |
|
250 | 189 | onClicked: series.axisY.visible = !series.axisY.visible; |
|
251 | 190 | } |
|
252 | 191 | Button { |
|
253 | 192 | text: "axis Y grid visible" |
|
254 | 193 | onClicked: series.axisY.gridVisible = !series.axisY.gridVisible; |
|
255 | 194 | } |
|
256 | 195 | Button { |
|
257 | 196 | text: "axis Y labels visible" |
|
258 | 197 | onClicked: series.axisY.labelsVisible = !series.axisY.labelsVisible; |
|
259 | 198 | } |
|
260 | 199 | Button { |
|
261 | 200 | text: "axis Y color" |
|
262 | 201 | onClicked: series.axisY.color = main.nextColor(); |
|
263 | 202 | } |
|
264 | 203 | Button { |
|
265 | 204 | text: "axis Y labels color" |
|
266 | 205 | onClicked: series.axisY.labelsColor = main.nextColor(); |
|
267 | 206 | } |
|
268 | 207 | Button { |
|
269 | 208 | text: "axis Y labels angle +" |
|
270 | 209 | onClicked: series.axisY.labelsAngle += 5; |
|
271 | 210 | } |
|
272 | 211 | Button { |
|
273 | 212 | text: "axis Y labels angle -" |
|
274 | 213 | onClicked: series.axisY.labelsAngle -= 5; |
|
275 | 214 | } |
|
276 | 215 | Button { |
|
277 | 216 | text: "axis Y shades visible" |
|
278 | 217 | onClicked: series.axisY.shadesVisible = !series.axisY.shadesVisible; |
|
279 | 218 | } |
|
280 | 219 | Button { |
|
281 | 220 | text: "axis Y shades color" |
|
282 | 221 | onClicked: series.axisY.shadesColor = main.nextColor(); |
|
283 | 222 | } |
|
284 | 223 | Button { |
|
285 | 224 | text: "axis Y shades bcolor" |
|
286 | 225 | onClicked: series.axisY.shadesBorderColor = main.nextColor(); |
|
287 | 226 | } |
|
288 | 227 | Button { |
|
289 | 228 | text: "axis Y max +" |
|
290 | 229 | onClicked: series.axisY.max += 0.1; |
|
291 | 230 | } |
|
292 | 231 | Button { |
|
293 | 232 | text: "axis Y max -" |
|
294 | 233 | onClicked: series.axisY.max -= 0.1; |
|
295 | 234 | } |
|
296 | 235 | Button { |
|
297 | 236 | text: "axis Y min +" |
|
298 | 237 | onClicked: series.axisY.min += 0.1; |
|
299 | 238 | } |
|
300 | 239 | Button { |
|
301 | 240 | text: "axis Y min -" |
|
302 | 241 | onClicked: series.axisY.min -= 0.1; |
|
303 | 242 | } |
|
304 | 243 | Button { |
|
305 | 244 | text: "axis Y ticks count +" |
|
306 | 245 | onClicked: series.axisY.ticksCount++; |
|
307 | 246 | } |
|
308 | 247 | Button { |
|
309 | 248 | text: "axis Y ticks count -" |
|
310 | 249 | onClicked: series.axisY.ticksCount--; |
|
311 | 250 | } |
|
312 | 251 | Button { |
|
313 | 252 | text: "axis Y nice nmb" |
|
314 | 253 | onClicked: series.axisY.niceNumbersEnabled = !series.axisY.niceNumbersEnabled; |
|
315 | 254 | } |
|
316 | 255 | } |
@@ -1,42 +1,54 | |||
|
1 | 1 | /**************************************************************************** |
|
2 | 2 | ** |
|
3 | 3 | ** Copyright (C) 2012 Digia Plc |
|
4 | 4 | ** All rights reserved. |
|
5 | 5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
6 | 6 | ** |
|
7 | 7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
8 | 8 | ** |
|
9 | 9 | ** $QT_BEGIN_LICENSE$ |
|
10 | 10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
11 | 11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
12 | 12 | ** Software or, alternatively, in accordance with the terms contained in |
|
13 | 13 | ** a written agreement between you and Digia. |
|
14 | 14 | ** |
|
15 | 15 | ** If you have questions regarding the use of this file, please use |
|
16 | 16 | ** contact form at http://qt.digia.com |
|
17 | 17 | ** $QT_END_LICENSE$ |
|
18 | 18 | ** |
|
19 | 19 | ****************************************************************************/ |
|
20 | 20 | |
|
21 | 21 | import QtQuick 1.0 |
|
22 | 22 | import QtCommercial.Chart 1.0 |
|
23 | 23 | |
|
24 | 24 | ChartView { |
|
25 | 25 | title: "Grouped bar series" |
|
26 | 26 | anchors.fill: parent |
|
27 | 27 | theme: ChartView.ChartThemeLight |
|
28 | 28 | legend.alignment: Qt.AlignBottom |
|
29 | 29 | axisXLabels: ["0", "2007", "1", "2008", "2", "2009", "3", "2010", "4", "2011", "5", "2012"] |
|
30 | 30 | |
|
31 |
property variant series: |
|
|
31 | property variant series: barSeries | |
|
32 | 32 | |
|
33 | 33 | GroupedBarSeries { |
|
34 |
id: |
|
|
34 | id: barSeries | |
|
35 | 35 | name: "bar" |
|
36 | onClicked: console.log("onClicked: " + barset + " " + index); | |
|
37 | onHovered: console.log("onHovered: " + barset + " " + status); | |
|
38 | BarSet { label: "Bob"; values: [2, 2, 3, 4, 5, 6] } | |
|
36 | BarSet { label: "Bob"; values: [2, 2, 3, 4, 5, 6] | |
|
37 | onClicked: console.log("barset.onClicked: " + index); | |
|
38 | onHovered: console.log("barset.onHovered: " + status); | |
|
39 | onColorChanged: console.log("barset.onColorChanged: " + color); | |
|
40 | onBorderColorChanged: console.log("barset.onBorderColorChanged: " + color); | |
|
41 | onLabelColorChanged: console.log("barset.onLabelColorChanged: " + color); | |
|
42 | onCountChanged: console.log("barset.onCountChanged: " + count); | |
|
43 | } | |
|
39 | 44 | BarSet { label: "Susan"; values: [5, 1, 2, 4, 1, 7] } |
|
40 | 45 | BarSet { label: "James"; values: [3, 5, 8, 13, 5, 8] } |
|
46 | ||
|
47 | onNameChanged: console.log("groupedBarSeries.onNameChanged: " + series.name); | |
|
48 | onVisibleChanged: console.log("groupedBarSeries.onVisibleChanged: " + series.visible); | |
|
49 | onClicked: console.log("groupedBarSeries.onClicked: " + barset + " " + index); | |
|
50 | onHovered: console.log("groupedBarSeries.onHovered: " + barset + " " + status); | |
|
51 | onLabelsVisibleChanged: console.log("groupedBarSeries.onLabelsVisibleChanged: " + series.labelsVisible); | |
|
52 | onCountChanged: console.log("groupedBarSeries.onCountChanged: " + count); | |
|
41 | 53 | } |
|
42 | 54 | } |
@@ -1,52 +1,60 | |||
|
1 | 1 | /**************************************************************************** |
|
2 | 2 | ** |
|
3 | 3 | ** Copyright (C) 2012 Digia Plc |
|
4 | 4 | ** All rights reserved. |
|
5 | 5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
6 | 6 | ** |
|
7 | 7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
8 | 8 | ** |
|
9 | 9 | ** $QT_BEGIN_LICENSE$ |
|
10 | 10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
11 | 11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
12 | 12 | ** Software or, alternatively, in accordance with the terms contained in |
|
13 | 13 | ** a written agreement between you and Digia. |
|
14 | 14 | ** |
|
15 | 15 | ** If you have questions regarding the use of this file, please use |
|
16 | 16 | ** contact form at http://qt.digia.com |
|
17 | 17 | ** $QT_END_LICENSE$ |
|
18 | 18 | ** |
|
19 | 19 | ****************************************************************************/ |
|
20 | 20 | |
|
21 | 21 | import QtQuick 1.0 |
|
22 | 22 | import QtCommercial.Chart 1.0 |
|
23 | 23 | |
|
24 | 24 | ChartView { |
|
25 | property variant series: lineSeries | |
|
26 | ||
|
25 | 27 | title: "line series" |
|
26 | 28 | anchors.fill: parent |
|
27 | 29 | |
|
28 | property variant series: daSeries | |
|
29 | ||
|
30 | 30 | LineSeries { |
|
31 |
id: |
|
|
31 | id: lineSeries | |
|
32 | 32 | name: "line 1" |
|
33 | onClicked: console.log("onClicked: " + point.x + ", " + point.y); | |
|
34 | 33 | XyPoint { x: 0; y: 0 } |
|
35 | 34 | XyPoint { x: 1.1; y: 2.1 } |
|
36 | 35 | XyPoint { x: 1.9; y: 3.3 } |
|
37 | 36 | XyPoint { x: 2.1; y: 2.1 } |
|
38 | 37 | XyPoint { x: 2.9; y: 4.9 } |
|
39 | 38 | XyPoint { x: 3.4; y: 3.0 } |
|
40 | 39 | XyPoint { x: 4.1; y: 3.3 } |
|
40 | ||
|
41 | onNameChanged: console.log("lineSeries.onNameChanged: " + name); | |
|
42 | onVisibleChanged: console.log("lineSeries.onVisibleChanged: " + visible); | |
|
43 | onClicked: console.log("lineSeries.onClicked: " + point.x + ", " + point.y); | |
|
44 | onPointReplaced: console.log("lineSeries.onPointReplaced: " + index); | |
|
45 | onPointRemoved: console.log("lineSeries.onPointRemoved: " + index); | |
|
46 | onPointAdded: console.log("lineSeries.onPointAdded: " + index); | |
|
47 | onColorChanged: console.log("lineSeries.onColorChanged: " + color); | |
|
48 | onCountChanged: console.log("lineSeries.onCountChanged: " + count); | |
|
41 | 49 | } |
|
42 | 50 | |
|
43 | 51 | LineSeries { |
|
44 | 52 | name: "line 2" |
|
45 | 53 | XyPoint { x: 1.1; y: 1.1 } |
|
46 | 54 | XyPoint { x: 1.9; y: 2.3 } |
|
47 | 55 | XyPoint { x: 2.1; y: 1.1 } |
|
48 | 56 | XyPoint { x: 2.9; y: 3.9 } |
|
49 | 57 | XyPoint { x: 3.4; y: 2.0 } |
|
50 | 58 | XyPoint { x: 4.1; y: 2.3 } |
|
51 | 59 | } |
|
52 | 60 | } |
@@ -1,60 +1,43 | |||
|
1 | 1 | /**************************************************************************** |
|
2 | 2 | ** |
|
3 | 3 | ** Copyright (C) 2012 Digia Plc |
|
4 | 4 | ** All rights reserved. |
|
5 | 5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
6 | 6 | ** |
|
7 | 7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
8 | 8 | ** |
|
9 | 9 | ** $QT_BEGIN_LICENSE$ |
|
10 | 10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
11 | 11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
12 | 12 | ** Software or, alternatively, in accordance with the terms contained in |
|
13 | 13 | ** a written agreement between you and Digia. |
|
14 | 14 | ** |
|
15 | 15 | ** If you have questions regarding the use of this file, please use |
|
16 | 16 | ** contact form at http://qt.digia.com |
|
17 | 17 | ** $QT_END_LICENSE$ |
|
18 | 18 | ** |
|
19 | 19 | ****************************************************************************/ |
|
20 | 20 | |
|
21 | 21 | import QtQuick 1.0 |
|
22 | 22 | import QtCommercial.Chart 1.0 |
|
23 | 23 | |
|
24 | 24 | |
|
25 | 25 | Flow { |
|
26 | 26 | id: flow |
|
27 | 27 | spacing: 5 |
|
28 | 28 | flow: Flow.TopToBottom |
|
29 | 29 | property variant series |
|
30 | 30 | |
|
31 | onSeriesChanged: { | |
|
32 | if (series && (series.name == "line 1" || series.name == "spline 1")) { | |
|
33 | seriesConnections.target = series; | |
|
34 | } else { | |
|
35 | seriesConnections.target = null; | |
|
36 | } | |
|
37 | } | |
|
38 | ||
|
39 | Connections { | |
|
40 | id: seriesConnections | |
|
41 | target: null | |
|
42 | onNameChanged: console.log("series.onNameChanged: " + series.name); | |
|
43 | onVisibleChanged: console.log("series.onVisibleChanged: " + series.visible); | |
|
44 | onColorChanged: console.log("series.onColorChanged: " + series.color); | |
|
45 | onCountChanged: console.log("series.onCountChanged: " + series.count); | |
|
46 | } | |
|
47 | ||
|
48 | 31 | Button { |
|
49 | 32 | text: "visible" |
|
50 | 33 | onClicked: series.visible = !series.visible; |
|
51 | 34 | } |
|
52 | 35 | Button { |
|
53 | 36 | text: "color" |
|
54 | 37 | onClicked: series.color = main.nextColor(); |
|
55 | 38 | } |
|
56 | 39 | Button { |
|
57 | 40 | text: "points visible" |
|
58 | 41 | onClicked: series.pointsVisible = !series.pointsVisible |
|
59 | 42 | } |
|
60 | 43 | } |
@@ -1,42 +1,54 | |||
|
1 | 1 | /**************************************************************************** |
|
2 | 2 | ** |
|
3 | 3 | ** Copyright (C) 2012 Digia Plc |
|
4 | 4 | ** All rights reserved. |
|
5 | 5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
6 | 6 | ** |
|
7 | 7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
8 | 8 | ** |
|
9 | 9 | ** $QT_BEGIN_LICENSE$ |
|
10 | 10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
11 | 11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
12 | 12 | ** Software or, alternatively, in accordance with the terms contained in |
|
13 | 13 | ** a written agreement between you and Digia. |
|
14 | 14 | ** |
|
15 | 15 | ** If you have questions regarding the use of this file, please use |
|
16 | 16 | ** contact form at http://qt.digia.com |
|
17 | 17 | ** $QT_END_LICENSE$ |
|
18 | 18 | ** |
|
19 | 19 | ****************************************************************************/ |
|
20 | 20 | |
|
21 | 21 | import QtQuick 1.0 |
|
22 | 22 | import QtCommercial.Chart 1.0 |
|
23 | 23 | |
|
24 | 24 | ChartView { |
|
25 | 25 | title: "Percent bar series" |
|
26 | 26 | anchors.fill: parent |
|
27 | 27 | theme: ChartView.ChartThemeLight |
|
28 | 28 | legend.alignment: Qt.AlignBottom |
|
29 | 29 | axisXLabels: ["0", "2007", "1", "2008", "2", "2009", "3", "2010", "4", "2011", "5", "2012"] |
|
30 | 30 | |
|
31 |
property variant series: |
|
|
31 | property variant series: barSeries | |
|
32 | 32 | |
|
33 | 33 | PercentBarSeries { |
|
34 |
id: |
|
|
34 | id: barSeries | |
|
35 | 35 | name: "bar" |
|
36 | onClicked: console.log("onClicked: " + barset + " " + index); | |
|
37 | onHovered: console.log("onHovered: " + barset + " " + status); | |
|
38 | BarSet { label: "Bob"; values: [2, 2, 3, 4, 5, 6] } | |
|
36 | BarSet { label: "Bob"; values: [2, 2, 3, 4, 5, 6] | |
|
37 | onClicked: console.log("barset.onClicked: " + index); | |
|
38 | onHovered: console.log("barset.onHovered: " + status); | |
|
39 | onColorChanged: console.log("barset.onColorChanged: " + color); | |
|
40 | onBorderColorChanged: console.log("barset.onBorderColorChanged: " + color); | |
|
41 | onLabelColorChanged: console.log("barset.onLabelColorChanged: " + color); | |
|
42 | onCountChanged: console.log("barset.onCountChanged: " + count); | |
|
43 | } | |
|
39 | 44 | BarSet { label: "Susan"; values: [5, 1, 2, 4, 1, 7] } |
|
40 | 45 | BarSet { label: "James"; values: [3, 5, 8, 13, 5, 8] } |
|
46 | ||
|
47 | onNameChanged: console.log("percentBarSeries.onNameChanged: " + series.name); | |
|
48 | onVisibleChanged: console.log("percentBarSeries.onVisibleChanged: " + series.visible); | |
|
49 | onClicked: console.log("percentBarSeries.onClicked: " + barset + " " + index); | |
|
50 | onHovered: console.log("percentBarSeries.onHovered: " + barset + " " + status); | |
|
51 | onLabelsVisibleChanged: console.log("percentBarSeries.onLabelsVisibleChanged: " + series.labelsVisible); | |
|
52 | onCountChanged: console.log("percentBarSeries.onCountChanged: " + count); | |
|
41 | 53 | } |
|
42 | 54 | } |
@@ -1,38 +1,66 | |||
|
1 | 1 | /**************************************************************************** |
|
2 | 2 | ** |
|
3 | 3 | ** Copyright (C) 2012 Digia Plc |
|
4 | 4 | ** All rights reserved. |
|
5 | 5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
6 | 6 | ** |
|
7 | 7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
8 | 8 | ** |
|
9 | 9 | ** $QT_BEGIN_LICENSE$ |
|
10 | 10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
11 | 11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
12 | 12 | ** Software or, alternatively, in accordance with the terms contained in |
|
13 | 13 | ** a written agreement between you and Digia. |
|
14 | 14 | ** |
|
15 | 15 | ** If you have questions regarding the use of this file, please use |
|
16 | 16 | ** contact form at http://qt.digia.com |
|
17 | 17 | ** $QT_END_LICENSE$ |
|
18 | 18 | ** |
|
19 | 19 | ****************************************************************************/ |
|
20 | 20 | |
|
21 | 21 | import QtQuick 1.0 |
|
22 | 22 | import QtCommercial.Chart 1.0 |
|
23 | 23 | |
|
24 | 24 | ChartView { |
|
25 | 25 | id: chart |
|
26 | 26 | title: "pie series" |
|
27 | 27 | animationOptions: ChartView.SeriesAnimations |
|
28 | 28 | |
|
29 | 29 | property variant series: pieSeries |
|
30 | 30 | |
|
31 | 31 | PieSeries { |
|
32 | 32 | id: pieSeries |
|
33 | 33 | name: "pie" |
|
34 |
PieSlice { label: "slice1"; value: 11 |
|
|
34 | PieSlice { label: "slice1"; value: 11; | |
|
35 | onValueChanged: console.log("slice.onValueChanged: " + value); | |
|
36 | onLabelVisibleChanged: console.log("slice.onLabelVisibleChanged: " + labelVisible); | |
|
37 | onPenChanged: console.log("slice.onPenChanged: " + pen); | |
|
38 | onBorderColorChanged: console.log("slice.onBorderColorChanged: " + borderColor); | |
|
39 | onBorderWidthChanged: console.log("slice.onBorderWidthChanged: " + borderWidth); | |
|
40 | onBrushChanged: console.log("slice.onBrushChanged: " + brush); | |
|
41 | onColorChanged: console.log("slice.onColorChanged: " + color); | |
|
42 | onLabelColorChanged: console.log("slice.onLabelColorChanged: " + labelColor); | |
|
43 | onLabelBrushChanged: console.log("slice.onLabelBrushChanged: " + labelBrush); | |
|
44 | onLabelFontChanged: console.log("slice.onLabelFontChanged: " + labelFont); | |
|
45 | onPercentageChanged: console.log("slice.onPercentageChanged: " + percentage); | |
|
46 | onStartAngleChanged: console.log("slice.onStartAngleChanged: " + startAngle); | |
|
47 | onAngleSpanChanged: console.log("slice.onAngleSpanChanged: " + angleSpan); | |
|
48 | onClicked: console.log("slice.onClicked: " + label); | |
|
49 | onHovered: console.log("slice.onHovered: " + state); | |
|
50 | } | |
|
35 | 51 | PieSlice { label: "slice2"; value: 22 } |
|
36 | 52 | PieSlice { label: "slice3"; value: 33 } |
|
53 | PieSlice { label: "slice4"; value: 44 } | |
|
54 | ||
|
55 | onNameChanged: console.log("pieSeries.onNameChanged: " + series.name); | |
|
56 | onVisibleChanged: console.log("pieSeries.onVisibleChanged: " + series.visible); | |
|
57 | onClicked: console.log("pieSeries.onClicked: " + slice.label); | |
|
58 | onHovered: console.log("pieSeries.onHovered: " + slice.label); | |
|
59 | onAdded: console.log("pieSeries.onAdded: " + slices); | |
|
60 | onSliceAdded: console.log("pieSeries.onSliceAdded: " + slice.label); | |
|
61 | onRemoved: console.log("pieSeries.onRemoved: " + slices); | |
|
62 | onSliceRemoved: console.log("pieSeries.onSliceRemoved: " + slice.label); | |
|
63 | onCountChanged: console.log("pieSeries.onCountChanged: " + series.count); | |
|
64 | onSumChanged: console.log("pieSeries.onSumChanged: " + series.sum); | |
|
37 | 65 | } |
|
38 | 66 | } |
@@ -1,164 +1,130 | |||
|
1 | 1 | /**************************************************************************** |
|
2 | 2 | ** |
|
3 | 3 | ** Copyright (C) 2012 Digia Plc |
|
4 | 4 | ** All rights reserved. |
|
5 | 5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
6 | 6 | ** |
|
7 | 7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
8 | 8 | ** |
|
9 | 9 | ** $QT_BEGIN_LICENSE$ |
|
10 | 10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
11 | 11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
12 | 12 | ** Software or, alternatively, in accordance with the terms contained in |
|
13 | 13 | ** a written agreement between you and Digia. |
|
14 | 14 | ** |
|
15 | 15 | ** If you have questions regarding the use of this file, please use |
|
16 | 16 | ** contact form at http://qt.digia.com |
|
17 | 17 | ** $QT_END_LICENSE$ |
|
18 | 18 | ** |
|
19 | 19 | ****************************************************************************/ |
|
20 | 20 | |
|
21 | 21 | import QtQuick 1.0 |
|
22 | 22 | import QtCommercial.Chart 1.0 |
|
23 | 23 | |
|
24 | 24 | Flow { |
|
25 | 25 | id: flow |
|
26 | 26 | spacing: 5 |
|
27 | 27 | flow: Flow.TopToBottom |
|
28 | 28 | property variant series |
|
29 | 29 | |
|
30 | onSeriesChanged: { | |
|
31 | if (series && series.name == "pie") { | |
|
32 | seriesConnections.target = series; | |
|
33 | sliceConnections.target = series.at(0); | |
|
34 | } else { | |
|
35 | seriesConnections.target = null; | |
|
36 | sliceConnections.target = null; | |
|
37 | } | |
|
38 | } | |
|
39 | ||
|
40 | Connections { | |
|
41 | id: seriesConnections | |
|
42 | target: null | |
|
43 | onVisibleChanged: console.log("series.onVisibleChanged: " + series.visible); | |
|
44 | onCountChanged: console.log("series.onCountChanged: " + series.count); | |
|
45 | onSumChanged: console.log("series.onSumChanged: " + series.sum); | |
|
46 | } | |
|
47 | ||
|
48 | Connections { | |
|
49 | id: sliceConnections | |
|
50 | target: null | |
|
51 | onValueChanged: console.log("slice.onValueChanged: " + series.at(0).value); | |
|
52 | onLabelVisibleChanged: console.log("slice.onLabelVisibleChanged: " + series.at(0).labelVisible); | |
|
53 | onPenChanged: console.log("slice.onPenChanged: " + series.at(0).pen); | |
|
54 | onBorderColorChanged: console.log("slice.onBorderColorChanged: " + series.at(0).borderColor); | |
|
55 | onBorderWidthChanged: console.log("slice.onBorderWidthChanged: " + series.at(0).borderWidth); | |
|
56 | onBrushChanged: console.log("slice.onBrushChanged: " + series.at(0).brush); | |
|
57 | onColorChanged: console.log("slice.onColorChanged: " + series.at(0).color); | |
|
58 | onLabelColorChanged: console.log("slice.onLabelColorChanged: " + series.at(0).labelColor); | |
|
59 | onLabelBrushChanged: console.log("slice.onLabelBrushChanged: " + series.at(0).labelBrush); | |
|
60 | onLabelFontChanged: console.log("slice.onLabelFontChanged: " + series.at(0).labelFont); | |
|
61 | onPercentageChanged: console.log("slice.onPercentageChanged: " + series.at(0).percentage); | |
|
62 | onStartAngleChanged: console.log("slice.onStartAngleChanged: " + series.at(0).startAngle); | |
|
63 | onAngleSpanChanged: console.log("slice.onAngleSpanChanged: " + series.at(0).angleSpan); | |
|
64 | onClicked: console.log("slice.onClicked"); | |
|
65 | onHovered: console.log("slice.onHovered: " + state); | |
|
66 | } | |
|
67 | ||
|
68 | 30 | Button { |
|
69 | 31 | text: "visible" |
|
70 | 32 | onClicked: series.visible = !series.visible; |
|
71 | 33 | } |
|
72 | 34 | Button { |
|
73 | 35 | text: "series hpos +" |
|
74 | 36 | onClicked: series.horizontalPosition += 0.1; |
|
75 | 37 | } |
|
76 | 38 | Button { |
|
77 | 39 | text: "series hpos -" |
|
78 | 40 | onClicked: series.horizontalPosition -= 0.1; |
|
79 | 41 | } |
|
80 | 42 | Button { |
|
81 | 43 | text: "series vpos +" |
|
82 | 44 | onClicked: series.verticalPosition += 0.1; |
|
83 | 45 | } |
|
84 | 46 | Button { |
|
85 | 47 | text: "series vpos -" |
|
86 | 48 | onClicked: series.verticalPosition -= 0.1; |
|
87 | 49 | } |
|
88 | 50 | Button { |
|
89 | 51 | text: "series size +" |
|
90 | 52 | onClicked: series.size += 0.1; |
|
91 | 53 | } |
|
92 | 54 | Button { |
|
93 | 55 | text: "series size -" |
|
94 | 56 | onClicked: series.size -= 0.1; |
|
95 | 57 | } |
|
96 | 58 | Button { |
|
97 | 59 | text: "series start angle +" |
|
98 | 60 | onClicked: series.startAngle += 1.1; |
|
99 | 61 | } |
|
100 | 62 | Button { |
|
101 | 63 | text: "series start angle -" |
|
102 | 64 | onClicked: series.startAngle -= 1.1; |
|
103 | 65 | } |
|
104 | 66 | Button { |
|
105 | 67 | text: "series end angle +" |
|
106 | 68 | onClicked: series.endAngle += 1.1; |
|
107 | 69 | } |
|
108 | 70 | Button { |
|
109 | 71 | text: "series end angle -" |
|
110 | 72 | onClicked: series.endAngle -= 1.1; |
|
111 | 73 | } |
|
112 | 74 | Button { |
|
75 | text: "remove slice" | |
|
76 | onClicked: series.remove(series.count - 1); | |
|
77 | } | |
|
78 | Button { | |
|
113 | 79 | text: "slice color" |
|
114 | 80 | onClicked: series.at(0).color = main.nextColor(); |
|
115 | 81 | } |
|
116 | 82 | Button { |
|
117 | 83 | text: "slice border color" |
|
118 | 84 | onClicked: series.at(0).borderColor = main.nextColor(); |
|
119 | 85 | } |
|
120 | 86 | Button { |
|
121 | 87 | text: "slice border width +" |
|
122 | 88 | onClicked: series.at(0).borderWidth++; |
|
123 | 89 | } |
|
124 | 90 | Button { |
|
125 | 91 | text: "slice border width -" |
|
126 | 92 | onClicked: series.at(0).borderWidth--; |
|
127 | 93 | } |
|
128 | 94 | Button { |
|
129 | 95 | text: "slice label visible" |
|
130 | 96 | onClicked: series.at(0).labelVisible = !series.at(0).labelVisible; |
|
131 | 97 | } |
|
132 | 98 | Button { |
|
133 | 99 | text: "slice label position inside" |
|
134 | 100 | onClicked: series.at(0).labelPosition = PieSlice.LabelInside; |
|
135 | 101 | } |
|
136 | 102 | Button { |
|
137 | 103 | text: "slice label position outside" |
|
138 | 104 | onClicked: series.at(0).labelPosition = PieSlice.LabelOutside; |
|
139 | 105 | } |
|
140 | 106 | Button { |
|
141 | 107 | text: "slice label arm len +" |
|
142 | 108 | onClicked: series.at(0).labelArmLengthFactor += 0.1; |
|
143 | 109 | } |
|
144 | 110 | Button { |
|
145 | 111 | text: "slice label arm len -" |
|
146 | 112 | onClicked: series.at(0).labelArmLengthFactor -= 0.1; |
|
147 | 113 | } |
|
148 | 114 | Button { |
|
149 | 115 | text: "slice label color" |
|
150 | 116 | onClicked: series.at(0).labelColor = main.nextColor(); |
|
151 | 117 | } |
|
152 | 118 | Button { |
|
153 | 119 | text: "slice exploded" |
|
154 | 120 | onClicked: series.at(0).exploded = !series.at(0).exploded; |
|
155 | 121 | } |
|
156 | 122 | Button { |
|
157 | 123 | text: "slice explode dist +" |
|
158 | 124 | onClicked: series.at(0).explodeDistanceFactor += 0.1; |
|
159 | 125 | } |
|
160 | 126 | Button { |
|
161 | 127 | text: "slice explode dist -" |
|
162 | 128 | onClicked: series.at(0).explodeDistanceFactor -= 0.1; |
|
163 | 129 | } |
|
164 | 130 | } |
@@ -1,51 +1,57 | |||
|
1 | 1 | /**************************************************************************** |
|
2 | 2 | ** |
|
3 | 3 | ** Copyright (C) 2012 Digia Plc |
|
4 | 4 | ** All rights reserved. |
|
5 | 5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
6 | 6 | ** |
|
7 | 7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
8 | 8 | ** |
|
9 | 9 | ** $QT_BEGIN_LICENSE$ |
|
10 | 10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
11 | 11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
12 | 12 | ** Software or, alternatively, in accordance with the terms contained in |
|
13 | 13 | ** a written agreement between you and Digia. |
|
14 | 14 | ** |
|
15 | 15 | ** If you have questions regarding the use of this file, please use |
|
16 | 16 | ** contact form at http://qt.digia.com |
|
17 | 17 | ** $QT_END_LICENSE$ |
|
18 | 18 | ** |
|
19 | 19 | ****************************************************************************/ |
|
20 | 20 | |
|
21 | 21 | import QtQuick 1.0 |
|
22 | 22 | import QtCommercial.Chart 1.0 |
|
23 | 23 | |
|
24 | 24 | ChartView { |
|
25 | 25 | title: "scatter series" |
|
26 | 26 | axisX.max: 4 |
|
27 | 27 | axisY.max: 4 |
|
28 |
property variant series: |
|
|
28 | property variant series: scatterSeries | |
|
29 | 29 | |
|
30 | 30 | ScatterSeries { |
|
31 |
id: |
|
|
31 | id: scatterSeries | |
|
32 | 32 | name: "scatter 1" |
|
33 | 33 | XyPoint { x: 1.5; y: 1.5 } |
|
34 | 34 | XyPoint { x: 1.5; y: 1.6 } |
|
35 | 35 | XyPoint { x: 1.57; y: 1.55 } |
|
36 | 36 | XyPoint { x: 1.8; y: 1.8 } |
|
37 | 37 | XyPoint { x: 1.9; y: 1.6 } |
|
38 | 38 | XyPoint { x: 2.1; y: 1.3 } |
|
39 | 39 | XyPoint { x: 2.5; y: 2.1 } |
|
40 | ||
|
41 | onNameChanged: console.log("scatterSeries.onNameChanged: " + name); | |
|
42 | onVisibleChanged: console.log("scatterSeries.onVisibleChanged: " + visible); | |
|
43 | onColorChanged: console.log("scatterSeries.onColorChanged: " + color); | |
|
44 | onBorderColorChanged: console.log("scatterSeries.onBorderColorChanged: " + borderColor); | |
|
45 | onCountChanged: console.log("scatterSeries.onCountChanged: " + count); | |
|
40 | 46 | } |
|
41 | 47 | |
|
42 | 48 | ScatterSeries { |
|
43 | 49 | name: "scatter2" |
|
44 | 50 | XyPoint { x: 2.0; y: 2.0 } |
|
45 | 51 | XyPoint { x: 2.0; y: 2.1 } |
|
46 | 52 | XyPoint { x: 2.07; y: 2.05 } |
|
47 | 53 | XyPoint { x: 2.2; y: 2.9 } |
|
48 | 54 | XyPoint { x: 2.4; y: 2.7 } |
|
49 | 55 | XyPoint { x: 2.67; y: 2.65 } |
|
50 | 56 | } |
|
51 | 57 | } |
@@ -1,73 +1,55 | |||
|
1 | 1 | /**************************************************************************** |
|
2 | 2 | ** |
|
3 | 3 | ** Copyright (C) 2012 Digia Plc |
|
4 | 4 | ** All rights reserved. |
|
5 | 5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
6 | 6 | ** |
|
7 | 7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
8 | 8 | ** |
|
9 | 9 | ** $QT_BEGIN_LICENSE$ |
|
10 | 10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
11 | 11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
12 | 12 | ** Software or, alternatively, in accordance with the terms contained in |
|
13 | 13 | ** a written agreement between you and Digia. |
|
14 | 14 | ** |
|
15 | 15 | ** If you have questions regarding the use of this file, please use |
|
16 | 16 | ** contact form at http://qt.digia.com |
|
17 | 17 | ** $QT_END_LICENSE$ |
|
18 | 18 | ** |
|
19 | 19 | ****************************************************************************/ |
|
20 | 20 | |
|
21 | 21 | import QtQuick 1.0 |
|
22 | 22 | import QtCommercial.Chart 1.0 |
|
23 | 23 | |
|
24 | 24 | |
|
25 | 25 | Flow { |
|
26 | 26 | id: flow |
|
27 | 27 | spacing: 5 |
|
28 | 28 | flow: Flow.TopToBottom |
|
29 | 29 | property variant series |
|
30 | 30 | |
|
31 | onSeriesChanged: { | |
|
32 | if (series && series.name == "scatter 1") { | |
|
33 | seriesConnections.target = series; | |
|
34 | } else { | |
|
35 | seriesConnections.target = null; | |
|
36 | } | |
|
37 | } | |
|
38 | ||
|
39 | Connections { | |
|
40 | id: seriesConnections | |
|
41 | target: null | |
|
42 | onNameChanged: console.log("series.onNameChanged: " + series.name); | |
|
43 | onVisibleChanged: console.log("series.onVisibleChanged: " + series.visible); | |
|
44 | onColorChanged: console.log("series.onColorChanged: " + series.color); | |
|
45 | onBorderColorChanged: console.log("series.onBorderColorChanged: " + series.borderColor); | |
|
46 | onCountChanged: console.log("series.onCountChanged: " + series.count); | |
|
47 | } | |
|
48 | ||
|
49 | 31 | Button { |
|
50 | 32 | text: "visible" |
|
51 | 33 | onClicked: series.visible = !series.visible; |
|
52 | 34 | } |
|
53 | 35 | Button { |
|
54 | 36 | text: "color" |
|
55 | 37 | onClicked: series.color = main.nextColor(); |
|
56 | 38 | } |
|
57 | 39 | Button { |
|
58 | 40 | text: "borderColor" |
|
59 | 41 | onClicked: series.borderColor = main.nextColor(); |
|
60 | 42 | } |
|
61 | 43 | Button { |
|
62 | 44 | text: "markerSize +" |
|
63 | 45 | onClicked: series.markerSize += 1.0; |
|
64 | 46 | } |
|
65 | 47 | Button { |
|
66 | 48 | text: "markerSize -" |
|
67 | 49 | onClicked: series.markerSize -= 1.0; |
|
68 | 50 | } |
|
69 | 51 | Button { |
|
70 | 52 | text: "markerShape" |
|
71 | 53 | onClicked: series.markerShape = ((series.markerShape + 1) % 2); |
|
72 | 54 | } |
|
73 | 55 | } |
@@ -1,50 +1,59 | |||
|
1 | 1 | /**************************************************************************** |
|
2 | 2 | ** |
|
3 | 3 | ** Copyright (C) 2012 Digia Plc |
|
4 | 4 | ** All rights reserved. |
|
5 | 5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
6 | 6 | ** |
|
7 | 7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
8 | 8 | ** |
|
9 | 9 | ** $QT_BEGIN_LICENSE$ |
|
10 | 10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
11 | 11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
12 | 12 | ** Software or, alternatively, in accordance with the terms contained in |
|
13 | 13 | ** a written agreement between you and Digia. |
|
14 | 14 | ** |
|
15 | 15 | ** If you have questions regarding the use of this file, please use |
|
16 | 16 | ** contact form at http://qt.digia.com |
|
17 | 17 | ** $QT_END_LICENSE$ |
|
18 | 18 | ** |
|
19 | 19 | ****************************************************************************/ |
|
20 | 20 | |
|
21 | 21 | import QtQuick 1.0 |
|
22 | 22 | import QtCommercial.Chart 1.0 |
|
23 | 23 | |
|
24 | 24 | ChartView { |
|
25 | 25 | title: "spline series" |
|
26 | 26 | anchors.fill: parent |
|
27 |
property variant series: |
|
|
27 | property variant series: splineSeries | |
|
28 | 28 | |
|
29 | 29 | SplineSeries { |
|
30 |
id: |
|
|
30 | id: splineSeries | |
|
31 | 31 | name: "spline 1" |
|
32 | 32 | XyPoint { x: 0; y: 0 } |
|
33 | 33 | XyPoint { x: 1.1; y: 2.1 } |
|
34 | 34 | XyPoint { x: 1.9; y: 3.3 } |
|
35 | 35 | XyPoint { x: 2.1; y: 2.1 } |
|
36 | 36 | XyPoint { x: 2.9; y: 4.9 } |
|
37 | 37 | XyPoint { x: 3.4; y: 3.0 } |
|
38 | 38 | XyPoint { x: 4.1; y: 3.3 } |
|
39 | ||
|
40 | onNameChanged: console.log("splineSeries.onNameChanged: " + name); | |
|
41 | onVisibleChanged: console.log("splineSeries.onVisibleChanged: " + visible); | |
|
42 | onClicked: console.log("splineSeries.onClicked: " + point.x + ", " + point.y); | |
|
43 | onPointReplaced: console.log("splineSeries.onPointReplaced: " + index); | |
|
44 | onPointRemoved: console.log("splineSeries.onPointRemoved: " + index); | |
|
45 | onPointAdded: console.log("splineSeries.onPointAdded: " + index); | |
|
46 | onColorChanged: console.log("splineSeries.onColorChanged: " + color); | |
|
47 | onCountChanged: console.log("splineSeries.onCountChanged: " + count); | |
|
39 | 48 | } |
|
40 | 49 | |
|
41 | 50 | SplineSeries { |
|
42 | 51 | name: "spline 2" |
|
43 | 52 | XyPoint { x: 1.1; y: 1.1 } |
|
44 | 53 | XyPoint { x: 1.9; y: 2.3 } |
|
45 | 54 | XyPoint { x: 2.1; y: 1.1 } |
|
46 | 55 | XyPoint { x: 2.9; y: 3.9 } |
|
47 | 56 | XyPoint { x: 3.4; y: 2.0 } |
|
48 | 57 | XyPoint { x: 4.1; y: 2.3 } |
|
49 | 58 | } |
|
50 | 59 | } |
@@ -1,42 +1,54 | |||
|
1 | 1 | /**************************************************************************** |
|
2 | 2 | ** |
|
3 | 3 | ** Copyright (C) 2012 Digia Plc |
|
4 | 4 | ** All rights reserved. |
|
5 | 5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
6 | 6 | ** |
|
7 | 7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
8 | 8 | ** |
|
9 | 9 | ** $QT_BEGIN_LICENSE$ |
|
10 | 10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
11 | 11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
12 | 12 | ** Software or, alternatively, in accordance with the terms contained in |
|
13 | 13 | ** a written agreement between you and Digia. |
|
14 | 14 | ** |
|
15 | 15 | ** If you have questions regarding the use of this file, please use |
|
16 | 16 | ** contact form at http://qt.digia.com |
|
17 | 17 | ** $QT_END_LICENSE$ |
|
18 | 18 | ** |
|
19 | 19 | ****************************************************************************/ |
|
20 | 20 | |
|
21 | 21 | import QtQuick 1.0 |
|
22 | 22 | import QtCommercial.Chart 1.0 |
|
23 | 23 | |
|
24 | 24 | ChartView { |
|
25 | 25 | title: "Stacked bar series" |
|
26 | 26 | anchors.fill: parent |
|
27 | 27 | theme: ChartView.ChartThemeLight |
|
28 | 28 | legend.alignment: Qt.AlignBottom |
|
29 | 29 | axisXLabels: ["0", "2007", "1", "2008", "2", "2009", "3", "2010", "4", "2011", "5", "2012"] |
|
30 | 30 | |
|
31 |
property variant series: |
|
|
31 | property variant series: barSeries | |
|
32 | 32 | |
|
33 | 33 | StackedBarSeries { |
|
34 |
id: |
|
|
34 | id: barSeries | |
|
35 | 35 | name: "bar" |
|
36 | onClicked: console.log("onClicked: " + barset + " " + index); | |
|
37 | onHovered: console.log("onHovered: " + barset + " " + status); | |
|
38 | BarSet { label: "Bob"; values: [2, 2, 3, 4, 5, 6] } | |
|
36 | BarSet { label: "Bob"; values: [2, 2, 3, 4, 5, 6] | |
|
37 | onClicked: console.log("barset.onClicked: " + index); | |
|
38 | onHovered: console.log("barset.onHovered: " + status); | |
|
39 | onColorChanged: console.log("barset.onColorChanged: " + color); | |
|
40 | onBorderColorChanged: console.log("barset.onBorderColorChanged: " + color); | |
|
41 | onLabelColorChanged: console.log("barset.onLabelColorChanged: " + color); | |
|
42 | onCountChanged: console.log("barset.onCountChanged: " + count); | |
|
43 | } | |
|
39 | 44 | BarSet { label: "Susan"; values: [5, 1, 2, 4, 1, 7] } |
|
40 | 45 | BarSet { label: "James"; values: [3, 5, 8, 13, 5, 8] } |
|
46 | ||
|
47 | onNameChanged: console.log("stackedBarSeries.onNameChanged: " + series.name); | |
|
48 | onVisibleChanged: console.log("stackedBarSeries.onVisibleChanged: " + series.visible); | |
|
49 | onClicked: console.log("stackedBarSeries.onClicked: " + barset + " " + index); | |
|
50 | onHovered: console.log("stackedBarSeries.onHovered: " + barset + " " + status); | |
|
51 | onLabelsVisibleChanged: console.log("stackedBarSeries.onLabelsVisibleChanged: " + series.labelsVisible); | |
|
52 | onCountChanged: console.log("stackedBarSeries.onCountChanged: " + count); | |
|
41 | 53 | } |
|
42 | 54 | } |
@@ -1,126 +1,125 | |||
|
1 | 1 | /**************************************************************************** |
|
2 | 2 | ** |
|
3 | 3 | ** Copyright (C) 2012 Digia Plc |
|
4 | 4 | ** All rights reserved. |
|
5 | 5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
6 | 6 | ** |
|
7 | 7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
8 | 8 | ** |
|
9 | 9 | ** $QT_BEGIN_LICENSE$ |
|
10 | 10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
11 | 11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
12 | 12 | ** Software or, alternatively, in accordance with the terms contained in |
|
13 | 13 | ** a written agreement between you and Digia. |
|
14 | 14 | ** |
|
15 | 15 | ** If you have questions regarding the use of this file, please use |
|
16 | 16 | ** contact form at http://qt.digia.com |
|
17 | 17 | ** $QT_END_LICENSE$ |
|
18 | 18 | ** |
|
19 | 19 | ****************************************************************************/ |
|
20 | 20 | |
|
21 | 21 | import QtQuick 1.0 |
|
22 | 22 | import QtCommercial.Chart 1.0 |
|
23 | 23 | |
|
24 | 24 | Rectangle { |
|
25 | 25 | id: main |
|
26 | 26 | width: parent.width |
|
27 | 27 | height: parent.height |
|
28 | 28 | property int viewNumber: 0 |
|
29 | 29 | property int viewCount: 10 |
|
30 | 30 | property variant colors: ["#637D74", "#403D3A", "#8C3B3B", "#AB6937", "#D4A960"] |
|
31 | 31 | property int colorIndex: 0 |
|
32 | 32 | |
|
33 | 33 | function nextColor() { |
|
34 | 34 | colorIndex++; |
|
35 | console.log("color: " + colors[colorIndex % colors.length]); | |
|
36 | 35 | return colors[colorIndex % colors.length]; |
|
37 | 36 | } |
|
38 | 37 | |
|
39 | 38 | onViewNumberChanged: { |
|
40 | 39 | if (viewNumber == 0) { |
|
41 | 40 | chartLoader.source = "Chart.qml"; |
|
42 | 41 | editorLoader.source = "ChartEditor.qml"; |
|
43 | 42 | } else if (viewNumber == 1) { |
|
44 | 43 | chartLoader.source = "PieChart.qml"; |
|
45 | 44 | editorLoader.source = "PieEditor.qml"; |
|
46 | 45 | } else if (viewNumber == 2) { |
|
47 | 46 | chartLoader.source = "LineChart.qml"; |
|
48 | 47 | editorLoader.source = "LineEditor.qml"; |
|
49 | 48 | } else if (viewNumber == 3) { |
|
50 | 49 | chartLoader.source = "SplineChart.qml"; |
|
51 | 50 | editorLoader.source = "LineEditor.qml"; |
|
52 | 51 | } else if (viewNumber == 4) { |
|
53 | 52 | chartLoader.source = "ScatterChart.qml"; |
|
54 | 53 | editorLoader.source = "ScatterEditor.qml"; |
|
55 | 54 | } else if (viewNumber == 5) { |
|
56 | 55 | chartLoader.source = "AreaChart.qml"; |
|
57 | 56 | editorLoader.source = "AreaEditor.qml"; |
|
58 | 57 | } else if (viewNumber == 6) { |
|
59 | 58 | chartLoader.source = "BarChart.qml"; |
|
60 | 59 | editorLoader.source = "BarEditor.qml"; |
|
61 | 60 | } else if (viewNumber == 7) { |
|
62 | 61 | chartLoader.source = "GroupedBarChart.qml"; |
|
63 | 62 | editorLoader.source = "BarEditor.qml"; |
|
64 | 63 | } else if (viewNumber == 8) { |
|
65 | 64 | chartLoader.source = "StackedBarChart.qml"; |
|
66 | 65 | editorLoader.source = "BarEditor.qml"; |
|
67 | 66 | } else if (viewNumber == 9) { |
|
68 | 67 | chartLoader.source = "PercentBarChart.qml"; |
|
69 | 68 | editorLoader.source = "BarEditor.qml"; |
|
70 | 69 | } else { |
|
71 | 70 | console.log("Illegal view number"); |
|
72 | 71 | } |
|
73 | 72 | } |
|
74 | 73 | |
|
75 | 74 | Row { |
|
76 | 75 | anchors.top: parent.top |
|
77 | 76 | anchors.bottom: buttonRow.top |
|
78 | 77 | anchors.bottomMargin: 10 |
|
79 | 78 | anchors.left: parent.left |
|
80 | 79 | anchors.right: parent.right |
|
81 | 80 | |
|
82 | 81 | Loader { |
|
83 | 82 | id: chartLoader |
|
84 | 83 | width: main.width - editorLoader.width |
|
85 | 84 | height: parent.height |
|
86 | 85 | source: "Chart.qml" |
|
87 | 86 | onStatusChanged: { |
|
88 | 87 | if (status == Loader.Ready && editorLoader.status == Loader.Ready && chartLoader.item) |
|
89 | 88 | editorLoader.item.series = chartLoader.item.series; |
|
90 | 89 | } |
|
91 | 90 | } |
|
92 | 91 | |
|
93 | 92 | Loader { |
|
94 | 93 | id: editorLoader |
|
95 | 94 | width: 280 |
|
96 | 95 | height: parent.height |
|
97 | 96 | source: "ChartEditor.qml" |
|
98 | 97 | onStatusChanged: { |
|
99 | 98 | if (status == Loader.Ready && chartLoader.status == Loader.Ready && chartLoader.item) |
|
100 | 99 | editorLoader.item.series = chartLoader.item.series; |
|
101 | 100 | } |
|
102 | 101 | } |
|
103 | 102 | } |
|
104 | 103 | |
|
105 | 104 | Row { |
|
106 | 105 | id: buttonRow |
|
107 | 106 | height: 40 |
|
108 | 107 | anchors.bottom: parent.bottom |
|
109 | 108 | anchors.horizontalCenter: parent.horizontalCenter |
|
110 | 109 | spacing: 10 |
|
111 | 110 | |
|
112 | 111 | Button { |
|
113 | 112 | text: "previous" |
|
114 | 113 | onClicked: { |
|
115 | 114 | viewNumber = (viewNumber + viewCount - 1) % viewCount; |
|
116 | 115 | } |
|
117 | 116 | } |
|
118 | 117 | |
|
119 | 118 | Button { |
|
120 | 119 | text: "next" |
|
121 | 120 | onClicked: { |
|
122 | 121 | viewNumber = (viewNumber + 1) % viewCount; |
|
123 | 122 | } |
|
124 | 123 | } |
|
125 | 124 | } |
|
126 | 125 | } |
General Comments 0
You need to be logged in to leave comments.
Login now