@@ -1,343 +1,331 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2014 Digia Plc |
|
3 | ** Copyright (C) 2014 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to Digia, please use contact form at http://qt.io |
|
5 | ** For any questions to Digia, please use contact form at http://qt.io | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Charts module. |
|
7 | ** This file is part of the Qt Charts module. | |
8 | ** |
|
8 | ** | |
9 | ** Licensees holding valid commercial license for Qt may use this file in |
|
9 | ** Licensees holding valid commercial license for Qt may use this file in | |
10 | ** accordance with the Qt License Agreement provided with the Software |
|
10 | ** accordance with the Qt License Agreement provided with the Software | |
11 | ** or, alternatively, in accordance with the terms contained in a written |
|
11 | ** or, alternatively, in accordance with the terms contained in a written | |
12 | ** agreement between you and Digia. |
|
12 | ** agreement between you and Digia. | |
13 | ** |
|
13 | ** | |
14 | ** If you have questions regarding the use of this file, please use |
|
14 | ** If you have questions regarding the use of this file, please use | |
15 | ** contact form at http://qt.io |
|
15 | ** contact form at http://qt.io | |
16 | ** |
|
16 | ** | |
17 | ****************************************************************************/ |
|
17 | ****************************************************************************/ | |
18 |
|
18 | |||
19 | #include <QtCharts/QCategoryAxis> |
|
19 | #include <QtCharts/QCategoryAxis> | |
20 | #include <private/qcategoryaxis_p.h> |
|
20 | #include <private/qcategoryaxis_p.h> | |
21 | #include <private/chartcategoryaxisx_p.h> |
|
21 | #include <private/chartcategoryaxisx_p.h> | |
22 | #include <private/chartcategoryaxisy_p.h> |
|
22 | #include <private/chartcategoryaxisy_p.h> | |
23 | #include <private/polarchartcategoryaxisangular_p.h> |
|
23 | #include <private/polarchartcategoryaxisangular_p.h> | |
24 | #include <private/polarchartcategoryaxisradial_p.h> |
|
24 | #include <private/polarchartcategoryaxisradial_p.h> | |
25 | #include <QtCharts/QChart> |
|
25 | #include <QtCharts/QChart> | |
26 | #include <QtCore/QtMath> |
|
26 | #include <QtCore/QtMath> | |
27 | #include <QtCore/QDebug> |
|
27 | #include <QtCore/QDebug> | |
28 |
|
28 | |||
29 | QT_CHARTS_BEGIN_NAMESPACE |
|
29 | QT_CHARTS_BEGIN_NAMESPACE | |
30 | /*! |
|
30 | /*! | |
31 | \class QCategoryAxis |
|
31 | \class QCategoryAxis | |
32 | \inmodule Qt Charts |
|
32 | \inmodule Qt Charts | |
33 | \brief The QCategoryAxis class allows putting a named ranges on the axis. |
|
33 | \brief The QCategoryAxis class allows putting a named ranges on the axis. | |
34 | \mainclass |
|
34 | \mainclass | |
35 |
|
35 | |||
36 | This class can be used when the underlying data needs to be given extra meaning. |
|
36 | This class can be used when the underlying data needs to be given extra meaning. | |
37 | Unlike with the QBarCategoryAxis the QCategoryAxis allows the categories ranges widths to be specified freely. |
|
37 | Unlike with the QBarCategoryAxis the QCategoryAxis allows the categories ranges widths to be specified freely. | |
38 |
|
38 | |||
39 | Example code on how to use QCategoryAxis: |
|
39 | Example code on how to use QCategoryAxis: | |
40 | \table |
|
40 | \image api_category_axis.png | |
41 | \row |
|
41 | \code | |
42 | \li \br |
|
42 | QChartView *chartView = new QChartView; | |
43 | \br |
|
43 | QLineSeries *series = new QLineSeries; | |
44 | \code |
|
44 | // ... | |
45 | QChartView *chartView = new QChartView; |
|
45 | chartView->chart()->addSeries(series); | |
46 | QLineSeries *series = new QLineSeries; |
|
46 | ||
47 | // ... |
|
47 | QCategoryAxis *axisY = new QCategoryAxis; | |
48 | chartView->chart()->addSeries(series); |
|
48 | axisY->setMin(0); | |
49 |
|
49 | axisY->setMax(52); | ||
50 | QCategoryAxis *axisY = new QCategoryAxis; |
|
50 | axisY->setStartValue(15); | |
51 | axisY->setMin(0); |
|
51 | axisY->append("First", 20); | |
52 | axisY->setMax(52); |
|
52 | axisY->append("Second", 37); | |
53 | axisY->setStartValue(15); |
|
53 | axisY->append("Third", 52); | |
54 | axisY->append("First", 20); |
|
54 | chartView->chart()->setAxisY(axisY, series); | |
55 | axisY->append("Second", 37); |
|
55 | \endcode | |
56 | axisY->append("Third", 52); |
|
|||
57 | chartView->chart()->setAxisY(axisY, series); |
|
|||
58 | \endcode |
|
|||
59 | \li \br |
|
|||
60 | \inlineimage api_category_axis.png |
|
|||
61 | \endtable |
|
|||
62 | */ |
|
56 | */ | |
63 | /*! |
|
57 | /*! | |
64 | \qmltype CategoryAxis |
|
58 | \qmltype CategoryAxis | |
65 | \instantiates QCategoryAxis |
|
59 | \instantiates QCategoryAxis | |
66 | \inqmlmodule QtCharts |
|
60 | \inqmlmodule QtCharts | |
67 |
|
61 | |||
68 | \inherits AbstractAxis |
|
62 | \inherits AbstractAxis | |
69 | \brief CategoryAxis allows putting a named ranges on the axis. |
|
63 | \brief CategoryAxis allows putting a named ranges on the axis. | |
70 |
|
64 | |||
71 | For example: |
|
65 | For example: | |
72 | \table |
|
66 | \image examples_qmlaxes3.png | |
73 | \row |
|
67 | \snippet qmlaxes/qml/qmlaxes/View3.qml 1 | |
74 | \li \br |
|
|||
75 | \br |
|
|||
76 | \br |
|
|||
77 | \snippet qmlaxes/qml/qmlaxes/View3.qml 1 |
|
|||
78 | \li \inlineimage examples_qmlaxes3.png |
|
|||
79 | \endtable |
|
|||
80 | */ |
|
68 | */ | |
81 |
|
69 | |||
82 | /*! |
|
70 | /*! | |
83 | \property QCategoryAxis::startValue |
|
71 | \property QCategoryAxis::startValue | |
84 | Defines the low end of the first category on the axis. |
|
72 | Defines the low end of the first category on the axis. | |
85 | */ |
|
73 | */ | |
86 | /*! |
|
74 | /*! | |
87 | \qmlproperty int CategoryAxis::startValue |
|
75 | \qmlproperty int CategoryAxis::startValue | |
88 | Defines the low end of the first category on the axis. |
|
76 | Defines the low end of the first category on the axis. | |
89 | */ |
|
77 | */ | |
90 |
|
78 | |||
91 | /*! |
|
79 | /*! | |
92 | \property QCategoryAxis::count |
|
80 | \property QCategoryAxis::count | |
93 | The count of categories. |
|
81 | The count of categories. | |
94 | */ |
|
82 | */ | |
95 | /*! |
|
83 | /*! | |
96 | \qmlproperty int CategoryAxis::count |
|
84 | \qmlproperty int CategoryAxis::count | |
97 | The count of categories. |
|
85 | The count of categories. | |
98 | */ |
|
86 | */ | |
99 |
|
87 | |||
100 | /*! |
|
88 | /*! | |
101 | \property QCategoryAxis::categoriesLabels |
|
89 | \property QCategoryAxis::categoriesLabels | |
102 | The category labels as a string list. |
|
90 | The category labels as a string list. | |
103 | */ |
|
91 | */ | |
104 | /*! |
|
92 | /*! | |
105 | \qmlproperty StringList CategoryAxis::categoriesLabels |
|
93 | \qmlproperty StringList CategoryAxis::categoriesLabels | |
106 | The category labels as a list of strings. |
|
94 | The category labels as a list of strings. | |
107 | */ |
|
95 | */ | |
108 |
|
96 | |||
109 | /*! |
|
97 | /*! | |
110 | \fn void QCategoryAxis::categoriesChanged() |
|
98 | \fn void QCategoryAxis::categoriesChanged() | |
111 | Axis emits signal when the categories of the axis have changed. |
|
99 | Axis emits signal when the categories of the axis have changed. | |
112 | */ |
|
100 | */ | |
113 |
|
101 | |||
114 |
|
102 | |||
115 | /*! |
|
103 | /*! | |
116 | Constructs an axis object which is a child of \a parent. |
|
104 | Constructs an axis object which is a child of \a parent. | |
117 | */ |
|
105 | */ | |
118 | QCategoryAxis::QCategoryAxis(QObject *parent): |
|
106 | QCategoryAxis::QCategoryAxis(QObject *parent): | |
119 | QValueAxis(*new QCategoryAxisPrivate(this), parent) |
|
107 | QValueAxis(*new QCategoryAxisPrivate(this), parent) | |
120 | { |
|
108 | { | |
121 | } |
|
109 | } | |
122 |
|
110 | |||
123 | /*! |
|
111 | /*! | |
124 | Destroys the object |
|
112 | Destroys the object | |
125 | */ |
|
113 | */ | |
126 | QCategoryAxis::~QCategoryAxis() |
|
114 | QCategoryAxis::~QCategoryAxis() | |
127 | { |
|
115 | { | |
128 | Q_D(QCategoryAxis); |
|
116 | Q_D(QCategoryAxis); | |
129 | if (d->m_chart) |
|
117 | if (d->m_chart) | |
130 | d->m_chart->removeAxis(this); |
|
118 | d->m_chart->removeAxis(this); | |
131 | } |
|
119 | } | |
132 |
|
120 | |||
133 | /*! |
|
121 | /*! | |
134 | \internal |
|
122 | \internal | |
135 | */ |
|
123 | */ | |
136 | QCategoryAxis::QCategoryAxis(QCategoryAxisPrivate &d, QObject *parent): QValueAxis(d, parent) |
|
124 | QCategoryAxis::QCategoryAxis(QCategoryAxisPrivate &d, QObject *parent): QValueAxis(d, parent) | |
137 | { |
|
125 | { | |
138 |
|
126 | |||
139 | } |
|
127 | } | |
140 |
|
128 | |||
141 | /*! |
|
129 | /*! | |
142 | \qmlmethod CategoryAxis::append(string label, real endValue) |
|
130 | \qmlmethod CategoryAxis::append(string label, real endValue) | |
143 | Appends new category to the axis with an \a label. Category label has to be unique. |
|
131 | Appends new category to the axis with an \a label. Category label has to be unique. | |
144 | Parameter \a endValue specifies the high end limit of the category. |
|
132 | Parameter \a endValue specifies the high end limit of the category. | |
145 | It has to be greater than the high end limit of the previous category. |
|
133 | It has to be greater than the high end limit of the previous category. | |
146 | Otherwise the method returns without adding a new category. |
|
134 | Otherwise the method returns without adding a new category. | |
147 | */ |
|
135 | */ | |
148 | /*! |
|
136 | /*! | |
149 | Appends new category to the axis with an \a categoryLabel. |
|
137 | Appends new category to the axis with an \a categoryLabel. | |
150 | Category label has to be unique. |
|
138 | Category label has to be unique. | |
151 | Parameter \a categoryEndValue specifies the high end limit of the category. |
|
139 | Parameter \a categoryEndValue specifies the high end limit of the category. | |
152 | It has to be greater than the high end limit of the previous category. |
|
140 | It has to be greater than the high end limit of the previous category. | |
153 | Otherwise the method returns without adding a new category. |
|
141 | Otherwise the method returns without adding a new category. | |
154 | */ |
|
142 | */ | |
155 | void QCategoryAxis::append(const QString &categoryLabel, qreal categoryEndValue) |
|
143 | void QCategoryAxis::append(const QString &categoryLabel, qreal categoryEndValue) | |
156 | { |
|
144 | { | |
157 | Q_D(QCategoryAxis); |
|
145 | Q_D(QCategoryAxis); | |
158 |
|
146 | |||
159 | if (!d->m_categories.contains(categoryLabel)) { |
|
147 | if (!d->m_categories.contains(categoryLabel)) { | |
160 | if (d->m_categories.isEmpty()) { |
|
148 | if (d->m_categories.isEmpty()) { | |
161 | Range range(d->m_categoryMinimum, categoryEndValue); |
|
149 | Range range(d->m_categoryMinimum, categoryEndValue); | |
162 | d->m_categoriesMap.insert(categoryLabel, range); |
|
150 | d->m_categoriesMap.insert(categoryLabel, range); | |
163 | d->m_categories.append(categoryLabel); |
|
151 | d->m_categories.append(categoryLabel); | |
164 | emit categoriesChanged(); |
|
152 | emit categoriesChanged(); | |
165 | } else if (categoryEndValue > endValue(d->m_categories.last())) { |
|
153 | } else if (categoryEndValue > endValue(d->m_categories.last())) { | |
166 | Range previousRange = d->m_categoriesMap.value(d->m_categories.last()); |
|
154 | Range previousRange = d->m_categoriesMap.value(d->m_categories.last()); | |
167 | d->m_categoriesMap.insert(categoryLabel, Range(previousRange.second, categoryEndValue)); |
|
155 | d->m_categoriesMap.insert(categoryLabel, Range(previousRange.second, categoryEndValue)); | |
168 | d->m_categories.append(categoryLabel); |
|
156 | d->m_categories.append(categoryLabel); | |
169 | emit categoriesChanged(); |
|
157 | emit categoriesChanged(); | |
170 | } |
|
158 | } | |
171 | } |
|
159 | } | |
172 | } |
|
160 | } | |
173 |
|
161 | |||
174 | /*! |
|
162 | /*! | |
175 | Sets \a min to be the low end limit of the first category on the axis. |
|
163 | Sets \a min to be the low end limit of the first category on the axis. | |
176 | If there is already some categories added to the axis then passed value must be lower than the high end value of the already defined first category range. |
|
164 | If there is already some categories added to the axis then passed value must be lower than the high end value of the already defined first category range. | |
177 | Otherwise nothing is done. |
|
165 | Otherwise nothing is done. | |
178 | */ |
|
166 | */ | |
179 | void QCategoryAxis::setStartValue(qreal min) |
|
167 | void QCategoryAxis::setStartValue(qreal min) | |
180 | { |
|
168 | { | |
181 | Q_D(QCategoryAxis); |
|
169 | Q_D(QCategoryAxis); | |
182 | if (d->m_categories.isEmpty()) { |
|
170 | if (d->m_categories.isEmpty()) { | |
183 | d->m_categoryMinimum = min; |
|
171 | d->m_categoryMinimum = min; | |
184 | emit categoriesChanged(); |
|
172 | emit categoriesChanged(); | |
185 | } else { |
|
173 | } else { | |
186 | Range range = d->m_categoriesMap.value(d->m_categories.first()); |
|
174 | Range range = d->m_categoriesMap.value(d->m_categories.first()); | |
187 | if (min < range.second) { |
|
175 | if (min < range.second) { | |
188 | d->m_categoriesMap.insert(d->m_categories.first(), Range(min, range.second)); |
|
176 | d->m_categoriesMap.insert(d->m_categories.first(), Range(min, range.second)); | |
189 | emit categoriesChanged(); |
|
177 | emit categoriesChanged(); | |
190 | } |
|
178 | } | |
191 | } |
|
179 | } | |
192 | } |
|
180 | } | |
193 |
|
181 | |||
194 | /*! |
|
182 | /*! | |
195 | Returns the low end limit of the category specified by an \a categoryLabel |
|
183 | Returns the low end limit of the category specified by an \a categoryLabel | |
196 | */ |
|
184 | */ | |
197 | qreal QCategoryAxis::startValue(const QString &categoryLabel) const |
|
185 | qreal QCategoryAxis::startValue(const QString &categoryLabel) const | |
198 | { |
|
186 | { | |
199 | Q_D(const QCategoryAxis); |
|
187 | Q_D(const QCategoryAxis); | |
200 | if (categoryLabel.isEmpty()) |
|
188 | if (categoryLabel.isEmpty()) | |
201 | return d->m_categoryMinimum; |
|
189 | return d->m_categoryMinimum; | |
202 | return d->m_categoriesMap.value(categoryLabel).first; |
|
190 | return d->m_categoriesMap.value(categoryLabel).first; | |
203 | } |
|
191 | } | |
204 |
|
192 | |||
205 | /*! |
|
193 | /*! | |
206 | Returns the high end limit of the interval specified by an \a categoryLabel |
|
194 | Returns the high end limit of the interval specified by an \a categoryLabel | |
207 | */ |
|
195 | */ | |
208 | qreal QCategoryAxis::endValue(const QString &categoryLabel) const |
|
196 | qreal QCategoryAxis::endValue(const QString &categoryLabel) const | |
209 | { |
|
197 | { | |
210 | Q_D(const QCategoryAxis); |
|
198 | Q_D(const QCategoryAxis); | |
211 | return d->m_categoriesMap.value(categoryLabel).second; |
|
199 | return d->m_categoriesMap.value(categoryLabel).second; | |
212 | } |
|
200 | } | |
213 |
|
201 | |||
214 | /*! |
|
202 | /*! | |
215 | \qmlmethod CategoryAxis::remove(string label) |
|
203 | \qmlmethod CategoryAxis::remove(string label) | |
216 | Removes a category specified by the \a label from the axis |
|
204 | Removes a category specified by the \a label from the axis | |
217 | */ |
|
205 | */ | |
218 | /*! |
|
206 | /*! | |
219 | Removes an interval specified by the \a categoryLabel from the axis |
|
207 | Removes an interval specified by the \a categoryLabel from the axis | |
220 | */ |
|
208 | */ | |
221 | void QCategoryAxis::remove(const QString &categoryLabel) |
|
209 | void QCategoryAxis::remove(const QString &categoryLabel) | |
222 | { |
|
210 | { | |
223 | Q_D(QCategoryAxis); |
|
211 | Q_D(QCategoryAxis); | |
224 | int labelIndex = d->m_categories.indexOf(categoryLabel); |
|
212 | int labelIndex = d->m_categories.indexOf(categoryLabel); | |
225 |
|
213 | |||
226 | // check if such label exists |
|
214 | // check if such label exists | |
227 | if (labelIndex != -1) { |
|
215 | if (labelIndex != -1) { | |
228 | d->m_categories.removeAt(labelIndex); |
|
216 | d->m_categories.removeAt(labelIndex); | |
229 | d->m_categoriesMap.remove(categoryLabel); |
|
217 | d->m_categoriesMap.remove(categoryLabel); | |
230 |
|
218 | |||
231 | // the range of the interval that follows (if exists) needs to be updated |
|
219 | // the range of the interval that follows (if exists) needs to be updated | |
232 | if (labelIndex < d->m_categories.count()) { |
|
220 | if (labelIndex < d->m_categories.count()) { | |
233 | QString label = d->m_categories.at(labelIndex); |
|
221 | QString label = d->m_categories.at(labelIndex); | |
234 | Range range = d->m_categoriesMap.value(label); |
|
222 | Range range = d->m_categoriesMap.value(label); | |
235 |
|
223 | |||
236 | // set the range |
|
224 | // set the range | |
237 | if (labelIndex == 0) { |
|
225 | if (labelIndex == 0) { | |
238 | range.first = d->m_categoryMinimum; |
|
226 | range.first = d->m_categoryMinimum; | |
239 | d->m_categoriesMap.insert(label, range); |
|
227 | d->m_categoriesMap.insert(label, range); | |
240 | } else { |
|
228 | } else { | |
241 | range.first = d->m_categoriesMap.value(d->m_categories.at(labelIndex - 1)).second; |
|
229 | range.first = d->m_categoriesMap.value(d->m_categories.at(labelIndex - 1)).second; | |
242 | d->m_categoriesMap.insert(label, range); |
|
230 | d->m_categoriesMap.insert(label, range); | |
243 | } |
|
231 | } | |
244 | } |
|
232 | } | |
245 | emit categoriesChanged(); |
|
233 | emit categoriesChanged(); | |
246 | } |
|
234 | } | |
247 | } |
|
235 | } | |
248 |
|
236 | |||
249 | /*! |
|
237 | /*! | |
250 | \qmlmethod CategoryAxis::replace(string oldLabel, string newLabel) |
|
238 | \qmlmethod CategoryAxis::replace(string oldLabel, string newLabel) | |
251 | Replaces \a oldLabel of an existing category with a \a newLabel. |
|
239 | Replaces \a oldLabel of an existing category with a \a newLabel. | |
252 | If the old label does not exist the method returns without making any changes. |
|
240 | If the old label does not exist the method returns without making any changes. | |
253 | */ |
|
241 | */ | |
254 | /*! |
|
242 | /*! | |
255 | Replaces \a oldLabel of an existing category with a \a newLabel |
|
243 | Replaces \a oldLabel of an existing category with a \a newLabel | |
256 | If the old label does not exist the method returns without making any changes. |
|
244 | If the old label does not exist the method returns without making any changes. | |
257 | */ |
|
245 | */ | |
258 | void QCategoryAxis::replaceLabel(const QString &oldLabel, const QString &newLabel) |
|
246 | void QCategoryAxis::replaceLabel(const QString &oldLabel, const QString &newLabel) | |
259 | { |
|
247 | { | |
260 | Q_D(QCategoryAxis); |
|
248 | Q_D(QCategoryAxis); | |
261 | int labelIndex = d->m_categories.indexOf(oldLabel); |
|
249 | int labelIndex = d->m_categories.indexOf(oldLabel); | |
262 |
|
250 | |||
263 | // check if such label exists |
|
251 | // check if such label exists | |
264 | if (labelIndex != -1) { |
|
252 | if (labelIndex != -1) { | |
265 | d->m_categories.replace(labelIndex, newLabel); |
|
253 | d->m_categories.replace(labelIndex, newLabel); | |
266 | Range range = d->m_categoriesMap.value(oldLabel); |
|
254 | Range range = d->m_categoriesMap.value(oldLabel); | |
267 | d->m_categoriesMap.remove(oldLabel); |
|
255 | d->m_categoriesMap.remove(oldLabel); | |
268 | d->m_categoriesMap.insert(newLabel, range); |
|
256 | d->m_categoriesMap.insert(newLabel, range); | |
269 | emit categoriesChanged(); |
|
257 | emit categoriesChanged(); | |
270 | } |
|
258 | } | |
271 | } |
|
259 | } | |
272 |
|
260 | |||
273 | /*! |
|
261 | /*! | |
274 | Returns the list of the intervals labels |
|
262 | Returns the list of the intervals labels | |
275 | */ |
|
263 | */ | |
276 | QStringList QCategoryAxis::categoriesLabels() |
|
264 | QStringList QCategoryAxis::categoriesLabels() | |
277 | { |
|
265 | { | |
278 | Q_D(QCategoryAxis); |
|
266 | Q_D(QCategoryAxis); | |
279 | return d->m_categories; |
|
267 | return d->m_categories; | |
280 | } |
|
268 | } | |
281 |
|
269 | |||
282 | /*! |
|
270 | /*! | |
283 | Returns number of intervals. |
|
271 | Returns number of intervals. | |
284 | */ |
|
272 | */ | |
285 | int QCategoryAxis::count() const |
|
273 | int QCategoryAxis::count() const | |
286 | { |
|
274 | { | |
287 | Q_D(const QCategoryAxis); |
|
275 | Q_D(const QCategoryAxis); | |
288 | return d->m_categories.count(); |
|
276 | return d->m_categories.count(); | |
289 | } |
|
277 | } | |
290 |
|
278 | |||
291 | /*! |
|
279 | /*! | |
292 | Returns the type of the axis |
|
280 | Returns the type of the axis | |
293 | */ |
|
281 | */ | |
294 | QAbstractAxis::AxisType QCategoryAxis::type() const |
|
282 | QAbstractAxis::AxisType QCategoryAxis::type() const | |
295 | { |
|
283 | { | |
296 | return QAbstractAxis::AxisTypeCategory; |
|
284 | return QAbstractAxis::AxisTypeCategory; | |
297 | } |
|
285 | } | |
298 |
|
286 | |||
299 | ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
|
287 | ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |
300 |
|
288 | |||
301 | QCategoryAxisPrivate::QCategoryAxisPrivate(QCategoryAxis *q) |
|
289 | QCategoryAxisPrivate::QCategoryAxisPrivate(QCategoryAxis *q) | |
302 | : QValueAxisPrivate(q), |
|
290 | : QValueAxisPrivate(q), | |
303 | m_categoryMinimum(0) |
|
291 | m_categoryMinimum(0) | |
304 | { |
|
292 | { | |
305 |
|
293 | |||
306 | } |
|
294 | } | |
307 |
|
295 | |||
308 | QCategoryAxisPrivate::~QCategoryAxisPrivate() |
|
296 | QCategoryAxisPrivate::~QCategoryAxisPrivate() | |
309 | { |
|
297 | { | |
310 |
|
298 | |||
311 | } |
|
299 | } | |
312 |
|
300 | |||
313 | int QCategoryAxisPrivate::ticksCount() const |
|
301 | int QCategoryAxisPrivate::ticksCount() const | |
314 | { |
|
302 | { | |
315 | return m_categories.count() + 1; |
|
303 | return m_categories.count() + 1; | |
316 | } |
|
304 | } | |
317 |
|
305 | |||
318 | void QCategoryAxisPrivate::initializeGraphics(QGraphicsItem *parent) |
|
306 | void QCategoryAxisPrivate::initializeGraphics(QGraphicsItem *parent) | |
319 | { |
|
307 | { | |
320 | Q_Q(QCategoryAxis); |
|
308 | Q_Q(QCategoryAxis); | |
321 | ChartAxisElement *axis(0); |
|
309 | ChartAxisElement *axis(0); | |
322 | if (m_chart->chartType() == QChart::ChartTypeCartesian) { |
|
310 | if (m_chart->chartType() == QChart::ChartTypeCartesian) { | |
323 | if (orientation() == Qt::Vertical) |
|
311 | if (orientation() == Qt::Vertical) | |
324 | axis = new ChartCategoryAxisY(q,parent); |
|
312 | axis = new ChartCategoryAxisY(q,parent); | |
325 | else if (orientation() == Qt::Horizontal) |
|
313 | else if (orientation() == Qt::Horizontal) | |
326 | axis = new ChartCategoryAxisX(q,parent); |
|
314 | axis = new ChartCategoryAxisX(q,parent); | |
327 | } |
|
315 | } | |
328 |
|
316 | |||
329 | if (m_chart->chartType() == QChart::ChartTypePolar) { |
|
317 | if (m_chart->chartType() == QChart::ChartTypePolar) { | |
330 | if (orientation() == Qt::Vertical) |
|
318 | if (orientation() == Qt::Vertical) | |
331 | axis = new PolarChartCategoryAxisRadial(q, parent); |
|
319 | axis = new PolarChartCategoryAxisRadial(q, parent); | |
332 | if (orientation() == Qt::Horizontal) |
|
320 | if (orientation() == Qt::Horizontal) | |
333 | axis = new PolarChartCategoryAxisAngular(q, parent); |
|
321 | axis = new PolarChartCategoryAxisAngular(q, parent); | |
334 | } |
|
322 | } | |
335 |
|
323 | |||
336 | m_item.reset(axis); |
|
324 | m_item.reset(axis); | |
337 | QAbstractAxisPrivate::initializeGraphics(parent); |
|
325 | QAbstractAxisPrivate::initializeGraphics(parent); | |
338 | } |
|
326 | } | |
339 |
|
327 | |||
340 | #include "moc_qcategoryaxis.cpp" |
|
328 | #include "moc_qcategoryaxis.cpp" | |
341 | #include "moc_qcategoryaxis_p.cpp" |
|
329 | #include "moc_qcategoryaxis_p.cpp" | |
342 |
|
330 | |||
343 | QT_CHARTS_END_NAMESPACE |
|
331 | QT_CHARTS_END_NAMESPACE |
@@ -1,26 +1,26 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2014 Digia Plc |
|
3 | ** Copyright (C) 2014 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to Digia, please use contact form at http://qt.io |
|
5 | ** For any questions to Digia, please use contact form at http://qt.io | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Charts module. |
|
7 | ** This file is part of the Qt Charts module. | |
8 | ** |
|
8 | ** | |
9 | ** Licensees holding valid commercial license for Qt may use this file in |
|
9 | ** Licensees holding valid commercial license for Qt may use this file in | |
10 | ** accordance with the Qt License Agreement provided with the Software |
|
10 | ** accordance with the Qt License Agreement provided with the Software | |
11 | ** or, alternatively, in accordance with the terms contained in a written |
|
11 | ** or, alternatively, in accordance with the terms contained in a written | |
12 | ** agreement between you and Digia. |
|
12 | ** agreement between you and Digia. | |
13 | ** |
|
13 | ** | |
14 | ** If you have questions regarding the use of this file, please use |
|
14 | ** If you have questions regarding the use of this file, please use | |
15 | ** contact form at http://qt.io |
|
15 | ** contact form at http://qt.io | |
16 | ** |
|
16 | ** | |
17 | ****************************************************************************/ |
|
17 | ****************************************************************************/ | |
18 |
|
18 | |||
19 | /*! |
|
19 | /*! | |
20 | \example audio |
|
20 | \example audio | |
21 |
\title Audio |
|
21 | \title Audio Example | |
22 | \ingroup qtcharts_examples |
|
22 | \ingroup qtcharts_examples | |
23 |
|
23 | |||
24 | \brief This example shows the drawing of dynamic data (microphone input). |
|
24 | \brief This example shows the drawing of dynamic data (microphone input). | |
25 | \image examples_audio.png |
|
25 | \image examples_audio.png | |
26 | */ |
|
26 | */ |
@@ -1,76 +1,76 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2014 Digia Plc |
|
3 | ** Copyright (C) 2014 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to Digia, please use contact form at http://qt.io |
|
5 | ** For any questions to Digia, please use contact form at http://qt.io | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Charts module. |
|
7 | ** This file is part of the Qt Charts module. | |
8 | ** |
|
8 | ** | |
9 | ** Licensees holding valid commercial license for Qt may use this file in |
|
9 | ** Licensees holding valid commercial license for Qt may use this file in | |
10 | ** accordance with the Qt License Agreement provided with the Software |
|
10 | ** accordance with the Qt License Agreement provided with the Software | |
11 | ** or, alternatively, in accordance with the terms contained in a written |
|
11 | ** or, alternatively, in accordance with the terms contained in a written | |
12 | ** agreement between you and Digia. |
|
12 | ** agreement between you and Digia. | |
13 | ** |
|
13 | ** | |
14 | ** If you have questions regarding the use of this file, please use |
|
14 | ** If you have questions regarding the use of this file, please use | |
15 | ** contact form at http://qt.io |
|
15 | ** contact form at http://qt.io | |
16 | ** |
|
16 | ** | |
17 | ****************************************************************************/ |
|
17 | ****************************************************************************/ | |
18 |
|
18 | |||
19 | /*! |
|
19 | /*! | |
20 | \example barmodelmapper |
|
20 | \example barmodelmapper | |
21 |
\title BarModelMapper |
|
21 | \title BarModelMapper Example | |
22 | \ingroup qtcharts_examples |
|
22 | \ingroup qtcharts_examples | |
23 |
|
23 | |||
24 | \brief This example shows how to use QAbstractItemModel derived model as the data for the bar |
|
24 | \brief This example shows how to use QAbstractItemModel derived model as the data for the bar | |
25 | series. |
|
25 | series. | |
26 |
|
26 | |||
27 | \image examples_barmodelmapper.png |
|
27 | \image examples_barmodelmapper.png | |
28 |
|
28 | |||
29 | Let's start by creating an instance of CustomTableModel class. |
|
29 | Let's start by creating an instance of CustomTableModel class. | |
30 | The CustomTableModel class is derived from QAbstractTableModel, and it was created for the purpose of this example. |
|
30 | The CustomTableModel class is derived from QAbstractTableModel, and it was created for the purpose of this example. | |
31 | The constructor of this class populates the model's internal data store with the data required for our chart example. |
|
31 | The constructor of this class populates the model's internal data store with the data required for our chart example. | |
32 |
|
32 | |||
33 | \snippet barmodelmapper/tablewidget.cpp 1 |
|
33 | \snippet barmodelmapper/tablewidget.cpp 1 | |
34 |
|
34 | |||
35 | We now have a model with data that we would like to display both on the chart and in a QTableView. |
|
35 | We now have a model with data that we would like to display both on the chart and in a QTableView. | |
36 | First, we create QTableView and tell it to use the model as a data source. To have the data presented nicely, the minimum width of the table view is set and its headers resize mode changed to stretch. |
|
36 | First, we create QTableView and tell it to use the model as a data source. To have the data presented nicely, the minimum width of the table view is set and its headers resize mode changed to stretch. | |
37 |
|
37 | |||
38 | \snippet barmodelmapper/tablewidget.cpp 2 |
|
38 | \snippet barmodelmapper/tablewidget.cpp 2 | |
39 |
|
39 | |||
40 | Now we need a QChart instance to display the same data on the chart. |
|
40 | Now we need a QChart instance to display the same data on the chart. | |
41 | We also enable animations. It makes it easier to see how a modification to the model's data affects the chart. |
|
41 | We also enable animations. It makes it easier to see how a modification to the model's data affects the chart. | |
42 |
|
42 | |||
43 | \snippet barmodelmapper/tablewidget.cpp 3 |
|
43 | \snippet barmodelmapper/tablewidget.cpp 3 | |
44 |
|
44 | |||
45 | The first line of the code below creates new bar series. Variables firstRow and rowCount are used to define a custom model mapping. |
|
45 | The first line of the code below creates new bar series. Variables firstRow and rowCount are used to define a custom model mapping. | |
46 | Custom mapping allows to take only part of the data from the model. In this case data from 5 rows starting with the row with the index 3. |
|
46 | Custom mapping allows to take only part of the data from the model. In this case data from 5 rows starting with the row with the index 3. | |
47 | The following three lines create an instance of the QVBarModelMapper class and specify that the data for the bar sets should be taken from the model's columns with indexes from 1 to 4 (inclusive). |
|
47 | The following three lines create an instance of the QVBarModelMapper class and specify that the data for the bar sets should be taken from the model's columns with indexes from 1 to 4 (inclusive). | |
48 | To create a connection between the series and the model we set both of those objects to QVBarModelMapper. |
|
48 | To create a connection between the series and the model we set both of those objects to QVBarModelMapper. | |
49 |
|
49 | |||
50 | Finally the series is added to the chart. |
|
50 | Finally the series is added to the chart. | |
51 |
|
51 | |||
52 | \snippet barmodelmapper/tablewidget.cpp 4 |
|
52 | \snippet barmodelmapper/tablewidget.cpp 4 | |
53 |
|
53 | |||
54 | To show in QTableView which data corresponds with which bar set, this example uses table coloring. |
|
54 | To show in QTableView which data corresponds with which bar set, this example uses table coloring. | |
55 | When series is added to the chart, it is assigned a color based on the currently selected theme. |
|
55 | When series is added to the chart, it is assigned a color based on the currently selected theme. | |
56 | Code below extracts that color from the series and uses it to create colored QTableView. |
|
56 | Code below extracts that color from the series and uses it to create colored QTableView. | |
57 | Coloring of the view is not a part of the QChart functionality. |
|
57 | Coloring of the view is not a part of the QChart functionality. | |
58 |
|
58 | |||
59 | \snippet barmodelmapper/tablewidget.cpp 5 |
|
59 | \snippet barmodelmapper/tablewidget.cpp 5 | |
60 |
|
60 | |||
61 | We would like to have categories placed on the chart's axis that describe what the data means. |
|
61 | We would like to have categories placed on the chart's axis that describe what the data means. | |
62 | Next snippet shows how to do that. |
|
62 | Next snippet shows how to do that. | |
63 |
|
63 | |||
64 | \snippet barmodelmapper/tablewidget.cpp 6 |
|
64 | \snippet barmodelmapper/tablewidget.cpp 6 | |
65 |
|
65 | |||
66 | To avoid setting up the QGraphicsScene we use the QChartView class that does it for us. The QChart object pointer is used as a parameter of the QChartView constructor. |
|
66 | To avoid setting up the QGraphicsScene we use the QChartView class that does it for us. The QChart object pointer is used as a parameter of the QChartView constructor. | |
67 | To make the render look nicer Antialiasing is turned on and the minimum size of the chartView widget is set. |
|
67 | To make the render look nicer Antialiasing is turned on and the minimum size of the chartView widget is set. | |
68 |
|
68 | |||
69 | \snippet barmodelmapper/tablewidget.cpp 7 |
|
69 | \snippet barmodelmapper/tablewidget.cpp 7 | |
70 |
|
70 | |||
71 | Finally, we place both widgets in a layout and use the layout as the application layout. |
|
71 | Finally, we place both widgets in a layout and use the layout as the application layout. | |
72 |
|
72 | |||
73 | \snippet barmodelmapper/tablewidget.cpp 8 |
|
73 | \snippet barmodelmapper/tablewidget.cpp 8 | |
74 |
|
74 | |||
75 | The application is ready. Try modifying the data in the table view and see how it affects the chart. |
|
75 | The application is ready. Try modifying the data in the table view and see how it affects the chart. | |
76 | */ |
|
76 | */ |
@@ -1,33 +1,33 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2014 Digia Plc |
|
3 | ** Copyright (C) 2014 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to Digia, please use contact form at http://qt.io |
|
5 | ** For any questions to Digia, please use contact form at http://qt.io | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Charts module. |
|
7 | ** This file is part of the Qt Charts module. | |
8 | ** |
|
8 | ** | |
9 | ** Licensees holding valid commercial license for Qt may use this file in |
|
9 | ** Licensees holding valid commercial license for Qt may use this file in | |
10 | ** accordance with the Qt License Agreement provided with the Software |
|
10 | ** accordance with the Qt License Agreement provided with the Software | |
11 | ** or, alternatively, in accordance with the terms contained in a written |
|
11 | ** or, alternatively, in accordance with the terms contained in a written | |
12 | ** agreement between you and Digia. |
|
12 | ** agreement between you and Digia. | |
13 | ** |
|
13 | ** | |
14 | ** If you have questions regarding the use of this file, please use |
|
14 | ** If you have questions regarding the use of this file, please use | |
15 | ** contact form at http://qt.io |
|
15 | ** contact form at http://qt.io | |
16 | ** |
|
16 | ** | |
17 | ****************************************************************************/ |
|
17 | ****************************************************************************/ | |
18 |
|
18 | |||
19 | /*! |
|
19 | /*! | |
20 | \example callout |
|
20 | \example callout | |
21 |
\title Callout |
|
21 | \title Callout Example | |
22 | \ingroup qtcharts_examples |
|
22 | \ingroup qtcharts_examples | |
23 |
|
23 | |||
24 | \brief This example shows how to draw an additional element (a callout) on top of the chart. |
|
24 | \brief This example shows how to draw an additional element (a callout) on top of the chart. | |
25 | \image examples_callout.png |
|
25 | \image examples_callout.png | |
26 |
|
26 | |||
27 | QChart class provides two methods that map between the scene coordinates and the series domain |
|
27 | QChart class provides two methods that map between the scene coordinates and the series domain | |
28 | (defined by the axes ranges). |
|
28 | (defined by the axes ranges). | |
29 |
|
29 | |||
30 | QPointF QChart::mapToPosition(const QPointF &value, QAbstractSeries *series) |
|
30 | QPointF QChart::mapToPosition(const QPointF &value, QAbstractSeries *series) | |
31 |
|
31 | |||
32 | QPointF QChart::mapToValue(const QPointF &position, QAbstractSeries *series) |
|
32 | QPointF QChart::mapToValue(const QPointF &position, QAbstractSeries *series) | |
33 | */ |
|
33 | */ |
@@ -1,33 +1,33 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2014 Digia Plc |
|
3 | ** Copyright (C) 2014 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to Digia, please use contact form at http://qt.io |
|
5 | ** For any questions to Digia, please use contact form at http://qt.io | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Charts module. |
|
7 | ** This file is part of the Qt Charts module. | |
8 | ** |
|
8 | ** | |
9 | ** Licensees holding valid commercial license for Qt may use this file in |
|
9 | ** Licensees holding valid commercial license for Qt may use this file in | |
10 | ** accordance with the Qt License Agreement provided with the Software |
|
10 | ** accordance with the Qt License Agreement provided with the Software | |
11 | ** or, alternatively, in accordance with the terms contained in a written |
|
11 | ** or, alternatively, in accordance with the terms contained in a written | |
12 | ** agreement between you and Digia. |
|
12 | ** agreement between you and Digia. | |
13 | ** |
|
13 | ** | |
14 | ** If you have questions regarding the use of this file, please use |
|
14 | ** If you have questions regarding the use of this file, please use | |
15 | ** contact form at http://qt.io |
|
15 | ** contact form at http://qt.io | |
16 | ** |
|
16 | ** | |
17 | ****************************************************************************/ |
|
17 | ****************************************************************************/ | |
18 |
|
18 | |||
19 | /*! |
|
19 | /*! | |
20 | \example chartthemes |
|
20 | \example chartthemes | |
21 |
\title Chart |
|
21 | \title Chart Themes Example | |
22 | \ingroup qtcharts_examples |
|
22 | \ingroup qtcharts_examples | |
23 |
|
23 | |||
24 | \brief The example shows the look and feel of the different built-in themes. |
|
24 | \brief The example shows the look and feel of the different built-in themes. | |
25 |
|
25 | |||
26 | This example shows the look and feel of the different built-in themes for all supported chart |
|
26 | This example shows the look and feel of the different built-in themes for all supported chart | |
27 | types. In order to give the result a more harmonious look, the background palette of the |
|
27 | types. In order to give the result a more harmonious look, the background palette of the | |
28 | application is customized to the theme selected. |
|
28 | application is customized to the theme selected. | |
29 |
|
29 | |||
30 | \image examples_chartthemes_light.png |
|
30 | \image examples_chartthemes_light.png | |
31 | \image examples_chartthemes_brown_sand.png |
|
31 | \image examples_chartthemes_brown_sand.png | |
32 | \image examples_chartthemes_blue_cerulean.png |
|
32 | \image examples_chartthemes_blue_cerulean.png | |
33 | */ |
|
33 | */ |
@@ -1,63 +1,63 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2014 Digia Plc |
|
3 | ** Copyright (C) 2014 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to Digia, please use contact form at http://qt.io |
|
5 | ** For any questions to Digia, please use contact form at http://qt.io | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Charts module. |
|
7 | ** This file is part of the Qt Charts module. | |
8 | ** |
|
8 | ** | |
9 | ** Licensees holding valid commercial license for Qt may use this file in |
|
9 | ** Licensees holding valid commercial license for Qt may use this file in | |
10 | ** accordance with the Qt License Agreement provided with the Software |
|
10 | ** accordance with the Qt License Agreement provided with the Software | |
11 | ** or, alternatively, in accordance with the terms contained in a written |
|
11 | ** or, alternatively, in accordance with the terms contained in a written | |
12 | ** agreement between you and Digia. |
|
12 | ** agreement between you and Digia. | |
13 | ** |
|
13 | ** | |
14 | ** If you have questions regarding the use of this file, please use |
|
14 | ** If you have questions regarding the use of this file, please use | |
15 | ** contact form at http://qt.io |
|
15 | ** contact form at http://qt.io | |
16 | ** |
|
16 | ** | |
17 | ****************************************************************************/ |
|
17 | ****************************************************************************/ | |
18 |
|
18 | |||
19 | /*! |
|
19 | /*! | |
20 | \example donutbreakdown |
|
20 | \example donutbreakdown | |
21 |
\title Donut |
|
21 | \title Donut Chart Breakdown Example | |
22 | \ingroup qtcharts_examples |
|
22 | \ingroup qtcharts_examples | |
23 |
|
23 | |||
24 | \brief This example shows how to use create a donut breakdown chart using QPieSeries API. |
|
24 | \brief This example shows how to use create a donut breakdown chart using QPieSeries API. | |
25 | \image examples_donutbreakdown.png |
|
25 | \image examples_donutbreakdown.png | |
26 |
|
26 | |||
27 | Let's start by defining some data for the chart. |
|
27 | Let's start by defining some data for the chart. | |
28 |
|
28 | |||
29 | \snippet donutbreakdown/main.cpp 1 |
|
29 | \snippet donutbreakdown/main.cpp 1 | |
30 |
|
30 | |||
31 | Then we create a chart where we add the data. Note that this is our own chart derived from QChart. |
|
31 | Then we create a chart where we add the data. Note that this is our own chart derived from QChart. | |
32 |
|
32 | |||
33 | \snippet donutbreakdown/main.cpp 2 |
|
33 | \snippet donutbreakdown/main.cpp 2 | |
34 |
|
34 | |||
35 | Our own chart works in such a way that we create a main series in the constructor we create a main series, |
|
35 | Our own chart works in such a way that we create a main series in the constructor we create a main series, | |
36 | which aggregates the data provided by the breakdown series. This is the piechart in the center. |
|
36 | which aggregates the data provided by the breakdown series. This is the piechart in the center. | |
37 |
|
37 | |||
38 | \snippet donutbreakdown/donutbreakdownchart.cpp 1 |
|
38 | \snippet donutbreakdown/donutbreakdownchart.cpp 1 | |
39 |
|
39 | |||
40 | When a breakdown series is added the data is used to create a slice in the main series and the |
|
40 | When a breakdown series is added the data is used to create a slice in the main series and the | |
41 | breakdown series itself is used to create a segment of a donut positioned so that it is aligned |
|
41 | breakdown series itself is used to create a segment of a donut positioned so that it is aligned | |
42 | with the corresponding slice in the main series. |
|
42 | with the corresponding slice in the main series. | |
43 |
|
43 | |||
44 | \snippet donutbreakdown/donutbreakdownchart.cpp 2 |
|
44 | \snippet donutbreakdown/donutbreakdownchart.cpp 2 | |
45 |
|
45 | |||
46 | Here's how the start and end angles for the donut segments are calculated. |
|
46 | Here's how the start and end angles for the donut segments are calculated. | |
47 |
|
47 | |||
48 | \snippet donutbreakdown/donutbreakdownchart.cpp 3 |
|
48 | \snippet donutbreakdown/donutbreakdownchart.cpp 3 | |
49 |
|
49 | |||
50 | The legend markers are customized to show the breakdown percentage. The markers for the main level slices are hidden. |
|
50 | The legend markers are customized to show the breakdown percentage. The markers for the main level slices are hidden. | |
51 |
|
51 | |||
52 | \snippet donutbreakdown/donutbreakdownchart.cpp 4 |
|
52 | \snippet donutbreakdown/donutbreakdownchart.cpp 4 | |
53 |
|
53 | |||
54 | Instead the main level slices show the percentage on the label. |
|
54 | Instead the main level slices show the percentage on the label. | |
55 |
|
55 | |||
56 | \snippet donutbreakdown/mainslice.cpp 1 |
|
56 | \snippet donutbreakdown/mainslice.cpp 1 | |
57 | \snippet donutbreakdown/mainslice.cpp 2 |
|
57 | \snippet donutbreakdown/mainslice.cpp 2 | |
58 |
|
58 | |||
59 | Now that we have our chart defined, we can finally create a QChartView and show the chart. |
|
59 | Now that we have our chart defined, we can finally create a QChartView and show the chart. | |
60 |
|
60 | |||
61 | \snippet donutbreakdown/main.cpp 3 |
|
61 | \snippet donutbreakdown/main.cpp 3 | |
62 |
|
62 | |||
63 | */ |
|
63 | */ |
@@ -1,28 +1,28 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2014 Digia Plc |
|
3 | ** Copyright (C) 2014 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to Digia, please use contact form at http://qt.io |
|
5 | ** For any questions to Digia, please use contact form at http://qt.io | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Charts module. |
|
7 | ** This file is part of the Qt Charts module. | |
8 | ** |
|
8 | ** | |
9 | ** Licensees holding valid commercial license for Qt may use this file in |
|
9 | ** Licensees holding valid commercial license for Qt may use this file in | |
10 | ** accordance with the Qt License Agreement provided with the Software |
|
10 | ** accordance with the Qt License Agreement provided with the Software | |
11 | ** or, alternatively, in accordance with the terms contained in a written |
|
11 | ** or, alternatively, in accordance with the terms contained in a written | |
12 | ** agreement between you and Digia. |
|
12 | ** agreement between you and Digia. | |
13 | ** |
|
13 | ** | |
14 | ** If you have questions regarding the use of this file, please use |
|
14 | ** If you have questions regarding the use of this file, please use | |
15 | ** contact form at http://qt.io |
|
15 | ** contact form at http://qt.io | |
16 | ** |
|
16 | ** | |
17 | ****************************************************************************/ |
|
17 | ****************************************************************************/ | |
18 |
|
18 | |||
19 | /*! |
|
19 | /*! | |
20 | \example dynamicspline |
|
20 | \example dynamicspline | |
21 |
\title Dynamic |
|
21 | \title Dynamic Spline Example | |
22 | \ingroup qtcharts_examples |
|
22 | \ingroup qtcharts_examples | |
23 |
|
23 | |||
24 | \brief This example shows how to draw dynamic data. |
|
24 | \brief This example shows how to draw dynamic data. | |
25 |
|
25 | |||
26 | \image examples_dynamicspline1.png |
|
26 | \image examples_dynamicspline1.png | |
27 | \image examples_dynamicspline2.png |
|
27 | \image examples_dynamicspline2.png | |
28 | */ |
|
28 | */ |
@@ -1,58 +1,55 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2014 Digia Plc |
|
3 | ** Copyright (C) 2014 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to Digia, please use contact form at http://qt.io |
|
5 | ** For any questions to Digia, please use contact form at http://qt.io | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Charts module. |
|
7 | ** This file is part of the Qt Charts module. | |
8 | ** |
|
8 | ** | |
9 | ** Licensees holding valid commercial license for Qt may use this file in |
|
9 | ** Licensees holding valid commercial license for Qt may use this file in | |
10 | ** accordance with the Qt License Agreement provided with the Software |
|
10 | ** accordance with the Qt License Agreement provided with the Software | |
11 | ** or, alternatively, in accordance with the terms contained in a written |
|
11 | ** or, alternatively, in accordance with the terms contained in a written | |
12 | ** agreement between you and Digia. |
|
12 | ** agreement between you and Digia. | |
13 | ** |
|
13 | ** | |
14 | ** If you have questions regarding the use of this file, please use |
|
14 | ** If you have questions regarding the use of this file, please use | |
15 | ** contact form at http://qt.io |
|
15 | ** contact form at http://qt.io | |
16 | ** |
|
16 | ** | |
17 | ****************************************************************************/ |
|
17 | ****************************************************************************/ | |
18 |
|
18 | |||
19 | /*! |
|
19 | /*! | |
20 | \example legend |
|
20 | \example legend | |
21 | \title Legend Example |
|
21 | \title Legend Example | |
22 | \ingroup qtcharts_examples |
|
22 | \ingroup qtcharts_examples | |
23 |
|
23 | |||
24 | \brief This example shows how to detach the legend from the chart and how to attach it back. |
|
24 | \brief This example shows how to detach the legend from the chart and how to attach it back. | |
25 |
|
25 | |||
26 | By default the chart draws the legend inside the same view with the chart. In some cases the |
|
26 | By default the chart draws the legend inside the same view with the chart. In some cases the | |
27 | user may want to draw the legend to somewhere else. To make this possible the legend can be |
|
27 | user may want to draw the legend to somewhere else. To make this possible the legend can be | |
28 | detached from the chart. Detaching means that the chart doesn't draw the legend or try to |
|
28 | detached from the chart. Detaching means that the chart doesn't draw the legend or try to | |
29 | change its layout. Detached legend can then be drawn wherever the user wishes, for example, |
|
29 | change its layout. Detached legend can then be drawn wherever the user wishes, for example, | |
30 | in a different graphics scene. The behavior of the legend can be inspected by running the |
|
30 | in a different graphics scene. The behavior of the legend can be inspected by running the | |
31 | legend example. |
|
31 | legend example. | |
32 | In the example we use the bar series where we add or remove the bar sets. The legend reflects |
|
32 | In the example we use the bar series where we add or remove the bar sets. The legend reflects | |
33 | the changes in series. The legend can be detached or attached back to the chart and its |
|
33 | the changes in series. The legend can be detached or attached back to the chart and its | |
34 | alignment can be modified. |
|
34 | alignment can be modified. | |
35 | When the legend is detached, it can be resized and positioned freely. |
|
35 | When the legend is detached, it can be resized and positioned freely. | |
36 |
|
36 | |||
37 | \table |
|
37 | \image examples_legend_detach.png | |
38 | \row |
|
38 | \image examples_legend_detach2.png | |
39 | \li \inlineimage examples_legend_detach.png |
|
|||
40 | \li \inlineimage examples_legend_detach2.png |
|
|||
41 | \endtable |
|
|||
42 |
|
39 | |||
43 | Here we turn the legend visible and set its alignment to the bottom of the chart. |
|
40 | Here we turn the legend visible and set its alignment to the bottom of the chart. | |
44 |
|
41 | |||
45 | \snippet legend/mainwidget.cpp 1 |
|
42 | \snippet legend/mainwidget.cpp 1 | |
46 |
|
43 | |||
47 | This snippet shows how to detach the legend from the chart. After detaching, we turn its background to visible and set a different color to it. This makes it easier to see how the items inside the legend are arranged in detached mode. |
|
44 | This snippet shows how to detach the legend from the chart. After detaching, we turn its background to visible and set a different color to it. This makes it easier to see how the items inside the legend are arranged in detached mode. | |
48 |
|
45 | |||
49 | \snippet legend/mainwidget.cpp 2 |
|
46 | \snippet legend/mainwidget.cpp 2 | |
50 |
|
47 | |||
51 | Here we attach the legend back to the chart. The background is turned invisible. |
|
48 | Here we attach the legend back to the chart. The background is turned invisible. | |
52 |
|
49 | |||
53 | \snippet legend/mainwidget.cpp 3 |
|
50 | \snippet legend/mainwidget.cpp 3 | |
54 |
|
51 | |||
55 | This shows how we set the detached legend dimensions. After setting the new values, we call update to show changes on screen. |
|
52 | This shows how we set the detached legend dimensions. After setting the new values, we call update to show changes on screen. | |
56 |
|
53 | |||
57 | \snippet legend/mainwidget.cpp 4 |
|
54 | \snippet legend/mainwidget.cpp 4 | |
58 | */ |
|
55 | */ |
@@ -1,68 +1,68 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2014 Digia Plc |
|
3 | ** Copyright (C) 2014 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to Digia, please use contact form at http://qt.io |
|
5 | ** For any questions to Digia, please use contact form at http://qt.io | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Charts module. |
|
7 | ** This file is part of the Qt Charts module. | |
8 | ** |
|
8 | ** | |
9 | ** Licensees holding valid commercial license for Qt may use this file in |
|
9 | ** Licensees holding valid commercial license for Qt may use this file in | |
10 | ** accordance with the Qt License Agreement provided with the Software |
|
10 | ** accordance with the Qt License Agreement provided with the Software | |
11 | ** or, alternatively, in accordance with the terms contained in a written |
|
11 | ** or, alternatively, in accordance with the terms contained in a written | |
12 | ** agreement between you and Digia. |
|
12 | ** agreement between you and Digia. | |
13 | ** |
|
13 | ** | |
14 | ** If you have questions regarding the use of this file, please use |
|
14 | ** If you have questions regarding the use of this file, please use | |
15 | ** contact form at http://qt.io |
|
15 | ** contact form at http://qt.io | |
16 | ** |
|
16 | ** | |
17 | ****************************************************************************/ |
|
17 | ****************************************************************************/ | |
18 |
|
18 | |||
19 | /*! |
|
19 | /*! | |
20 | \example nesteddonuts |
|
20 | \example nesteddonuts | |
21 |
\title Nested |
|
21 | \title Nested Donuts Example | |
22 | \ingroup qtcharts_examples |
|
22 | \ingroup qtcharts_examples | |
23 |
|
23 | |||
24 | \brief This example shows how to create a nested donuts chart using the QPieSeries API. |
|
24 | \brief This example shows how to create a nested donuts chart using the QPieSeries API. | |
25 | \image examples_nesteddonuts.png |
|
25 | \image examples_nesteddonuts.png | |
26 |
|
26 | |||
27 | Let's start by creating a QChartView instance and enabling the Antialiasing on it. A QChart object is then obtained from the QChartView instance. |
|
27 | Let's start by creating a QChartView instance and enabling the Antialiasing on it. A QChart object is then obtained from the QChartView instance. | |
28 | The legend is disabled and the title of the chart is set. Last line enables the animations of the chart. |
|
28 | The legend is disabled and the title of the chart is set. Last line enables the animations of the chart. | |
29 |
|
29 | |||
30 | \snippet nesteddonuts/widget.cpp 1 |
|
30 | \snippet nesteddonuts/widget.cpp 1 | |
31 |
|
31 | |||
32 | Three variables are defined that will be used to define the donut chart. Min and max size define the relative size of the whole donut. |
|
32 | Three variables are defined that will be used to define the donut chart. Min and max size define the relative size of the whole donut. | |
33 | minSize is the relative inner size of the smallest donut. maxSize is the relative outer size of the biggest donut. |
|
33 | minSize is the relative inner size of the smallest donut. maxSize is the relative outer size of the biggest donut. | |
34 |
|
34 | |||
35 | \snippet nesteddonuts/widget.cpp 2 |
|
35 | \snippet nesteddonuts/widget.cpp 2 | |
36 |
|
36 | |||
37 | The following block of code defines the individual donuts and their slices. First a new QPieSeries object is created. |
|
37 | The following block of code defines the individual donuts and their slices. First a new QPieSeries object is created. | |
38 | The number of slices in each donut is randomized. |
|
38 | The number of slices in each donut is randomized. | |
39 | The internal for loop creates the slices with a random value and label same as the value. |
|
39 | The internal for loop creates the slices with a random value and label same as the value. | |
40 | Next the label of the slice is set to be visible and its color is set to white. |
|
40 | Next the label of the slice is set to be visible and its color is set to white. | |
41 | To make the example more interesting the hovered signal of the slice is connected to widget's slot, of which the inner workings are explained later. |
|
41 | To make the example more interesting the hovered signal of the slice is connected to widget's slot, of which the inner workings are explained later. | |
42 | Finally the slice is added to the donut. The donut's size is adjusted to achieve the nesting of the donuts. |
|
42 | Finally the slice is added to the donut. The donut's size is adjusted to achieve the nesting of the donuts. | |
43 | Then the donut is added to the widget's list of donuts and to the chart. |
|
43 | Then the donut is added to the widget's list of donuts and to the chart. | |
44 |
|
44 | |||
45 | \snippet nesteddonuts/widget.cpp 3 |
|
45 | \snippet nesteddonuts/widget.cpp 3 | |
46 |
|
46 | |||
47 | Finally the widget is placed in a layout used by the application. |
|
47 | Finally the widget is placed in a layout used by the application. | |
48 |
|
48 | |||
49 | \snippet nesteddonuts/widget.cpp 4 |
|
49 | \snippet nesteddonuts/widget.cpp 4 | |
50 |
|
50 | |||
51 | To make the example more interesting the donuts are rotated randomly every 1.25 sec. |
|
51 | To make the example more interesting the donuts are rotated randomly every 1.25 sec. | |
52 |
|
52 | |||
53 | \snippet nesteddonuts/widget.cpp 5 |
|
53 | \snippet nesteddonuts/widget.cpp 5 | |
54 |
|
54 | |||
55 | The widget's updatedRotation slot is defined below. |
|
55 | The widget's updatedRotation slot is defined below. | |
56 | It goes through all of the donuts and modifies their current rotation by a random value. |
|
56 | It goes through all of the donuts and modifies their current rotation by a random value. | |
57 |
|
57 | |||
58 | \snippet nesteddonuts/widget.cpp 6 |
|
58 | \snippet nesteddonuts/widget.cpp 6 | |
59 |
|
59 | |||
60 | The earlier mentioned explodeSlice slot code is provided below. |
|
60 | The earlier mentioned explodeSlice slot code is provided below. | |
61 | If the slice is set to exploded, then stop the timer that controls the donuts rotation. |
|
61 | If the slice is set to exploded, then stop the timer that controls the donuts rotation. | |
62 | Then the slice's start and end angles are obtained from the slice. |
|
62 | Then the slice's start and end angles are obtained from the slice. | |
63 | To highlight the selected slice all the other donuts that lie outward from the one that contains the selected slice |
|
63 | To highlight the selected slice all the other donuts that lie outward from the one that contains the selected slice | |
64 | have their start and end angles modified so that they wouldn't "block" the way for the hightlighted slice. |
|
64 | have their start and end angles modified so that they wouldn't "block" the way for the hightlighted slice. | |
65 | If the slice is no longer selected return to the original state. |
|
65 | If the slice is no longer selected return to the original state. | |
66 |
|
66 | |||
67 | \snippet nesteddonuts/widget.cpp 7 |
|
67 | \snippet nesteddonuts/widget.cpp 7 | |
68 | */ |
|
68 | */ |
@@ -1,26 +1,26 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2014 Digia Plc |
|
3 | ** Copyright (C) 2014 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to Digia, please use contact form at http://qt.io |
|
5 | ** For any questions to Digia, please use contact form at http://qt.io | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Charts module. |
|
7 | ** This file is part of the Qt Charts module. | |
8 | ** |
|
8 | ** | |
9 | ** Licensees holding valid commercial license for Qt may use this file in |
|
9 | ** Licensees holding valid commercial license for Qt may use this file in | |
10 | ** accordance with the Qt License Agreement provided with the Software |
|
10 | ** accordance with the Qt License Agreement provided with the Software | |
11 | ** or, alternatively, in accordance with the terms contained in a written |
|
11 | ** or, alternatively, in accordance with the terms contained in a written | |
12 | ** agreement between you and Digia. |
|
12 | ** agreement between you and Digia. | |
13 | ** |
|
13 | ** | |
14 | ** If you have questions regarding the use of this file, please use |
|
14 | ** If you have questions regarding the use of this file, please use | |
15 | ** contact form at http://qt.io |
|
15 | ** contact form at http://qt.io | |
16 | ** |
|
16 | ** | |
17 | ****************************************************************************/ |
|
17 | ****************************************************************************/ | |
18 |
|
18 | |||
19 | /*! |
|
19 | /*! | |
20 | \example piechartcustomization |
|
20 | \example piechartcustomization | |
21 |
\title Pie |
|
21 | \title Pie Chart Customization Example | |
22 | \ingroup qtcharts_examples |
|
22 | \ingroup qtcharts_examples | |
23 |
|
23 | |||
24 | \brief This example shows how the look and feel of a pie chart can be customized. |
|
24 | \brief This example shows how the look and feel of a pie chart can be customized. | |
25 | \image piechart_customization.png |
|
25 | \image piechart_customization.png | |
26 | */ |
|
26 | */ |
@@ -1,50 +1,41 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2014 Digia Plc |
|
3 | ** Copyright (C) 2014 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to Digia, please use contact form at http://qt.io |
|
5 | ** For any questions to Digia, please use contact form at http://qt.io | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Charts module. |
|
7 | ** This file is part of the Qt Charts module. | |
8 | ** |
|
8 | ** | |
9 | ** Licensees holding valid commercial license for Qt may use this file in |
|
9 | ** Licensees holding valid commercial license for Qt may use this file in | |
10 | ** accordance with the Qt License Agreement provided with the Software |
|
10 | ** accordance with the Qt License Agreement provided with the Software | |
11 | ** or, alternatively, in accordance with the terms contained in a written |
|
11 | ** or, alternatively, in accordance with the terms contained in a written | |
12 | ** agreement between you and Digia. |
|
12 | ** agreement between you and Digia. | |
13 | ** |
|
13 | ** | |
14 | ** If you have questions regarding the use of this file, please use |
|
14 | ** If you have questions regarding the use of this file, please use | |
15 | ** contact form at http://qt.io |
|
15 | ** contact form at http://qt.io | |
16 | ** |
|
16 | ** | |
17 | ****************************************************************************/ |
|
17 | ****************************************************************************/ | |
18 |
|
18 | |||
19 | /*! |
|
19 | /*! | |
20 | \example qmlaxes |
|
20 | \example qmlaxes | |
21 | \title Qml Axes |
|
21 | \title Qml Axes | |
22 | \ingroup qtcharts_examples |
|
22 | \ingroup qtcharts_examples | |
23 |
|
23 | |||
24 | \brief This is a demonstration of how to use axes in your QML application. |
|
24 | \brief This is a demonstration of how to use axes in your QML application. | |
25 |
|
25 | |||
26 | \table |
|
26 | We begin with a chart that has a line series and a scatter series with random | |
27 | \row |
|
27 | data. Both series use the same axes. | |
28 | \li \br |
|
28 | ||
29 | We begin with a chart that has a line series and a scatter series with random |
|
29 | \image examples_qmlaxes1.png | |
30 | data. Both series use the same axes. |
|
30 | \snippet qmlaxes/qml/qmlaxes/View1.qml 1 | |
31 | \br |
|
31 | ||
32 | \br |
|
32 | The next example shows a chart with some accurate historical data that makes us to use a DateTimeAxis. | |
33 | \snippet qmlaxes/qml/qmlaxes/View1.qml 1 |
|
33 | ||
34 |
|
|
34 | \image examples_qmlaxes2.png | |
35 | \row |
|
35 | \snippet qmlaxes/qml/qmlaxes/View2.qml 1 | |
36 | \li \br |
|
36 | ||
37 | The next example shows a chart with some accurate historical data that makes us to use a DateTimeAxis. |
|
37 | And the final example with a chart that uses a CategoryAxis to make the data easier to understand. | |
38 | \br |
|
38 | ||
39 | \br |
|
39 | \image examples_qmlaxes3.png | |
40 |
|
|
40 | \snippet qmlaxes/qml/qmlaxes/View3.qml 1 | |
41 | \li \inlineimage examples_qmlaxes2.png |
|
|||
42 | \row |
|
|||
43 | \li \br |
|
|||
44 | And the final example with a chart that uses a CategoryAxis to make the data easier to understand. |
|
|||
45 | \br |
|
|||
46 | \br |
|
|||
47 | \snippet qmlaxes/qml/qmlaxes/View3.qml 1 |
|
|||
48 | \li \inlineimage examples_qmlaxes3.png |
|
|||
49 | \endtable |
|
|||
50 | */ |
|
41 | */ |
@@ -1,143 +1,82 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2014 Digia Plc |
|
3 | ** Copyright (C) 2014 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to Digia, please use contact form at http://qt.io |
|
5 | ** For any questions to Digia, please use contact form at http://qt.io | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Charts module. |
|
7 | ** This file is part of the Qt Charts module. | |
8 | ** |
|
8 | ** | |
9 | ** Licensees holding valid commercial license for Qt may use this file in |
|
9 | ** Licensees holding valid commercial license for Qt may use this file in | |
10 | ** accordance with the Qt License Agreement provided with the Software |
|
10 | ** accordance with the Qt License Agreement provided with the Software | |
11 | ** or, alternatively, in accordance with the terms contained in a written |
|
11 | ** or, alternatively, in accordance with the terms contained in a written | |
12 | ** agreement between you and Digia. |
|
12 | ** agreement between you and Digia. | |
13 | ** |
|
13 | ** | |
14 | ** If you have questions regarding the use of this file, please use |
|
14 | ** If you have questions regarding the use of this file, please use | |
15 | ** contact form at http://qt.io |
|
15 | ** contact form at http://qt.io | |
16 | ** |
|
16 | ** | |
17 | ****************************************************************************/ |
|
17 | ****************************************************************************/ | |
18 |
|
18 | |||
19 | /*! |
|
19 | /*! | |
20 | \example qmlchart |
|
20 | \example qmlchart | |
21 |
\title Qml |
|
21 | \title Qml Charts Example | |
22 | \ingroup qtcharts_examples |
|
22 | \ingroup qtcharts_examples | |
23 |
|
23 | |||
24 | \brief This basic demonstration shows how to use the different chart types by using qml. |
|
24 | \brief This basic demonstration shows how to use the different chart types by using qml. | |
25 |
|
25 | |||
26 | Creating each chart type begins with the creation of a ChartView. |
|
26 | Creating each chart type begins with the creation of a ChartView. | |
27 |
|
27 | |||
28 | \table |
|
28 | To create a pie, we use the PieSeries API together with a few PieSlices: | |
29 | \row |
|
29 | ||
30 | \li \br |
|
30 | \image examples_qmlchart1.png | |
31 | To create a pie, we use the PieSeries API together with a few PieSlices: |
|
31 | \snippet qmlchart/qml/qmlchart/View1.qml 1 | |
32 | \br |
|
32 | ||
33 | \br |
|
33 | To create a chart with a line series: | |
34 | \snippet qmlchart/qml/qmlchart/View1.qml 1 |
|
34 | ||
35 |
|
|
35 | \image examples_qmlchart2.png | |
36 | \endtable |
|
36 | \snippet qmlchart/qml/qmlchart/View2.qml 1 | |
37 |
|
37 | |||
38 | \table |
|
38 | And spline series: | |
39 | \row |
|
39 | ||
40 | \li \br |
|
40 | \image examples_qmlchart3.png | |
41 | To create a chart with a line series: |
|
41 | \snippet qmlchart/qml/qmlchart/View3.qml 1 | |
42 | \br |
|
42 | ||
43 | \br |
|
43 | Then we create a chart that illustrates the NHL All-Star player selections by using | |
44 | \snippet qmlchart/qml/qmlchart/View2.qml 1 |
|
44 | three area series: | |
45 | \li \inlineimage examples_qmlchart2.png |
|
45 | ||
46 | \endtable |
|
46 | \image examples_qmlchart4.png | |
47 |
|
47 | \snippet qmlchart/qml/qmlchart/View4.qml 1 | ||
48 |
\ |
|
48 | \dots | |
49 | \row |
|
49 | ||
50 | \li \br |
|
50 | Then a couple of scatter series: | |
51 | And spline series: |
|
51 | ||
52 | \br |
|
52 | \image examples_qmlchart5.png | |
53 | \br |
|
53 | \snippet qmlchart/qml/qmlchart/View5.qml 1 | |
54 | \snippet qmlchart/qml/qmlchart/View3.qml 1 |
|
54 | \dots | |
55 | \li \inlineimage examples_qmlchart3.png |
|
|||
56 | \endtable |
|
|||
57 |
|
||||
58 | \table |
|
|||
59 | \row |
|
|||
60 | \li \br |
|
|||
61 | Then we create a chart that illustrates the NHL All-Star player selections by using |
|
|||
62 | three area series: |
|
|||
63 | \br |
|
|||
64 | \br |
|
|||
65 | \snippet qmlchart/qml/qmlchart/View4.qml 1 |
|
|||
66 | \dots |
|
|||
67 | \li \inlineimage examples_qmlchart4.png |
|
|||
68 | \endtable |
|
|||
69 |
|
||||
70 | \table |
|
|||
71 | \row |
|
|||
72 | \li \br |
|
|||
73 | Then a couple of scatter series: |
|
|||
74 | \br |
|
|||
75 | \br |
|
|||
76 | \snippet qmlchart/qml/qmlchart/View5.qml 1 |
|
|||
77 | \dots |
|
|||
78 | \li \inlineimage examples_qmlchart5.png |
|
|||
79 | \endtable |
|
|||
80 |
|
55 | |||
81 | And a few different bar series: |
|
56 | And a few different bar series: | |
82 | \table |
|
57 | ||
83 | \row |
|
58 | \image examples_qmlchart6.png | |
84 | \li \br |
|
59 | \snippet qmlchart/qml/qmlchart/View6.qml 1 | |
85 | \br |
|
60 | ||
86 | \br |
|
61 | \image examples_qmlchart7.png | |
87 |
|
|
62 | \snippet qmlchart/qml/qmlchart/View7.qml 1 | |
88 | \li \inlineimage examples_qmlchart6.png |
|
63 | ||
89 | \endtable |
|
64 | \image examples_qmlchart8.png | |
90 | \table |
|
65 | \snippet qmlchart/qml/qmlchart/View8.qml 1 | |
91 | \row |
|
66 | ||
92 | \li \br |
|
67 | \image examples_qmlchart9.png | |
93 | \br |
|
68 | \snippet qmlchart/qml/qmlchart/View9.qml 1 | |
94 | \br |
|
69 | ||
95 | \snippet qmlchart/qml/qmlchart/View7.qml 1 |
|
70 | \image examples_qmlchart10.png | |
96 | \li \inlineimage examples_qmlchart7.png |
|
71 | \snippet qmlchart/qml/qmlchart/View10.qml 1 | |
97 | \endtable |
|
72 | ||
98 | \table |
|
73 | \image examples_qmlchart11.png | |
99 | \row |
|
74 | \snippet qmlchart/qml/qmlchart/View11.qml 1 | |
100 | \li \br |
|
75 | ||
101 | \br |
|
76 | And finally an example demonstrating how to create a donut chart with two pie series: | |
102 | \br |
|
77 | ||
103 | \snippet qmlchart/qml/qmlchart/View8.qml 1 |
|
78 | \image examples_qmlchart12.png | |
104 | \li \inlineimage examples_qmlchart8.png |
|
79 | \snippet qmlchart/qml/qmlchart/View12.qml 1 | |
105 | \endtable |
|
|||
106 | \table |
|
|||
107 | \row |
|
|||
108 | \li \br |
|
|||
109 | \br |
|
|||
110 | \br |
|
|||
111 | \snippet qmlchart/qml/qmlchart/View9.qml 1 |
|
|||
112 | \li \inlineimage examples_qmlchart9.png |
|
|||
113 | \endtable |
|
|||
114 | \table |
|
|||
115 | \row |
|
|||
116 | \li \br |
|
|||
117 | \br |
|
|||
118 | \br |
|
|||
119 | \snippet qmlchart/qml/qmlchart/View10.qml 1 |
|
|||
120 | \li \inlineimage examples_qmlchart10.png |
|
|||
121 | \endtable |
|
|||
122 | \table |
|
|||
123 | \row |
|
|||
124 | \li \br |
|
|||
125 | \br |
|
|||
126 | \br |
|
|||
127 | \snippet qmlchart/qml/qmlchart/View11.qml 1 |
|
|||
128 | \li \inlineimage examples_qmlchart11.png |
|
|||
129 | \endtable |
|
|||
130 |
|
||||
131 | \table |
|
|||
132 | \row |
|
|||
133 | \li \br |
|
|||
134 | And finally an example demonstrating how to create a donut chart with two pie |
|
|||
135 | series: |
|
|||
136 | \br |
|
|||
137 | \br |
|
|||
138 | \snippet qmlchart/qml/qmlchart/View12.qml 1 |
|
|||
139 | \li \inlineimage examples_qmlchart12.png |
|
|||
140 | \endtable |
|
|||
141 |
|
80 | |||
142 | Additionally, antialiasing is set with the qml property in Qt Quick 2. |
|
81 | Additionally, antialiasing is set with the qml property in Qt Quick 2. | |
143 | */ |
|
82 | */ |
@@ -1,61 +1,49 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2014 Digia Plc |
|
3 | ** Copyright (C) 2014 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to Digia, please use contact form at http://qt.io |
|
5 | ** For any questions to Digia, please use contact form at http://qt.io | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Charts module. |
|
7 | ** This file is part of the Qt Charts module. | |
8 | ** |
|
8 | ** | |
9 | ** Licensees holding valid commercial license for Qt may use this file in |
|
9 | ** Licensees holding valid commercial license for Qt may use this file in | |
10 | ** accordance with the Qt License Agreement provided with the Software |
|
10 | ** accordance with the Qt License Agreement provided with the Software | |
11 | ** or, alternatively, in accordance with the terms contained in a written |
|
11 | ** or, alternatively, in accordance with the terms contained in a written | |
12 | ** agreement between you and Digia. |
|
12 | ** agreement between you and Digia. | |
13 | ** |
|
13 | ** | |
14 | ** If you have questions regarding the use of this file, please use |
|
14 | ** If you have questions regarding the use of this file, please use | |
15 | ** contact form at http://qt.io |
|
15 | ** contact form at http://qt.io | |
16 | ** |
|
16 | ** | |
17 | ****************************************************************************/ |
|
17 | ****************************************************************************/ | |
18 |
|
18 | |||
19 | /*! |
|
19 | /*! | |
20 | \example qmlcustomlegend |
|
20 | \example qmlcustomlegend | |
21 | \title Qml Custom Legend |
|
21 | \title Qml Custom Legend | |
22 | \ingroup qtcharts_examples |
|
22 | \ingroup qtcharts_examples | |
23 |
|
23 | |||
24 | \brief This example shows you how to create your own custom legend. |
|
24 | \brief This example shows you how to create your own custom legend. | |
25 |
|
25 | |||
26 | This application shows you how to create your own custom legend instead of using the |
|
26 | This application shows you how to create your own custom legend instead of using the | |
27 | built-in legend of ChartView API. |
|
27 | built-in legend of ChartView API. | |
28 |
|
28 | |||
29 | \table |
|
29 | The main view of the application shows a stacked area chart. This is how one of | |
30 | \row |
|
30 | the stacked areas is created. See ChartViewStacked.qml and AnimatedAreaSeries.qml. | |
31 | \li \br |
|
31 | ||
32 | The main view of the application shows a stacked area chart. This is how one of |
|
32 | \image examples_qmlcustomlegend1.png | |
33 | \br |
|
33 | \snippet qmlcustomlegend/qml/qmlcustomlegend/ChartViewStacked.qml 1 | |
34 | the stacked areas is created. See ChartViewStacked.qml and AnimatedAreaSeries.qml. |
|
34 | ||
35 | \br |
|
35 | Hovering with mouse on top of the legend will highlight the hovered series. | |
36 | \br |
|
36 | (see CustomLegend.qml). | |
37 | \snippet qmlcustomlegend/qml/qmlcustomlegend/ChartViewStacked.qml 1 |
|
37 | ||
38 |
|
|
38 | \image examples_qmlcustomlegend2.png | |
39 | \row |
|
39 | \snippet qmlcustomlegend/qml/qmlcustomlegend/CustomLegend.qml 1 | |
40 | \li \br |
|
40 | \snippet qmlcustomlegend/qml/qmlcustomlegend/CustomLegend.qml 2 | |
41 | Hovering with mouse on top of the legend will highlight the hovered series. |
|
41 | \dots | |
42 | \br |
|
42 | \snippet qmlcustomlegend/qml/qmlcustomlegend/CustomLegend.qml 3 | |
43 | (see CustomLegend.qml). |
|
43 | ||
44 | \br |
|
44 | You can also select one of the stacked areas for a closer look as a line series by | |
45 | \br |
|
45 | a mouse click (see ChartViewHighlighted.qml). | |
46 | \snippet qmlcustomlegend/qml/qmlcustomlegend/CustomLegend.qml 1 |
|
46 | ||
47 | \snippet qmlcustomlegend/qml/qmlcustomlegend/CustomLegend.qml 2 |
|
47 | \image examples_qmlcustomlegend3.png | |
48 | \dots |
|
48 | \snippet qmlcustomlegend/qml/qmlcustomlegend/ChartViewHighlighted.qml 1 | |
49 | \snippet qmlcustomlegend/qml/qmlcustomlegend/CustomLegend.qml 3 |
|
|||
50 | \li \inlineimage examples_qmlcustomlegend2.png |
|
|||
51 | \row |
|
|||
52 | \li \br |
|
|||
53 | You can also select one of the stacked areas for a closer look as a line series by |
|
|||
54 | \br |
|
|||
55 | a mouse click (see ChartViewHighlighted.qml). |
|
|||
56 | \br |
|
|||
57 | \br |
|
|||
58 | \snippet qmlcustomlegend/qml/qmlcustomlegend/ChartViewHighlighted.qml 1 |
|
|||
59 | \li \inlineimage examples_qmlcustomlegend3.png |
|
|||
60 | \endtable |
|
|||
61 | */ |
|
49 | */ |
@@ -1,53 +1,43 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2014 Digia Plc |
|
3 | ** Copyright (C) 2014 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to Digia, please use contact form at http://qt.io |
|
5 | ** For any questions to Digia, please use contact form at http://qt.io | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Charts module. |
|
7 | ** This file is part of the Qt Charts module. | |
8 | ** |
|
8 | ** | |
9 | ** Licensees holding valid commercial license for Qt may use this file in |
|
9 | ** Licensees holding valid commercial license for Qt may use this file in | |
10 | ** accordance with the Qt License Agreement provided with the Software |
|
10 | ** accordance with the Qt License Agreement provided with the Software | |
11 | ** or, alternatively, in accordance with the terms contained in a written |
|
11 | ** or, alternatively, in accordance with the terms contained in a written | |
12 | ** agreement between you and Digia. |
|
12 | ** agreement between you and Digia. | |
13 | ** |
|
13 | ** | |
14 | ** If you have questions regarding the use of this file, please use |
|
14 | ** If you have questions regarding the use of this file, please use | |
15 | ** contact form at http://qt.io |
|
15 | ** contact form at http://qt.io | |
16 | ** |
|
16 | ** | |
17 | ****************************************************************************/ |
|
17 | ****************************************************************************/ | |
18 |
|
18 | |||
19 | /*! |
|
19 | /*! | |
20 | \example qmlpolarchart |
|
20 | \example qmlpolarchart | |
21 | \title Qml Polar Chart |
|
21 | \title Qml Polar Chart | |
22 | \ingroup qtcharts_examples |
|
22 | \ingroup qtcharts_examples | |
23 |
|
23 | |||
24 | \brief This is a demonstration on how to use a polar chart in your QML application. |
|
24 | \brief This is a demonstration on how to use a polar chart in your QML application. | |
25 |
|
25 | |||
26 | \table |
|
26 | We begin with a chart that has a spline series and a scatter series with random | |
27 | \row |
|
27 | data. Both series use the same axes. | |
28 | \li \br |
|
28 | ||
29 | We begin with a chart that has a spline series and a scatter series with random |
|
29 | \image examples_qmlpolarchart1.png | |
30 | data. Both series use the same axes. |
|
30 | \snippet qmlpolarchart/qml/qmlpolarchart/View1.qml 1 | |
31 | \br |
|
31 | ||
32 | \br |
|
32 | The next example shows a chart with some accurate historical data for which we need | |
33 | \snippet qmlpolarchart/qml/qmlpolarchart/View1.qml 1 |
|
33 | to use a DateTimeAxis and a AreaSeries. | |
34 | \li \inlineimage examples_qmlpolarchart1.png |
|
34 | ||
35 | \row |
|
35 | \image examples_qmlpolarchart2.png | |
36 | \li \br |
|
36 | \snippet qmlpolarchart/qml/qmlpolarchart/View2.qml 1 | |
37 | The next example shows a chart with some accurate historical data for which we need |
|
37 | ||
38 | to use a DateTimeAxis |
|
38 | And the final example with a chart that uses a CategoryAxis to make the data easier | |
39 | and a AreaSeries. |
|
39 | to understand. | |
40 | \br |
|
40 | ||
41 | \br |
|
41 | \image examples_qmlpolarchart3.png | |
42 |
|
|
42 | \snippet qmlpolarchart/qml/qmlpolarchart/View3.qml 1 | |
43 | \li \inlineimage examples_qmlpolarchart2.png |
|
|||
44 | \row |
|
|||
45 | \li \br |
|
|||
46 | And the final example with a chart that uses a CategoryAxis to make the data easier |
|
|||
47 | to understand. |
|
|||
48 | \br |
|
|||
49 | \br |
|
|||
50 | \snippet qmlpolarchart/qml/qmlpolarchart/View3.qml 1 |
|
|||
51 | \li \inlineimage examples_qmlpolarchart3.png |
|
|||
52 | \endtable |
|
|||
53 | */ |
|
43 | */ |
@@ -1,28 +1,28 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2014 Digia Plc |
|
3 | ** Copyright (C) 2014 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to Digia, please use contact form at http://qt.io |
|
5 | ** For any questions to Digia, please use contact form at http://qt.io | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Charts module. |
|
7 | ** This file is part of the Qt Charts module. | |
8 | ** |
|
8 | ** | |
9 | ** Licensees holding valid commercial license for Qt may use this file in |
|
9 | ** Licensees holding valid commercial license for Qt may use this file in | |
10 | ** accordance with the Qt License Agreement provided with the Software |
|
10 | ** accordance with the Qt License Agreement provided with the Software | |
11 | ** or, alternatively, in accordance with the terms contained in a written |
|
11 | ** or, alternatively, in accordance with the terms contained in a written | |
12 | ** agreement between you and Digia. |
|
12 | ** agreement between you and Digia. | |
13 | ** |
|
13 | ** | |
14 | ** If you have questions regarding the use of this file, please use |
|
14 | ** If you have questions regarding the use of this file, please use | |
15 | ** contact form at http://qt.io |
|
15 | ** contact form at http://qt.io | |
16 | ** |
|
16 | ** | |
17 | ****************************************************************************/ |
|
17 | ****************************************************************************/ | |
18 |
|
18 | |||
19 | /*! |
|
19 | /*! | |
20 | \example scatterinteractions |
|
20 | \example scatterinteractions | |
21 | \title ScatterInteractions Example |
|
21 | \title Scatter Interactions Example | |
22 | \ingroup qtcharts_examples |
|
22 | \ingroup qtcharts_examples | |
23 |
|
23 | |||
24 | \brief This example shows how to create a simple scatter chart and how to interact with the |
|
24 | \brief This example shows how to create a simple scatter chart and how to interact with the | |
25 | chart. |
|
25 | chart. | |
26 |
|
26 | |||
27 | \image examples_scatterinteractions.png |
|
27 | \image examples_scatterinteractions.png | |
28 | */ |
|
28 | */ |
@@ -1,64 +1,64 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2014 Digia Plc |
|
3 | ** Copyright (C) 2014 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to Digia, please use contact form at http://qt.io |
|
5 | ** For any questions to Digia, please use contact form at http://qt.io | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Charts module. |
|
7 | ** This file is part of the Qt Charts module. | |
8 | ** |
|
8 | ** | |
9 | ** Licensees holding valid commercial license for Qt may use this file in |
|
9 | ** Licensees holding valid commercial license for Qt may use this file in | |
10 | ** accordance with the Qt License Agreement provided with the Software |
|
10 | ** accordance with the Qt License Agreement provided with the Software | |
11 | ** or, alternatively, in accordance with the terms contained in a written |
|
11 | ** or, alternatively, in accordance with the terms contained in a written | |
12 | ** agreement between you and Digia. |
|
12 | ** agreement between you and Digia. | |
13 | ** |
|
13 | ** | |
14 | ** If you have questions regarding the use of this file, please use |
|
14 | ** If you have questions regarding the use of this file, please use | |
15 | ** contact form at http://qt.io |
|
15 | ** contact form at http://qt.io | |
16 | ** |
|
16 | ** | |
17 | ****************************************************************************/ |
|
17 | ****************************************************************************/ | |
18 |
|
18 | |||
19 | /*! |
|
19 | /*! | |
20 | \example temperaturerecords |
|
20 | \example temperaturerecords | |
21 |
\title Temperature |
|
21 | \title Temperature Records Example | |
22 | \ingroup qtcharts_examples |
|
22 | \ingroup qtcharts_examples | |
23 |
|
23 | |||
24 | \brief The example shows how to create a bar chart with negative bars. |
|
24 | \brief The example shows how to create a bar chart with negative bars. | |
25 |
|
25 | |||
26 | For our example we use temperature data. |
|
26 | For our example we use temperature data. | |
27 |
|
27 | |||
28 | \image examples_temperaturerecords.png |
|
28 | \image examples_temperaturerecords.png | |
29 |
|
29 | |||
30 | First we create two barsets and append the data to them. One set represents the minimum temperatures and another the maximum temperatures. |
|
30 | First we create two barsets and append the data to them. One set represents the minimum temperatures and another the maximum temperatures. | |
31 |
|
31 | |||
32 | \snippet temperaturerecords/main.cpp 1 |
|
32 | \snippet temperaturerecords/main.cpp 1 | |
33 |
|
33 | |||
34 | We create the series and append the barsets to it. The series takes ownership of the barsets. |
|
34 | We create the series and append the barsets to it. The series takes ownership of the barsets. | |
35 |
|
35 | |||
36 | \snippet temperaturerecords/main.cpp 2 |
|
36 | \snippet temperaturerecords/main.cpp 2 | |
37 |
|
37 | |||
38 | Here we create the chart object and add the series to it. We set the title for the chart with setTitle, and then turn on animations of the series by calling |
|
38 | Here we create the chart object and add the series to it. We set the title for the chart with setTitle, and then turn on animations of the series by calling | |
39 | setAnimationOptions(QChart::SeriesAnimations) |
|
39 | setAnimationOptions(QChart::SeriesAnimations) | |
40 |
|
40 | |||
41 | \snippet temperaturerecords/main.cpp 3 |
|
41 | \snippet temperaturerecords/main.cpp 3 | |
42 |
|
42 | |||
43 | To have categories displayed on an axis, we need to create a QBarCategoryAxis. Here we create a category axis with a list of categories and |
|
43 | To have categories displayed on an axis, we need to create a QBarCategoryAxis. Here we create a category axis with a list of categories and | |
44 | set it to be the x-axis of the chart. The chart takes ownership of the axis. For y-axis we use the default axis, which is created and scaled to the series data |
|
44 | set it to be the x-axis of the chart. The chart takes ownership of the axis. For y-axis we use the default axis, which is created and scaled to the series data | |
45 | by calling createDefaultAxes of the chart. We change the range for the y-axis, since this gives nicer result than with autoscaling. |
|
45 | by calling createDefaultAxes of the chart. We change the range for the y-axis, since this gives nicer result than with autoscaling. | |
46 |
|
46 | |||
47 | Note that the call for createDefaultAxes must be before we set the category axis. Otherwise the default axis will override the category axis. |
|
47 | Note that the call for createDefaultAxes must be before we set the category axis. Otherwise the default axis will override the category axis. | |
48 |
|
48 | |||
49 | \snippet temperaturerecords/main.cpp 4 |
|
49 | \snippet temperaturerecords/main.cpp 4 | |
50 |
|
50 | |||
51 | We also want to show the legend. To do so, we get the legend pointer from the chart and set it to visible. We also place the legend to the bottom |
|
51 | We also want to show the legend. To do so, we get the legend pointer from the chart and set it to visible. We also place the legend to the bottom | |
52 | of the chart by setting its alignment to Qt::AlignBottom. |
|
52 | of the chart by setting its alignment to Qt::AlignBottom. | |
53 |
|
53 | |||
54 | \snippet temperaturerecords/main.cpp 5 |
|
54 | \snippet temperaturerecords/main.cpp 5 | |
55 |
|
55 | |||
56 | Finally we add the chart onto a view. We also turn on the antialiasing for the chartView. |
|
56 | Finally we add the chart onto a view. We also turn on the antialiasing for the chartView. | |
57 |
|
57 | |||
58 | \snippet temperaturerecords/main.cpp 6 |
|
58 | \snippet temperaturerecords/main.cpp 6 | |
59 |
|
59 | |||
60 | Chart is ready to be shown. We set the chart to be the central widget of the window. |
|
60 | Chart is ready to be shown. We set the chart to be the central widget of the window. | |
61 | We also set the size for the chart window and show it. |
|
61 | We also set the size for the chart window and show it. | |
62 |
|
62 | |||
63 | \snippet temperaturerecords/main.cpp 7 |
|
63 | \snippet temperaturerecords/main.cpp 7 | |
64 | */ |
|
64 | */ |
@@ -1,61 +1,60 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2014 Digia Plc |
|
3 | ** Copyright (C) 2014 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to Digia, please use contact form at http://qt.io |
|
5 | ** For any questions to Digia, please use contact form at http://qt.io | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Charts module. |
|
7 | ** This file is part of the Qt Charts module. | |
8 | ** |
|
8 | ** | |
9 | ** Licensees holding valid commercial license for Qt may use this file in |
|
9 | ** Licensees holding valid commercial license for Qt may use this file in | |
10 | ** accordance with the Qt License Agreement provided with the Software |
|
10 | ** accordance with the Qt License Agreement provided with the Software | |
11 | ** or, alternatively, in accordance with the terms contained in a written |
|
11 | ** or, alternatively, in accordance with the terms contained in a written | |
12 | ** agreement between you and Digia. |
|
12 | ** agreement between you and Digia. | |
13 | ** |
|
13 | ** | |
14 | ** If you have questions regarding the use of this file, please use |
|
14 | ** If you have questions regarding the use of this file, please use | |
15 | ** contact form at http://qt.io |
|
15 | ** contact form at http://qt.io | |
16 | ** |
|
16 | ** | |
17 | ****************************************************************************/ |
|
17 | ****************************************************************************/ | |
18 |
|
18 | |||
19 | /*! |
|
19 | /*! | |
20 | \title Qt Charts |
|
20 | \title Qt Charts | |
21 | \page index.html |
|
21 | \page index.html | |
22 | \keyword About |
|
22 | \keyword About | |
23 |
|
23 | |||
24 | Qt Charts is a part of the Qt Enterprise addons package. It provides a set of easy to use chart |
|
24 | Qt Charts module provides a set of easy to use chart components. It uses the Qt Graphics View | |
25 | components which are available for Qt customers. It uses the Qt Graphics View |
|
|||
26 | Framework, therefore charts can be easily integrated to modern user interfaces. Qt Charts can |
|
25 | Framework, therefore charts can be easily integrated to modern user interfaces. Qt Charts can | |
27 | be used as QWidgets, QGraphicsWidget, or QML types. Users can easily create impressive |
|
26 | be used as QWidgets, QGraphicsWidget, or QML types. Users can easily create impressive | |
28 | graphs by selecting one of the charts themes. |
|
27 | graphs by selecting one of the charts themes. | |
29 |
|
28 | |||
30 | \section1 Getting Started |
|
29 | \section1 Getting Started | |
31 |
|
30 | |||
32 | To import Qt Charts QML types, add the following import statement to your \c .qml file: |
|
31 | To import Qt Charts QML types, add the following import statement to your \c .qml file: | |
33 |
|
32 | |||
34 | \snippet doc_src_qmlcharts.cpp 0 |
|
33 | \snippet doc_src_qmlcharts.cpp 0 | |
35 |
|
34 | |||
36 | If you intend to use Qt Charts C++ classes in your application, use the |
|
35 | If you intend to use Qt Charts C++ classes in your application, use the | |
37 | following include and using directives: |
|
36 | following include and using directives: | |
38 |
|
37 | |||
39 | \snippet doc_src_qtcharts.cpp 0 |
|
38 | \snippet doc_src_qtcharts.cpp 0 | |
40 |
|
39 | |||
41 | \note If you are only using a few classes from this module, we recommend including only those |
|
40 | \note If you are only using a few classes from this module, we recommend including only those | |
42 | specific classes instead of the whole module. |
|
41 | specific classes instead of the whole module. | |
43 |
|
42 | |||
44 | To link against the Qt Charts module, add this line to your \c qmake project file: |
|
43 | To link against the Qt Charts module, add this line to your \c qmake project file: | |
45 |
|
44 | |||
46 | \snippet doc_src_qtcharts.pro 0 |
|
45 | \snippet doc_src_qtcharts.pro 0 | |
47 |
|
46 | |||
48 | See the \l{Qt Charts Getting Started}{Getting started} page for further information on |
|
47 | See the \l{Qt Charts Getting Started}{Getting started} page for further information on | |
49 | how to use Qt Charts in your application. |
|
48 | how to use Qt Charts in your application. | |
50 |
|
49 | |||
51 | \section1 References |
|
50 | \section1 References | |
52 | \list |
|
51 | \list | |
53 | \li \l{Qt Charts C++ Classes} |
|
52 | \li \l{Qt Charts C++ Classes} | |
54 | \li \l{Qt Charts QML Types} |
|
53 | \li \l{Qt Charts QML Types} | |
55 | \endlist |
|
54 | \endlist | |
56 |
|
55 | |||
57 | Qt Charts comes with the following examples: |
|
56 | Qt Charts comes with the following examples: | |
58 |
|
57 | |||
59 | \annotatedlist qtcharts_examples |
|
58 | \annotatedlist qtcharts_examples | |
60 |
|
59 | |||
61 | */ |
|
60 | */ |
@@ -1,200 +1,194 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2014 Digia Plc |
|
3 | ** Copyright (C) 2014 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to Digia, please use contact form at http://qt.io |
|
5 | ** For any questions to Digia, please use contact form at http://qt.io | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Charts module. |
|
7 | ** This file is part of the Qt Charts module. | |
8 | ** |
|
8 | ** | |
9 | ** Licensees holding valid commercial license for Qt may use this file in |
|
9 | ** Licensees holding valid commercial license for Qt may use this file in | |
10 | ** accordance with the Qt License Agreement provided with the Software |
|
10 | ** accordance with the Qt License Agreement provided with the Software | |
11 | ** or, alternatively, in accordance with the terms contained in a written |
|
11 | ** or, alternatively, in accordance with the terms contained in a written | |
12 | ** agreement between you and Digia. |
|
12 | ** agreement between you and Digia. | |
13 | ** |
|
13 | ** | |
14 | ** If you have questions regarding the use of this file, please use |
|
14 | ** If you have questions regarding the use of this file, please use | |
15 | ** contact form at http://qt.io |
|
15 | ** contact form at http://qt.io | |
16 | ** |
|
16 | ** | |
17 | ****************************************************************************/ |
|
17 | ****************************************************************************/ | |
18 |
|
18 | |||
19 | /*! |
|
19 | /*! | |
20 | \module Qt Charts |
|
20 | \module Qt Charts | |
21 | \title Qt Charts C++ Classes |
|
21 | \title Qt Charts C++ Classes | |
22 | \ingroup modules |
|
22 | \ingroup modules | |
23 |
|
23 | |||
24 | \brief C++ classes for the Qt Charts API. |
|
24 | \brief C++ classes for the Qt Charts API. | |
25 |
|
25 | |||
26 | Charts API is built on top of Qt Graphics View Framework. Charts can be displayed as QGraphicsWidget using the QChart class. However |
|
26 | Charts API is built on top of Qt Graphics View Framework. Charts can be displayed as QGraphicsWidget using the QChart class. However | |
27 | there is also the convenience class QChartView, which is QWidget based. These enable us to quickly use Qt Charts as a normal Qt widget. |
|
27 | there is also the convenience class QChartView, which is QWidget based. These enable us to quickly use Qt Charts as a normal Qt widget. | |
28 |
|
28 | |||
29 | Each chart type is represented by the QAbstractSeries derived class. To create charts, the users have to use an instance of the related |
|
29 | Each chart type is represented by the QAbstractSeries derived class. To create charts, the users have to use an instance of the related | |
30 | series class and add it to a QChart instance. |
|
30 | series class and add it to a QChart instance. | |
31 | \code |
|
31 | \code | |
32 | QLineSeries* series = new QLineSeries(); |
|
32 | QLineSeries* series = new QLineSeries(); | |
33 | series->add(0, 6); |
|
33 | series->add(0, 6); | |
34 | series->add(2, 4); |
|
34 | series->add(2, 4); | |
35 | ... |
|
35 | ... | |
36 | chartView->chart()->addSeries(series); |
|
36 | chartView->chart()->addSeries(series); | |
37 | chartView->chart()->createDefaultAxes(); |
|
37 | chartView->chart()->createDefaultAxes(); | |
38 | \endcode |
|
38 | \endcode | |
39 | */ |
|
39 | */ | |
40 |
|
40 | |||
41 | /*! |
|
41 | /*! | |
42 | \qmlmodule QtCharts 2.0 |
|
42 | \qmlmodule QtCharts 2.0 | |
43 | \title Qt Charts QML Types |
|
43 | \title Qt Charts QML Types | |
44 | \ingroup qmlmodules |
|
44 | \ingroup qmlmodules | |
45 |
|
45 | |||
46 | \brief QML types for the Qt Charts API. |
|
46 | \brief QML types for the Qt Charts API. | |
47 |
|
47 | |||
48 | The Qt Charts QML API is an intuitive and simple way to show charts in your QML |
|
48 | The Qt Charts QML API is an intuitive and simple way to show charts in your QML | |
49 | applications. |
|
49 | applications. | |
50 |
|
50 | |||
51 | \table |
|
51 | Use the following QML to create a simple pie chart: | |
52 | \row |
|
52 | \image examples_qmlpiechart.png | |
53 | \li \br |
|
53 | \snippet qmlpiechart/qml/qmlpiechart/main.qml 1 | |
54 | Use the following QML to create a simple pie chart: |
|
54 | \snippet qmlpiechart/qml/qmlpiechart/main.qml 2 | |
55 | \br |
|
55 | \snippet qmlpiechart/qml/qmlpiechart/main.qml 3 | |
56 | \br |
|
|||
57 | \snippet qmlpiechart/qml/qmlpiechart/main.qml 1 |
|
|||
58 | \snippet qmlpiechart/qml/qmlpiechart/main.qml 2 |
|
|||
59 | \snippet qmlpiechart/qml/qmlpiechart/main.qml 3 |
|
|||
60 | \li \inlineimage examples_qmlpiechart.png |
|
|||
61 | \endtable |
|
|||
62 |
|
56 | |||
63 | \note Since Qt Creator 3.0 the project created with Qt Quick Application wizard based on |
|
57 | \note Since Qt Creator 3.0 the project created with Qt Quick Application wizard based on | |
64 | Qt Quick 2 template uses QGuiApplication by default. As Qt Charts utilizes Qt Graphics View |
|
58 | Qt Quick 2 template uses QGuiApplication by default. As Qt Charts utilizes Qt Graphics View | |
65 | Framework for drawing, QApplication must be used. The project created with the wizard is |
|
59 | Framework for drawing, QApplication must be used. The project created with the wizard is | |
66 | usable with Qt Charts after the QGuiApplication is replaced with QApplication. |
|
60 | usable with Qt Charts after the QGuiApplication is replaced with QApplication. | |
67 |
|
61 | |||
68 | \section1 QML Types |
|
62 | \section1 QML Types | |
69 | */ |
|
63 | */ | |
70 |
|
64 | |||
71 | /*! |
|
65 | /*! | |
72 | \group charts_examples |
|
66 | \group charts_examples | |
73 | \ingroup all-examples |
|
67 | \ingroup all-examples | |
74 | \title Qt Charts Examples |
|
68 | \title Qt Charts Examples | |
75 |
|
69 | |||
76 | \brief Examples for the Qt Charts. |
|
70 | \brief Examples for the Qt Charts. | |
77 |
|
71 | |||
78 | For some code examples, see one of the Qt Charts examples: |
|
72 | For some code examples, see one of the Qt Charts examples: | |
79 |
|
73 | |||
80 | \section1 Examples |
|
74 | \section1 Examples | |
81 |
|
75 | |||
82 | \annotatedlist qtcharts_examples |
|
76 | \annotatedlist qtcharts_examples | |
83 | */ |
|
77 | */ | |
84 |
|
78 | |||
85 | /*! |
|
79 | /*! | |
86 | \group qtcharts_getting_started |
|
80 | \group qtcharts_getting_started | |
87 | \title Qt Charts Getting Started |
|
81 | \title Qt Charts Getting Started | |
88 |
|
82 | |||
89 | \section1 Installing the Qt Charts module |
|
83 | \section1 Installing the Qt Charts module | |
90 |
|
84 | |||
91 | Use the \c {Package Manager} in \c {Maintenance Tool} or the \c {Online installer} to install |
|
85 | Use the \c {Package Manager} in \c {Maintenance Tool} or the \c {Online installer} to install | |
92 | the Qt Charts module. The module can be found under \c {Qt Enterprise Add-Ons} in the |
|
86 | the Qt Charts module. The module can be found under \c {Qt Enterprise Add-Ons} in the | |
93 | package manager. |
|
87 | package manager. | |
94 |
|
88 | |||
95 | After installation Qt Charts documentation and examples are available in Qt Creator. |
|
89 | After installation Qt Charts documentation and examples are available in Qt Creator. | |
96 | Examples can be found on the examples page of Qt Creator by selecting the Qt Charts |
|
90 | Examples can be found on the examples page of Qt Creator by selecting the Qt Charts | |
97 | component from the drop-down menu. |
|
91 | component from the drop-down menu. | |
98 |
|
92 | |||
99 | The source code is installed into the QtCharts folder under EnterpriseAddOns. |
|
93 | The source code is installed into the QtCharts folder under EnterpriseAddOns. | |
100 |
|
94 | |||
101 | \section1 Building Qt Charts |
|
95 | \section1 Building Qt Charts | |
102 |
|
96 | |||
103 | To build the Qt Charts module from source code yourself, set up a command prompt with |
|
97 | To build the Qt Charts module from source code yourself, set up a command prompt with | |
104 | an environment for building Qt applications, navigate to the directory containing |
|
98 | an environment for building Qt applications, navigate to the directory containing | |
105 | \c {qtcharts.pro}, and configure the project with qmake: |
|
99 | \c {qtcharts.pro}, and configure the project with qmake: | |
106 | \code |
|
100 | \code | |
107 | qmake |
|
101 | qmake | |
108 | \endcode |
|
102 | \endcode | |
109 |
|
103 | |||
110 | After running qmake, build the project with make: |
|
104 | After running qmake, build the project with make: | |
111 | \table |
|
105 | \table | |
112 | \header |
|
106 | \header | |
113 | \li OS \li Make command |
|
107 | \li OS \li Make command | |
114 | \row |
|
108 | \row | |
115 | \li Linux \li make |
|
109 | \li Linux \li make | |
116 | \row |
|
110 | \row | |
117 | \li Windows (MinGw) \li mingw32-make |
|
111 | \li Windows (MinGw) \li mingw32-make | |
118 | \row |
|
112 | \row | |
119 | \li Windows (MSVC) \li nmake |
|
113 | \li Windows (MSVC) \li nmake | |
120 | \row |
|
114 | \row | |
121 | \li OSX \li make |
|
115 | \li OSX \li make | |
122 | \endtable |
|
116 | \endtable | |
123 |
|
117 | |||
124 | The above generates the default makefiles for your configuration, which is typically |
|
118 | The above generates the default makefiles for your configuration, which is typically | |
125 | the release build if you are using precompiled binary Qt distribution. To build both debug |
|
119 | the release build if you are using precompiled binary Qt distribution. To build both debug | |
126 | and release, or one specifically, use one of the following qmake lines instead. |
|
120 | and release, or one specifically, use one of the following qmake lines instead. | |
127 |
|
121 | |||
128 | For debug builds: |
|
122 | For debug builds: | |
129 | \code |
|
123 | \code | |
130 | qmake CONFIG+=debug |
|
124 | qmake CONFIG+=debug | |
131 | make |
|
125 | make | |
132 | \endcode |
|
126 | \endcode | |
133 | or |
|
127 | or | |
134 | \code |
|
128 | \code | |
135 | qmake CONFIG+=debug_and_release |
|
129 | qmake CONFIG+=debug_and_release | |
136 | make debug |
|
130 | make debug | |
137 | \endcode |
|
131 | \endcode | |
138 |
|
132 | |||
139 | For release builds: |
|
133 | For release builds: | |
140 | \code |
|
134 | \code | |
141 | qmake CONFIG+=release |
|
135 | qmake CONFIG+=release | |
142 | make |
|
136 | make | |
143 | \endcode |
|
137 | \endcode | |
144 | or |
|
138 | or | |
145 | \code |
|
139 | \code | |
146 | qmake CONFIG+=debug_and_release |
|
140 | qmake CONFIG+=debug_and_release | |
147 | make release |
|
141 | make release | |
148 | \endcode |
|
142 | \endcode | |
149 |
|
143 | |||
150 | For both builds (Windows/OS X only): |
|
144 | For both builds (Windows/OS X only): | |
151 | \code |
|
145 | \code | |
152 | qmake CONFIG+="debug_and_release build_all" |
|
146 | qmake CONFIG+="debug_and_release build_all" | |
153 | make |
|
147 | make | |
154 | \endcode |
|
148 | \endcode | |
155 |
|
149 | |||
156 | After building, install the module to your Qt directory: |
|
150 | After building, install the module to your Qt directory: | |
157 | \code |
|
151 | \code | |
158 | make install |
|
152 | make install | |
159 | \endcode |
|
153 | \endcode | |
160 |
|
154 | |||
161 | If you want to uninstall the module: |
|
155 | If you want to uninstall the module: | |
162 | \code |
|
156 | \code | |
163 | make uninstall |
|
157 | make uninstall | |
164 | \endcode |
|
158 | \endcode | |
165 |
|
159 | |||
166 | To build a statically linked version of the Qt Charts module, give the following commands: |
|
160 | To build a statically linked version of the Qt Charts module, give the following commands: | |
167 |
|
161 | |||
168 | \snippet doc_src_qtcharts.cpp 1 |
|
162 | \snippet doc_src_qtcharts.cpp 1 | |
169 |
|
163 | |||
170 | \section1 Running examples |
|
164 | \section1 Running examples | |
171 |
|
165 | |||
172 | Qt Charts examples are found under the \c examples subdirectory. To build and run a single |
|
166 | Qt Charts examples are found under the \c examples subdirectory. To build and run a single | |
173 | example, in this case qmlpolarchart, navigate to the example directory and enter the following |
|
167 | example, in this case qmlpolarchart, navigate to the example directory and enter the following | |
174 | commands: |
|
168 | commands: | |
175 |
|
169 | |||
176 | \snippet doc_src_qtcharts.cpp 2 |
|
170 | \snippet doc_src_qtcharts.cpp 2 | |
177 |
|
171 | |||
178 | \note On some platforms, such as Windows, the executable can be generated under debug or |
|
172 | \note On some platforms, such as Windows, the executable can be generated under debug or | |
179 | release folders, depending on your build. |
|
173 | release folders, depending on your build. | |
180 |
|
174 | |||
181 | \section1 Creating a simple application |
|
175 | \section1 Creating a simple application | |
182 |
|
176 | |||
183 | To create a simple application, start by creating a new Qt Gui Application project in Qt |
|
177 | To create a simple application, start by creating a new Qt Gui Application project in Qt | |
184 | Creator and add this line to the \c .pro file of the project: |
|
178 | Creator and add this line to the \c .pro file of the project: | |
185 |
|
179 | |||
186 | \snippet doc_src_qtcharts.pro 0 |
|
180 | \snippet doc_src_qtcharts.pro 0 | |
187 |
|
181 | |||
188 | In the \c main.cpp file, include the module headers and declare namespace usage: |
|
182 | In the \c main.cpp file, include the module headers and declare namespace usage: | |
189 |
|
183 | |||
190 | \snippet doc_src_qtcharts.cpp 0 |
|
184 | \snippet doc_src_qtcharts.cpp 0 | |
191 |
|
185 | |||
192 | \note Since Qt Creator 3.0 the project created with Qt Quick Application wizard based on |
|
186 | \note Since Qt Creator 3.0 the project created with Qt Quick Application wizard based on | |
193 | Qt Quick 2 template uses QGuiApplication by default. As Qt Charts utilizes Qt Graphics View |
|
187 | Qt Quick 2 template uses QGuiApplication by default. As Qt Charts utilizes Qt Graphics View | |
194 | Framework for drawing, QApplication must be used. The project created with the wizard is |
|
188 | Framework for drawing, QApplication must be used. The project created with the wizard is | |
195 | usable with Qt Charts after the QGuiApplication is replaced with QApplication. |
|
189 | usable with Qt Charts after the QGuiApplication is replaced with QApplication. | |
196 |
|
190 | |||
197 | For further code examples, see one of the Qt Charts examples: |
|
191 | For further code examples, see one of the Qt Charts examples: | |
198 |
|
192 | |||
199 | \annotatedlist qtcharts_examples |
|
193 | \annotatedlist qtcharts_examples | |
200 | */ |
|
194 | */ |
@@ -1,1005 +1,1002 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2014 Digia Plc |
|
3 | ** Copyright (C) 2014 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to Digia, please use contact form at http://qt.io |
|
5 | ** For any questions to Digia, please use contact form at http://qt.io | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Charts module. |
|
7 | ** This file is part of the Qt Charts module. | |
8 | ** |
|
8 | ** | |
9 | ** Licensees holding valid commercial license for Qt may use this file in |
|
9 | ** Licensees holding valid commercial license for Qt may use this file in | |
10 | ** accordance with the Qt License Agreement provided with the Software |
|
10 | ** accordance with the Qt License Agreement provided with the Software | |
11 | ** or, alternatively, in accordance with the terms contained in a written |
|
11 | ** or, alternatively, in accordance with the terms contained in a written | |
12 | ** agreement between you and Digia. |
|
12 | ** agreement between you and Digia. | |
13 | ** |
|
13 | ** | |
14 | ** If you have questions regarding the use of this file, please use |
|
14 | ** If you have questions regarding the use of this file, please use | |
15 | ** contact form at http://qt.io |
|
15 | ** contact form at http://qt.io | |
16 | ** |
|
16 | ** | |
17 | ****************************************************************************/ |
|
17 | ****************************************************************************/ | |
18 |
|
18 | |||
19 | #include <QtCharts/QPieSeries> |
|
19 | #include <QtCharts/QPieSeries> | |
20 | #include <private/qpieseries_p.h> |
|
20 | #include <private/qpieseries_p.h> | |
21 | #include <QtCharts/QPieSlice> |
|
21 | #include <QtCharts/QPieSlice> | |
22 | #include <private/qpieslice_p.h> |
|
22 | #include <private/qpieslice_p.h> | |
23 | #include <private/pieslicedata_p.h> |
|
23 | #include <private/pieslicedata_p.h> | |
24 | #include <private/chartdataset_p.h> |
|
24 | #include <private/chartdataset_p.h> | |
25 | #include <private/charttheme_p.h> |
|
25 | #include <private/charttheme_p.h> | |
26 | #include <QtCharts/QAbstractAxis> |
|
26 | #include <QtCharts/QAbstractAxis> | |
27 | #include <private/pieanimation_p.h> |
|
27 | #include <private/pieanimation_p.h> | |
28 | #include <private/charthelpers_p.h> |
|
28 | #include <private/charthelpers_p.h> | |
29 |
|
29 | |||
30 | #include <QtCharts/QPieLegendMarker> |
|
30 | #include <QtCharts/QPieLegendMarker> | |
31 |
|
31 | |||
32 | QT_CHARTS_BEGIN_NAMESPACE |
|
32 | QT_CHARTS_BEGIN_NAMESPACE | |
33 |
|
33 | |||
34 | /*! |
|
34 | /*! | |
35 | \class QPieSeries |
|
35 | \class QPieSeries | |
36 | \inmodule Qt Charts |
|
36 | \inmodule Qt Charts | |
37 | \brief Pie series API for Qt Charts. |
|
37 | \brief Pie series API for Qt Charts. | |
38 |
|
38 | |||
39 | The pie series defines a pie chart which consists of pie slices which are defined as QPieSlice objects. |
|
39 | The pie series defines a pie chart which consists of pie slices which are defined as QPieSlice objects. | |
40 | The slices can have any values as the QPieSeries will calculate its relative value to the sum of all slices. |
|
40 | The slices can have any values as the QPieSeries will calculate its relative value to the sum of all slices. | |
41 | The actual slice size is determined by that relative value. |
|
41 | The actual slice size is determined by that relative value. | |
42 |
|
42 | |||
43 | Pie size and position on the chart is controlled by using relative values which range from 0.0 to 1.0. |
|
43 | Pie size and position on the chart is controlled by using relative values which range from 0.0 to 1.0. | |
44 | These relate to the actual chart rectangle. |
|
44 | These relate to the actual chart rectangle. | |
45 |
|
45 | |||
46 | By default the pie is defined as a full pie but it can also be a partial pie. |
|
46 | By default the pie is defined as a full pie but it can also be a partial pie. | |
47 | This can be done by setting a starting angle and angle span to the series. |
|
47 | This can be done by setting a starting angle and angle span to the series. | |
48 | Full pie is 360 degrees where 0 is at 12 a'clock. |
|
48 | Full pie is 360 degrees where 0 is at 12 a'clock. | |
49 |
|
49 | |||
50 | See the \l {PieChart Example} {pie chart example} or \l {DonutChart Example} {donut chart example} to learn how to use QPieSeries. |
|
50 | See the \l {PieChart Example} {pie chart example} or \l {DonutChart Example} {donut chart example} to learn how to use QPieSeries. | |
51 | \table 100% |
|
51 | \image examples_piechart.png | |
52 | \row |
|
52 | \image examples_donutchart.png | |
53 | \li \image examples_piechart.png |
|
|||
54 | \li \image examples_donutchart.png |
|
|||
55 | \endtable |
|
|||
56 | */ |
|
53 | */ | |
57 | /*! |
|
54 | /*! | |
58 | \qmltype PieSeries |
|
55 | \qmltype PieSeries | |
59 | \instantiates QPieSeries |
|
56 | \instantiates QPieSeries | |
60 | \inqmlmodule QtCharts |
|
57 | \inqmlmodule QtCharts | |
61 |
|
58 | |||
62 | \inherits AbstractSeries |
|
59 | \inherits AbstractSeries | |
63 |
|
60 | |||
64 | \brief The PieSeries type is used for making pie charts. |
|
61 | \brief The PieSeries type is used for making pie charts. | |
65 |
|
62 | |||
66 | The following QML shows how to create a simple pie chart. |
|
63 | The following QML shows how to create a simple pie chart. | |
67 |
|
64 | |||
68 | \snippet qmlchart/qml/qmlchart/View1.qml 1 |
|
65 | \snippet qmlchart/qml/qmlchart/View1.qml 1 | |
69 |
|
66 | |||
70 | \beginfloatleft |
|
67 | \beginfloatleft | |
71 | \image examples_qmlchart1.png |
|
68 | \image examples_qmlchart1.png | |
72 | \endfloat |
|
69 | \endfloat | |
73 | \clearfloat |
|
70 | \clearfloat | |
74 | */ |
|
71 | */ | |
75 |
|
72 | |||
76 | /*! |
|
73 | /*! | |
77 | \property QPieSeries::horizontalPosition |
|
74 | \property QPieSeries::horizontalPosition | |
78 | \brief Defines the horizontal position of the pie. |
|
75 | \brief Defines the horizontal position of the pie. | |
79 |
|
76 | |||
80 | The value is a relative value to the chart rectangle where: |
|
77 | The value is a relative value to the chart rectangle where: | |
81 |
|
78 | |||
82 | \list |
|
79 | \list | |
83 | \li 0.0 is the absolute left. |
|
80 | \li 0.0 is the absolute left. | |
84 | \li 1.0 is the absolute right. |
|
81 | \li 1.0 is the absolute right. | |
85 | \endlist |
|
82 | \endlist | |
86 | Default value is 0.5 (center). |
|
83 | Default value is 0.5 (center). | |
87 | \sa verticalPosition |
|
84 | \sa verticalPosition | |
88 | */ |
|
85 | */ | |
89 |
|
86 | |||
90 | /*! |
|
87 | /*! | |
91 | \qmlproperty real PieSeries::horizontalPosition |
|
88 | \qmlproperty real PieSeries::horizontalPosition | |
92 |
|
89 | |||
93 | Defines the horizontal position of the pie. |
|
90 | Defines the horizontal position of the pie. | |
94 |
|
91 | |||
95 | The value is a relative value to the chart rectangle where: |
|
92 | The value is a relative value to the chart rectangle where: | |
96 |
|
93 | |||
97 | \list |
|
94 | \list | |
98 | \li 0.0 is the absolute left. |
|
95 | \li 0.0 is the absolute left. | |
99 | \li 1.0 is the absolute right. |
|
96 | \li 1.0 is the absolute right. | |
100 | \endlist |
|
97 | \endlist | |
101 | Default value is 0.5 (center). |
|
98 | Default value is 0.5 (center). | |
102 | \sa verticalPosition |
|
99 | \sa verticalPosition | |
103 | */ |
|
100 | */ | |
104 |
|
101 | |||
105 | /*! |
|
102 | /*! | |
106 | \property QPieSeries::verticalPosition |
|
103 | \property QPieSeries::verticalPosition | |
107 | \brief Defines the vertical position of the pie. |
|
104 | \brief Defines the vertical position of the pie. | |
108 |
|
105 | |||
109 | The value is a relative value to the chart rectangle where: |
|
106 | The value is a relative value to the chart rectangle where: | |
110 |
|
107 | |||
111 | \list |
|
108 | \list | |
112 | \li 0.0 is the absolute top. |
|
109 | \li 0.0 is the absolute top. | |
113 | \li 1.0 is the absolute bottom. |
|
110 | \li 1.0 is the absolute bottom. | |
114 | \endlist |
|
111 | \endlist | |
115 | Default value is 0.5 (center). |
|
112 | Default value is 0.5 (center). | |
116 | \sa horizontalPosition |
|
113 | \sa horizontalPosition | |
117 | */ |
|
114 | */ | |
118 |
|
115 | |||
119 | /*! |
|
116 | /*! | |
120 | \qmlproperty real PieSeries::verticalPosition |
|
117 | \qmlproperty real PieSeries::verticalPosition | |
121 |
|
118 | |||
122 | Defines the vertical position of the pie. |
|
119 | Defines the vertical position of the pie. | |
123 |
|
120 | |||
124 | The value is a relative value to the chart rectangle where: |
|
121 | The value is a relative value to the chart rectangle where: | |
125 |
|
122 | |||
126 | \list |
|
123 | \list | |
127 | \li 0.0 is the absolute top. |
|
124 | \li 0.0 is the absolute top. | |
128 | \li 1.0 is the absolute bottom. |
|
125 | \li 1.0 is the absolute bottom. | |
129 | \endlist |
|
126 | \endlist | |
130 | Default value is 0.5 (center). |
|
127 | Default value is 0.5 (center). | |
131 | \sa horizontalPosition |
|
128 | \sa horizontalPosition | |
132 | */ |
|
129 | */ | |
133 |
|
130 | |||
134 | /*! |
|
131 | /*! | |
135 | \property QPieSeries::size |
|
132 | \property QPieSeries::size | |
136 | \brief Defines the pie size. |
|
133 | \brief Defines the pie size. | |
137 |
|
134 | |||
138 | The value is a relative value to the chart rectangle where: |
|
135 | The value is a relative value to the chart rectangle where: | |
139 |
|
136 | |||
140 | \list |
|
137 | \list | |
141 | \li 0.0 is the minimum size (pie not drawn). |
|
138 | \li 0.0 is the minimum size (pie not drawn). | |
142 | \li 1.0 is the maximum size that can fit the chart. |
|
139 | \li 1.0 is the maximum size that can fit the chart. | |
143 | \endlist |
|
140 | \endlist | |
144 |
|
141 | |||
145 | When setting this property the holeSize property is adjusted if necessary, to ensure that the hole size is not greater than the outer size. |
|
142 | When setting this property the holeSize property is adjusted if necessary, to ensure that the hole size is not greater than the outer size. | |
146 |
|
143 | |||
147 | Default value is 0.7. |
|
144 | Default value is 0.7. | |
148 | */ |
|
145 | */ | |
149 |
|
146 | |||
150 | /*! |
|
147 | /*! | |
151 | \qmlproperty real PieSeries::size |
|
148 | \qmlproperty real PieSeries::size | |
152 |
|
149 | |||
153 | Defines the pie size. |
|
150 | Defines the pie size. | |
154 |
|
151 | |||
155 | The value is a relative value to the chart rectangle where: |
|
152 | The value is a relative value to the chart rectangle where: | |
156 |
|
153 | |||
157 | \list |
|
154 | \list | |
158 | \li 0.0 is the minimum size (pie not drawn). |
|
155 | \li 0.0 is the minimum size (pie not drawn). | |
159 | \li 1.0 is the maximum size that can fit the chart. |
|
156 | \li 1.0 is the maximum size that can fit the chart. | |
160 | \endlist |
|
157 | \endlist | |
161 |
|
158 | |||
162 | Default value is 0.7. |
|
159 | Default value is 0.7. | |
163 | */ |
|
160 | */ | |
164 |
|
161 | |||
165 | /*! |
|
162 | /*! | |
166 | \property QPieSeries::holeSize |
|
163 | \property QPieSeries::holeSize | |
167 | \brief Defines the donut hole size. |
|
164 | \brief Defines the donut hole size. | |
168 |
|
165 | |||
169 | The value is a relative value to the chart rectangle where: |
|
166 | The value is a relative value to the chart rectangle where: | |
170 |
|
167 | |||
171 | \list |
|
168 | \list | |
172 | \li 0.0 is the minimum size (full pie drawn, without any hole inside). |
|
169 | \li 0.0 is the minimum size (full pie drawn, without any hole inside). | |
173 | \li 1.0 is the maximum size that can fit the chart. (donut has no width) |
|
170 | \li 1.0 is the maximum size that can fit the chart. (donut has no width) | |
174 | \endlist |
|
171 | \endlist | |
175 |
|
172 | |||
176 | The value is never greater then size property. |
|
173 | The value is never greater then size property. | |
177 | Default value is 0.0. |
|
174 | Default value is 0.0. | |
178 | */ |
|
175 | */ | |
179 |
|
176 | |||
180 | /*! |
|
177 | /*! | |
181 | \qmlproperty real PieSeries::holeSize |
|
178 | \qmlproperty real PieSeries::holeSize | |
182 |
|
179 | |||
183 | Defines the donut hole size. |
|
180 | Defines the donut hole size. | |
184 |
|
181 | |||
185 | The value is a relative value to the chart rectangle where: |
|
182 | The value is a relative value to the chart rectangle where: | |
186 |
|
183 | |||
187 | \list |
|
184 | \list | |
188 | \li 0.0 is the minimum size (full pie drawn, without any hole inside). |
|
185 | \li 0.0 is the minimum size (full pie drawn, without any hole inside). | |
189 | \li 1.0 is the maximum size that can fit the chart. (donut has no width) |
|
186 | \li 1.0 is the maximum size that can fit the chart. (donut has no width) | |
190 | \endlist |
|
187 | \endlist | |
191 |
|
188 | |||
192 | When setting this property the size property is adjusted if necessary, to ensure that the inner size is not greater than the outer size. |
|
189 | When setting this property the size property is adjusted if necessary, to ensure that the inner size is not greater than the outer size. | |
193 |
|
190 | |||
194 | Default value is 0.0. |
|
191 | Default value is 0.0. | |
195 | */ |
|
192 | */ | |
196 |
|
193 | |||
197 | /*! |
|
194 | /*! | |
198 | \property QPieSeries::startAngle |
|
195 | \property QPieSeries::startAngle | |
199 | \brief Defines the starting angle of the pie. |
|
196 | \brief Defines the starting angle of the pie. | |
200 |
|
197 | |||
201 | Full pie is 360 degrees where 0 degrees is at 12 a'clock. |
|
198 | Full pie is 360 degrees where 0 degrees is at 12 a'clock. | |
202 |
|
199 | |||
203 | Default is value is 0. |
|
200 | Default is value is 0. | |
204 | */ |
|
201 | */ | |
205 |
|
202 | |||
206 | /*! |
|
203 | /*! | |
207 | \qmlproperty real PieSeries::startAngle |
|
204 | \qmlproperty real PieSeries::startAngle | |
208 |
|
205 | |||
209 | Defines the starting angle of the pie. |
|
206 | Defines the starting angle of the pie. | |
210 |
|
207 | |||
211 | Full pie is 360 degrees where 0 degrees is at 12 a'clock. |
|
208 | Full pie is 360 degrees where 0 degrees is at 12 a'clock. | |
212 |
|
209 | |||
213 | Default is value is 0. |
|
210 | Default is value is 0. | |
214 | */ |
|
211 | */ | |
215 |
|
212 | |||
216 | /*! |
|
213 | /*! | |
217 | \property QPieSeries::endAngle |
|
214 | \property QPieSeries::endAngle | |
218 | \brief Defines the ending angle of the pie. |
|
215 | \brief Defines the ending angle of the pie. | |
219 |
|
216 | |||
220 | Full pie is 360 degrees where 0 degrees is at 12 a'clock. |
|
217 | Full pie is 360 degrees where 0 degrees is at 12 a'clock. | |
221 |
|
218 | |||
222 | Default is value is 360. |
|
219 | Default is value is 360. | |
223 | */ |
|
220 | */ | |
224 |
|
221 | |||
225 | /*! |
|
222 | /*! | |
226 | \qmlproperty real PieSeries::endAngle |
|
223 | \qmlproperty real PieSeries::endAngle | |
227 |
|
224 | |||
228 | Defines the ending angle of the pie. |
|
225 | Defines the ending angle of the pie. | |
229 |
|
226 | |||
230 | Full pie is 360 degrees where 0 degrees is at 12 a'clock. |
|
227 | Full pie is 360 degrees where 0 degrees is at 12 a'clock. | |
231 |
|
228 | |||
232 | Default is value is 360. |
|
229 | Default is value is 360. | |
233 | */ |
|
230 | */ | |
234 |
|
231 | |||
235 | /*! |
|
232 | /*! | |
236 | \property QPieSeries::count |
|
233 | \property QPieSeries::count | |
237 |
|
234 | |||
238 | Number of slices in the series. |
|
235 | Number of slices in the series. | |
239 | */ |
|
236 | */ | |
240 |
|
237 | |||
241 | /*! |
|
238 | /*! | |
242 | \qmlproperty int PieSeries::count |
|
239 | \qmlproperty int PieSeries::count | |
243 |
|
240 | |||
244 | Number of slices in the series. |
|
241 | Number of slices in the series. | |
245 | */ |
|
242 | */ | |
246 |
|
243 | |||
247 | /*! |
|
244 | /*! | |
248 | \fn void QPieSeries::countChanged() |
|
245 | \fn void QPieSeries::countChanged() | |
249 | Emitted when the slice count has changed. |
|
246 | Emitted when the slice count has changed. | |
250 | \sa count |
|
247 | \sa count | |
251 | */ |
|
248 | */ | |
252 | /*! |
|
249 | /*! | |
253 | \qmlsignal PieSeries::onCountChanged() |
|
250 | \qmlsignal PieSeries::onCountChanged() | |
254 | Emitted when the slice count has changed. |
|
251 | Emitted when the slice count has changed. | |
255 | */ |
|
252 | */ | |
256 |
|
253 | |||
257 | /*! |
|
254 | /*! | |
258 | \property QPieSeries::sum |
|
255 | \property QPieSeries::sum | |
259 |
|
256 | |||
260 | Sum of all slices. |
|
257 | Sum of all slices. | |
261 |
|
258 | |||
262 | The series keeps track of the sum of all slices it holds. |
|
259 | The series keeps track of the sum of all slices it holds. | |
263 | */ |
|
260 | */ | |
264 |
|
261 | |||
265 | /*! |
|
262 | /*! | |
266 | \qmlproperty real PieSeries::sum |
|
263 | \qmlproperty real PieSeries::sum | |
267 |
|
264 | |||
268 | Sum of all slices. |
|
265 | Sum of all slices. | |
269 |
|
266 | |||
270 | The series keeps track of the sum of all slices it holds. |
|
267 | The series keeps track of the sum of all slices it holds. | |
271 | */ |
|
268 | */ | |
272 |
|
269 | |||
273 | /*! |
|
270 | /*! | |
274 | \fn void QPieSeries::sumChanged() |
|
271 | \fn void QPieSeries::sumChanged() | |
275 | Emitted when the sum of all slices has changed. |
|
272 | Emitted when the sum of all slices has changed. | |
276 | \sa sum |
|
273 | \sa sum | |
277 | */ |
|
274 | */ | |
278 | /*! |
|
275 | /*! | |
279 | \qmlsignal PieSeries::onSumChanged() |
|
276 | \qmlsignal PieSeries::onSumChanged() | |
280 | Emitted when the sum of all slices has changed. This may happen for example if you add or remove slices, or if you |
|
277 | Emitted when the sum of all slices has changed. This may happen for example if you add or remove slices, or if you | |
281 | change value of a slice. |
|
278 | change value of a slice. | |
282 | */ |
|
279 | */ | |
283 |
|
280 | |||
284 | /*! |
|
281 | /*! | |
285 | \fn void QPieSeries::added(QList<QPieSlice*> slices) |
|
282 | \fn void QPieSeries::added(QList<QPieSlice*> slices) | |
286 |
|
283 | |||
287 | This signal is emitted when \a slices have been added to the series. |
|
284 | This signal is emitted when \a slices have been added to the series. | |
288 |
|
285 | |||
289 | \sa append(), insert() |
|
286 | \sa append(), insert() | |
290 | */ |
|
287 | */ | |
291 | /*! |
|
288 | /*! | |
292 | \qmlsignal PieSeries::onAdded(PieSlice slice) |
|
289 | \qmlsignal PieSeries::onAdded(PieSlice slice) | |
293 | Emitted when \a slice has been added to the series. |
|
290 | Emitted when \a slice has been added to the series. | |
294 | */ |
|
291 | */ | |
295 |
|
292 | |||
296 | /*! |
|
293 | /*! | |
297 | \fn void QPieSeries::removed(QList<QPieSlice*> slices) |
|
294 | \fn void QPieSeries::removed(QList<QPieSlice*> slices) | |
298 | This signal is emitted when \a slices have been removed from the series. |
|
295 | This signal is emitted when \a slices have been removed from the series. | |
299 | \sa remove() |
|
296 | \sa remove() | |
300 | */ |
|
297 | */ | |
301 | /*! |
|
298 | /*! | |
302 | \qmlsignal PieSeries::onRemoved(PieSlice slice) |
|
299 | \qmlsignal PieSeries::onRemoved(PieSlice slice) | |
303 | Emitted when \a slice has been removed from the series. |
|
300 | Emitted when \a slice has been removed from the series. | |
304 | */ |
|
301 | */ | |
305 |
|
302 | |||
306 | /*! |
|
303 | /*! | |
307 | \fn void QPieSeries::clicked(QPieSlice *slice) |
|
304 | \fn void QPieSeries::clicked(QPieSlice *slice) | |
308 | This signal is emitted when a \a slice has been clicked. |
|
305 | This signal is emitted when a \a slice has been clicked. | |
309 | \sa QPieSlice::clicked() |
|
306 | \sa QPieSlice::clicked() | |
310 | */ |
|
307 | */ | |
311 | /*! |
|
308 | /*! | |
312 | \qmlsignal PieSeries::onClicked(PieSlice slice) |
|
309 | \qmlsignal PieSeries::onClicked(PieSlice slice) | |
313 | This signal is emitted when a \a slice has been clicked. |
|
310 | This signal is emitted when a \a slice has been clicked. | |
314 | */ |
|
311 | */ | |
315 |
|
312 | |||
316 | /*! |
|
313 | /*! | |
317 | \fn void QPieSeries::pressed(QPieSlice *slice) |
|
314 | \fn void QPieSeries::pressed(QPieSlice *slice) | |
318 | This signal is emitted when a \a slice has been pressed. |
|
315 | This signal is emitted when a \a slice has been pressed. | |
319 | \sa QPieSlice::pressed() |
|
316 | \sa QPieSlice::pressed() | |
320 | */ |
|
317 | */ | |
321 | /*! |
|
318 | /*! | |
322 | \qmlsignal PieSeries::onPressed(PieSlice slice) |
|
319 | \qmlsignal PieSeries::onPressed(PieSlice slice) | |
323 | This signal is emitted when a \a slice has been pressed. |
|
320 | This signal is emitted when a \a slice has been pressed. | |
324 | */ |
|
321 | */ | |
325 |
|
322 | |||
326 | /*! |
|
323 | /*! | |
327 | \fn void QPieSeries::released(QPieSlice *slice) |
|
324 | \fn void QPieSeries::released(QPieSlice *slice) | |
328 | This signal is emitted when a \a slice has been released. |
|
325 | This signal is emitted when a \a slice has been released. | |
329 | \sa QPieSlice::released() |
|
326 | \sa QPieSlice::released() | |
330 | */ |
|
327 | */ | |
331 | /*! |
|
328 | /*! | |
332 | \qmlsignal PieSeries::onReleased(PieSlice slice) |
|
329 | \qmlsignal PieSeries::onReleased(PieSlice slice) | |
333 | This signal is emitted when a \a slice has been released. |
|
330 | This signal is emitted when a \a slice has been released. | |
334 | */ |
|
331 | */ | |
335 |
|
332 | |||
336 | /*! |
|
333 | /*! | |
337 | \fn void QPieSeries::doubleClicked(QPieSlice *slice) |
|
334 | \fn void QPieSeries::doubleClicked(QPieSlice *slice) | |
338 | This signal is emitted when a \a slice has been doubleClicked. |
|
335 | This signal is emitted when a \a slice has been doubleClicked. | |
339 | \sa QPieSlice::doubleClicked() |
|
336 | \sa QPieSlice::doubleClicked() | |
340 | */ |
|
337 | */ | |
341 | /*! |
|
338 | /*! | |
342 | \qmlsignal PieSeries::onDoubleClicked(PieSlice slice) |
|
339 | \qmlsignal PieSeries::onDoubleClicked(PieSlice slice) | |
343 | This signal is emitted when a \a slice has been doubleClicked. |
|
340 | This signal is emitted when a \a slice has been doubleClicked. | |
344 | */ |
|
341 | */ | |
345 |
|
342 | |||
346 | /*! |
|
343 | /*! | |
347 | \fn void QPieSeries::hovered(QPieSlice* slice, bool state) |
|
344 | \fn void QPieSeries::hovered(QPieSlice* slice, bool state) | |
348 | This signal is emitted when user has hovered over or away from the \a slice. |
|
345 | This signal is emitted when user has hovered over or away from the \a slice. | |
349 | \a state is true when user has hovered over the slice and false when hover has moved away from the slice. |
|
346 | \a state is true when user has hovered over the slice and false when hover has moved away from the slice. | |
350 | \sa QPieSlice::hovered() |
|
347 | \sa QPieSlice::hovered() | |
351 | */ |
|
348 | */ | |
352 | /*! |
|
349 | /*! | |
353 | \qmlsignal PieSeries::onHovered(PieSlice slice, bool state) |
|
350 | \qmlsignal PieSeries::onHovered(PieSlice slice, bool state) | |
354 | This signal is emitted when user has hovered over or away from the \a slice. \a state is true when user has hovered |
|
351 | This signal is emitted when user has hovered over or away from the \a slice. \a state is true when user has hovered | |
355 | over the slice and false when hover has moved away from the slice. |
|
352 | over the slice and false when hover has moved away from the slice. | |
356 | */ |
|
353 | */ | |
357 |
|
354 | |||
358 | /*! |
|
355 | /*! | |
359 | \qmlmethod PieSlice PieSeries::at(int index) |
|
356 | \qmlmethod PieSlice PieSeries::at(int index) | |
360 | Returns slice at \a index. Returns null if the index is not valid. |
|
357 | Returns slice at \a index. Returns null if the index is not valid. | |
361 | */ |
|
358 | */ | |
362 |
|
359 | |||
363 | /*! |
|
360 | /*! | |
364 | \qmlmethod PieSlice PieSeries::find(string label) |
|
361 | \qmlmethod PieSlice PieSeries::find(string label) | |
365 | Returns the first slice with \a label. Returns null if the index is not valid. |
|
362 | Returns the first slice with \a label. Returns null if the index is not valid. | |
366 | */ |
|
363 | */ | |
367 |
|
364 | |||
368 | /*! |
|
365 | /*! | |
369 | \qmlmethod PieSlice PieSeries::append(string label, real value) |
|
366 | \qmlmethod PieSlice PieSeries::append(string label, real value) | |
370 | Adds a new slice with \a label and \a value to the pie. |
|
367 | Adds a new slice with \a label and \a value to the pie. | |
371 | */ |
|
368 | */ | |
372 |
|
369 | |||
373 | /*! |
|
370 | /*! | |
374 | \qmlmethod bool PieSeries::remove(PieSlice slice) |
|
371 | \qmlmethod bool PieSeries::remove(PieSlice slice) | |
375 | Removes the \a slice from the pie. Returns true if the removal was successful, false otherwise. |
|
372 | Removes the \a slice from the pie. Returns true if the removal was successful, false otherwise. | |
376 | */ |
|
373 | */ | |
377 |
|
374 | |||
378 | /*! |
|
375 | /*! | |
379 | \qmlmethod PieSeries::clear() |
|
376 | \qmlmethod PieSeries::clear() | |
380 | Removes all slices from the pie. |
|
377 | Removes all slices from the pie. | |
381 | */ |
|
378 | */ | |
382 |
|
379 | |||
383 | /*! |
|
380 | /*! | |
384 | Constructs a series object which is a child of \a parent. |
|
381 | Constructs a series object which is a child of \a parent. | |
385 | */ |
|
382 | */ | |
386 | QPieSeries::QPieSeries(QObject *parent) |
|
383 | QPieSeries::QPieSeries(QObject *parent) | |
387 | : QAbstractSeries(*new QPieSeriesPrivate(this), parent) |
|
384 | : QAbstractSeries(*new QPieSeriesPrivate(this), parent) | |
388 | { |
|
385 | { | |
389 | Q_D(QPieSeries); |
|
386 | Q_D(QPieSeries); | |
390 | QObject::connect(this, SIGNAL(countChanged()), d, SIGNAL(countChanged())); |
|
387 | QObject::connect(this, SIGNAL(countChanged()), d, SIGNAL(countChanged())); | |
391 | } |
|
388 | } | |
392 |
|
389 | |||
393 | /*! |
|
390 | /*! | |
394 | Destroys the series and its slices. |
|
391 | Destroys the series and its slices. | |
395 | */ |
|
392 | */ | |
396 | QPieSeries::~QPieSeries() |
|
393 | QPieSeries::~QPieSeries() | |
397 | { |
|
394 | { | |
398 | // NOTE: d_prt destroyed by QObject |
|
395 | // NOTE: d_prt destroyed by QObject | |
399 | clear(); |
|
396 | clear(); | |
400 | } |
|
397 | } | |
401 |
|
398 | |||
402 | /*! |
|
399 | /*! | |
403 | Returns QAbstractSeries::SeriesTypePie. |
|
400 | Returns QAbstractSeries::SeriesTypePie. | |
404 | */ |
|
401 | */ | |
405 | QAbstractSeries::SeriesType QPieSeries::type() const |
|
402 | QAbstractSeries::SeriesType QPieSeries::type() const | |
406 | { |
|
403 | { | |
407 | return QAbstractSeries::SeriesTypePie; |
|
404 | return QAbstractSeries::SeriesTypePie; | |
408 | } |
|
405 | } | |
409 |
|
406 | |||
410 | /*! |
|
407 | /*! | |
411 | Appends a single \a slice to the series. |
|
408 | Appends a single \a slice to the series. | |
412 | Slice ownership is passed to the series. |
|
409 | Slice ownership is passed to the series. | |
413 |
|
410 | |||
414 | Returns true if append was succesfull. |
|
411 | Returns true if append was succesfull. | |
415 | */ |
|
412 | */ | |
416 | bool QPieSeries::append(QPieSlice *slice) |
|
413 | bool QPieSeries::append(QPieSlice *slice) | |
417 | { |
|
414 | { | |
418 | return append(QList<QPieSlice *>() << slice); |
|
415 | return append(QList<QPieSlice *>() << slice); | |
419 | } |
|
416 | } | |
420 |
|
417 | |||
421 | /*! |
|
418 | /*! | |
422 | Appends an array of \a slices to the series. |
|
419 | Appends an array of \a slices to the series. | |
423 | Slice ownership is passed to the series. |
|
420 | Slice ownership is passed to the series. | |
424 |
|
421 | |||
425 | Returns true if append was successful. |
|
422 | Returns true if append was successful. | |
426 | */ |
|
423 | */ | |
427 | bool QPieSeries::append(QList<QPieSlice *> slices) |
|
424 | bool QPieSeries::append(QList<QPieSlice *> slices) | |
428 | { |
|
425 | { | |
429 | Q_D(QPieSeries); |
|
426 | Q_D(QPieSeries); | |
430 |
|
427 | |||
431 | if (slices.count() == 0) |
|
428 | if (slices.count() == 0) | |
432 | return false; |
|
429 | return false; | |
433 |
|
430 | |||
434 | foreach (QPieSlice *s, slices) { |
|
431 | foreach (QPieSlice *s, slices) { | |
435 | if (!s || d->m_slices.contains(s)) |
|
432 | if (!s || d->m_slices.contains(s)) | |
436 | return false; |
|
433 | return false; | |
437 | if (s->series()) // already added to some series |
|
434 | if (s->series()) // already added to some series | |
438 | return false; |
|
435 | return false; | |
439 | if (!isValidValue(s->value())) |
|
436 | if (!isValidValue(s->value())) | |
440 | return false; |
|
437 | return false; | |
441 | } |
|
438 | } | |
442 |
|
439 | |||
443 | foreach (QPieSlice *s, slices) { |
|
440 | foreach (QPieSlice *s, slices) { | |
444 | s->setParent(this); |
|
441 | s->setParent(this); | |
445 | QPieSlicePrivate::fromSlice(s)->m_series = this; |
|
442 | QPieSlicePrivate::fromSlice(s)->m_series = this; | |
446 | d->m_slices << s; |
|
443 | d->m_slices << s; | |
447 | } |
|
444 | } | |
448 |
|
445 | |||
449 | d->updateDerivativeData(); |
|
446 | d->updateDerivativeData(); | |
450 |
|
447 | |||
451 | foreach(QPieSlice * s, slices) { |
|
448 | foreach(QPieSlice * s, slices) { | |
452 | connect(s, SIGNAL(valueChanged()), d, SLOT(sliceValueChanged())); |
|
449 | connect(s, SIGNAL(valueChanged()), d, SLOT(sliceValueChanged())); | |
453 | connect(s, SIGNAL(clicked()), d, SLOT(sliceClicked())); |
|
450 | connect(s, SIGNAL(clicked()), d, SLOT(sliceClicked())); | |
454 | connect(s, SIGNAL(hovered(bool)), d, SLOT(sliceHovered(bool))); |
|
451 | connect(s, SIGNAL(hovered(bool)), d, SLOT(sliceHovered(bool))); | |
455 | connect(s, SIGNAL(pressed()), d, SLOT(slicePressed())); |
|
452 | connect(s, SIGNAL(pressed()), d, SLOT(slicePressed())); | |
456 | connect(s, SIGNAL(released()), d, SLOT(sliceReleased())); |
|
453 | connect(s, SIGNAL(released()), d, SLOT(sliceReleased())); | |
457 | connect(s, SIGNAL(doubleClicked()), d, SLOT(sliceDoubleClicked())); |
|
454 | connect(s, SIGNAL(doubleClicked()), d, SLOT(sliceDoubleClicked())); | |
458 | } |
|
455 | } | |
459 |
|
456 | |||
460 | emit added(slices); |
|
457 | emit added(slices); | |
461 | emit countChanged(); |
|
458 | emit countChanged(); | |
462 |
|
459 | |||
463 | return true; |
|
460 | return true; | |
464 | } |
|
461 | } | |
465 |
|
462 | |||
466 | /*! |
|
463 | /*! | |
467 | Appends a single \a slice to the series and returns a reference to the series. |
|
464 | Appends a single \a slice to the series and returns a reference to the series. | |
468 | Slice ownership is passed to the series. |
|
465 | Slice ownership is passed to the series. | |
469 | */ |
|
466 | */ | |
470 | QPieSeries &QPieSeries::operator << (QPieSlice *slice) |
|
467 | QPieSeries &QPieSeries::operator << (QPieSlice *slice) | |
471 | { |
|
468 | { | |
472 | append(slice); |
|
469 | append(slice); | |
473 | return *this; |
|
470 | return *this; | |
474 | } |
|
471 | } | |
475 |
|
472 | |||
476 |
|
473 | |||
477 | /*! |
|
474 | /*! | |
478 | Appends a single slice to the series with give \a value and \a label. |
|
475 | Appends a single slice to the series with give \a value and \a label. | |
479 | Slice ownership is passed to the series. |
|
476 | Slice ownership is passed to the series. | |
480 | Returns NULL if value is NaN, Inf or -Inf and no slice is added to the series. |
|
477 | Returns NULL if value is NaN, Inf or -Inf and no slice is added to the series. | |
481 | */ |
|
478 | */ | |
482 | QPieSlice *QPieSeries::append(QString label, qreal value) |
|
479 | QPieSlice *QPieSeries::append(QString label, qreal value) | |
483 | { |
|
480 | { | |
484 | if (isValidValue(value)) { |
|
481 | if (isValidValue(value)) { | |
485 | QPieSlice *slice = new QPieSlice(label, value); |
|
482 | QPieSlice *slice = new QPieSlice(label, value); | |
486 | append(slice); |
|
483 | append(slice); | |
487 | return slice; |
|
484 | return slice; | |
488 | } else { |
|
485 | } else { | |
489 | return 0; |
|
486 | return 0; | |
490 | } |
|
487 | } | |
491 | } |
|
488 | } | |
492 |
|
489 | |||
493 | /*! |
|
490 | /*! | |
494 | Inserts a single \a slice to the series before the slice at \a index position. |
|
491 | Inserts a single \a slice to the series before the slice at \a index position. | |
495 | Slice ownership is passed to the series. |
|
492 | Slice ownership is passed to the series. | |
496 |
|
493 | |||
497 | Returns true if insert was successful. |
|
494 | Returns true if insert was successful. | |
498 | */ |
|
495 | */ | |
499 | bool QPieSeries::insert(int index, QPieSlice *slice) |
|
496 | bool QPieSeries::insert(int index, QPieSlice *slice) | |
500 | { |
|
497 | { | |
501 | Q_D(QPieSeries); |
|
498 | Q_D(QPieSeries); | |
502 |
|
499 | |||
503 | if (index < 0 || index > d->m_slices.count()) |
|
500 | if (index < 0 || index > d->m_slices.count()) | |
504 | return false; |
|
501 | return false; | |
505 |
|
502 | |||
506 | if (!slice || d->m_slices.contains(slice)) |
|
503 | if (!slice || d->m_slices.contains(slice)) | |
507 | return false; |
|
504 | return false; | |
508 |
|
505 | |||
509 | if (slice->series()) // already added to some series |
|
506 | if (slice->series()) // already added to some series | |
510 | return false; |
|
507 | return false; | |
511 |
|
508 | |||
512 | if (!isValidValue(slice->value())) |
|
509 | if (!isValidValue(slice->value())) | |
513 | return false; |
|
510 | return false; | |
514 |
|
511 | |||
515 | slice->setParent(this); |
|
512 | slice->setParent(this); | |
516 | QPieSlicePrivate::fromSlice(slice)->m_series = this; |
|
513 | QPieSlicePrivate::fromSlice(slice)->m_series = this; | |
517 | d->m_slices.insert(index, slice); |
|
514 | d->m_slices.insert(index, slice); | |
518 |
|
515 | |||
519 | d->updateDerivativeData(); |
|
516 | d->updateDerivativeData(); | |
520 |
|
517 | |||
521 | connect(slice, SIGNAL(valueChanged()), d, SLOT(sliceValueChanged())); |
|
518 | connect(slice, SIGNAL(valueChanged()), d, SLOT(sliceValueChanged())); | |
522 | connect(slice, SIGNAL(clicked()), d, SLOT(sliceClicked())); |
|
519 | connect(slice, SIGNAL(clicked()), d, SLOT(sliceClicked())); | |
523 | connect(slice, SIGNAL(hovered(bool)), d, SLOT(sliceHovered(bool))); |
|
520 | connect(slice, SIGNAL(hovered(bool)), d, SLOT(sliceHovered(bool))); | |
524 | connect(slice, SIGNAL(pressed()), d, SLOT(slicePressed())); |
|
521 | connect(slice, SIGNAL(pressed()), d, SLOT(slicePressed())); | |
525 | connect(slice, SIGNAL(released()), d, SLOT(sliceReleased())); |
|
522 | connect(slice, SIGNAL(released()), d, SLOT(sliceReleased())); | |
526 | connect(slice, SIGNAL(doubleClicked()), d, SLOT(sliceDoubleClicked())); |
|
523 | connect(slice, SIGNAL(doubleClicked()), d, SLOT(sliceDoubleClicked())); | |
527 |
|
524 | |||
528 | emit added(QList<QPieSlice *>() << slice); |
|
525 | emit added(QList<QPieSlice *>() << slice); | |
529 | emit countChanged(); |
|
526 | emit countChanged(); | |
530 |
|
527 | |||
531 | return true; |
|
528 | return true; | |
532 | } |
|
529 | } | |
533 |
|
530 | |||
534 | /*! |
|
531 | /*! | |
535 | Removes a single \a slice from the series and deletes the slice. |
|
532 | Removes a single \a slice from the series and deletes the slice. | |
536 |
|
533 | |||
537 | Do not reference the pointer after this call. |
|
534 | Do not reference the pointer after this call. | |
538 |
|
535 | |||
539 | Returns true if remove was successful. |
|
536 | Returns true if remove was successful. | |
540 | */ |
|
537 | */ | |
541 | bool QPieSeries::remove(QPieSlice *slice) |
|
538 | bool QPieSeries::remove(QPieSlice *slice) | |
542 | { |
|
539 | { | |
543 | Q_D(QPieSeries); |
|
540 | Q_D(QPieSeries); | |
544 |
|
541 | |||
545 | if (!d->m_slices.removeOne(slice)) |
|
542 | if (!d->m_slices.removeOne(slice)) | |
546 | return false; |
|
543 | return false; | |
547 |
|
544 | |||
548 | d->updateDerivativeData(); |
|
545 | d->updateDerivativeData(); | |
549 |
|
546 | |||
550 | emit removed(QList<QPieSlice *>() << slice); |
|
547 | emit removed(QList<QPieSlice *>() << slice); | |
551 | emit countChanged(); |
|
548 | emit countChanged(); | |
552 |
|
549 | |||
553 | delete slice; |
|
550 | delete slice; | |
554 | slice = 0; |
|
551 | slice = 0; | |
555 |
|
552 | |||
556 | return true; |
|
553 | return true; | |
557 | } |
|
554 | } | |
558 |
|
555 | |||
559 | /*! |
|
556 | /*! | |
560 | Takes a single \a slice from the series. Does not destroy the slice object. |
|
557 | Takes a single \a slice from the series. Does not destroy the slice object. | |
561 |
|
558 | |||
562 | \note The series remains as the slice's parent object. You must set the |
|
559 | \note The series remains as the slice's parent object. You must set the | |
563 | parent object to take full ownership. |
|
560 | parent object to take full ownership. | |
564 |
|
561 | |||
565 | Returns true if take was successful. |
|
562 | Returns true if take was successful. | |
566 | */ |
|
563 | */ | |
567 | bool QPieSeries::take(QPieSlice *slice) |
|
564 | bool QPieSeries::take(QPieSlice *slice) | |
568 | { |
|
565 | { | |
569 | Q_D(QPieSeries); |
|
566 | Q_D(QPieSeries); | |
570 |
|
567 | |||
571 | if (!d->m_slices.removeOne(slice)) |
|
568 | if (!d->m_slices.removeOne(slice)) | |
572 | return false; |
|
569 | return false; | |
573 |
|
570 | |||
574 | QPieSlicePrivate::fromSlice(slice)->m_series = 0; |
|
571 | QPieSlicePrivate::fromSlice(slice)->m_series = 0; | |
575 | slice->disconnect(d); |
|
572 | slice->disconnect(d); | |
576 |
|
573 | |||
577 | d->updateDerivativeData(); |
|
574 | d->updateDerivativeData(); | |
578 |
|
575 | |||
579 | emit removed(QList<QPieSlice *>() << slice); |
|
576 | emit removed(QList<QPieSlice *>() << slice); | |
580 | emit countChanged(); |
|
577 | emit countChanged(); | |
581 |
|
578 | |||
582 | return true; |
|
579 | return true; | |
583 | } |
|
580 | } | |
584 |
|
581 | |||
585 | /*! |
|
582 | /*! | |
586 | Clears all slices from the series. |
|
583 | Clears all slices from the series. | |
587 | */ |
|
584 | */ | |
588 | void QPieSeries::clear() |
|
585 | void QPieSeries::clear() | |
589 | { |
|
586 | { | |
590 | Q_D(QPieSeries); |
|
587 | Q_D(QPieSeries); | |
591 | if (d->m_slices.count() == 0) |
|
588 | if (d->m_slices.count() == 0) | |
592 | return; |
|
589 | return; | |
593 |
|
590 | |||
594 | QList<QPieSlice *> slices = d->m_slices; |
|
591 | QList<QPieSlice *> slices = d->m_slices; | |
595 | foreach (QPieSlice *s, d->m_slices) |
|
592 | foreach (QPieSlice *s, d->m_slices) | |
596 | d->m_slices.removeOne(s); |
|
593 | d->m_slices.removeOne(s); | |
597 |
|
594 | |||
598 | d->updateDerivativeData(); |
|
595 | d->updateDerivativeData(); | |
599 |
|
596 | |||
600 | emit removed(slices); |
|
597 | emit removed(slices); | |
601 | emit countChanged(); |
|
598 | emit countChanged(); | |
602 |
|
599 | |||
603 | foreach (QPieSlice *s, slices) |
|
600 | foreach (QPieSlice *s, slices) | |
604 | delete s; |
|
601 | delete s; | |
605 | } |
|
602 | } | |
606 |
|
603 | |||
607 | /*! |
|
604 | /*! | |
608 | Returns a list of slices that belong to this series. |
|
605 | Returns a list of slices that belong to this series. | |
609 | */ |
|
606 | */ | |
610 | QList<QPieSlice *> QPieSeries::slices() const |
|
607 | QList<QPieSlice *> QPieSeries::slices() const | |
611 | { |
|
608 | { | |
612 | Q_D(const QPieSeries); |
|
609 | Q_D(const QPieSeries); | |
613 | return d->m_slices; |
|
610 | return d->m_slices; | |
614 | } |
|
611 | } | |
615 |
|
612 | |||
616 | /*! |
|
613 | /*! | |
617 | returns the number of the slices in this series. |
|
614 | returns the number of the slices in this series. | |
618 | */ |
|
615 | */ | |
619 | int QPieSeries::count() const |
|
616 | int QPieSeries::count() const | |
620 | { |
|
617 | { | |
621 | Q_D(const QPieSeries); |
|
618 | Q_D(const QPieSeries); | |
622 | return d->m_slices.count(); |
|
619 | return d->m_slices.count(); | |
623 | } |
|
620 | } | |
624 |
|
621 | |||
625 | /*! |
|
622 | /*! | |
626 | Returns true is the series is empty. |
|
623 | Returns true is the series is empty. | |
627 | */ |
|
624 | */ | |
628 | bool QPieSeries::isEmpty() const |
|
625 | bool QPieSeries::isEmpty() const | |
629 | { |
|
626 | { | |
630 | Q_D(const QPieSeries); |
|
627 | Q_D(const QPieSeries); | |
631 | return d->m_slices.isEmpty(); |
|
628 | return d->m_slices.isEmpty(); | |
632 | } |
|
629 | } | |
633 |
|
630 | |||
634 | /*! |
|
631 | /*! | |
635 | Returns the sum of all slice values in this series. |
|
632 | Returns the sum of all slice values in this series. | |
636 |
|
633 | |||
637 | \sa QPieSlice::value(), QPieSlice::setValue(), QPieSlice::percentage() |
|
634 | \sa QPieSlice::value(), QPieSlice::setValue(), QPieSlice::percentage() | |
638 | */ |
|
635 | */ | |
639 | qreal QPieSeries::sum() const |
|
636 | qreal QPieSeries::sum() const | |
640 | { |
|
637 | { | |
641 | Q_D(const QPieSeries); |
|
638 | Q_D(const QPieSeries); | |
642 | return d->m_sum; |
|
639 | return d->m_sum; | |
643 | } |
|
640 | } | |
644 |
|
641 | |||
645 | void QPieSeries::setHoleSize(qreal holeSize) |
|
642 | void QPieSeries::setHoleSize(qreal holeSize) | |
646 | { |
|
643 | { | |
647 | Q_D(QPieSeries); |
|
644 | Q_D(QPieSeries); | |
648 | holeSize = qBound((qreal)0.0, holeSize, (qreal)1.0); |
|
645 | holeSize = qBound((qreal)0.0, holeSize, (qreal)1.0); | |
649 | d->setSizes(holeSize, qMax(d->m_pieRelativeSize, holeSize)); |
|
646 | d->setSizes(holeSize, qMax(d->m_pieRelativeSize, holeSize)); | |
650 | } |
|
647 | } | |
651 |
|
648 | |||
652 | qreal QPieSeries::holeSize() const |
|
649 | qreal QPieSeries::holeSize() const | |
653 | { |
|
650 | { | |
654 | Q_D(const QPieSeries); |
|
651 | Q_D(const QPieSeries); | |
655 | return d->m_holeRelativeSize; |
|
652 | return d->m_holeRelativeSize; | |
656 | } |
|
653 | } | |
657 |
|
654 | |||
658 | void QPieSeries::setHorizontalPosition(qreal relativePosition) |
|
655 | void QPieSeries::setHorizontalPosition(qreal relativePosition) | |
659 | { |
|
656 | { | |
660 | Q_D(QPieSeries); |
|
657 | Q_D(QPieSeries); | |
661 |
|
658 | |||
662 | if (relativePosition < 0.0) |
|
659 | if (relativePosition < 0.0) | |
663 | relativePosition = 0.0; |
|
660 | relativePosition = 0.0; | |
664 | if (relativePosition > 1.0) |
|
661 | if (relativePosition > 1.0) | |
665 | relativePosition = 1.0; |
|
662 | relativePosition = 1.0; | |
666 |
|
663 | |||
667 | if (!qFuzzyCompare(d->m_pieRelativeHorPos, relativePosition)) { |
|
664 | if (!qFuzzyCompare(d->m_pieRelativeHorPos, relativePosition)) { | |
668 | d->m_pieRelativeHorPos = relativePosition; |
|
665 | d->m_pieRelativeHorPos = relativePosition; | |
669 | emit d->horizontalPositionChanged(); |
|
666 | emit d->horizontalPositionChanged(); | |
670 | } |
|
667 | } | |
671 | } |
|
668 | } | |
672 |
|
669 | |||
673 | qreal QPieSeries::horizontalPosition() const |
|
670 | qreal QPieSeries::horizontalPosition() const | |
674 | { |
|
671 | { | |
675 | Q_D(const QPieSeries); |
|
672 | Q_D(const QPieSeries); | |
676 | return d->m_pieRelativeHorPos; |
|
673 | return d->m_pieRelativeHorPos; | |
677 | } |
|
674 | } | |
678 |
|
675 | |||
679 | void QPieSeries::setVerticalPosition(qreal relativePosition) |
|
676 | void QPieSeries::setVerticalPosition(qreal relativePosition) | |
680 | { |
|
677 | { | |
681 | Q_D(QPieSeries); |
|
678 | Q_D(QPieSeries); | |
682 |
|
679 | |||
683 | if (relativePosition < 0.0) |
|
680 | if (relativePosition < 0.0) | |
684 | relativePosition = 0.0; |
|
681 | relativePosition = 0.0; | |
685 | if (relativePosition > 1.0) |
|
682 | if (relativePosition > 1.0) | |
686 | relativePosition = 1.0; |
|
683 | relativePosition = 1.0; | |
687 |
|
684 | |||
688 | if (!qFuzzyCompare(d->m_pieRelativeVerPos, relativePosition)) { |
|
685 | if (!qFuzzyCompare(d->m_pieRelativeVerPos, relativePosition)) { | |
689 | d->m_pieRelativeVerPos = relativePosition; |
|
686 | d->m_pieRelativeVerPos = relativePosition; | |
690 | emit d->verticalPositionChanged(); |
|
687 | emit d->verticalPositionChanged(); | |
691 | } |
|
688 | } | |
692 | } |
|
689 | } | |
693 |
|
690 | |||
694 | qreal QPieSeries::verticalPosition() const |
|
691 | qreal QPieSeries::verticalPosition() const | |
695 | { |
|
692 | { | |
696 | Q_D(const QPieSeries); |
|
693 | Q_D(const QPieSeries); | |
697 | return d->m_pieRelativeVerPos; |
|
694 | return d->m_pieRelativeVerPos; | |
698 | } |
|
695 | } | |
699 |
|
696 | |||
700 | void QPieSeries::setPieSize(qreal relativeSize) |
|
697 | void QPieSeries::setPieSize(qreal relativeSize) | |
701 | { |
|
698 | { | |
702 | Q_D(QPieSeries); |
|
699 | Q_D(QPieSeries); | |
703 | relativeSize = qBound((qreal)0.0, relativeSize, (qreal)1.0); |
|
700 | relativeSize = qBound((qreal)0.0, relativeSize, (qreal)1.0); | |
704 | d->setSizes(qMin(d->m_holeRelativeSize, relativeSize), relativeSize); |
|
701 | d->setSizes(qMin(d->m_holeRelativeSize, relativeSize), relativeSize); | |
705 |
|
702 | |||
706 | } |
|
703 | } | |
707 |
|
704 | |||
708 | qreal QPieSeries::pieSize() const |
|
705 | qreal QPieSeries::pieSize() const | |
709 | { |
|
706 | { | |
710 | Q_D(const QPieSeries); |
|
707 | Q_D(const QPieSeries); | |
711 | return d->m_pieRelativeSize; |
|
708 | return d->m_pieRelativeSize; | |
712 | } |
|
709 | } | |
713 |
|
710 | |||
714 |
|
711 | |||
715 | void QPieSeries::setPieStartAngle(qreal angle) |
|
712 | void QPieSeries::setPieStartAngle(qreal angle) | |
716 | { |
|
713 | { | |
717 | Q_D(QPieSeries); |
|
714 | Q_D(QPieSeries); | |
718 | if (qFuzzyCompare(d->m_pieStartAngle, angle)) |
|
715 | if (qFuzzyCompare(d->m_pieStartAngle, angle)) | |
719 | return; |
|
716 | return; | |
720 | d->m_pieStartAngle = angle; |
|
717 | d->m_pieStartAngle = angle; | |
721 | d->updateDerivativeData(); |
|
718 | d->updateDerivativeData(); | |
722 | emit d->pieStartAngleChanged(); |
|
719 | emit d->pieStartAngleChanged(); | |
723 | } |
|
720 | } | |
724 |
|
721 | |||
725 | qreal QPieSeries::pieStartAngle() const |
|
722 | qreal QPieSeries::pieStartAngle() const | |
726 | { |
|
723 | { | |
727 | Q_D(const QPieSeries); |
|
724 | Q_D(const QPieSeries); | |
728 | return d->m_pieStartAngle; |
|
725 | return d->m_pieStartAngle; | |
729 | } |
|
726 | } | |
730 |
|
727 | |||
731 | /*! |
|
728 | /*! | |
732 | Sets the end angle of the pie. |
|
729 | Sets the end angle of the pie. | |
733 |
|
730 | |||
734 | Full pie is 360 degrees where 0 degrees is at 12 a'clock. |
|
731 | Full pie is 360 degrees where 0 degrees is at 12 a'clock. | |
735 |
|
732 | |||
736 | \a angle must be greater than start angle. |
|
733 | \a angle must be greater than start angle. | |
737 |
|
734 | |||
738 | \sa pieEndAngle(), pieStartAngle(), setPieStartAngle() |
|
735 | \sa pieEndAngle(), pieStartAngle(), setPieStartAngle() | |
739 | */ |
|
736 | */ | |
740 | void QPieSeries::setPieEndAngle(qreal angle) |
|
737 | void QPieSeries::setPieEndAngle(qreal angle) | |
741 | { |
|
738 | { | |
742 | Q_D(QPieSeries); |
|
739 | Q_D(QPieSeries); | |
743 | if (qFuzzyCompare(d->m_pieEndAngle, angle)) |
|
740 | if (qFuzzyCompare(d->m_pieEndAngle, angle)) | |
744 | return; |
|
741 | return; | |
745 | d->m_pieEndAngle = angle; |
|
742 | d->m_pieEndAngle = angle; | |
746 | d->updateDerivativeData(); |
|
743 | d->updateDerivativeData(); | |
747 | emit d->pieEndAngleChanged(); |
|
744 | emit d->pieEndAngleChanged(); | |
748 | } |
|
745 | } | |
749 |
|
746 | |||
750 | /*! |
|
747 | /*! | |
751 | Returns the end angle of the pie. |
|
748 | Returns the end angle of the pie. | |
752 |
|
749 | |||
753 | Full pie is 360 degrees where 0 degrees is at 12 a'clock. |
|
750 | Full pie is 360 degrees where 0 degrees is at 12 a'clock. | |
754 |
|
751 | |||
755 | \sa setPieEndAngle(), pieStartAngle(), setPieStartAngle() |
|
752 | \sa setPieEndAngle(), pieStartAngle(), setPieStartAngle() | |
756 | */ |
|
753 | */ | |
757 | qreal QPieSeries::pieEndAngle() const |
|
754 | qreal QPieSeries::pieEndAngle() const | |
758 | { |
|
755 | { | |
759 | Q_D(const QPieSeries); |
|
756 | Q_D(const QPieSeries); | |
760 | return d->m_pieEndAngle; |
|
757 | return d->m_pieEndAngle; | |
761 | } |
|
758 | } | |
762 |
|
759 | |||
763 | /*! |
|
760 | /*! | |
764 | Sets the all the slice labels \a visible or invisible. |
|
761 | Sets the all the slice labels \a visible or invisible. | |
765 |
|
762 | |||
766 | Note that this affects only the current slices in the series. |
|
763 | Note that this affects only the current slices in the series. | |
767 | If user adds a new slice the default label visibility is false. |
|
764 | If user adds a new slice the default label visibility is false. | |
768 |
|
765 | |||
769 | \sa QPieSlice::isLabelVisible(), QPieSlice::setLabelVisible() |
|
766 | \sa QPieSlice::isLabelVisible(), QPieSlice::setLabelVisible() | |
770 | */ |
|
767 | */ | |
771 | void QPieSeries::setLabelsVisible(bool visible) |
|
768 | void QPieSeries::setLabelsVisible(bool visible) | |
772 | { |
|
769 | { | |
773 | Q_D(QPieSeries); |
|
770 | Q_D(QPieSeries); | |
774 | foreach (QPieSlice *s, d->m_slices) |
|
771 | foreach (QPieSlice *s, d->m_slices) | |
775 | s->setLabelVisible(visible); |
|
772 | s->setLabelVisible(visible); | |
776 | } |
|
773 | } | |
777 |
|
774 | |||
778 | /*! |
|
775 | /*! | |
779 | Sets the all the slice labels \a position |
|
776 | Sets the all the slice labels \a position | |
780 |
|
777 | |||
781 | Note that this affects only the current slices in the series. |
|
778 | Note that this affects only the current slices in the series. | |
782 | If user adds a new slice the default label position is LabelOutside |
|
779 | If user adds a new slice the default label position is LabelOutside | |
783 |
|
780 | |||
784 | \sa QPieSlice::labelPosition(), QPieSlice::setLabelPosition() |
|
781 | \sa QPieSlice::labelPosition(), QPieSlice::setLabelPosition() | |
785 | */ |
|
782 | */ | |
786 | void QPieSeries::setLabelsPosition(QPieSlice::LabelPosition position) |
|
783 | void QPieSeries::setLabelsPosition(QPieSlice::LabelPosition position) | |
787 | { |
|
784 | { | |
788 | Q_D(QPieSeries); |
|
785 | Q_D(QPieSeries); | |
789 | foreach (QPieSlice *s, d->m_slices) |
|
786 | foreach (QPieSlice *s, d->m_slices) | |
790 | s->setLabelPosition(position); |
|
787 | s->setLabelPosition(position); | |
791 | } |
|
788 | } | |
792 |
|
789 | |||
793 | /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
|
790 | /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |
794 |
|
791 | |||
795 |
|
792 | |||
796 | QPieSeriesPrivate::QPieSeriesPrivate(QPieSeries *parent) : |
|
793 | QPieSeriesPrivate::QPieSeriesPrivate(QPieSeries *parent) : | |
797 | QAbstractSeriesPrivate(parent), |
|
794 | QAbstractSeriesPrivate(parent), | |
798 | m_pieRelativeHorPos(0.5), |
|
795 | m_pieRelativeHorPos(0.5), | |
799 | m_pieRelativeVerPos(0.5), |
|
796 | m_pieRelativeVerPos(0.5), | |
800 | m_pieRelativeSize(0.7), |
|
797 | m_pieRelativeSize(0.7), | |
801 | m_pieStartAngle(0), |
|
798 | m_pieStartAngle(0), | |
802 | m_pieEndAngle(360), |
|
799 | m_pieEndAngle(360), | |
803 | m_sum(0), |
|
800 | m_sum(0), | |
804 | m_holeRelativeSize(0.0) |
|
801 | m_holeRelativeSize(0.0) | |
805 | { |
|
802 | { | |
806 | } |
|
803 | } | |
807 |
|
804 | |||
808 | QPieSeriesPrivate::~QPieSeriesPrivate() |
|
805 | QPieSeriesPrivate::~QPieSeriesPrivate() | |
809 | { |
|
806 | { | |
810 | } |
|
807 | } | |
811 |
|
808 | |||
812 | void QPieSeriesPrivate::updateDerivativeData() |
|
809 | void QPieSeriesPrivate::updateDerivativeData() | |
813 | { |
|
810 | { | |
814 | // calculate sum of all slices |
|
811 | // calculate sum of all slices | |
815 | qreal sum = 0; |
|
812 | qreal sum = 0; | |
816 | foreach (QPieSlice *s, m_slices) |
|
813 | foreach (QPieSlice *s, m_slices) | |
817 | sum += s->value(); |
|
814 | sum += s->value(); | |
818 |
|
815 | |||
819 | if (!qFuzzyCompare(m_sum, sum)) { |
|
816 | if (!qFuzzyCompare(m_sum, sum)) { | |
820 | m_sum = sum; |
|
817 | m_sum = sum; | |
821 | emit q_func()->sumChanged(); |
|
818 | emit q_func()->sumChanged(); | |
822 | } |
|
819 | } | |
823 |
|
820 | |||
824 | // nothing to show.. |
|
821 | // nothing to show.. | |
825 | if (qFuzzyCompare(m_sum, 0)) |
|
822 | if (qFuzzyCompare(m_sum, 0)) | |
826 | return; |
|
823 | return; | |
827 |
|
824 | |||
828 | // update slice attributes |
|
825 | // update slice attributes | |
829 | qreal sliceAngle = m_pieStartAngle; |
|
826 | qreal sliceAngle = m_pieStartAngle; | |
830 | qreal pieSpan = m_pieEndAngle - m_pieStartAngle; |
|
827 | qreal pieSpan = m_pieEndAngle - m_pieStartAngle; | |
831 | QVector<QPieSlice *> changed; |
|
828 | QVector<QPieSlice *> changed; | |
832 | foreach (QPieSlice *s, m_slices) { |
|
829 | foreach (QPieSlice *s, m_slices) { | |
833 | QPieSlicePrivate *d = QPieSlicePrivate::fromSlice(s); |
|
830 | QPieSlicePrivate *d = QPieSlicePrivate::fromSlice(s); | |
834 | d->setPercentage(s->value() / m_sum); |
|
831 | d->setPercentage(s->value() / m_sum); | |
835 | d->setStartAngle(sliceAngle); |
|
832 | d->setStartAngle(sliceAngle); | |
836 | d->setAngleSpan(pieSpan * s->percentage()); |
|
833 | d->setAngleSpan(pieSpan * s->percentage()); | |
837 | sliceAngle += s->angleSpan(); |
|
834 | sliceAngle += s->angleSpan(); | |
838 | } |
|
835 | } | |
839 |
|
836 | |||
840 |
|
837 | |||
841 | emit calculatedDataChanged(); |
|
838 | emit calculatedDataChanged(); | |
842 | } |
|
839 | } | |
843 |
|
840 | |||
844 | void QPieSeriesPrivate::setSizes(qreal innerSize, qreal outerSize) |
|
841 | void QPieSeriesPrivate::setSizes(qreal innerSize, qreal outerSize) | |
845 | { |
|
842 | { | |
846 | bool changed = false; |
|
843 | bool changed = false; | |
847 |
|
844 | |||
848 | if (!qFuzzyCompare(m_holeRelativeSize, innerSize)) { |
|
845 | if (!qFuzzyCompare(m_holeRelativeSize, innerSize)) { | |
849 | m_holeRelativeSize = innerSize; |
|
846 | m_holeRelativeSize = innerSize; | |
850 | changed = true; |
|
847 | changed = true; | |
851 | } |
|
848 | } | |
852 |
|
849 | |||
853 | if (!qFuzzyCompare(m_pieRelativeSize, outerSize)) { |
|
850 | if (!qFuzzyCompare(m_pieRelativeSize, outerSize)) { | |
854 | m_pieRelativeSize = outerSize; |
|
851 | m_pieRelativeSize = outerSize; | |
855 | changed = true; |
|
852 | changed = true; | |
856 | } |
|
853 | } | |
857 |
|
854 | |||
858 | if (changed) |
|
855 | if (changed) | |
859 | emit pieSizeChanged(); |
|
856 | emit pieSizeChanged(); | |
860 | } |
|
857 | } | |
861 |
|
858 | |||
862 | QPieSeriesPrivate *QPieSeriesPrivate::fromSeries(QPieSeries *series) |
|
859 | QPieSeriesPrivate *QPieSeriesPrivate::fromSeries(QPieSeries *series) | |
863 | { |
|
860 | { | |
864 | return series->d_func(); |
|
861 | return series->d_func(); | |
865 | } |
|
862 | } | |
866 |
|
863 | |||
867 | void QPieSeriesPrivate::sliceValueChanged() |
|
864 | void QPieSeriesPrivate::sliceValueChanged() | |
868 | { |
|
865 | { | |
869 | Q_ASSERT(m_slices.contains(qobject_cast<QPieSlice *>(sender()))); |
|
866 | Q_ASSERT(m_slices.contains(qobject_cast<QPieSlice *>(sender()))); | |
870 | updateDerivativeData(); |
|
867 | updateDerivativeData(); | |
871 | } |
|
868 | } | |
872 |
|
869 | |||
873 | void QPieSeriesPrivate::sliceClicked() |
|
870 | void QPieSeriesPrivate::sliceClicked() | |
874 | { |
|
871 | { | |
875 | QPieSlice *slice = qobject_cast<QPieSlice *>(sender()); |
|
872 | QPieSlice *slice = qobject_cast<QPieSlice *>(sender()); | |
876 | Q_ASSERT(m_slices.contains(slice)); |
|
873 | Q_ASSERT(m_slices.contains(slice)); | |
877 | Q_Q(QPieSeries); |
|
874 | Q_Q(QPieSeries); | |
878 | emit q->clicked(slice); |
|
875 | emit q->clicked(slice); | |
879 | } |
|
876 | } | |
880 |
|
877 | |||
881 | void QPieSeriesPrivate::sliceHovered(bool state) |
|
878 | void QPieSeriesPrivate::sliceHovered(bool state) | |
882 | { |
|
879 | { | |
883 | QPieSlice *slice = qobject_cast<QPieSlice *>(sender()); |
|
880 | QPieSlice *slice = qobject_cast<QPieSlice *>(sender()); | |
884 | if (!m_slices.isEmpty()) { |
|
881 | if (!m_slices.isEmpty()) { | |
885 | Q_ASSERT(m_slices.contains(slice)); |
|
882 | Q_ASSERT(m_slices.contains(slice)); | |
886 | Q_Q(QPieSeries); |
|
883 | Q_Q(QPieSeries); | |
887 | emit q->hovered(slice, state); |
|
884 | emit q->hovered(slice, state); | |
888 | } |
|
885 | } | |
889 | } |
|
886 | } | |
890 |
|
887 | |||
891 | void QPieSeriesPrivate::slicePressed() |
|
888 | void QPieSeriesPrivate::slicePressed() | |
892 | { |
|
889 | { | |
893 | QPieSlice *slice = qobject_cast<QPieSlice *>(sender()); |
|
890 | QPieSlice *slice = qobject_cast<QPieSlice *>(sender()); | |
894 | Q_ASSERT(m_slices.contains(slice)); |
|
891 | Q_ASSERT(m_slices.contains(slice)); | |
895 | Q_Q(QPieSeries); |
|
892 | Q_Q(QPieSeries); | |
896 | emit q->pressed(slice); |
|
893 | emit q->pressed(slice); | |
897 | } |
|
894 | } | |
898 |
|
895 | |||
899 | void QPieSeriesPrivate::sliceReleased() |
|
896 | void QPieSeriesPrivate::sliceReleased() | |
900 | { |
|
897 | { | |
901 | QPieSlice *slice = qobject_cast<QPieSlice *>(sender()); |
|
898 | QPieSlice *slice = qobject_cast<QPieSlice *>(sender()); | |
902 | Q_ASSERT(m_slices.contains(slice)); |
|
899 | Q_ASSERT(m_slices.contains(slice)); | |
903 | Q_Q(QPieSeries); |
|
900 | Q_Q(QPieSeries); | |
904 | emit q->released(slice); |
|
901 | emit q->released(slice); | |
905 | } |
|
902 | } | |
906 |
|
903 | |||
907 | void QPieSeriesPrivate::sliceDoubleClicked() |
|
904 | void QPieSeriesPrivate::sliceDoubleClicked() | |
908 | { |
|
905 | { | |
909 | QPieSlice *slice = qobject_cast<QPieSlice *>(sender()); |
|
906 | QPieSlice *slice = qobject_cast<QPieSlice *>(sender()); | |
910 | Q_ASSERT(m_slices.contains(slice)); |
|
907 | Q_ASSERT(m_slices.contains(slice)); | |
911 | Q_Q(QPieSeries); |
|
908 | Q_Q(QPieSeries); | |
912 | emit q->doubleClicked(slice); |
|
909 | emit q->doubleClicked(slice); | |
913 | } |
|
910 | } | |
914 |
|
911 | |||
915 | void QPieSeriesPrivate::initializeDomain() |
|
912 | void QPieSeriesPrivate::initializeDomain() | |
916 | { |
|
913 | { | |
917 | // does not apply to pie |
|
914 | // does not apply to pie | |
918 | } |
|
915 | } | |
919 |
|
916 | |||
920 | void QPieSeriesPrivate::initializeGraphics(QGraphicsItem* parent) |
|
917 | void QPieSeriesPrivate::initializeGraphics(QGraphicsItem* parent) | |
921 | { |
|
918 | { | |
922 | Q_Q(QPieSeries); |
|
919 | Q_Q(QPieSeries); | |
923 | PieChartItem *pie = new PieChartItem(q,parent); |
|
920 | PieChartItem *pie = new PieChartItem(q,parent); | |
924 | m_item.reset(pie); |
|
921 | m_item.reset(pie); | |
925 | QAbstractSeriesPrivate::initializeGraphics(parent); |
|
922 | QAbstractSeriesPrivate::initializeGraphics(parent); | |
926 | } |
|
923 | } | |
927 |
|
924 | |||
928 | void QPieSeriesPrivate::initializeAnimations(QtCharts::QChart::AnimationOptions options) |
|
925 | void QPieSeriesPrivate::initializeAnimations(QtCharts::QChart::AnimationOptions options) | |
929 | { |
|
926 | { | |
930 | PieChartItem *item = static_cast<PieChartItem *>(m_item.data()); |
|
927 | PieChartItem *item = static_cast<PieChartItem *>(m_item.data()); | |
931 | Q_ASSERT(item); |
|
928 | Q_ASSERT(item); | |
932 | if (item->animation()) |
|
929 | if (item->animation()) | |
933 | item->animation()->stopAndDestroyLater(); |
|
930 | item->animation()->stopAndDestroyLater(); | |
934 |
|
931 | |||
935 | if (options.testFlag(QChart::SeriesAnimations)) |
|
932 | if (options.testFlag(QChart::SeriesAnimations)) | |
936 | item->setAnimation(new PieAnimation(item)); |
|
933 | item->setAnimation(new PieAnimation(item)); | |
937 | else |
|
934 | else | |
938 | item->setAnimation(0); |
|
935 | item->setAnimation(0); | |
939 | QAbstractSeriesPrivate::initializeAnimations(options); |
|
936 | QAbstractSeriesPrivate::initializeAnimations(options); | |
940 | } |
|
937 | } | |
941 |
|
938 | |||
942 | QList<QLegendMarker*> QPieSeriesPrivate::createLegendMarkers(QLegend* legend) |
|
939 | QList<QLegendMarker*> QPieSeriesPrivate::createLegendMarkers(QLegend* legend) | |
943 | { |
|
940 | { | |
944 | Q_Q(QPieSeries); |
|
941 | Q_Q(QPieSeries); | |
945 | QList<QLegendMarker*> markers; |
|
942 | QList<QLegendMarker*> markers; | |
946 | foreach(QPieSlice* slice, q->slices()) { |
|
943 | foreach(QPieSlice* slice, q->slices()) { | |
947 | QPieLegendMarker* marker = new QPieLegendMarker(q,slice,legend); |
|
944 | QPieLegendMarker* marker = new QPieLegendMarker(q,slice,legend); | |
948 | markers << marker; |
|
945 | markers << marker; | |
949 | } |
|
946 | } | |
950 | return markers; |
|
947 | return markers; | |
951 | } |
|
948 | } | |
952 |
|
949 | |||
953 | void QPieSeriesPrivate::initializeAxes() |
|
950 | void QPieSeriesPrivate::initializeAxes() | |
954 | { |
|
951 | { | |
955 |
|
952 | |||
956 | } |
|
953 | } | |
957 |
|
954 | |||
958 | QAbstractAxis::AxisType QPieSeriesPrivate::defaultAxisType(Qt::Orientation orientation) const |
|
955 | QAbstractAxis::AxisType QPieSeriesPrivate::defaultAxisType(Qt::Orientation orientation) const | |
959 | { |
|
956 | { | |
960 | Q_UNUSED(orientation); |
|
957 | Q_UNUSED(orientation); | |
961 | return QAbstractAxis::AxisTypeNoAxis; |
|
958 | return QAbstractAxis::AxisTypeNoAxis; | |
962 | } |
|
959 | } | |
963 |
|
960 | |||
964 | QAbstractAxis* QPieSeriesPrivate::createDefaultAxis(Qt::Orientation orientation) const |
|
961 | QAbstractAxis* QPieSeriesPrivate::createDefaultAxis(Qt::Orientation orientation) const | |
965 | { |
|
962 | { | |
966 | Q_UNUSED(orientation); |
|
963 | Q_UNUSED(orientation); | |
967 | return 0; |
|
964 | return 0; | |
968 | } |
|
965 | } | |
969 |
|
966 | |||
970 | void QPieSeriesPrivate::initializeTheme(int index, ChartTheme* theme, bool forced) |
|
967 | void QPieSeriesPrivate::initializeTheme(int index, ChartTheme* theme, bool forced) | |
971 | { |
|
968 | { | |
972 | //Q_Q(QPieSeries); |
|
969 | //Q_Q(QPieSeries); | |
973 | //const QList<QColor>& colors = theme->seriesColors(); |
|
970 | //const QList<QColor>& colors = theme->seriesColors(); | |
974 | const QList<QGradient>& gradients = theme->seriesGradients(); |
|
971 | const QList<QGradient>& gradients = theme->seriesGradients(); | |
975 |
|
972 | |||
976 | for (int i(0); i < m_slices.count(); i++) { |
|
973 | for (int i(0); i < m_slices.count(); i++) { | |
977 |
|
974 | |||
978 | QColor penColor = ChartThemeManager::colorAt(gradients.at(index % gradients.size()), 0.0); |
|
975 | QColor penColor = ChartThemeManager::colorAt(gradients.at(index % gradients.size()), 0.0); | |
979 |
|
976 | |||
980 | // Get color for a slice from a gradient linearly, beginning from the start of the gradient |
|
977 | // Get color for a slice from a gradient linearly, beginning from the start of the gradient | |
981 | qreal pos = (qreal)(i + 1) / (qreal) m_slices.count(); |
|
978 | qreal pos = (qreal)(i + 1) / (qreal) m_slices.count(); | |
982 | QColor brushColor = ChartThemeManager::colorAt(gradients.at(index % gradients.size()), pos); |
|
979 | QColor brushColor = ChartThemeManager::colorAt(gradients.at(index % gradients.size()), pos); | |
983 |
|
980 | |||
984 | QPieSlice *s = m_slices.at(i); |
|
981 | QPieSlice *s = m_slices.at(i); | |
985 | QPieSlicePrivate *d = QPieSlicePrivate::fromSlice(s); |
|
982 | QPieSlicePrivate *d = QPieSlicePrivate::fromSlice(s); | |
986 |
|
983 | |||
987 | if (forced || d->m_data.m_slicePen.isThemed()) |
|
984 | if (forced || d->m_data.m_slicePen.isThemed()) | |
988 | d->setPen(penColor, true); |
|
985 | d->setPen(penColor, true); | |
989 |
|
986 | |||
990 | if (forced || d->m_data.m_sliceBrush.isThemed()) |
|
987 | if (forced || d->m_data.m_sliceBrush.isThemed()) | |
991 | d->setBrush(brushColor, true); |
|
988 | d->setBrush(brushColor, true); | |
992 |
|
989 | |||
993 | if (forced || d->m_data.m_labelBrush.isThemed()) |
|
990 | if (forced || d->m_data.m_labelBrush.isThemed()) | |
994 | d->setLabelBrush(theme->labelBrush().color(), true); |
|
991 | d->setLabelBrush(theme->labelBrush().color(), true); | |
995 |
|
992 | |||
996 | if (forced || d->m_data.m_labelFont.isThemed()) |
|
993 | if (forced || d->m_data.m_labelFont.isThemed()) | |
997 | d->setLabelFont(theme->labelFont(), true); |
|
994 | d->setLabelFont(theme->labelFont(), true); | |
998 | } |
|
995 | } | |
999 | } |
|
996 | } | |
1000 |
|
997 | |||
1001 |
|
998 | |||
1002 | #include "moc_qpieseries.cpp" |
|
999 | #include "moc_qpieseries.cpp" | |
1003 | #include "moc_qpieseries_p.cpp" |
|
1000 | #include "moc_qpieseries_p.cpp" | |
1004 |
|
1001 | |||
1005 | QT_CHARTS_END_NAMESPACE |
|
1002 | QT_CHARTS_END_NAMESPACE |
General Comments 0
You need to be logged in to leave comments.
Login now