##// END OF EJS Templates
Fix QAbstractAxis::AxisTypes enum values....
Miikka Heikkinen -
r2719:5490e1de47f4
parent child
Show More
@@ -1,1012 +1,1012
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.digia.com
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 **
6 **
7 ** This file is part of the Qt Enterprise Charts Add-on.
7 ** This file is part of the Qt Enterprise Charts Add-on.
8 **
8 **
9 ** $QT_BEGIN_LICENSE$
9 ** $QT_BEGIN_LICENSE$
10 ** Licensees holding valid Qt Enterprise licenses may use this file in
10 ** Licensees holding valid Qt Enterprise licenses may use this file in
11 ** accordance with the Qt Enterprise License Agreement provided with the
11 ** accordance with the Qt Enterprise License Agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia.
13 ** a written agreement between you and Digia.
14 **
14 **
15 ** If you have questions regarding the use of this file, please use
15 ** If you have questions regarding the use of this file, please use
16 ** contact form at http://qt.digia.com
16 ** contact form at http://qt.digia.com
17 ** $QT_END_LICENSE$
17 ** $QT_END_LICENSE$
18 **
18 **
19 ****************************************************************************/
19 ****************************************************************************/
20
20
21 #include <QtCharts/QAbstractAxis>
21 #include <QtCharts/QAbstractAxis>
22 #include <private/qabstractaxis_p.h>
22 #include <private/qabstractaxis_p.h>
23 #include <private/chartdataset_p.h>
23 #include <private/chartdataset_p.h>
24 #include <private/charttheme_p.h>
24 #include <private/charttheme_p.h>
25 #include <private/qchart_p.h>
25 #include <private/qchart_p.h>
26
26
27 QT_CHARTS_BEGIN_NAMESPACE
27 QT_CHARTS_BEGIN_NAMESPACE
28
28
29 /*!
29 /*!
30 \class QAbstractAxis
30 \class QAbstractAxis
31 \inmodule Qt Charts
31 \inmodule Qt Charts
32 \brief The QAbstractAxis class is used for manipulating chart's axis.
32 \brief The QAbstractAxis class is used for manipulating chart's axis.
33 \mainclass
33 \mainclass
34
34
35 Each series can be bound to one or more horizontal and vertical axes, but mixing axis types
35 Each series can be bound to one or more horizontal and vertical axes, but mixing axis types
36 that would result in different domains is not supported, such as specifying
36 that would result in different domains is not supported, such as specifying
37 QValueAxis and QLogValueAxis on the same orientation.
37 QValueAxis and QLogValueAxis on the same orientation.
38
38
39 Properties and visibility of various axis elements such as axis line, title, labels, grid lines,
39 Properties and visibility of various axis elements such as axis line, title, labels, grid lines,
40 and shades can be individually controlled.
40 and shades can be individually controlled.
41 */
41 */
42 /*!
42 /*!
43 \qmltype AbstractAxis
43 \qmltype AbstractAxis
44 \instantiates QAbstractAxis
44 \instantiates QAbstractAxis
45 \inqmlmodule QtCharts
45 \inqmlmodule QtCharts
46
46
47 \brief The AbstractAxis is a base element used for specialized axis elements.
47 \brief The AbstractAxis is a base element used for specialized axis elements.
48
48
49 Each series can be bound to only one horizontal and vertical axis.
49 Each series can be bound to only one horizontal and vertical axis.
50
50
51 Properties and visibility of various axis elements such as axis line, title, labels, grid lines,
51 Properties and visibility of various axis elements such as axis line, title, labels, grid lines,
52 and shades can be individually controlled.
52 and shades can be individually controlled.
53 */
53 */
54
54
55 /*!
55 /*!
56 \enum QAbstractAxis::AxisType
56 \enum QAbstractAxis::AxisType
57
57
58 The type of the series object.
58 The type of the axis object.
59
59
60 \value AxisTypeNoAxis
60 \value AxisTypeNoAxis
61 \value AxisTypeValue
61 \value AxisTypeValue
62 \value AxisTypeBarCategory
62 \value AxisTypeBarCategory
63 \value AxisTypeCategory
63 \value AxisTypeCategory
64 \value AxisTypeDateTime
64 \value AxisTypeDateTime
65 \value AxisTypeLogValue
65 \value AxisTypeLogValue
66 */
66 */
67
67
68 /*!
68 /*!
69 *\fn void QAbstractAxis::type() const
69 *\fn void QAbstractAxis::type() const
70 Returns the type of the axis
70 Returns the type of the axis
71 */
71 */
72
72
73 /*!
73 /*!
74 \property QAbstractAxis::lineVisible
74 \property QAbstractAxis::lineVisible
75 The visibility of the axis line
75 The visibility of the axis line
76 */
76 */
77 /*!
77 /*!
78 \qmlproperty bool AbstractAxis::lineVisible
78 \qmlproperty bool AbstractAxis::lineVisible
79 The visibility of the axis line
79 The visibility of the axis line
80 */
80 */
81
81
82 /*!
82 /*!
83 \property QAbstractAxis::linePen
83 \property QAbstractAxis::linePen
84 The pen of the line.
84 The pen of the line.
85 */
85 */
86
86
87 /*!
87 /*!
88 \property QAbstractAxis::labelsVisible
88 \property QAbstractAxis::labelsVisible
89 Defines if axis labels are visible.
89 Defines if axis labels are visible.
90 */
90 */
91 /*!
91 /*!
92 \qmlproperty bool AbstractAxis::labelsVisible
92 \qmlproperty bool AbstractAxis::labelsVisible
93 Defines if axis labels are visible.
93 Defines if axis labels are visible.
94 */
94 */
95
95
96 /*!
96 /*!
97 \property QAbstractAxis::labelsPen
97 \property QAbstractAxis::labelsPen
98 \deprecated
98 \deprecated
99 The pen of the labels.
99 The pen of the labels.
100 */
100 */
101
101
102 /*!
102 /*!
103 \property QAbstractAxis::labelsBrush
103 \property QAbstractAxis::labelsBrush
104 The brush of the labels. Only the color of the brush is relevant.
104 The brush of the labels. Only the color of the brush is relevant.
105 */
105 */
106
106
107 /*!
107 /*!
108 \property QAbstractAxis::visible
108 \property QAbstractAxis::visible
109 The visibility of the axis.
109 The visibility of the axis.
110 */
110 */
111 /*!
111 /*!
112 \qmlproperty bool AbstractAxis::visible
112 \qmlproperty bool AbstractAxis::visible
113 The visibility of the axis.
113 The visibility of the axis.
114 */
114 */
115
115
116 /*!
116 /*!
117 \property QAbstractAxis::gridVisible
117 \property QAbstractAxis::gridVisible
118 The visibility of the grid lines.
118 The visibility of the grid lines.
119 */
119 */
120 /*!
120 /*!
121 \qmlproperty bool AbstractAxis::gridVisible
121 \qmlproperty bool AbstractAxis::gridVisible
122 The visibility of the grid lines.
122 The visibility of the grid lines.
123 */
123 */
124
124
125 /*!
125 /*!
126 \property QAbstractAxis::color
126 \property QAbstractAxis::color
127 The color of the axis and ticks.
127 The color of the axis and ticks.
128 */
128 */
129 /*!
129 /*!
130 \qmlproperty color AbstractAxis::color
130 \qmlproperty color AbstractAxis::color
131 The color of the axis and ticks.
131 The color of the axis and ticks.
132 */
132 */
133
133
134 /*!
134 /*!
135 \property QAbstractAxis::gridLinePen
135 \property QAbstractAxis::gridLinePen
136 The pen of the grid line.
136 The pen of the grid line.
137 */
137 */
138
138
139 /*!
139 /*!
140 \property QAbstractAxis::labelsFont
140 \property QAbstractAxis::labelsFont
141 The font of the axis labels.
141 The font of the axis labels.
142 */
142 */
143
143
144 /*!
144 /*!
145 \qmlproperty Font AbstractAxis::labelsFont
145 \qmlproperty Font AbstractAxis::labelsFont
146 The font of the axis labels.
146 The font of the axis labels.
147
147
148 See the Qt documentation for more details of Font.
148 See the Qt documentation for more details of Font.
149 */
149 */
150
150
151 /*!
151 /*!
152 \property QAbstractAxis::labelsColor
152 \property QAbstractAxis::labelsColor
153 The color of the axis labels.
153 The color of the axis labels.
154 */
154 */
155 /*!
155 /*!
156 \qmlproperty color AbstractAxis::labelsColor
156 \qmlproperty color AbstractAxis::labelsColor
157 The color of the axis labels.
157 The color of the axis labels.
158 */
158 */
159
159
160 /*!
160 /*!
161 \property QAbstractAxis::labelsAngle
161 \property QAbstractAxis::labelsAngle
162 The angle of the axis labels in degrees.
162 The angle of the axis labels in degrees.
163 */
163 */
164 /*!
164 /*!
165 \qmlproperty int AbstractAxis::labelsAngle
165 \qmlproperty int AbstractAxis::labelsAngle
166 The angle of the axis labels in degrees.
166 The angle of the axis labels in degrees.
167 */
167 */
168
168
169 /*!
169 /*!
170 \property QAbstractAxis::shadesVisible
170 \property QAbstractAxis::shadesVisible
171 The visibility of the axis shades.
171 The visibility of the axis shades.
172 */
172 */
173 /*!
173 /*!
174 \qmlproperty bool AbstractAxis::shadesVisible
174 \qmlproperty bool AbstractAxis::shadesVisible
175 The visibility of the axis shades.
175 The visibility of the axis shades.
176 */
176 */
177
177
178 /*!
178 /*!
179 \property QAbstractAxis::shadesColor
179 \property QAbstractAxis::shadesColor
180 The fill (brush) color of the axis shades.
180 The fill (brush) color of the axis shades.
181 */
181 */
182 /*!
182 /*!
183 \qmlproperty color AbstractAxis::shadesColor
183 \qmlproperty color AbstractAxis::shadesColor
184 The fill (brush) color of the axis shades.
184 The fill (brush) color of the axis shades.
185 */
185 */
186
186
187 /*!
187 /*!
188 \property QAbstractAxis::shadesBorderColor
188 \property QAbstractAxis::shadesBorderColor
189 The border (pen) color of the axis shades.
189 The border (pen) color of the axis shades.
190 */
190 */
191 /*!
191 /*!
192 \qmlproperty color AbstractAxis::shadesBorderColor
192 \qmlproperty color AbstractAxis::shadesBorderColor
193 The border (pen) color of the axis shades.
193 The border (pen) color of the axis shades.
194 */
194 */
195
195
196 /*!
196 /*!
197 \property QAbstractAxis::shadesPen
197 \property QAbstractAxis::shadesPen
198 The pen of the axis shades (area between grid lines).
198 The pen of the axis shades (area between grid lines).
199 */
199 */
200
200
201 /*!
201 /*!
202 \property QAbstractAxis::shadesBrush
202 \property QAbstractAxis::shadesBrush
203 The brush of the axis shades (area between grid lines).
203 The brush of the axis shades (area between grid lines).
204 */
204 */
205
205
206 /*!
206 /*!
207 \property QAbstractAxis::titleVisible
207 \property QAbstractAxis::titleVisible
208 The visibility of the axis title. By default the value is true.
208 The visibility of the axis title. By default the value is true.
209 */
209 */
210 /*!
210 /*!
211 \qmlproperty bool AbstractAxis::titleVisible
211 \qmlproperty bool AbstractAxis::titleVisible
212 The visibility of the axis title. By default the value is true.
212 The visibility of the axis title. By default the value is true.
213 */
213 */
214
214
215 /*!
215 /*!
216 \property QAbstractAxis::titleText
216 \property QAbstractAxis::titleText
217 The title of the axis. Empty by default. Axis titles support html formatting.
217 The title of the axis. Empty by default. Axis titles support html formatting.
218 */
218 */
219 /*!
219 /*!
220 \qmlproperty String AbstractAxis::titleText
220 \qmlproperty String AbstractAxis::titleText
221 The title of the axis. Empty by default. Axis titles support html formatting.
221 The title of the axis. Empty by default. Axis titles support html formatting.
222 */
222 */
223
223
224 /*!
224 /*!
225 \property QAbstractAxis::titlePen
225 \property QAbstractAxis::titlePen
226 \deprecated
226 \deprecated
227 The pen of the title text.
227 The pen of the title text.
228 */
228 */
229
229
230 /*!
230 /*!
231 \property QAbstractAxis::titleBrush
231 \property QAbstractAxis::titleBrush
232 The brush of the title text. Only the color of the brush is relevant.
232 The brush of the title text. Only the color of the brush is relevant.
233 */
233 */
234
234
235 /*!
235 /*!
236 \property QAbstractAxis::titleFont
236 \property QAbstractAxis::titleFont
237 The font of the title of the axis.
237 The font of the title of the axis.
238 */
238 */
239 /*!
239 /*!
240 \qmlproperty Font AbstractAxis::titleFont
240 \qmlproperty Font AbstractAxis::titleFont
241 The font of the title of the axis.
241 The font of the title of the axis.
242 */
242 */
243
243
244 /*!
244 /*!
245 \property QAbstractAxis::orientation
245 \property QAbstractAxis::orientation
246 The orientation of the axis. Fixed to either Qt::Horizontal or Qt::Vertical when you add the axis to a chart.
246 The orientation of the axis. Fixed to either Qt::Horizontal or Qt::Vertical when you add the axis to a chart.
247 */
247 */
248 /*!
248 /*!
249 \qmlproperty Qt.Orientation AbstractAxis::orientation
249 \qmlproperty Qt.Orientation AbstractAxis::orientation
250 The orientation of the axis. Fixed to either Qt.Horizontal or Qt.Vertical when the axis is set to a series.
250 The orientation of the axis. Fixed to either Qt.Horizontal or Qt.Vertical when the axis is set to a series.
251 */
251 */
252
252
253 /*!
253 /*!
254 \property QAbstractAxis::alignment
254 \property QAbstractAxis::alignment
255 The alignment of the axis. Can be Qt::AlignLeft, Qt::AlignRight, Qt::AlignBottom, or Qt::AlignTop.
255 The alignment of the axis. Can be Qt::AlignLeft, Qt::AlignRight, Qt::AlignBottom, or Qt::AlignTop.
256 */
256 */
257 /*!
257 /*!
258 \qmlproperty alignment AbstractAxis::alignment
258 \qmlproperty alignment AbstractAxis::alignment
259 The alignment of the axis. Can be Qt.AlignLeft, Qt.AlignRight, Qt.AlignBottom, or Qt.AlignTop.
259 The alignment of the axis. Can be Qt.AlignLeft, Qt.AlignRight, Qt.AlignBottom, or Qt.AlignTop.
260 */
260 */
261
261
262 /*!
262 /*!
263 \fn void QAbstractAxis::visibleChanged(bool visible)
263 \fn void QAbstractAxis::visibleChanged(bool visible)
264 Visibility of the axis has changed to \a visible.
264 Visibility of the axis has changed to \a visible.
265 */
265 */
266 /*!
266 /*!
267 \qmlsignal AbstractAxis::onVisibleChanged(bool visible)
267 \qmlsignal AbstractAxis::onVisibleChanged(bool visible)
268 Visibility of the axis has changed to \a visible.
268 Visibility of the axis has changed to \a visible.
269 */
269 */
270
270
271 /*!
271 /*!
272 \fn void QAbstractAxis::linePenChanged(const QPen& pen)
272 \fn void QAbstractAxis::linePenChanged(const QPen& pen)
273 The pen of the line of the axis has changed to \a pen.
273 The pen of the line of the axis has changed to \a pen.
274 */
274 */
275
275
276 /*!
276 /*!
277 \fn void QAbstractAxis::lineVisibleChanged(bool visible)
277 \fn void QAbstractAxis::lineVisibleChanged(bool visible)
278 Visibility of the axis line has changed to \a visible.
278 Visibility of the axis line has changed to \a visible.
279 */
279 */
280 /*!
280 /*!
281 \qmlsignal AbstractAxis::onLineVisibleChanged(bool visible)
281 \qmlsignal AbstractAxis::onLineVisibleChanged(bool visible)
282 Visibility of the axis line has changed to \a visible.
282 Visibility of the axis line has changed to \a visible.
283 */
283 */
284
284
285 /*!
285 /*!
286 \fn void QAbstractAxis::labelsVisibleChanged(bool visible)
286 \fn void QAbstractAxis::labelsVisibleChanged(bool visible)
287 Visibility of the labels of the axis has changed to \a visible.
287 Visibility of the labels of the axis has changed to \a visible.
288 */
288 */
289 /*!
289 /*!
290 \qmlsignal AbstractAxis::onLabelsVisibleChanged(bool visible)
290 \qmlsignal AbstractAxis::onLabelsVisibleChanged(bool visible)
291 Visibility of the labels of the axis has changed to \a visible.
291 Visibility of the labels of the axis has changed to \a visible.
292 */
292 */
293
293
294 /*!
294 /*!
295 \fn void QAbstractAxis::labelsFontChanged(const QFont& font)
295 \fn void QAbstractAxis::labelsFontChanged(const QFont& font)
296 The font of the axis labels has changed to \a font.
296 The font of the axis labels has changed to \a font.
297 */
297 */
298 /*!
298 /*!
299 \qmlsignal AbstractAxis::onLabelsFontChanged(Font font)
299 \qmlsignal AbstractAxis::onLabelsFontChanged(Font font)
300 The font of the axis labels has changed to \a font.
300 The font of the axis labels has changed to \a font.
301 */
301 */
302
302
303 /*!
303 /*!
304 \fn void QAbstractAxis::labelsPenChanged(const QPen& pen)
304 \fn void QAbstractAxis::labelsPenChanged(const QPen& pen)
305 \deprecated
305 \deprecated
306 The pen of the axis labels has changed to \a pen.
306 The pen of the axis labels has changed to \a pen.
307 */
307 */
308
308
309 /*!
309 /*!
310 \fn void QAbstractAxis::labelsBrushChanged(const QBrush& brush)
310 \fn void QAbstractAxis::labelsBrushChanged(const QBrush& brush)
311 The brush of the axis labels has changed to \a brush.
311 The brush of the axis labels has changed to \a brush.
312 */
312 */
313
313
314 /*!
314 /*!
315 \fn void QAbstractAxis::labelsAngleChanged(int angle)
315 \fn void QAbstractAxis::labelsAngleChanged(int angle)
316 The angle of the axis labels has changed to \a angle.
316 The angle of the axis labels has changed to \a angle.
317 */
317 */
318 /*!
318 /*!
319 \qmlsignal AbstractAxis::onLabelsAngleChanged(int angle)
319 \qmlsignal AbstractAxis::onLabelsAngleChanged(int angle)
320 The angle of the axis labels has changed to \a angle.
320 The angle of the axis labels has changed to \a angle.
321 */
321 */
322
322
323 /*!
323 /*!
324 \fn void QAbstractAxis::gridVisibleChanged(bool visible)
324 \fn void QAbstractAxis::gridVisibleChanged(bool visible)
325 Visibility of the grid lines of the axis has changed to \a visible.
325 Visibility of the grid lines of the axis has changed to \a visible.
326 */
326 */
327 /*!
327 /*!
328 \qmlsignal AbstractAxis::onGridVisibleChanged(bool visible)
328 \qmlsignal AbstractAxis::onGridVisibleChanged(bool visible)
329 Visibility of the grid lines of the axis has changed to \a visible.
329 Visibility of the grid lines of the axis has changed to \a visible.
330 */
330 */
331
331
332 /*!
332 /*!
333 \fn void QAbstractAxis::gridLinePenChanged(const QPen& pen)
333 \fn void QAbstractAxis::gridLinePenChanged(const QPen& pen)
334 The pen of the grid line has changed to \a pen.
334 The pen of the grid line has changed to \a pen.
335 */
335 */
336
336
337 /*!
337 /*!
338 \fn void QAbstractAxis::colorChanged(QColor color)
338 \fn void QAbstractAxis::colorChanged(QColor color)
339 Emitted if the \a color of the axis is changed.
339 Emitted if the \a color of the axis is changed.
340 */
340 */
341 /*!
341 /*!
342 \qmlsignal AbstractAxis::onColorChanged(QColor color)
342 \qmlsignal AbstractAxis::onColorChanged(QColor color)
343 Emitted if the \a color of the axis is changed.
343 Emitted if the \a color of the axis is changed.
344 */
344 */
345
345
346 /*!
346 /*!
347 \fn void QAbstractAxis::labelsColorChanged(QColor color)
347 \fn void QAbstractAxis::labelsColorChanged(QColor color)
348 Emitted if the \a color of the axis labels is changed.
348 Emitted if the \a color of the axis labels is changed.
349 */
349 */
350 /*!
350 /*!
351 \qmlsignal AbstractAxis::onLabelsColorChanged(QColor color)
351 \qmlsignal AbstractAxis::onLabelsColorChanged(QColor color)
352 Emitted if the \a color of the axis labels is changed.
352 Emitted if the \a color of the axis labels is changed.
353 */
353 */
354
354
355 /*!
355 /*!
356 \fn void QAbstractAxis::titleVisibleChanged(bool visible)
356 \fn void QAbstractAxis::titleVisibleChanged(bool visible)
357 Visibility of the title text of the axis has changed to \a visible.
357 Visibility of the title text of the axis has changed to \a visible.
358 */
358 */
359 /*!
359 /*!
360 \qmlsignal AbstractAxis::onTitleVisibleChanged(bool visible)
360 \qmlsignal AbstractAxis::onTitleVisibleChanged(bool visible)
361 Visibility of the title text of the axis has changed to \a visible.
361 Visibility of the title text of the axis has changed to \a visible.
362 */
362 */
363
363
364 /*!
364 /*!
365 \fn void QAbstractAxis::titleTextChanged(const QString& text)
365 \fn void QAbstractAxis::titleTextChanged(const QString& text)
366 The text of the axis title has changed to \a text.
366 The text of the axis title has changed to \a text.
367 */
367 */
368 /*!
368 /*!
369 \qmlsignal AbstractAxis::onTitleTextChanged(String text)
369 \qmlsignal AbstractAxis::onTitleTextChanged(String text)
370 The text of the axis title has changed to \a text.
370 The text of the axis title has changed to \a text.
371 */
371 */
372
372
373 /*!
373 /*!
374 \fn void QAbstractAxis::titlePenChanged(const QPen& pen)
374 \fn void QAbstractAxis::titlePenChanged(const QPen& pen)
375 \deprecated
375 \deprecated
376 The pen of the axis shades has changed to \a pen.
376 The pen of the axis shades has changed to \a pen.
377 */
377 */
378
378
379 /*!
379 /*!
380 \fn void QAbstractAxis::titleBrushChanged(const QBrush& brush)
380 \fn void QAbstractAxis::titleBrushChanged(const QBrush& brush)
381 The brush of the axis title has changed to \a brush.
381 The brush of the axis title has changed to \a brush.
382 */
382 */
383
383
384 /*!
384 /*!
385 \fn void QAbstractAxis::titleFontChanged(const QFont& font)
385 \fn void QAbstractAxis::titleFontChanged(const QFont& font)
386 The font of the axis title has changed to \a font.
386 The font of the axis title has changed to \a font.
387 */
387 */
388 /*!
388 /*!
389 \qmlsignal AbstractAxis::onTitleFontChanged(Font font)
389 \qmlsignal AbstractAxis::onTitleFontChanged(Font font)
390 The font of the axis title has changed to \a font.
390 The font of the axis title has changed to \a font.
391 */
391 */
392
392
393 /*!
393 /*!
394 \fn void QAbstractAxis::shadesVisibleChanged(bool)
394 \fn void QAbstractAxis::shadesVisibleChanged(bool)
395 Emitted if the visibility of the axis shades is changed to \a visible.
395 Emitted if the visibility of the axis shades is changed to \a visible.
396 */
396 */
397 /*!
397 /*!
398 \qmlsignal AbstractAxis::onShadesVisibleChanged(bool visible)
398 \qmlsignal AbstractAxis::onShadesVisibleChanged(bool visible)
399 Emitted if the visibility of the axis shades is changed to \a visible.
399 Emitted if the visibility of the axis shades is changed to \a visible.
400 */
400 */
401
401
402 /*!
402 /*!
403 \fn void QAbstractAxis::shadesColorChanged(QColor color)
403 \fn void QAbstractAxis::shadesColorChanged(QColor color)
404 Emitted if the \a color of the axis shades is changed.
404 Emitted if the \a color of the axis shades is changed.
405 */
405 */
406 /*!
406 /*!
407 \qmlsignal AbstractAxis::onShadesColorChanged(QColor color)
407 \qmlsignal AbstractAxis::onShadesColorChanged(QColor color)
408 Emitted if the \a color of the axis shades is changed.
408 Emitted if the \a color of the axis shades is changed.
409 */
409 */
410
410
411 /*!
411 /*!
412 \fn void QAbstractAxis::shadesBorderColorChanged(QColor)
412 \fn void QAbstractAxis::shadesBorderColorChanged(QColor)
413 Emitted if the border \a color of the axis shades is changed.
413 Emitted if the border \a color of the axis shades is changed.
414 */
414 */
415 /*!
415 /*!
416 \qmlsignal AbstractAxis::onBorderColorChanged(QColor color)
416 \qmlsignal AbstractAxis::onBorderColorChanged(QColor color)
417 Emitted if the border \a color of the axis shades is changed.
417 Emitted if the border \a color of the axis shades is changed.
418 */
418 */
419
419
420 /*!
420 /*!
421 \fn void QAbstractAxis::shadesBrushChanged(const QBrush& brush)
421 \fn void QAbstractAxis::shadesBrushChanged(const QBrush& brush)
422 The brush of the axis shades has changed to \a brush.
422 The brush of the axis shades has changed to \a brush.
423 */
423 */
424
424
425 /*!
425 /*!
426 \fn void QAbstractAxis::shadesPenChanged(const QPen& pen)
426 \fn void QAbstractAxis::shadesPenChanged(const QPen& pen)
427 The pen of the axis shades has changed to \a pen.
427 The pen of the axis shades has changed to \a pen.
428 */
428 */
429
429
430 /*!
430 /*!
431 \internal
431 \internal
432 Constructs new axis object which is a child of \a parent. Ownership is taken by
432 Constructs new axis object which is a child of \a parent. Ownership is taken by
433 QChart when axis added.
433 QChart when axis added.
434 */
434 */
435
435
436 QAbstractAxis::QAbstractAxis(QAbstractAxisPrivate &d, QObject *parent)
436 QAbstractAxis::QAbstractAxis(QAbstractAxisPrivate &d, QObject *parent)
437 : QObject(parent),
437 : QObject(parent),
438 d_ptr(&d)
438 d_ptr(&d)
439 {
439 {
440 }
440 }
441
441
442 /*!
442 /*!
443 Destructor of the axis object. When axis is added to chart, chart object takes ownership.
443 Destructor of the axis object. When axis is added to chart, chart object takes ownership.
444 */
444 */
445
445
446 QAbstractAxis::~QAbstractAxis()
446 QAbstractAxis::~QAbstractAxis()
447 {
447 {
448 if (d_ptr->m_chart)
448 if (d_ptr->m_chart)
449 qFatal("Still binded axis detected !");
449 qFatal("Still binded axis detected !");
450 }
450 }
451
451
452 /*!
452 /*!
453 Sets \a pen used to draw axis line and ticks.
453 Sets \a pen used to draw axis line and ticks.
454 */
454 */
455 void QAbstractAxis::setLinePen(const QPen &pen)
455 void QAbstractAxis::setLinePen(const QPen &pen)
456 {
456 {
457 if (d_ptr->m_axisPen != pen) {
457 if (d_ptr->m_axisPen != pen) {
458 d_ptr->m_axisPen = pen;
458 d_ptr->m_axisPen = pen;
459 emit linePenChanged(pen);
459 emit linePenChanged(pen);
460 }
460 }
461 }
461 }
462
462
463 /*!
463 /*!
464 Returns pen used to draw axis and ticks.
464 Returns pen used to draw axis and ticks.
465 */
465 */
466 QPen QAbstractAxis::linePen() const
466 QPen QAbstractAxis::linePen() const
467 {
467 {
468 if (d_ptr->m_axisPen == QChartPrivate::defaultPen())
468 if (d_ptr->m_axisPen == QChartPrivate::defaultPen())
469 return QPen();
469 return QPen();
470 else
470 else
471 return d_ptr->m_axisPen;
471 return d_ptr->m_axisPen;
472 }
472 }
473
473
474 void QAbstractAxis::setLinePenColor(QColor color)
474 void QAbstractAxis::setLinePenColor(QColor color)
475 {
475 {
476 QPen p = d_ptr->m_axisPen;
476 QPen p = d_ptr->m_axisPen;
477 if (p.color() != color) {
477 if (p.color() != color) {
478 p.setColor(color);
478 p.setColor(color);
479 setLinePen(p);
479 setLinePen(p);
480 emit colorChanged(color);
480 emit colorChanged(color);
481 }
481 }
482 }
482 }
483
483
484 QColor QAbstractAxis::linePenColor() const
484 QColor QAbstractAxis::linePenColor() const
485 {
485 {
486 return linePen().color();
486 return linePen().color();
487 }
487 }
488
488
489 /*!
489 /*!
490 Sets if axis and ticks are \a visible.
490 Sets if axis and ticks are \a visible.
491 */
491 */
492 void QAbstractAxis::setLineVisible(bool visible)
492 void QAbstractAxis::setLineVisible(bool visible)
493 {
493 {
494 if (d_ptr->m_arrowVisible != visible) {
494 if (d_ptr->m_arrowVisible != visible) {
495 d_ptr->m_arrowVisible = visible;
495 d_ptr->m_arrowVisible = visible;
496 emit lineVisibleChanged(visible);
496 emit lineVisibleChanged(visible);
497 }
497 }
498 }
498 }
499
499
500 bool QAbstractAxis::isLineVisible() const
500 bool QAbstractAxis::isLineVisible() const
501 {
501 {
502 return d_ptr->m_arrowVisible;
502 return d_ptr->m_arrowVisible;
503 }
503 }
504
504
505 void QAbstractAxis::setGridLineVisible(bool visible)
505 void QAbstractAxis::setGridLineVisible(bool visible)
506 {
506 {
507 if (d_ptr->m_gridLineVisible != visible) {
507 if (d_ptr->m_gridLineVisible != visible) {
508 d_ptr->m_gridLineVisible = visible;
508 d_ptr->m_gridLineVisible = visible;
509 emit gridVisibleChanged(visible);
509 emit gridVisibleChanged(visible);
510 }
510 }
511 }
511 }
512
512
513 bool QAbstractAxis::isGridLineVisible() const
513 bool QAbstractAxis::isGridLineVisible() const
514 {
514 {
515 return d_ptr->m_gridLineVisible;
515 return d_ptr->m_gridLineVisible;
516 }
516 }
517
517
518 /*!
518 /*!
519 Sets \a pen used to draw grid line.
519 Sets \a pen used to draw grid line.
520 */
520 */
521 void QAbstractAxis::setGridLinePen(const QPen &pen)
521 void QAbstractAxis::setGridLinePen(const QPen &pen)
522 {
522 {
523 if (d_ptr->m_gridLinePen != pen) {
523 if (d_ptr->m_gridLinePen != pen) {
524 d_ptr->m_gridLinePen = pen;
524 d_ptr->m_gridLinePen = pen;
525 emit gridLinePenChanged(pen);
525 emit gridLinePenChanged(pen);
526 }
526 }
527 }
527 }
528
528
529 /*!
529 /*!
530 Returns pen used to draw grid.
530 Returns pen used to draw grid.
531 */
531 */
532 QPen QAbstractAxis::gridLinePen() const
532 QPen QAbstractAxis::gridLinePen() const
533 {
533 {
534 if (d_ptr->m_gridLinePen == QChartPrivate::defaultPen())
534 if (d_ptr->m_gridLinePen == QChartPrivate::defaultPen())
535 return QPen();
535 return QPen();
536 else
536 else
537 return d_ptr->m_gridLinePen;
537 return d_ptr->m_gridLinePen;
538 }
538 }
539
539
540 void QAbstractAxis::setLabelsVisible(bool visible)
540 void QAbstractAxis::setLabelsVisible(bool visible)
541 {
541 {
542 if (d_ptr->m_labelsVisible != visible) {
542 if (d_ptr->m_labelsVisible != visible) {
543 d_ptr->m_labelsVisible = visible;
543 d_ptr->m_labelsVisible = visible;
544 emit labelsVisibleChanged(visible);
544 emit labelsVisibleChanged(visible);
545 }
545 }
546 }
546 }
547
547
548 bool QAbstractAxis::labelsVisible() const
548 bool QAbstractAxis::labelsVisible() const
549 {
549 {
550 return d_ptr->m_labelsVisible;
550 return d_ptr->m_labelsVisible;
551 }
551 }
552
552
553 void QAbstractAxis::setLabelsPen(const QPen &pen)
553 void QAbstractAxis::setLabelsPen(const QPen &pen)
554 {
554 {
555 if (d_ptr->m_labelsPen != pen) {
555 if (d_ptr->m_labelsPen != pen) {
556 d_ptr->m_labelsPen = pen;
556 d_ptr->m_labelsPen = pen;
557 emit labelsPenChanged(pen);
557 emit labelsPenChanged(pen);
558 }
558 }
559 }
559 }
560
560
561 QPen QAbstractAxis::labelsPen() const
561 QPen QAbstractAxis::labelsPen() const
562 {
562 {
563 if (d_ptr->m_labelsPen == QChartPrivate::defaultPen())
563 if (d_ptr->m_labelsPen == QChartPrivate::defaultPen())
564 return QPen();
564 return QPen();
565 else
565 else
566 return d_ptr->m_labelsPen;
566 return d_ptr->m_labelsPen;
567 }
567 }
568
568
569 /*!
569 /*!
570 Sets \a brush used to draw labels.
570 Sets \a brush used to draw labels.
571 */
571 */
572 void QAbstractAxis::setLabelsBrush(const QBrush &brush)
572 void QAbstractAxis::setLabelsBrush(const QBrush &brush)
573 {
573 {
574 if (d_ptr->m_labelsBrush != brush) {
574 if (d_ptr->m_labelsBrush != brush) {
575 d_ptr->m_labelsBrush = brush;
575 d_ptr->m_labelsBrush = brush;
576 emit labelsBrushChanged(brush);
576 emit labelsBrushChanged(brush);
577 }
577 }
578 }
578 }
579
579
580 /*!
580 /*!
581 Returns brush used to draw labels.
581 Returns brush used to draw labels.
582 */
582 */
583 QBrush QAbstractAxis::labelsBrush() const
583 QBrush QAbstractAxis::labelsBrush() const
584 {
584 {
585 if (d_ptr->m_labelsBrush == QChartPrivate::defaultBrush())
585 if (d_ptr->m_labelsBrush == QChartPrivate::defaultBrush())
586 return QBrush();
586 return QBrush();
587 else
587 else
588 return d_ptr->m_labelsBrush;
588 return d_ptr->m_labelsBrush;
589 }
589 }
590
590
591 /*!
591 /*!
592 Sets \a font used to draw labels.
592 Sets \a font used to draw labels.
593 */
593 */
594 void QAbstractAxis::setLabelsFont(const QFont &font)
594 void QAbstractAxis::setLabelsFont(const QFont &font)
595 {
595 {
596 if (d_ptr->m_labelsFont != font) {
596 if (d_ptr->m_labelsFont != font) {
597 d_ptr->m_labelsFont = font;
597 d_ptr->m_labelsFont = font;
598 emit labelsFontChanged(font);
598 emit labelsFontChanged(font);
599 }
599 }
600 }
600 }
601
601
602 /*!
602 /*!
603 Returns font used to draw labels.
603 Returns font used to draw labels.
604 */
604 */
605 QFont QAbstractAxis::labelsFont() const
605 QFont QAbstractAxis::labelsFont() const
606 {
606 {
607 if (d_ptr->m_labelsFont == QChartPrivate::defaultFont())
607 if (d_ptr->m_labelsFont == QChartPrivate::defaultFont())
608 return QFont();
608 return QFont();
609 else
609 else
610 return d_ptr->m_labelsFont;
610 return d_ptr->m_labelsFont;
611 }
611 }
612
612
613 void QAbstractAxis::setLabelsAngle(int angle)
613 void QAbstractAxis::setLabelsAngle(int angle)
614 {
614 {
615 if (d_ptr->m_labelsAngle != angle) {
615 if (d_ptr->m_labelsAngle != angle) {
616 d_ptr->m_labelsAngle = angle;
616 d_ptr->m_labelsAngle = angle;
617 emit labelsAngleChanged(angle);
617 emit labelsAngleChanged(angle);
618 }
618 }
619 }
619 }
620
620
621 int QAbstractAxis::labelsAngle() const
621 int QAbstractAxis::labelsAngle() const
622 {
622 {
623 return d_ptr->m_labelsAngle;
623 return d_ptr->m_labelsAngle;
624 }
624 }
625 void QAbstractAxis::setLabelsColor(QColor color)
625 void QAbstractAxis::setLabelsColor(QColor color)
626 {
626 {
627 QBrush b = d_ptr->m_labelsBrush;
627 QBrush b = d_ptr->m_labelsBrush;
628 if (b.color() != color) {
628 if (b.color() != color) {
629 b.setColor(color);
629 b.setColor(color);
630 setLabelsBrush(b);
630 setLabelsBrush(b);
631 emit labelsColorChanged(color);
631 emit labelsColorChanged(color);
632 }
632 }
633 }
633 }
634
634
635 QColor QAbstractAxis::labelsColor() const
635 QColor QAbstractAxis::labelsColor() const
636 {
636 {
637 return labelsBrush().color();
637 return labelsBrush().color();
638 }
638 }
639
639
640 void QAbstractAxis::setTitleVisible(bool visible)
640 void QAbstractAxis::setTitleVisible(bool visible)
641 {
641 {
642 if (d_ptr->m_titleVisible != visible) {
642 if (d_ptr->m_titleVisible != visible) {
643 d_ptr->m_titleVisible = visible;
643 d_ptr->m_titleVisible = visible;
644 emit titleVisibleChanged(visible);
644 emit titleVisibleChanged(visible);
645 }
645 }
646 }
646 }
647
647
648 bool QAbstractAxis::isTitleVisible() const
648 bool QAbstractAxis::isTitleVisible() const
649 {
649 {
650 return d_ptr->m_titleVisible;
650 return d_ptr->m_titleVisible;
651 }
651 }
652
652
653 void QAbstractAxis::setTitlePen(const QPen &pen)
653 void QAbstractAxis::setTitlePen(const QPen &pen)
654 {
654 {
655 if (d_ptr->m_titlePen != pen) {
655 if (d_ptr->m_titlePen != pen) {
656 d_ptr->m_titlePen = pen;
656 d_ptr->m_titlePen = pen;
657 emit titlePenChanged(pen);
657 emit titlePenChanged(pen);
658 }
658 }
659 }
659 }
660
660
661 QPen QAbstractAxis::titlePen() const
661 QPen QAbstractAxis::titlePen() const
662 {
662 {
663 if (d_ptr->m_titlePen == QChartPrivate::defaultPen())
663 if (d_ptr->m_titlePen == QChartPrivate::defaultPen())
664 return QPen();
664 return QPen();
665 else
665 else
666 return d_ptr->m_titlePen;
666 return d_ptr->m_titlePen;
667 }
667 }
668
668
669 /*!
669 /*!
670 Sets \a brush used to draw title.
670 Sets \a brush used to draw title.
671 */
671 */
672 void QAbstractAxis::setTitleBrush(const QBrush &brush)
672 void QAbstractAxis::setTitleBrush(const QBrush &brush)
673 {
673 {
674 if (d_ptr->m_titleBrush != brush) {
674 if (d_ptr->m_titleBrush != brush) {
675 d_ptr->m_titleBrush = brush;
675 d_ptr->m_titleBrush = brush;
676 emit titleBrushChanged(brush);
676 emit titleBrushChanged(brush);
677 }
677 }
678 }
678 }
679
679
680 /*!
680 /*!
681 Returns brush used to draw title.
681 Returns brush used to draw title.
682 */
682 */
683 QBrush QAbstractAxis::titleBrush() const
683 QBrush QAbstractAxis::titleBrush() const
684 {
684 {
685 if (d_ptr->m_titleBrush == QChartPrivate::defaultBrush())
685 if (d_ptr->m_titleBrush == QChartPrivate::defaultBrush())
686 return QBrush();
686 return QBrush();
687 else
687 else
688 return d_ptr->m_titleBrush;
688 return d_ptr->m_titleBrush;
689 }
689 }
690
690
691 /*!
691 /*!
692 Sets \a font used to draw title.
692 Sets \a font used to draw title.
693 */
693 */
694 void QAbstractAxis::setTitleFont(const QFont &font)
694 void QAbstractAxis::setTitleFont(const QFont &font)
695 {
695 {
696 if (d_ptr->m_titleFont != font) {
696 if (d_ptr->m_titleFont != font) {
697 d_ptr->m_titleFont = font;
697 d_ptr->m_titleFont = font;
698 emit titleFontChanged(font);
698 emit titleFontChanged(font);
699 }
699 }
700 }
700 }
701
701
702 /*!
702 /*!
703 Returns font used to draw title.
703 Returns font used to draw title.
704 */
704 */
705 QFont QAbstractAxis::titleFont() const
705 QFont QAbstractAxis::titleFont() const
706 {
706 {
707 if (d_ptr->m_titleFont == QChartPrivate::defaultFont())
707 if (d_ptr->m_titleFont == QChartPrivate::defaultFont())
708 return QFont();
708 return QFont();
709 else
709 else
710 return d_ptr->m_titleFont;
710 return d_ptr->m_titleFont;
711 }
711 }
712
712
713 void QAbstractAxis::setTitleText(const QString &title)
713 void QAbstractAxis::setTitleText(const QString &title)
714 {
714 {
715 if (d_ptr->m_title != title) {
715 if (d_ptr->m_title != title) {
716 d_ptr->m_title = title;
716 d_ptr->m_title = title;
717 emit titleTextChanged(title);
717 emit titleTextChanged(title);
718 }
718 }
719 }
719 }
720
720
721 QString QAbstractAxis::titleText() const
721 QString QAbstractAxis::titleText() const
722 {
722 {
723 return d_ptr->m_title;
723 return d_ptr->m_title;
724 }
724 }
725
725
726
726
727 void QAbstractAxis::setShadesVisible(bool visible)
727 void QAbstractAxis::setShadesVisible(bool visible)
728 {
728 {
729 if (d_ptr->m_shadesVisible != visible) {
729 if (d_ptr->m_shadesVisible != visible) {
730 d_ptr->m_shadesVisible = visible;
730 d_ptr->m_shadesVisible = visible;
731 emit shadesVisibleChanged(visible);
731 emit shadesVisibleChanged(visible);
732 }
732 }
733 }
733 }
734
734
735 bool QAbstractAxis::shadesVisible() const
735 bool QAbstractAxis::shadesVisible() const
736 {
736 {
737 return d_ptr->m_shadesVisible;
737 return d_ptr->m_shadesVisible;
738 }
738 }
739
739
740 /*!
740 /*!
741 Sets \a pen used to draw shades.
741 Sets \a pen used to draw shades.
742 */
742 */
743 void QAbstractAxis::setShadesPen(const QPen &pen)
743 void QAbstractAxis::setShadesPen(const QPen &pen)
744 {
744 {
745 if (d_ptr->m_shadesPen != pen) {
745 if (d_ptr->m_shadesPen != pen) {
746 d_ptr->m_shadesPen = pen;
746 d_ptr->m_shadesPen = pen;
747 emit shadesPenChanged(pen);
747 emit shadesPenChanged(pen);
748 }
748 }
749 }
749 }
750
750
751 /*!
751 /*!
752 Returns pen used to draw shades.
752 Returns pen used to draw shades.
753 */
753 */
754 QPen QAbstractAxis::shadesPen() const
754 QPen QAbstractAxis::shadesPen() const
755 {
755 {
756 if (d_ptr->m_shadesPen == QChartPrivate::defaultPen())
756 if (d_ptr->m_shadesPen == QChartPrivate::defaultPen())
757 return QPen();
757 return QPen();
758 else
758 else
759 return d_ptr->m_shadesPen;
759 return d_ptr->m_shadesPen;
760 }
760 }
761
761
762 /*!
762 /*!
763 Sets \a brush used to draw shades.
763 Sets \a brush used to draw shades.
764 */
764 */
765 void QAbstractAxis::setShadesBrush(const QBrush &brush)
765 void QAbstractAxis::setShadesBrush(const QBrush &brush)
766 {
766 {
767 if (d_ptr->m_shadesBrush != brush) {
767 if (d_ptr->m_shadesBrush != brush) {
768 d_ptr->m_shadesBrush = brush;
768 d_ptr->m_shadesBrush = brush;
769 emit shadesBrushChanged(brush);
769 emit shadesBrushChanged(brush);
770 }
770 }
771 }
771 }
772
772
773 /*!
773 /*!
774 Returns brush used to draw shades.
774 Returns brush used to draw shades.
775 */
775 */
776 QBrush QAbstractAxis::shadesBrush() const
776 QBrush QAbstractAxis::shadesBrush() const
777 {
777 {
778 if (d_ptr->m_shadesBrush == QChartPrivate::defaultBrush())
778 if (d_ptr->m_shadesBrush == QChartPrivate::defaultBrush())
779 return QBrush(Qt::SolidPattern);
779 return QBrush(Qt::SolidPattern);
780 else
780 else
781 return d_ptr->m_shadesBrush;
781 return d_ptr->m_shadesBrush;
782 }
782 }
783
783
784 void QAbstractAxis::setShadesColor(QColor color)
784 void QAbstractAxis::setShadesColor(QColor color)
785 {
785 {
786 QBrush b = d_ptr->m_shadesBrush;
786 QBrush b = d_ptr->m_shadesBrush;
787 if (b.color() != color) {
787 if (b.color() != color) {
788 b.setColor(color);
788 b.setColor(color);
789 setShadesBrush(b);
789 setShadesBrush(b);
790 emit shadesColorChanged(color);
790 emit shadesColorChanged(color);
791 }
791 }
792 }
792 }
793
793
794 QColor QAbstractAxis::shadesColor() const
794 QColor QAbstractAxis::shadesColor() const
795 {
795 {
796 return shadesBrush().color();
796 return shadesBrush().color();
797 }
797 }
798
798
799 void QAbstractAxis::setShadesBorderColor(QColor color)
799 void QAbstractAxis::setShadesBorderColor(QColor color)
800 {
800 {
801 QPen p = d_ptr->m_shadesPen;
801 QPen p = d_ptr->m_shadesPen;
802 if (p.color() != color) {
802 if (p.color() != color) {
803 p.setColor(color);
803 p.setColor(color);
804 setShadesPen(p);
804 setShadesPen(p);
805 emit shadesColorChanged(color);
805 emit shadesColorChanged(color);
806 }
806 }
807 }
807 }
808
808
809 QColor QAbstractAxis::shadesBorderColor() const
809 QColor QAbstractAxis::shadesBorderColor() const
810 {
810 {
811 return shadesPen().color();
811 return shadesPen().color();
812 }
812 }
813
813
814
814
815 bool QAbstractAxis::isVisible() const
815 bool QAbstractAxis::isVisible() const
816 {
816 {
817 return d_ptr->m_visible;
817 return d_ptr->m_visible;
818 }
818 }
819
819
820 /*!
820 /*!
821 Sets axis, shades, labels and grid lines to be visible.
821 Sets axis, shades, labels and grid lines to be visible.
822 */
822 */
823 void QAbstractAxis::setVisible(bool visible)
823 void QAbstractAxis::setVisible(bool visible)
824 {
824 {
825 if (d_ptr->m_visible != visible) {
825 if (d_ptr->m_visible != visible) {
826 d_ptr->m_visible = visible;
826 d_ptr->m_visible = visible;
827 emit visibleChanged(visible);
827 emit visibleChanged(visible);
828 }
828 }
829 }
829 }
830
830
831
831
832 /*!
832 /*!
833 Sets axis, shades, labels and grid lines to be visible.
833 Sets axis, shades, labels and grid lines to be visible.
834 */
834 */
835 void QAbstractAxis::show()
835 void QAbstractAxis::show()
836 {
836 {
837 setVisible(true);
837 setVisible(true);
838 }
838 }
839
839
840 /*!
840 /*!
841 Sets axis, shades, labels and grid lines to not be visible.
841 Sets axis, shades, labels and grid lines to not be visible.
842 */
842 */
843 void QAbstractAxis::hide()
843 void QAbstractAxis::hide()
844 {
844 {
845 setVisible(false);
845 setVisible(false);
846 }
846 }
847
847
848 /*!
848 /*!
849 Sets the minimum value shown on the axis.
849 Sets the minimum value shown on the axis.
850 Depending on the actual axis type the \a min parameter is converted to appropriate type.
850 Depending on the actual axis type the \a min parameter is converted to appropriate type.
851 If the conversion is impossible then the function call does nothing
851 If the conversion is impossible then the function call does nothing
852 */
852 */
853 void QAbstractAxis::setMin(const QVariant &min)
853 void QAbstractAxis::setMin(const QVariant &min)
854 {
854 {
855 d_ptr->setMin(min);
855 d_ptr->setMin(min);
856 }
856 }
857
857
858 /*!
858 /*!
859 Sets the maximum value shown on the axis.
859 Sets the maximum value shown on the axis.
860 Depending on the actual axis type the \a max parameter is converted to appropriate type.
860 Depending on the actual axis type the \a max parameter is converted to appropriate type.
861 If the conversion is impossible then the function call does nothing
861 If the conversion is impossible then the function call does nothing
862 */
862 */
863 void QAbstractAxis::setMax(const QVariant &max)
863 void QAbstractAxis::setMax(const QVariant &max)
864 {
864 {
865 d_ptr->setMax(max);
865 d_ptr->setMax(max);
866 }
866 }
867
867
868 /*!
868 /*!
869 Sets the range shown on the axis.
869 Sets the range shown on the axis.
870 Depending on the actual axis type the \a min and \a max parameters are converted to appropriate types.
870 Depending on the actual axis type the \a min and \a max parameters are converted to appropriate types.
871 If the conversion is impossible then the function call does nothing.
871 If the conversion is impossible then the function call does nothing.
872 */
872 */
873 void QAbstractAxis::setRange(const QVariant &min, const QVariant &max)
873 void QAbstractAxis::setRange(const QVariant &min, const QVariant &max)
874 {
874 {
875 d_ptr->setRange(min, max);
875 d_ptr->setRange(min, max);
876 }
876 }
877
877
878
878
879 /*!
879 /*!
880 Returns the orientation in which the axis is being used (Vertical or Horizontal)
880 Returns the orientation in which the axis is being used (Vertical or Horizontal)
881 */
881 */
882 Qt::Orientation QAbstractAxis::orientation()
882 Qt::Orientation QAbstractAxis::orientation()
883 {
883 {
884 return d_ptr->orientation();
884 return d_ptr->orientation();
885 }
885 }
886
886
887 Qt::Alignment QAbstractAxis::alignment() const
887 Qt::Alignment QAbstractAxis::alignment() const
888 {
888 {
889 return d_ptr->alignment();
889 return d_ptr->alignment();
890 }
890 }
891
891
892 /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
892 /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
893
893
894 QAbstractAxisPrivate::QAbstractAxisPrivate(QAbstractAxis *q)
894 QAbstractAxisPrivate::QAbstractAxisPrivate(QAbstractAxis *q)
895 : q_ptr(q),
895 : q_ptr(q),
896 m_chart(0),
896 m_chart(0),
897 m_alignment(0),
897 m_alignment(0),
898 m_orientation(Qt::Orientation(0)),
898 m_orientation(Qt::Orientation(0)),
899 m_visible(true),
899 m_visible(true),
900 m_arrowVisible(true),
900 m_arrowVisible(true),
901 m_axisPen(QChartPrivate::defaultPen()),
901 m_axisPen(QChartPrivate::defaultPen()),
902 m_axisBrush(QChartPrivate::defaultBrush()),
902 m_axisBrush(QChartPrivate::defaultBrush()),
903 m_gridLineVisible(true),
903 m_gridLineVisible(true),
904 m_gridLinePen(QChartPrivate::defaultPen()),
904 m_gridLinePen(QChartPrivate::defaultPen()),
905 m_labelsVisible(true),
905 m_labelsVisible(true),
906 m_labelsPen(QChartPrivate::defaultPen()),
906 m_labelsPen(QChartPrivate::defaultPen()),
907 m_labelsBrush(QChartPrivate::defaultBrush()),
907 m_labelsBrush(QChartPrivate::defaultBrush()),
908 m_labelsFont(QChartPrivate::defaultFont()),
908 m_labelsFont(QChartPrivate::defaultFont()),
909 m_labelsAngle(0),
909 m_labelsAngle(0),
910 m_titleVisible(true),
910 m_titleVisible(true),
911 m_titlePen(QChartPrivate::defaultPen()),
911 m_titlePen(QChartPrivate::defaultPen()),
912 m_titleBrush(QChartPrivate::defaultBrush()),
912 m_titleBrush(QChartPrivate::defaultBrush()),
913 m_titleFont(QChartPrivate::defaultFont()),
913 m_titleFont(QChartPrivate::defaultFont()),
914 m_shadesVisible(false),
914 m_shadesVisible(false),
915 m_shadesPen(QChartPrivate::defaultPen()),
915 m_shadesPen(QChartPrivate::defaultPen()),
916 m_shadesBrush(QChartPrivate::defaultBrush()),
916 m_shadesBrush(QChartPrivate::defaultBrush()),
917 m_shadesOpacity(1.0),
917 m_shadesOpacity(1.0),
918 m_dirty(false)
918 m_dirty(false)
919 {
919 {
920 }
920 }
921
921
922 QAbstractAxisPrivate::~QAbstractAxisPrivate()
922 QAbstractAxisPrivate::~QAbstractAxisPrivate()
923 {
923 {
924 }
924 }
925
925
926 void QAbstractAxisPrivate::setAlignment( Qt::Alignment alignment)
926 void QAbstractAxisPrivate::setAlignment( Qt::Alignment alignment)
927 {
927 {
928 switch(alignment) {
928 switch(alignment) {
929 case Qt::AlignTop:
929 case Qt::AlignTop:
930 case Qt::AlignBottom:
930 case Qt::AlignBottom:
931 m_orientation = Qt::Horizontal;
931 m_orientation = Qt::Horizontal;
932 break;
932 break;
933 case Qt::AlignLeft:
933 case Qt::AlignLeft:
934 case Qt::AlignRight:
934 case Qt::AlignRight:
935 m_orientation = Qt::Vertical;
935 m_orientation = Qt::Vertical;
936 break;
936 break;
937 default:
937 default:
938 qWarning()<<"No alignment specified !";
938 qWarning()<<"No alignment specified !";
939 break;
939 break;
940 };
940 };
941 m_alignment=alignment;
941 m_alignment=alignment;
942 }
942 }
943
943
944 void QAbstractAxisPrivate::initializeTheme(ChartTheme* theme, bool forced)
944 void QAbstractAxisPrivate::initializeTheme(ChartTheme* theme, bool forced)
945 {
945 {
946 if (forced || QChartPrivate::defaultPen() == m_axisPen)
946 if (forced || QChartPrivate::defaultPen() == m_axisPen)
947 q_ptr->setLinePen(theme->axisLinePen());
947 q_ptr->setLinePen(theme->axisLinePen());
948
948
949 if (forced || QChartPrivate::defaultPen() == m_gridLinePen)
949 if (forced || QChartPrivate::defaultPen() == m_gridLinePen)
950 q_ptr->setGridLinePen(theme->girdLinePen());
950 q_ptr->setGridLinePen(theme->girdLinePen());
951
951
952 if (forced || QChartPrivate::defaultBrush() == m_labelsBrush)
952 if (forced || QChartPrivate::defaultBrush() == m_labelsBrush)
953 q_ptr->setLabelsBrush(theme->labelBrush());
953 q_ptr->setLabelsBrush(theme->labelBrush());
954 if (forced || QChartPrivate::defaultPen() == m_labelsPen)
954 if (forced || QChartPrivate::defaultPen() == m_labelsPen)
955 q_ptr->setLabelsPen(Qt::NoPen); // NoPen for performance reasons
955 q_ptr->setLabelsPen(Qt::NoPen); // NoPen for performance reasons
956 if (forced || QChartPrivate::defaultFont() == m_labelsFont)
956 if (forced || QChartPrivate::defaultFont() == m_labelsFont)
957 q_ptr->setLabelsFont(theme->labelFont());
957 q_ptr->setLabelsFont(theme->labelFont());
958
958
959 if (forced || QChartPrivate::defaultBrush() == m_titleBrush)
959 if (forced || QChartPrivate::defaultBrush() == m_titleBrush)
960 q_ptr->setTitleBrush(theme->labelBrush());
960 q_ptr->setTitleBrush(theme->labelBrush());
961 if (forced || QChartPrivate::defaultPen() == m_titlePen)
961 if (forced || QChartPrivate::defaultPen() == m_titlePen)
962 q_ptr->setTitlePen(Qt::NoPen); // NoPen for performance reasons
962 q_ptr->setTitlePen(Qt::NoPen); // NoPen for performance reasons
963 if (forced || QChartPrivate::defaultFont() == m_titleFont) {
963 if (forced || QChartPrivate::defaultFont() == m_titleFont) {
964 QFont font(m_labelsFont);
964 QFont font(m_labelsFont);
965 font.setBold(true);
965 font.setBold(true);
966 q_ptr->setTitleFont(font);
966 q_ptr->setTitleFont(font);
967 }
967 }
968
968
969 if (forced || QChartPrivate::defaultBrush() == m_shadesBrush)
969 if (forced || QChartPrivate::defaultBrush() == m_shadesBrush)
970 q_ptr->setShadesBrush(theme->backgroundShadesBrush());
970 q_ptr->setShadesBrush(theme->backgroundShadesBrush());
971 if (forced || QChartPrivate::defaultPen() == m_shadesPen)
971 if (forced || QChartPrivate::defaultPen() == m_shadesPen)
972 q_ptr->setShadesPen(theme->backgroundShadesPen());
972 q_ptr->setShadesPen(theme->backgroundShadesPen());
973
973
974 bool axisX = m_orientation == Qt::Horizontal;
974 bool axisX = m_orientation == Qt::Horizontal;
975 if (forced && (theme->backgroundShades() == ChartTheme::BackgroundShadesBoth
975 if (forced && (theme->backgroundShades() == ChartTheme::BackgroundShadesBoth
976 || (theme->backgroundShades() == ChartTheme::BackgroundShadesVertical && axisX)
976 || (theme->backgroundShades() == ChartTheme::BackgroundShadesVertical && axisX)
977 || (theme->backgroundShades() == ChartTheme::BackgroundShadesHorizontal && !axisX))) {
977 || (theme->backgroundShades() == ChartTheme::BackgroundShadesHorizontal && !axisX))) {
978 q_ptr->setShadesVisible(true);
978 q_ptr->setShadesVisible(true);
979 } else if (forced) {
979 } else if (forced) {
980 q_ptr->setShadesVisible(false);
980 q_ptr->setShadesVisible(false);
981 }
981 }
982 }
982 }
983
983
984 void QAbstractAxisPrivate::handleRangeChanged(qreal min, qreal max)
984 void QAbstractAxisPrivate::handleRangeChanged(qreal min, qreal max)
985 {
985 {
986 setRange(min,max);
986 setRange(min,max);
987 }
987 }
988
988
989 void QAbstractAxisPrivate::initializeGraphics(QGraphicsItem* parent)
989 void QAbstractAxisPrivate::initializeGraphics(QGraphicsItem* parent)
990 {
990 {
991 Q_UNUSED(parent);
991 Q_UNUSED(parent);
992 }
992 }
993
993
994 void QAbstractAxisPrivate::initializeAnimations(QChart::AnimationOptions options)
994 void QAbstractAxisPrivate::initializeAnimations(QChart::AnimationOptions options)
995 {
995 {
996 ChartAxisElement *axis = m_item.data();
996 ChartAxisElement *axis = m_item.data();
997 Q_ASSERT(axis);
997 Q_ASSERT(axis);
998 if (axis->animation())
998 if (axis->animation())
999 axis->animation()->stopAndDestroyLater();
999 axis->animation()->stopAndDestroyLater();
1000
1000
1001 if (options.testFlag(QChart::GridAxisAnimations))
1001 if (options.testFlag(QChart::GridAxisAnimations))
1002 axis->setAnimation(new AxisAnimation(axis));
1002 axis->setAnimation(new AxisAnimation(axis));
1003 else
1003 else
1004 axis->setAnimation(0);
1004 axis->setAnimation(0);
1005 }
1005 }
1006
1006
1007
1007
1008
1008
1009 #include "moc_qabstractaxis.cpp"
1009 #include "moc_qabstractaxis.cpp"
1010 #include "moc_qabstractaxis_p.cpp"
1010 #include "moc_qabstractaxis_p.cpp"
1011
1011
1012 QT_CHARTS_END_NAMESPACE
1012 QT_CHARTS_END_NAMESPACE
@@ -1,193 +1,193
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.digia.com
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 **
6 **
7 ** This file is part of the Qt Enterprise Charts Add-on.
7 ** This file is part of the Qt Enterprise Charts Add-on.
8 **
8 **
9 ** $QT_BEGIN_LICENSE$
9 ** $QT_BEGIN_LICENSE$
10 ** Licensees holding valid Qt Enterprise licenses may use this file in
10 ** Licensees holding valid Qt Enterprise licenses may use this file in
11 ** accordance with the Qt Enterprise License Agreement provided with the
11 ** accordance with the Qt Enterprise License Agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia.
13 ** a written agreement between you and Digia.
14 **
14 **
15 ** If you have questions regarding the use of this file, please use
15 ** If you have questions regarding the use of this file, please use
16 ** contact form at http://qt.digia.com
16 ** contact form at http://qt.digia.com
17 ** $QT_END_LICENSE$
17 ** $QT_END_LICENSE$
18 **
18 **
19 ****************************************************************************/
19 ****************************************************************************/
20
20
21 #ifndef QABSTRACTAXIS_H
21 #ifndef QABSTRACTAXIS_H
22 #define QABSTRACTAXIS_H
22 #define QABSTRACTAXIS_H
23
23
24 #include <QtCharts/QChartGlobal>
24 #include <QtCharts/QChartGlobal>
25 #include <QtGui/QPen>
25 #include <QtGui/QPen>
26 #include <QtGui/QFont>
26 #include <QtGui/QFont>
27 #include <QtCore/QVariant>
27 #include <QtCore/QVariant>
28
28
29 QT_CHARTS_BEGIN_NAMESPACE
29 QT_CHARTS_BEGIN_NAMESPACE
30
30
31 class QAbstractAxisPrivate;
31 class QAbstractAxisPrivate;
32
32
33 class QT_CHARTS_EXPORT QAbstractAxis : public QObject
33 class QT_CHARTS_EXPORT QAbstractAxis : public QObject
34 {
34 {
35 Q_OBJECT
35 Q_OBJECT
36 //visibility
36 //visibility
37 Q_PROPERTY(bool visible READ isVisible WRITE setVisible NOTIFY visibleChanged)
37 Q_PROPERTY(bool visible READ isVisible WRITE setVisible NOTIFY visibleChanged)
38 //arrow
38 //arrow
39 Q_PROPERTY(bool lineVisible READ isLineVisible WRITE setLineVisible NOTIFY lineVisibleChanged)
39 Q_PROPERTY(bool lineVisible READ isLineVisible WRITE setLineVisible NOTIFY lineVisibleChanged)
40 Q_PROPERTY(QPen linePen READ linePen WRITE setLinePen NOTIFY linePenChanged)
40 Q_PROPERTY(QPen linePen READ linePen WRITE setLinePen NOTIFY linePenChanged)
41 Q_PROPERTY(QColor color READ linePenColor WRITE setLinePenColor NOTIFY colorChanged)
41 Q_PROPERTY(QColor color READ linePenColor WRITE setLinePenColor NOTIFY colorChanged)
42 //labels
42 //labels
43 Q_PROPERTY(bool labelsVisible READ labelsVisible WRITE setLabelsVisible NOTIFY labelsVisibleChanged)
43 Q_PROPERTY(bool labelsVisible READ labelsVisible WRITE setLabelsVisible NOTIFY labelsVisibleChanged)
44 Q_PROPERTY(QPen labelsPen READ labelsPen WRITE setLabelsPen NOTIFY labelsPenChanged)
44 Q_PROPERTY(QPen labelsPen READ labelsPen WRITE setLabelsPen NOTIFY labelsPenChanged)
45 Q_PROPERTY(QBrush labelsBrush READ labelsBrush WRITE setLabelsBrush NOTIFY labelsBrushChanged)
45 Q_PROPERTY(QBrush labelsBrush READ labelsBrush WRITE setLabelsBrush NOTIFY labelsBrushChanged)
46 Q_PROPERTY(int labelsAngle READ labelsAngle WRITE setLabelsAngle NOTIFY labelsAngleChanged)
46 Q_PROPERTY(int labelsAngle READ labelsAngle WRITE setLabelsAngle NOTIFY labelsAngleChanged)
47 Q_PROPERTY(QFont labelsFont READ labelsFont WRITE setLabelsFont NOTIFY labelsFontChanged)
47 Q_PROPERTY(QFont labelsFont READ labelsFont WRITE setLabelsFont NOTIFY labelsFontChanged)
48 Q_PROPERTY(QColor labelsColor READ labelsColor WRITE setLabelsColor NOTIFY labelsColorChanged)
48 Q_PROPERTY(QColor labelsColor READ labelsColor WRITE setLabelsColor NOTIFY labelsColorChanged)
49 //grid
49 //grid
50 Q_PROPERTY(bool gridVisible READ isGridLineVisible WRITE setGridLineVisible NOTIFY gridVisibleChanged)
50 Q_PROPERTY(bool gridVisible READ isGridLineVisible WRITE setGridLineVisible NOTIFY gridVisibleChanged)
51 Q_PROPERTY(QPen gridLinePen READ gridLinePen WRITE setGridLinePen NOTIFY gridLinePenChanged)
51 Q_PROPERTY(QPen gridLinePen READ gridLinePen WRITE setGridLinePen NOTIFY gridLinePenChanged)
52 //shades
52 //shades
53 Q_PROPERTY(bool shadesVisible READ shadesVisible WRITE setShadesVisible NOTIFY shadesVisibleChanged)
53 Q_PROPERTY(bool shadesVisible READ shadesVisible WRITE setShadesVisible NOTIFY shadesVisibleChanged)
54 Q_PROPERTY(QColor shadesColor READ shadesColor WRITE setShadesColor NOTIFY shadesColorChanged)
54 Q_PROPERTY(QColor shadesColor READ shadesColor WRITE setShadesColor NOTIFY shadesColorChanged)
55 Q_PROPERTY(QColor shadesBorderColor READ shadesBorderColor WRITE setShadesBorderColor NOTIFY shadesBorderColorChanged)
55 Q_PROPERTY(QColor shadesBorderColor READ shadesBorderColor WRITE setShadesBorderColor NOTIFY shadesBorderColorChanged)
56 Q_PROPERTY(QPen shadesPen READ shadesPen WRITE setShadesPen NOTIFY shadesPenChanged)
56 Q_PROPERTY(QPen shadesPen READ shadesPen WRITE setShadesPen NOTIFY shadesPenChanged)
57 Q_PROPERTY(QBrush shadesBrush READ shadesBrush WRITE setShadesBrush NOTIFY shadesBrushChanged)
57 Q_PROPERTY(QBrush shadesBrush READ shadesBrush WRITE setShadesBrush NOTIFY shadesBrushChanged)
58 //title
58 //title
59 Q_PROPERTY(QString titleText READ titleText WRITE setTitleText NOTIFY titleTextChanged)
59 Q_PROPERTY(QString titleText READ titleText WRITE setTitleText NOTIFY titleTextChanged)
60 Q_PROPERTY(QPen titlePen READ titlePen WRITE setTitlePen NOTIFY titlePenChanged)
60 Q_PROPERTY(QPen titlePen READ titlePen WRITE setTitlePen NOTIFY titlePenChanged)
61 Q_PROPERTY(QBrush titleBrush READ titleBrush WRITE setTitleBrush NOTIFY titleBrushChanged)
61 Q_PROPERTY(QBrush titleBrush READ titleBrush WRITE setTitleBrush NOTIFY titleBrushChanged)
62 Q_PROPERTY(bool titleVisible READ isTitleVisible WRITE setTitleVisible NOTIFY titleVisibleChanged)
62 Q_PROPERTY(bool titleVisible READ isTitleVisible WRITE setTitleVisible NOTIFY titleVisibleChanged)
63 Q_PROPERTY(QFont titleFont READ titleFont WRITE setTitleFont NOTIFY titleFontChanged)
63 Q_PROPERTY(QFont titleFont READ titleFont WRITE setTitleFont NOTIFY titleFontChanged)
64 //orientation
64 //orientation
65 Q_PROPERTY(Qt::Orientation orientation READ orientation)
65 Q_PROPERTY(Qt::Orientation orientation READ orientation)
66 //aligment
66 //aligment
67 Q_PROPERTY(Qt::Alignment alignment READ alignment)
67 Q_PROPERTY(Qt::Alignment alignment READ alignment)
68
68
69 public:
69 public:
70
70
71 enum AxisType {
71 enum AxisType {
72 AxisTypeNoAxis = 0x0,
72 AxisTypeNoAxis = 0x0,
73 AxisTypeValue = 0x1,
73 AxisTypeValue = 0x1,
74 AxisTypeBarCategory = 0x2,
74 AxisTypeBarCategory = 0x2,
75 AxisTypeCategory = 0x3,
75 AxisTypeCategory = 0x4,
76 AxisTypeDateTime = 0x4,
76 AxisTypeDateTime = 0x8,
77 AxisTypeLogValue = 0x5
77 AxisTypeLogValue = 0x10
78 };
78 };
79
79
80 Q_DECLARE_FLAGS(AxisTypes, AxisType)
80 Q_DECLARE_FLAGS(AxisTypes, AxisType)
81
81
82 protected:
82 protected:
83 explicit QAbstractAxis(QAbstractAxisPrivate &d, QObject *parent = 0);
83 explicit QAbstractAxis(QAbstractAxisPrivate &d, QObject *parent = 0);
84
84
85 public:
85 public:
86 ~QAbstractAxis();
86 ~QAbstractAxis();
87
87
88 virtual AxisType type() const = 0;
88 virtual AxisType type() const = 0;
89
89
90 //visibility handling
90 //visibility handling
91 bool isVisible() const;
91 bool isVisible() const;
92 void setVisible(bool visible = true);
92 void setVisible(bool visible = true);
93 void show();
93 void show();
94 void hide();
94 void hide();
95
95
96 //arrow handling
96 //arrow handling
97 bool isLineVisible() const;
97 bool isLineVisible() const;
98 void setLineVisible(bool visible = true);
98 void setLineVisible(bool visible = true);
99 void setLinePen(const QPen &pen);
99 void setLinePen(const QPen &pen);
100 QPen linePen() const;
100 QPen linePen() const;
101 void setLinePenColor(QColor color);
101 void setLinePenColor(QColor color);
102 QColor linePenColor() const;
102 QColor linePenColor() const;
103
103
104 //grid handling
104 //grid handling
105 bool isGridLineVisible() const;
105 bool isGridLineVisible() const;
106 void setGridLineVisible(bool visible = true);
106 void setGridLineVisible(bool visible = true);
107 void setGridLinePen(const QPen &pen);
107 void setGridLinePen(const QPen &pen);
108 QPen gridLinePen() const;
108 QPen gridLinePen() const;
109
109
110 //labels handling
110 //labels handling
111 bool labelsVisible() const;
111 bool labelsVisible() const;
112 void setLabelsVisible(bool visible = true);
112 void setLabelsVisible(bool visible = true);
113 void setLabelsPen(const QPen &pen);
113 void setLabelsPen(const QPen &pen);
114 QPen labelsPen() const;
114 QPen labelsPen() const;
115 void setLabelsBrush(const QBrush &brush);
115 void setLabelsBrush(const QBrush &brush);
116 QBrush labelsBrush() const;
116 QBrush labelsBrush() const;
117 void setLabelsFont(const QFont &font);
117 void setLabelsFont(const QFont &font);
118 QFont labelsFont() const;
118 QFont labelsFont() const;
119 void setLabelsAngle(int angle);
119 void setLabelsAngle(int angle);
120 int labelsAngle() const;
120 int labelsAngle() const;
121 void setLabelsColor(QColor color);
121 void setLabelsColor(QColor color);
122 QColor labelsColor() const;
122 QColor labelsColor() const;
123
123
124 //title handling
124 //title handling
125 bool isTitleVisible() const;
125 bool isTitleVisible() const;
126 void setTitleVisible(bool visible = true);
126 void setTitleVisible(bool visible = true);
127 void setTitlePen(const QPen &pen);
127 void setTitlePen(const QPen &pen);
128 QPen titlePen() const;
128 QPen titlePen() const;
129 void setTitleBrush(const QBrush &brush);
129 void setTitleBrush(const QBrush &brush);
130 QBrush titleBrush() const;
130 QBrush titleBrush() const;
131 void setTitleFont(const QFont &font);
131 void setTitleFont(const QFont &font);
132 QFont titleFont() const;
132 QFont titleFont() const;
133 void setTitleText(const QString &title);
133 void setTitleText(const QString &title);
134 QString titleText() const;
134 QString titleText() const;
135
135
136 //shades handling
136 //shades handling
137 bool shadesVisible() const;
137 bool shadesVisible() const;
138 void setShadesVisible(bool visible = true);
138 void setShadesVisible(bool visible = true);
139 void setShadesPen(const QPen &pen);
139 void setShadesPen(const QPen &pen);
140 QPen shadesPen() const;
140 QPen shadesPen() const;
141 void setShadesBrush(const QBrush &brush);
141 void setShadesBrush(const QBrush &brush);
142 QBrush shadesBrush() const;
142 QBrush shadesBrush() const;
143 void setShadesColor(QColor color);
143 void setShadesColor(QColor color);
144 QColor shadesColor() const;
144 QColor shadesColor() const;
145 void setShadesBorderColor(QColor color);
145 void setShadesBorderColor(QColor color);
146 QColor shadesBorderColor() const;
146 QColor shadesBorderColor() const;
147
147
148 Qt::Orientation orientation();
148 Qt::Orientation orientation();
149 Qt::Alignment alignment() const;
149 Qt::Alignment alignment() const;
150
150
151 //range handling
151 //range handling
152 void setMin(const QVariant &min);
152 void setMin(const QVariant &min);
153 void setMax(const QVariant &max);
153 void setMax(const QVariant &max);
154 void setRange(const QVariant &min, const QVariant &max);
154 void setRange(const QVariant &min, const QVariant &max);
155
155
156 Q_SIGNALS:
156 Q_SIGNALS:
157 void visibleChanged(bool visible);
157 void visibleChanged(bool visible);
158 void linePenChanged(const QPen &pen);
158 void linePenChanged(const QPen &pen);
159 void lineVisibleChanged(bool visible);
159 void lineVisibleChanged(bool visible);
160 void labelsVisibleChanged(bool visible);
160 void labelsVisibleChanged(bool visible);
161 void labelsPenChanged(const QPen &pen);
161 void labelsPenChanged(const QPen &pen);
162 void labelsBrushChanged(const QBrush &brush);
162 void labelsBrushChanged(const QBrush &brush);
163 void labelsFontChanged(const QFont &pen);
163 void labelsFontChanged(const QFont &pen);
164 void labelsAngleChanged(int angle);
164 void labelsAngleChanged(int angle);
165 void gridLinePenChanged(const QPen &pen);
165 void gridLinePenChanged(const QPen &pen);
166 void gridVisibleChanged(bool visible);
166 void gridVisibleChanged(bool visible);
167 void colorChanged(QColor color);
167 void colorChanged(QColor color);
168 void labelsColorChanged(QColor color);
168 void labelsColorChanged(QColor color);
169 void titleTextChanged(const QString &title);
169 void titleTextChanged(const QString &title);
170 void titlePenChanged(const QPen &pen);
170 void titlePenChanged(const QPen &pen);
171 void titleBrushChanged(const QBrush &brush);
171 void titleBrushChanged(const QBrush &brush);
172 void titleVisibleChanged(bool visible);
172 void titleVisibleChanged(bool visible);
173 void titleFontChanged(const QFont &font);
173 void titleFontChanged(const QFont &font);
174 void shadesVisibleChanged(bool visible);
174 void shadesVisibleChanged(bool visible);
175 void shadesColorChanged(QColor color);
175 void shadesColorChanged(QColor color);
176 void shadesBorderColorChanged(QColor color);
176 void shadesBorderColorChanged(QColor color);
177 void shadesPenChanged(const QPen &pen);
177 void shadesPenChanged(const QPen &pen);
178 void shadesBrushChanged(const QBrush &brush);
178 void shadesBrushChanged(const QBrush &brush);
179
179
180 protected:
180 protected:
181 QScopedPointer<QAbstractAxisPrivate> d_ptr;
181 QScopedPointer<QAbstractAxisPrivate> d_ptr;
182 Q_DISABLE_COPY(QAbstractAxis)
182 Q_DISABLE_COPY(QAbstractAxis)
183 friend class ChartDataSet;
183 friend class ChartDataSet;
184 friend class ChartPresenter;
184 friend class ChartPresenter;
185 friend class ChartThemeManager;
185 friend class ChartThemeManager;
186 friend class AbstractDomain;
186 friend class AbstractDomain;
187 friend class ChartAxisElement;
187 friend class ChartAxisElement;
188 friend class XYChart;
188 friend class XYChart;
189 };
189 };
190
190
191 QT_CHARTS_END_NAMESPACE
191 QT_CHARTS_END_NAMESPACE
192
192
193 #endif // QABSTRACTAXIS_H
193 #endif // QABSTRACTAXIS_H
@@ -1,639 +1,624
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.digia.com
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 **
6 **
7 ** This file is part of the Qt Enterprise Charts Add-on.
7 ** This file is part of the Qt Enterprise Charts Add-on.
8 **
8 **
9 ** $QT_BEGIN_LICENSE$
9 ** $QT_BEGIN_LICENSE$
10 ** Licensees holding valid Qt Enterprise licenses may use this file in
10 ** Licensees holding valid Qt Enterprise licenses may use this file in
11 ** accordance with the Qt Enterprise License Agreement provided with the
11 ** accordance with the Qt Enterprise License Agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia.
13 ** a written agreement between you and Digia.
14 **
14 **
15 ** If you have questions regarding the use of this file, please use
15 ** If you have questions regarding the use of this file, please use
16 ** contact form at http://qt.digia.com
16 ** contact form at http://qt.digia.com
17 ** $QT_END_LICENSE$
17 ** $QT_END_LICENSE$
18 **
18 **
19 ****************************************************************************/
19 ****************************************************************************/
20
20
21 #include <private/chartdataset_p.h>
21 #include <private/chartdataset_p.h>
22 #include <private/chartpresenter_p.h>
22 #include <private/chartpresenter_p.h>
23 #include <QtCharts/QChart>
23 #include <QtCharts/QChart>
24 #include <private/qchart_p.h>
24 #include <private/qchart_p.h>
25 #include <QtCharts/QValueAxis>
25 #include <QtCharts/QValueAxis>
26 #include <QtCharts/QBarCategoryAxis>
26 #include <QtCharts/QBarCategoryAxis>
27 #include <private/qvalueaxis_p.h>
27 #include <private/qvalueaxis_p.h>
28 #include <QtCharts/QCategoryAxis>
28 #include <QtCharts/QCategoryAxis>
29 #include <private/qabstractseries_p.h>
29 #include <private/qabstractseries_p.h>
30 #include <QtCharts/QAbstractBarSeries>
30 #include <QtCharts/QAbstractBarSeries>
31 #include <QtCharts/QStackedBarSeries>
31 #include <QtCharts/QStackedBarSeries>
32 #include <QtCharts/QPercentBarSeries>
32 #include <QtCharts/QPercentBarSeries>
33 #include <QtCharts/QPieSeries>
33 #include <QtCharts/QPieSeries>
34 #include <private/chartitem_p.h>
34 #include <private/chartitem_p.h>
35 #include <private/xydomain_p.h>
35 #include <private/xydomain_p.h>
36 #include <private/xypolardomain_p.h>
36 #include <private/xypolardomain_p.h>
37 #include <private/xlogydomain_p.h>
37 #include <private/xlogydomain_p.h>
38 #include <private/logxydomain_p.h>
38 #include <private/logxydomain_p.h>
39 #include <private/logxlogydomain_p.h>
39 #include <private/logxlogydomain_p.h>
40 #include <private/xlogypolardomain_p.h>
40 #include <private/xlogypolardomain_p.h>
41 #include <private/logxypolardomain_p.h>
41 #include <private/logxypolardomain_p.h>
42 #include <private/logxlogypolardomain_p.h>
42 #include <private/logxlogypolardomain_p.h>
43
43
44 #ifndef QT_ON_ARM
44 #ifndef QT_ON_ARM
45 #include <QtCharts/QDateTimeAxis>
45 #include <QtCharts/QDateTimeAxis>
46 #endif
46 #endif
47
47
48 QT_CHARTS_BEGIN_NAMESPACE
48 QT_CHARTS_BEGIN_NAMESPACE
49
49
50 ChartDataSet::ChartDataSet(QChart *chart)
50 ChartDataSet::ChartDataSet(QChart *chart)
51 : QObject(chart),
51 : QObject(chart),
52 m_chart(chart)
52 m_chart(chart)
53 {
53 {
54
54
55 }
55 }
56
56
57 ChartDataSet::~ChartDataSet()
57 ChartDataSet::~ChartDataSet()
58 {
58 {
59 deleteAllSeries();
59 deleteAllSeries();
60 deleteAllAxes();
60 deleteAllAxes();
61 }
61 }
62
62
63 /*
63 /*
64 * This method adds series to chartdataset, series ownership is taken from caller.
64 * This method adds series to chartdataset, series ownership is taken from caller.
65 */
65 */
66 void ChartDataSet::addSeries(QAbstractSeries *series)
66 void ChartDataSet::addSeries(QAbstractSeries *series)
67 {
67 {
68 if (m_seriesList.contains(series)) {
68 if (m_seriesList.contains(series)) {
69 qWarning() << QObject::tr("Can not add series. Series already on the chart.");
69 qWarning() << QObject::tr("Can not add series. Series already on the chart.");
70 return;
70 return;
71 }
71 }
72
72
73 // Ignore unsupported series added to polar chart
73 // Ignore unsupported series added to polar chart
74 if (m_chart && m_chart->chartType() == QChart::ChartTypePolar) {
74 if (m_chart && m_chart->chartType() == QChart::ChartTypePolar) {
75 if (!(series->type() == QAbstractSeries::SeriesTypeArea
75 if (!(series->type() == QAbstractSeries::SeriesTypeArea
76 || series->type() == QAbstractSeries::SeriesTypeLine
76 || series->type() == QAbstractSeries::SeriesTypeLine
77 || series->type() == QAbstractSeries::SeriesTypeScatter
77 || series->type() == QAbstractSeries::SeriesTypeScatter
78 || series->type() == QAbstractSeries::SeriesTypeSpline)) {
78 || series->type() == QAbstractSeries::SeriesTypeSpline)) {
79 qWarning() << QObject::tr("Can not add series. Series type is not supported by a polar chart.");
79 qWarning() << QObject::tr("Can not add series. Series type is not supported by a polar chart.");
80 return;
80 return;
81 }
81 }
82 series->d_ptr->setDomain(new XYPolarDomain());
82 series->d_ptr->setDomain(new XYPolarDomain());
83 } else {
83 } else {
84 series->d_ptr->setDomain(new XYDomain());
84 series->d_ptr->setDomain(new XYDomain());
85 }
85 }
86
86
87 series->d_ptr->initializeDomain();
87 series->d_ptr->initializeDomain();
88 m_seriesList.append(series);
88 m_seriesList.append(series);
89
89
90 series->setParent(this); // take ownership
90 series->setParent(this); // take ownership
91 series->d_ptr->m_chart = m_chart;
91 series->d_ptr->m_chart = m_chart;
92
92
93 emit seriesAdded(series);
93 emit seriesAdded(series);
94 }
94 }
95
95
96 /*
96 /*
97 * This method adds axis to chartdataset, axis ownership is taken from caller.
97 * This method adds axis to chartdataset, axis ownership is taken from caller.
98 */
98 */
99 void ChartDataSet::addAxis(QAbstractAxis *axis, Qt::Alignment aligment)
99 void ChartDataSet::addAxis(QAbstractAxis *axis, Qt::Alignment aligment)
100 {
100 {
101 if (m_axisList.contains(axis)) {
101 if (m_axisList.contains(axis)) {
102 qWarning() << QObject::tr("Can not add axis. Axis already on the chart.");
102 qWarning() << QObject::tr("Can not add axis. Axis already on the chart.");
103 return;
103 return;
104 }
104 }
105
105
106 axis->d_ptr->setAlignment(aligment);
106 axis->d_ptr->setAlignment(aligment);
107
107
108 if (!axis->alignment()) {
108 if (!axis->alignment()) {
109 qWarning() << QObject::tr("No alignment specified !");
109 qWarning() << QObject::tr("No alignment specified !");
110 return;
110 return;
111 };
111 };
112
112
113 AbstractDomain *newDomain;
113 AbstractDomain *newDomain;
114 if (m_chart && m_chart->chartType() == QChart::ChartTypePolar)
114 if (m_chart && m_chart->chartType() == QChart::ChartTypePolar)
115 newDomain = new XYPolarDomain();
115 newDomain = new XYPolarDomain();
116 else
116 else
117 newDomain = new XYDomain();
117 newDomain = new XYDomain();
118
118
119 QSharedPointer<AbstractDomain> domain(newDomain);
119 QSharedPointer<AbstractDomain> domain(newDomain);
120 axis->d_ptr->initializeDomain(domain.data());
120 axis->d_ptr->initializeDomain(domain.data());
121
121
122 axis->setParent(this);
122 axis->setParent(this);
123 axis->d_ptr->m_chart = m_chart;
123 axis->d_ptr->m_chart = m_chart;
124 m_axisList.append(axis);
124 m_axisList.append(axis);
125
125
126 emit axisAdded(axis);
126 emit axisAdded(axis);
127 }
127 }
128
128
129 /*
129 /*
130 * This method removes series form chartdataset, series ownership is passed back to caller.
130 * This method removes series form chartdataset, series ownership is passed back to caller.
131 */
131 */
132 void ChartDataSet::removeSeries(QAbstractSeries *series)
132 void ChartDataSet::removeSeries(QAbstractSeries *series)
133 {
133 {
134
134
135 if (! m_seriesList.contains(series)) {
135 if (! m_seriesList.contains(series)) {
136 qWarning() << QObject::tr("Can not remove series. Series not found on the chart.");
136 qWarning() << QObject::tr("Can not remove series. Series not found on the chart.");
137 return;
137 return;
138 }
138 }
139
139
140 QList<QAbstractAxis*> axes = series->d_ptr->m_axes;
140 QList<QAbstractAxis*> axes = series->d_ptr->m_axes;
141
141
142 foreach(QAbstractAxis* axis, axes) {
142 foreach(QAbstractAxis* axis, axes) {
143 detachAxis(series,axis);
143 detachAxis(series,axis);
144 }
144 }
145
145
146 emit seriesRemoved(series);
146 emit seriesRemoved(series);
147 m_seriesList.removeAll(series);
147 m_seriesList.removeAll(series);
148
148
149 // Reset domain to default
149 // Reset domain to default
150 series->d_ptr->setDomain(new XYDomain());
150 series->d_ptr->setDomain(new XYDomain());
151 series->setParent(0);
151 series->setParent(0);
152 series->d_ptr->m_chart = 0;
152 series->d_ptr->m_chart = 0;
153 }
153 }
154
154
155 /*
155 /*
156 * This method removes axis form chartdataset, series ownership is passed back to caller.
156 * This method removes axis form chartdataset, series ownership is passed back to caller.
157 */
157 */
158 void ChartDataSet::removeAxis(QAbstractAxis *axis)
158 void ChartDataSet::removeAxis(QAbstractAxis *axis)
159 {
159 {
160 if (! m_axisList.contains(axis)) {
160 if (! m_axisList.contains(axis)) {
161 qWarning() << QObject::tr("Can not remove axis. Axis not found on the chart.");
161 qWarning() << QObject::tr("Can not remove axis. Axis not found on the chart.");
162 return;
162 return;
163 }
163 }
164
164
165 QList<QAbstractSeries*> series = axis->d_ptr->m_series;
165 QList<QAbstractSeries*> series = axis->d_ptr->m_series;
166
166
167 foreach(QAbstractSeries* s, series) {
167 foreach(QAbstractSeries* s, series) {
168 detachAxis(s,axis);
168 detachAxis(s,axis);
169 }
169 }
170
170
171 emit axisRemoved(axis);
171 emit axisRemoved(axis);
172 m_axisList.removeAll(axis);
172 m_axisList.removeAll(axis);
173
173
174 axis->setParent(0);
174 axis->setParent(0);
175 axis->d_ptr->m_chart = 0;
175 axis->d_ptr->m_chart = 0;
176 }
176 }
177
177
178 /*
178 /*
179 * This method attaches axis to series, return true if success.
179 * This method attaches axis to series, return true if success.
180 */
180 */
181 bool ChartDataSet::attachAxis(QAbstractSeries *series,QAbstractAxis *axis)
181 bool ChartDataSet::attachAxis(QAbstractSeries *series,QAbstractAxis *axis)
182 {
182 {
183 Q_ASSERT(axis);
183 Q_ASSERT(axis);
184
184
185 if (!series)
185 if (!series)
186 return false;
186 return false;
187
187
188 QList<QAbstractSeries *> attachedSeriesList = axis->d_ptr->m_series;
188 QList<QAbstractSeries *> attachedSeriesList = axis->d_ptr->m_series;
189 QList<QAbstractAxis *> attachedAxisList = series->d_ptr->m_axes;
189 QList<QAbstractAxis *> attachedAxisList = series->d_ptr->m_axes;
190
190
191 if (!m_seriesList.contains(series)) {
191 if (!m_seriesList.contains(series)) {
192 qWarning() << QObject::tr("Can not find series on the chart.");
192 qWarning() << QObject::tr("Can not find series on the chart.");
193 return false;
193 return false;
194 }
194 }
195
195
196 if (axis && !m_axisList.contains(axis)) {
196 if (axis && !m_axisList.contains(axis)) {
197 qWarning() << QObject::tr("Can not find axis on the chart.");
197 qWarning() << QObject::tr("Can not find axis on the chart.");
198 return false;
198 return false;
199 }
199 }
200
200
201 if (attachedAxisList.contains(axis)) {
201 if (attachedAxisList.contains(axis)) {
202 qWarning() << QObject::tr("Axis already attached to series.");
202 qWarning() << QObject::tr("Axis already attached to series.");
203 return false;
203 return false;
204 }
204 }
205
205
206 if (attachedSeriesList.contains(series)) {
206 if (attachedSeriesList.contains(series)) {
207 qWarning() << QObject::tr("Axis already attached to series.");
207 qWarning() << QObject::tr("Axis already attached to series.");
208 return false;
208 return false;
209 }
209 }
210
210
211 AbstractDomain *domain = series->d_ptr->domain();
211 AbstractDomain *domain = series->d_ptr->domain();
212 AbstractDomain::DomainType type = selectDomain(attachedAxisList<<axis);
212 AbstractDomain::DomainType type = selectDomain(attachedAxisList<<axis);
213
213
214 if (type == AbstractDomain::UndefinedDomain) return false;
214 if (type == AbstractDomain::UndefinedDomain) return false;
215
215
216 if (domain->type() != type) {
216 if (domain->type() != type) {
217 AbstractDomain *old = domain;
217 AbstractDomain *old = domain;
218 domain = createDomain(type);
218 domain = createDomain(type);
219 domain->setRange(old->minX(), old->maxX(), old->minY(), old->maxY());
219 domain->setRange(old->minX(), old->maxX(), old->minY(), old->maxY());
220 // Initialize domain size to old domain size, as it won't get updated
220 // Initialize domain size to old domain size, as it won't get updated
221 // unless geometry changes.
221 // unless geometry changes.
222 domain->setSize(old->size());
222 domain->setSize(old->size());
223 }
223 }
224
224
225 if (!domain)
225 if (!domain)
226 return false;
226 return false;
227
227
228 if (!domain->attachAxis(axis))
228 if (!domain->attachAxis(axis))
229 return false;
229 return false;
230
230
231 QList<AbstractDomain *> blockedDomains;
231 QList<AbstractDomain *> blockedDomains;
232 domain->blockRangeSignals(true);
232 domain->blockRangeSignals(true);
233 blockedDomains << domain;
233 blockedDomains << domain;
234
234
235 if (domain != series->d_ptr->domain()) {
235 if (domain != series->d_ptr->domain()) {
236 foreach (QAbstractAxis *axis, series->d_ptr->m_axes) {
236 foreach (QAbstractAxis *axis, series->d_ptr->m_axes) {
237 series->d_ptr->domain()->detachAxis(axis);
237 series->d_ptr->domain()->detachAxis(axis);
238 domain->attachAxis(axis);
238 domain->attachAxis(axis);
239 foreach (QAbstractSeries *otherSeries, axis->d_ptr->m_series) {
239 foreach (QAbstractSeries *otherSeries, axis->d_ptr->m_series) {
240 if (otherSeries != series && otherSeries->d_ptr->domain()) {
240 if (otherSeries != series && otherSeries->d_ptr->domain()) {
241 if (!otherSeries->d_ptr->domain()->rangeSignalsBlocked()) {
241 if (!otherSeries->d_ptr->domain()->rangeSignalsBlocked()) {
242 otherSeries->d_ptr->domain()->blockRangeSignals(true);
242 otherSeries->d_ptr->domain()->blockRangeSignals(true);
243 blockedDomains << otherSeries->d_ptr->domain();
243 blockedDomains << otherSeries->d_ptr->domain();
244 }
244 }
245 }
245 }
246 }
246 }
247 }
247 }
248 series->d_ptr->setDomain(domain);
248 series->d_ptr->setDomain(domain);
249 series->d_ptr->initializeDomain();
249 series->d_ptr->initializeDomain();
250 }
250 }
251
251
252 series->d_ptr->m_axes<<axis;
252 series->d_ptr->m_axes<<axis;
253 axis->d_ptr->m_series<<series;
253 axis->d_ptr->m_series<<series;
254
254
255 series->d_ptr->initializeAxes();
255 series->d_ptr->initializeAxes();
256 axis->d_ptr->initializeDomain(domain);
256 axis->d_ptr->initializeDomain(domain);
257
257
258 foreach (AbstractDomain *blockedDomain, blockedDomains)
258 foreach (AbstractDomain *blockedDomain, blockedDomains)
259 blockedDomain->blockRangeSignals(false);
259 blockedDomain->blockRangeSignals(false);
260
260
261 return true;
261 return true;
262 }
262 }
263
263
264 /*
264 /*
265 * This method detaches axis to series, return true if success.
265 * This method detaches axis to series, return true if success.
266 */
266 */
267 bool ChartDataSet::detachAxis(QAbstractSeries* series,QAbstractAxis *axis)
267 bool ChartDataSet::detachAxis(QAbstractSeries* series,QAbstractAxis *axis)
268 {
268 {
269 Q_ASSERT(series);
269 Q_ASSERT(series);
270 Q_ASSERT(axis);
270 Q_ASSERT(axis);
271
271
272 QList<QAbstractSeries* > attachedSeriesList = axis->d_ptr->m_series;
272 QList<QAbstractSeries* > attachedSeriesList = axis->d_ptr->m_series;
273 QList<QAbstractAxis* > attachedAxisList = series->d_ptr->m_axes;
273 QList<QAbstractAxis* > attachedAxisList = series->d_ptr->m_axes;
274 AbstractDomain* domain = series->d_ptr->domain();
274 AbstractDomain* domain = series->d_ptr->domain();
275
275
276 if (!m_seriesList.contains(series)) {
276 if (!m_seriesList.contains(series)) {
277 qWarning() << QObject::tr("Can not find series on the chart.");
277 qWarning() << QObject::tr("Can not find series on the chart.");
278 return false;
278 return false;
279 }
279 }
280
280
281 if (axis && !m_axisList.contains(axis)) {
281 if (axis && !m_axisList.contains(axis)) {
282 qWarning() << QObject::tr("Can not find axis on the chart.");
282 qWarning() << QObject::tr("Can not find axis on the chart.");
283 return false;
283 return false;
284 }
284 }
285
285
286 if (!attachedAxisList.contains(axis)) {
286 if (!attachedAxisList.contains(axis)) {
287 qWarning() << QObject::tr("Axis not attached to series.");
287 qWarning() << QObject::tr("Axis not attached to series.");
288 return false;
288 return false;
289 }
289 }
290
290
291 Q_ASSERT(axis->d_ptr->m_series.contains(series));
291 Q_ASSERT(axis->d_ptr->m_series.contains(series));
292
292
293 domain->detachAxis(axis);
293 domain->detachAxis(axis);
294 series->d_ptr->m_axes.removeAll(axis);
294 series->d_ptr->m_axes.removeAll(axis);
295 axis->d_ptr->m_series.removeAll(series);
295 axis->d_ptr->m_series.removeAll(series);
296
296
297 return true;
297 return true;
298 }
298 }
299
299
300 void ChartDataSet::createDefaultAxes()
300 void ChartDataSet::createDefaultAxes()
301 {
301 {
302 if (m_seriesList.isEmpty())
302 if (m_seriesList.isEmpty())
303 return;
303 return;
304
304
305 QAbstractAxis::AxisTypes typeX(0);
305 QAbstractAxis::AxisTypes typeX(0);
306 QAbstractAxis::AxisTypes typeY(0);
306 QAbstractAxis::AxisTypes typeY(0);
307
307
308 // Remove possibly existing axes
308 // Remove possibly existing axes
309 deleteAllAxes();
309 deleteAllAxes();
310
310
311 Q_ASSERT(m_axisList.isEmpty());
311 Q_ASSERT(m_axisList.isEmpty());
312
312
313 // Select the required axis x and axis y types based on the types of the current series
313 // Select the required axis x and axis y types based on the types of the current series
314 foreach(QAbstractSeries* s, m_seriesList) {
314 foreach(QAbstractSeries* s, m_seriesList) {
315 typeX |= s->d_ptr->defaultAxisType(Qt::Horizontal);
315 typeX |= s->d_ptr->defaultAxisType(Qt::Horizontal);
316 typeY |= s->d_ptr->defaultAxisType(Qt::Vertical);
316 typeY |= s->d_ptr->defaultAxisType(Qt::Vertical);
317 }
317 }
318
318
319 // Create the axes of the types selected
319 createAxes(typeX, Qt::Horizontal);
320 // As long as AxisType enum balues are sequential a check to see if there are series of
320 createAxes(typeY, Qt::Vertical);
321 // different types is needed. In such cases AxisTypeNoAxis is used to create separate axes
322 // for the types.
323 if (typeX != QAbstractAxis::AxisTypeNoAxis) {
324 if (typeX != m_seriesList.first()->d_ptr->defaultAxisType(Qt::Horizontal))
325 typeX = QAbstractAxis::AxisTypeNoAxis;
326 createAxes(typeX, Qt::Horizontal);
327 }
328
329 if (typeY != QAbstractAxis::AxisTypeNoAxis) {
330 if (typeY != m_seriesList.first()->d_ptr->defaultAxisType(Qt::Vertical))
331 typeY = QAbstractAxis::AxisTypeNoAxis;
332 createAxes(typeY, Qt::Vertical);
333 }
334
335 }
321 }
336
322
337 void ChartDataSet::createAxes(QAbstractAxis::AxisTypes type, Qt::Orientation orientation)
323 void ChartDataSet::createAxes(QAbstractAxis::AxisTypes type, Qt::Orientation orientation)
338 {
324 {
339 QAbstractAxis *axis = 0;
325 QAbstractAxis *axis = 0;
340 //decide what axis should be created
326 //decide what axis should be created
341
327
342 switch (type) {
328 switch (type) {
343 case QAbstractAxis::AxisTypeValue:
329 case QAbstractAxis::AxisTypeValue:
344 axis = new QValueAxis(this);
330 axis = new QValueAxis(this);
345 break;
331 break;
346 case QAbstractAxis::AxisTypeBarCategory:
332 case QAbstractAxis::AxisTypeBarCategory:
347 axis = new QBarCategoryAxis(this);
333 axis = new QBarCategoryAxis(this);
348 break;
334 break;
349 case QAbstractAxis::AxisTypeCategory:
335 case QAbstractAxis::AxisTypeCategory:
350 axis = new QCategoryAxis(this);
336 axis = new QCategoryAxis(this);
351 break;
337 break;
352 #ifndef Q_WS_QWS
338 #ifndef Q_WS_QWS
353 case QAbstractAxis::AxisTypeDateTime:
339 case QAbstractAxis::AxisTypeDateTime:
354 axis = new QDateTimeAxis(this);
340 axis = new QDateTimeAxis(this);
355 break;
341 break;
356 #endif
342 #endif
357 default:
343 default:
358 axis = 0;
344 axis = 0;
359 break;
345 break;
360 }
346 }
361
347
362 if (axis) {
348 if (axis) {
363 //create one axis for all
349 //create one axis for all
364
350
365 addAxis(axis,orientation==Qt::Horizontal?Qt::AlignBottom:Qt::AlignLeft);
351 addAxis(axis,orientation==Qt::Horizontal?Qt::AlignBottom:Qt::AlignLeft);
366 qreal min = 0;
352 qreal min = 0;
367 qreal max = 0;
353 qreal max = 0;
368 findMinMaxForSeries(m_seriesList,orientation,min,max);
354 findMinMaxForSeries(m_seriesList,orientation,min,max);
369 foreach(QAbstractSeries *s, m_seriesList) {
355 foreach(QAbstractSeries *s, m_seriesList) {
370 attachAxis(s,axis);
356 attachAxis(s,axis);
371 }
357 }
372 axis->setRange(min,max);
358 axis->setRange(min,max);
373 }
359 } else {
374 else if (type.testFlag(QAbstractAxis::AxisTypeNoAxis)) {
360 // Create separate axis for each series
375 //create separate axis
376 foreach(QAbstractSeries *s, m_seriesList) {
361 foreach(QAbstractSeries *s, m_seriesList) {
377 QAbstractAxis *axis = s->d_ptr->createDefaultAxis(orientation);
362 QAbstractAxis *axis = s->d_ptr->createDefaultAxis(orientation);
378 if(axis) {
363 if(axis) {
379 addAxis(axis,orientation==Qt::Horizontal?Qt::AlignBottom:Qt::AlignLeft);
364 addAxis(axis,orientation==Qt::Horizontal?Qt::AlignBottom:Qt::AlignLeft);
380 attachAxis(s,axis);
365 attachAxis(s,axis);
381 }
366 }
382 }
367 }
383 }
368 }
384 }
369 }
385
370
386 void ChartDataSet::findMinMaxForSeries(QList<QAbstractSeries *> series,Qt::Orientations orientation, qreal &min, qreal &max)
371 void ChartDataSet::findMinMaxForSeries(QList<QAbstractSeries *> series,Qt::Orientations orientation, qreal &min, qreal &max)
387 {
372 {
388 Q_ASSERT(!series.isEmpty());
373 Q_ASSERT(!series.isEmpty());
389
374
390 AbstractDomain *domain = series.first()->d_ptr->domain();
375 AbstractDomain *domain = series.first()->d_ptr->domain();
391 min = (orientation == Qt::Vertical) ? domain->minY() : domain->minX();
376 min = (orientation == Qt::Vertical) ? domain->minY() : domain->minX();
392 max = (orientation == Qt::Vertical) ? domain->maxY() : domain->maxX();
377 max = (orientation == Qt::Vertical) ? domain->maxY() : domain->maxX();
393
378
394 for (int i = 1; i< series.size(); i++) {
379 for (int i = 1; i< series.size(); i++) {
395 AbstractDomain *domain = series[i]->d_ptr->domain();
380 AbstractDomain *domain = series[i]->d_ptr->domain();
396 min = qMin((orientation == Qt::Vertical) ? domain->minY() : domain->minX(), min);
381 min = qMin((orientation == Qt::Vertical) ? domain->minY() : domain->minX(), min);
397 max = qMax((orientation == Qt::Vertical) ? domain->maxY() : domain->maxX(), max);
382 max = qMax((orientation == Qt::Vertical) ? domain->maxY() : domain->maxX(), max);
398 }
383 }
399 if (min == max) {
384 if (min == max) {
400 min -= 0.5;
385 min -= 0.5;
401 max += 0.5;
386 max += 0.5;
402 }
387 }
403 }
388 }
404
389
405 void ChartDataSet::deleteAllSeries()
390 void ChartDataSet::deleteAllSeries()
406 {
391 {
407 foreach (QAbstractSeries *s , m_seriesList){
392 foreach (QAbstractSeries *s , m_seriesList){
408 removeSeries(s);
393 removeSeries(s);
409 s->deleteLater();
394 s->deleteLater();
410 }
395 }
411 Q_ASSERT(m_seriesList.count() == 0);
396 Q_ASSERT(m_seriesList.count() == 0);
412 }
397 }
413
398
414 void ChartDataSet::deleteAllAxes()
399 void ChartDataSet::deleteAllAxes()
415 {
400 {
416 foreach (QAbstractAxis *a , m_axisList){
401 foreach (QAbstractAxis *a , m_axisList){
417 removeAxis(a);
402 removeAxis(a);
418 a->deleteLater();
403 a->deleteLater();
419 }
404 }
420 Q_ASSERT(m_axisList.count() == 0);
405 Q_ASSERT(m_axisList.count() == 0);
421 }
406 }
422
407
423 void ChartDataSet::zoomInDomain(const QRectF &rect)
408 void ChartDataSet::zoomInDomain(const QRectF &rect)
424 {
409 {
425 QList<AbstractDomain*> domains;
410 QList<AbstractDomain*> domains;
426 foreach(QAbstractSeries *s, m_seriesList) {
411 foreach(QAbstractSeries *s, m_seriesList) {
427 AbstractDomain* domain = s->d_ptr->domain();
412 AbstractDomain* domain = s->d_ptr->domain();
428 s->d_ptr->m_domain->blockRangeSignals(true);
413 s->d_ptr->m_domain->blockRangeSignals(true);
429 domains<<domain;
414 domains<<domain;
430 }
415 }
431
416
432 foreach(AbstractDomain *domain, domains)
417 foreach(AbstractDomain *domain, domains)
433 domain->zoomIn(rect);
418 domain->zoomIn(rect);
434
419
435 foreach(AbstractDomain *domain, domains)
420 foreach(AbstractDomain *domain, domains)
436 domain->blockRangeSignals(false);
421 domain->blockRangeSignals(false);
437 }
422 }
438
423
439 void ChartDataSet::zoomOutDomain(const QRectF &rect)
424 void ChartDataSet::zoomOutDomain(const QRectF &rect)
440 {
425 {
441 QList<AbstractDomain*> domains;
426 QList<AbstractDomain*> domains;
442 foreach(QAbstractSeries *s, m_seriesList) {
427 foreach(QAbstractSeries *s, m_seriesList) {
443 AbstractDomain* domain = s->d_ptr->domain();
428 AbstractDomain* domain = s->d_ptr->domain();
444 s->d_ptr->m_domain->blockRangeSignals(true);
429 s->d_ptr->m_domain->blockRangeSignals(true);
445 domains<<domain;
430 domains<<domain;
446 }
431 }
447
432
448 foreach(AbstractDomain *domain, domains)
433 foreach(AbstractDomain *domain, domains)
449 domain->zoomOut(rect);
434 domain->zoomOut(rect);
450
435
451 foreach(AbstractDomain *domain, domains)
436 foreach(AbstractDomain *domain, domains)
452 domain->blockRangeSignals(false);
437 domain->blockRangeSignals(false);
453 }
438 }
454
439
455 void ChartDataSet::zoomResetDomain()
440 void ChartDataSet::zoomResetDomain()
456 {
441 {
457 QList<AbstractDomain*> domains;
442 QList<AbstractDomain*> domains;
458 foreach (QAbstractSeries *s, m_seriesList) {
443 foreach (QAbstractSeries *s, m_seriesList) {
459 AbstractDomain *domain = s->d_ptr->domain();
444 AbstractDomain *domain = s->d_ptr->domain();
460 s->d_ptr->m_domain->blockRangeSignals(true);
445 s->d_ptr->m_domain->blockRangeSignals(true);
461 domains << domain;
446 domains << domain;
462 }
447 }
463
448
464 foreach (AbstractDomain *domain, domains)
449 foreach (AbstractDomain *domain, domains)
465 domain->zoomReset();
450 domain->zoomReset();
466
451
467 foreach (AbstractDomain *domain, domains)
452 foreach (AbstractDomain *domain, domains)
468 domain->blockRangeSignals(false);
453 domain->blockRangeSignals(false);
469 }
454 }
470
455
471 bool ChartDataSet::isZoomedDomain()
456 bool ChartDataSet::isZoomedDomain()
472 {
457 {
473 foreach (QAbstractSeries *s, m_seriesList) {
458 foreach (QAbstractSeries *s, m_seriesList) {
474 if (s->d_ptr->domain()->isZoomed())
459 if (s->d_ptr->domain()->isZoomed())
475 return true;
460 return true;
476 }
461 }
477 return false;
462 return false;
478 }
463 }
479
464
480 void ChartDataSet::scrollDomain(qreal dx, qreal dy)
465 void ChartDataSet::scrollDomain(qreal dx, qreal dy)
481 {
466 {
482 QList<AbstractDomain*> domains;
467 QList<AbstractDomain*> domains;
483 foreach(QAbstractSeries *s, m_seriesList) {
468 foreach(QAbstractSeries *s, m_seriesList) {
484 AbstractDomain* domain = s->d_ptr->domain();
469 AbstractDomain* domain = s->d_ptr->domain();
485 s->d_ptr->m_domain->blockRangeSignals(true);
470 s->d_ptr->m_domain->blockRangeSignals(true);
486 domains<<domain;
471 domains<<domain;
487 }
472 }
488
473
489 foreach(AbstractDomain *domain, domains)
474 foreach(AbstractDomain *domain, domains)
490 domain->move(dx, dy);
475 domain->move(dx, dy);
491
476
492 foreach(AbstractDomain *domain, domains)
477 foreach(AbstractDomain *domain, domains)
493 domain->blockRangeSignals(false);
478 domain->blockRangeSignals(false);
494 }
479 }
495
480
496 QPointF ChartDataSet::mapToValue(const QPointF &position, QAbstractSeries *series)
481 QPointF ChartDataSet::mapToValue(const QPointF &position, QAbstractSeries *series)
497 {
482 {
498 QPointF point;
483 QPointF point;
499 if (series == 0 && !m_seriesList.isEmpty())
484 if (series == 0 && !m_seriesList.isEmpty())
500 series = m_seriesList.first();
485 series = m_seriesList.first();
501
486
502 if (series && series->type() == QAbstractSeries::SeriesTypePie)
487 if (series && series->type() == QAbstractSeries::SeriesTypePie)
503 return point;
488 return point;
504
489
505 if (series && m_seriesList.contains(series))
490 if (series && m_seriesList.contains(series))
506 point = series->d_ptr->m_domain->calculateDomainPoint(position - m_chart->plotArea().topLeft());
491 point = series->d_ptr->m_domain->calculateDomainPoint(position - m_chart->plotArea().topLeft());
507 return point;
492 return point;
508 }
493 }
509
494
510 QPointF ChartDataSet::mapToPosition(const QPointF &value, QAbstractSeries *series)
495 QPointF ChartDataSet::mapToPosition(const QPointF &value, QAbstractSeries *series)
511 {
496 {
512 QPointF point = m_chart->plotArea().topLeft();
497 QPointF point = m_chart->plotArea().topLeft();
513 if (series == 0 && !m_seriesList.isEmpty())
498 if (series == 0 && !m_seriesList.isEmpty())
514 series = m_seriesList.first();
499 series = m_seriesList.first();
515
500
516 if (series && series->type() == QAbstractSeries::SeriesTypePie)
501 if (series && series->type() == QAbstractSeries::SeriesTypePie)
517 return QPoint(0, 0);
502 return QPoint(0, 0);
518
503
519 bool ok;
504 bool ok;
520 if (series && m_seriesList.contains(series))
505 if (series && m_seriesList.contains(series))
521 point += series->d_ptr->m_domain->calculateGeometryPoint(value, ok);
506 point += series->d_ptr->m_domain->calculateGeometryPoint(value, ok);
522 return point;
507 return point;
523 }
508 }
524
509
525 QList<QAbstractAxis *> ChartDataSet::axes() const
510 QList<QAbstractAxis *> ChartDataSet::axes() const
526 {
511 {
527 return m_axisList;
512 return m_axisList;
528 }
513 }
529
514
530 QList<QAbstractSeries *> ChartDataSet::series() const
515 QList<QAbstractSeries *> ChartDataSet::series() const
531 {
516 {
532 return m_seriesList;
517 return m_seriesList;
533 }
518 }
534
519
535 AbstractDomain::DomainType ChartDataSet::selectDomain(QList<QAbstractAxis *> axes)
520 AbstractDomain::DomainType ChartDataSet::selectDomain(QList<QAbstractAxis *> axes)
536 {
521 {
537 enum Type {
522 enum Type {
538 Undefined = 0,
523 Undefined = 0,
539 LogType = 0x1,
524 LogType = 0x1,
540 ValueType = 0x2
525 ValueType = 0x2
541 };
526 };
542
527
543 int horizontal(Undefined);
528 int horizontal(Undefined);
544 int vertical(Undefined);
529 int vertical(Undefined);
545
530
546 // Assume cartesian chart type, unless chart is set
531 // Assume cartesian chart type, unless chart is set
547 QChart::ChartType chartType(QChart::ChartTypeCartesian);
532 QChart::ChartType chartType(QChart::ChartTypeCartesian);
548 if (m_chart)
533 if (m_chart)
549 chartType = m_chart->chartType();
534 chartType = m_chart->chartType();
550
535
551 foreach (QAbstractAxis *axis, axes)
536 foreach (QAbstractAxis *axis, axes)
552 {
537 {
553 switch (axis->type()) {
538 switch (axis->type()) {
554 case QAbstractAxis::AxisTypeLogValue:
539 case QAbstractAxis::AxisTypeLogValue:
555 if (axis->orientation() == Qt::Horizontal)
540 if (axis->orientation() == Qt::Horizontal)
556 horizontal |= LogType;
541 horizontal |= LogType;
557 if (axis->orientation() == Qt::Vertical)
542 if (axis->orientation() == Qt::Vertical)
558 vertical |= LogType;
543 vertical |= LogType;
559 break;
544 break;
560 case QAbstractAxis::AxisTypeValue:
545 case QAbstractAxis::AxisTypeValue:
561 case QAbstractAxis::AxisTypeBarCategory:
546 case QAbstractAxis::AxisTypeBarCategory:
562 case QAbstractAxis::AxisTypeCategory:
547 case QAbstractAxis::AxisTypeCategory:
563 case QAbstractAxis::AxisTypeDateTime:
548 case QAbstractAxis::AxisTypeDateTime:
564 if (axis->orientation() == Qt::Horizontal)
549 if (axis->orientation() == Qt::Horizontal)
565 horizontal |= ValueType;
550 horizontal |= ValueType;
566 if (axis->orientation() == Qt::Vertical)
551 if (axis->orientation() == Qt::Vertical)
567 vertical |= ValueType;
552 vertical |= ValueType;
568 break;
553 break;
569 default:
554 default:
570 qWarning() << "Undefined type";
555 qWarning() << "Undefined type";
571 break;
556 break;
572 }
557 }
573 }
558 }
574
559
575 if (vertical == Undefined)
560 if (vertical == Undefined)
576 vertical = ValueType;
561 vertical = ValueType;
577 if (horizontal == Undefined)
562 if (horizontal == Undefined)
578 horizontal = ValueType;
563 horizontal = ValueType;
579
564
580 if (vertical == ValueType && horizontal == ValueType) {
565 if (vertical == ValueType && horizontal == ValueType) {
581 if (chartType == QChart::ChartTypeCartesian)
566 if (chartType == QChart::ChartTypeCartesian)
582 return AbstractDomain::XYDomain;
567 return AbstractDomain::XYDomain;
583 else if (chartType == QChart::ChartTypePolar)
568 else if (chartType == QChart::ChartTypePolar)
584 return AbstractDomain::XYPolarDomain;
569 return AbstractDomain::XYPolarDomain;
585 }
570 }
586
571
587 if (vertical == LogType && horizontal == ValueType) {
572 if (vertical == LogType && horizontal == ValueType) {
588 if (chartType == QChart::ChartTypeCartesian)
573 if (chartType == QChart::ChartTypeCartesian)
589 return AbstractDomain::XLogYDomain;
574 return AbstractDomain::XLogYDomain;
590 if (chartType == QChart::ChartTypePolar)
575 if (chartType == QChart::ChartTypePolar)
591 return AbstractDomain::XLogYPolarDomain;
576 return AbstractDomain::XLogYPolarDomain;
592 }
577 }
593
578
594 if (vertical == ValueType && horizontal == LogType) {
579 if (vertical == ValueType && horizontal == LogType) {
595 if (chartType == QChart::ChartTypeCartesian)
580 if (chartType == QChart::ChartTypeCartesian)
596 return AbstractDomain::LogXYDomain;
581 return AbstractDomain::LogXYDomain;
597 else if (chartType == QChart::ChartTypePolar)
582 else if (chartType == QChart::ChartTypePolar)
598 return AbstractDomain::LogXYPolarDomain;
583 return AbstractDomain::LogXYPolarDomain;
599 }
584 }
600
585
601 if (vertical == LogType && horizontal == LogType) {
586 if (vertical == LogType && horizontal == LogType) {
602 if (chartType == QChart::ChartTypeCartesian)
587 if (chartType == QChart::ChartTypeCartesian)
603 return AbstractDomain::LogXLogYDomain;
588 return AbstractDomain::LogXLogYDomain;
604 else if (chartType == QChart::ChartTypePolar)
589 else if (chartType == QChart::ChartTypePolar)
605 return AbstractDomain::LogXLogYPolarDomain;
590 return AbstractDomain::LogXLogYPolarDomain;
606 }
591 }
607
592
608 return AbstractDomain::UndefinedDomain;
593 return AbstractDomain::UndefinedDomain;
609 }
594 }
610
595
611 //refactor create factory
596 //refactor create factory
612 AbstractDomain* ChartDataSet::createDomain(AbstractDomain::DomainType type)
597 AbstractDomain* ChartDataSet::createDomain(AbstractDomain::DomainType type)
613 {
598 {
614 switch (type)
599 switch (type)
615 {
600 {
616 case AbstractDomain::LogXLogYDomain:
601 case AbstractDomain::LogXLogYDomain:
617 return new LogXLogYDomain();
602 return new LogXLogYDomain();
618 case AbstractDomain::XYDomain:
603 case AbstractDomain::XYDomain:
619 return new XYDomain();
604 return new XYDomain();
620 case AbstractDomain::XLogYDomain:
605 case AbstractDomain::XLogYDomain:
621 return new XLogYDomain();
606 return new XLogYDomain();
622 case AbstractDomain::LogXYDomain:
607 case AbstractDomain::LogXYDomain:
623 return new LogXYDomain();
608 return new LogXYDomain();
624 case AbstractDomain::XYPolarDomain:
609 case AbstractDomain::XYPolarDomain:
625 return new XYPolarDomain();
610 return new XYPolarDomain();
626 case AbstractDomain::XLogYPolarDomain:
611 case AbstractDomain::XLogYPolarDomain:
627 return new XLogYPolarDomain();
612 return new XLogYPolarDomain();
628 case AbstractDomain::LogXYPolarDomain:
613 case AbstractDomain::LogXYPolarDomain:
629 return new LogXYPolarDomain();
614 return new LogXYPolarDomain();
630 case AbstractDomain::LogXLogYPolarDomain:
615 case AbstractDomain::LogXLogYPolarDomain:
631 return new LogXLogYPolarDomain();
616 return new LogXLogYPolarDomain();
632 default:
617 default:
633 return 0;
618 return 0;
634 }
619 }
635 }
620 }
636
621
637 #include "moc_chartdataset_p.cpp"
622 #include "moc_chartdataset_p.cpp"
638
623
639 QT_CHARTS_END_NAMESPACE
624 QT_CHARTS_END_NAMESPACE
General Comments 0
You need to be logged in to leave comments. Login now