##// END OF EJS Templates
Added missing properties to QAxis
Tero Ahola -
r1449:e88bf0c8e17d
parent child
Show More
@@ -9,6 +9,7
9 <ul>
9 <ul>
10 <li><a href="qml-chartview.html">ChartView</a></li>
10 <li><a href="qml-chartview.html">ChartView</a></li>
11 <li><a href="qml-pieseries.html">PieSeries</a></li>
11 <li><a href="qml-pieseries.html">PieSeries</a></li>
12 <li><a href="qml-axis.html">Axis</a></li>
12 </ul>
13 </ul>
13 \endraw
14 \endraw
14 */
15 */
@@ -310,7 +310,7 void ChartAxis::handleAxisUpdated()
310 }
310 }
311
311
312 if (m_chartAxis->shadesVisible()) {
312 if (m_chartAxis->shadesVisible()) {
313 setShadesOpacity(m_chartAxis->shadesOpacity());
313 setShadesOpacity(100);
314 } else {
314 } else {
315 setShadesOpacity(0);
315 setShadesOpacity(0);
316 }
316 }
@@ -30,151 +30,217 QTCOMMERCIALCHART_BEGIN_NAMESPACE
30 \mainclass
30 \mainclass
31
31
32 There is only one x Axis, however there can be multiple y axes.
32 There is only one x Axis, however there can be multiple y axes.
33 Each chart series can be bound to exactly one Y axis and the share common X axis.
33 Each chart series can be bound to exactly one Y axis and the shared common X axis.
34 Axis can be setup to show axis line with ticks, gird lines and shades.
34 Axis can be setup to show axis line with tick marks, grid lines and shades.
35 */
36
37 /*!
38 \qmlclass Axis QAxis
39 \brief The Axis element is used for manipulating chart's axes
35
40
41 There is only one x Axis, however there can be multiple y axes on a ChartView.
42 Each chart series can be bound to exactly one Y axis and the shared common X axis.
43 Axis can be setup to show axis line with tick marks, grid lines and shades.
36 */
44 */
37
45
38 /*!
46 /*!
39 \property QAxis::labelsVisible
47 \property QAxis::labelsVisible
40
48 Defines if axis labels are visible.
49 */
50 /*!
51 \qmlproperty bool Axis::labelsVisible
41 Defines if axis labels are visible.
52 Defines if axis labels are visible.
42 */
53 */
43
54
44 /*!
55 /*!
45 \property QAxis::min
56 \property QAxis::min
46
57 Defines the minimum value on the axis.
58 */
59 /*!
60 \qmlproperty real Axis::min
47 Defines the minimum value on the axis.
61 Defines the minimum value on the axis.
48 */
62 */
49
63
50 /*!
64 /*!
51 \property QAxis::max
65 \property QAxis::max
52
66 Defines the maximum value on the axis.
67 */
68 /*!
69 \qmlproperty real Axis::max
53 Defines the maximum value on the axis.
70 Defines the maximum value on the axis.
54 */
71 */
55
72
56 /*!
73 /*!
57 \fn bool QAxis::isAxisVisible() const
74 \property QAxis::visible
58 \brief Returns if axis is visible
75 The visibility of the axis.
59 \sa setAxisVisible()
76 */
77 /*!
78 \qmlproperty bool Axis::visible
79 The visibility of the axis.
60 */
80 */
61
81
62 /*!
82 /*!
63 \fn QPen QAxis::axisPen() const
83 \property QAxis::gridVisible
64 \brief Returns pen used to draw axis and ticks.
84 The visibility of the grid lines.
65 \sa setAxisPen()
85 */
86 /*!
87 \qmlproperty bool Axis::gridVisible
88 The visibility of the grid lines.
66 */
89 */
67
90
91 /*!
92 \property QAxis::color
93 The color of the axis and ticks.
94 */
95 /*!
96 \qmlproperty color Axis::color
97 The color of the axis and ticks.
98 */
68
99
69 /*!
100 /*!
70 \fn bool QAxis::isGridLineVisible() const
101 \property QAxis::labelsColor
71 \brief Returns if grid is visible
102 The color of the axis labels.
72 \sa setGridLineVisible()
103 */
104 /*!
105 \qmlproperty color Axis::labelsColor
106 The color of the axis labels.
73 */
107 */
74
108
75 /*!
109 /*!
76 \fn QPen QAxis::gridLinePen() const
110 \property QAxis::labelsAngle
77 \brief Returns pen used to draw grid.
111 The angle of the axis labels in degrees.
78 \sa setGridLinePen()
112 */
113 /*!
114 \qmlproperty int Axis::labelsAngle
115 The angle of the axis labels in degrees.
79 */
116 */
80
117
81 /*!
118 /*!
82 \fn QPen QAxis::labelsPen() const
119 \property QAxis::shadesVisible
83 \brief Returns the pen used to labels.
120 The visibility of the axis shades.
84 \sa setLabelsPen()
121 */
122 /*!
123 \qmlproperty bool Axis::shadesVisible
124 The visibility of the axis shades.
85 */
125 */
86
126
87 /*!
127 /*!
88 \fn QBrush QAxis::labelsBrush() const
128 \property QAxis::shadesColor
89 \brief Returns brush used to draw labels.
129 The fill (brush) color of the axis shades.
90 \sa setLabelsBrush()
130 */
131 /*!
132 \qmlproperty color Axis::shadesColor
133 The fill (brush) color of the axis shades.
91 */
134 */
92
135
93 /*!
136 /*!
94 \fn QFont QAxis::labelsFont() const
137 \property QAxis::shadesBorderColor
95 \brief Returns font used to draw labels.
138 The border (pen) color of the axis shades.
96 \sa setLabelsFont()
139 */
140 /*!
141 \qmlproperty color Axis::shadesBorderColor
142 The border (pen) color of the axis shades.
97 */
143 */
98
144
99 /*!
145 /*!
100 \fn QFont QAxis::labelsAngle() const
146 \property QAxis::ticksCount
101 \brief Returns angle used to draw labels.
147 The number of tick marks for the axis.
102 \sa setLabelsAngle()
148 */
149 /*!
150 \qmlproperty int Axis::ticksCount
151 The number of tick marks for the axis.
103 */
152 */
104
153
105 /*!
154 /*!
106 \fn bool QAxis::shadesVisible() const
155 \property QAxis::niceNumbersEnabled
107 \brief Returns if shades are visible.
156 Whether the nice numbers algorithm is enabled or not for the axis.
108 \sa setShadesVisible()
157 */
158 /*!
159 \qmlproperty bool Axis::niceNumbersEnabled
160 Whether the nice numbers algorithm is enabled or not for the axis.
109 */
161 */
110
162
111 /*!
163 /*!
112 \fn qreal QAxis::shadesOpacity() const
164 \fn void QAxis::visibleChanged(bool)
113 \brief Returns opacity of shades.
165 Visiblity of the axis has changed to \a visible.
114 */
166 */
115
167
116 /*!
168 /*!
117 \fn QPen QAxis::shadesPen() const
169 \fn void QAxis::labelsVisibleChanged(bool)
118 \brief Returns pen used to draw shades.
170 Visiblity of the labels of the axis has changed to \a visible.
119 \sa setShadesPen()
120 */
171 */
121
172
122 /*!
173 /*!
123 \fn QBrush QAxis::shadesBrush() const
174 \fn void QAxis::gridVisibleChanged(bool)
124 \brief Returns brush used to draw shades.
175 Visiblity of the grid lines of the axis has changed to \a visible.
125 \sa setShadesBrush()
176 */
177
178 /*!
179 \fn void QAxis::minChanged(qreal min)
180 Axis emits signal when \a min of axis has changed.
181 */
182
183 /*!
184 \fn void QAxis::maxChanged(qreal max)
185 Axis emits signal when \a max of axis has changed.
186 */
187
188 /*!
189 \fn void QAxis::rangeChanged(qreal min, qreal max)
190 Axis emits signal when \a min or \a max of axis has changed.
126 */
191 */
127
192
128 /*!
193 /*!
129 \fn qreal QAxis::min() const
194 \fn QChartAxisCategories* QAxis::categories()
130 \brief Returns minimum value on the axis.
195 Returns pointer to the list of categories which correspond to the values on the axis.
131 \sa setMin()
132 */
196 */
133
197
134 /*!
198 /*!
135 \fn qreal QAxis::max() const
199 \fn void QAxis::colorChanged(QColor)
136 \brief Returns maximim value on the axis.
200 Emitted if the \a color of the axis is changed.
137 \sa setMax()
138 */
201 */
139
202
140 /*!
203 /*!
141 \fn void QAxis::minChanged(qreal min)
204 \fn void QAxis::labelsColorChanged(QColor)
142 \brief Axis emits signal when \a min of axis has changed.
205 Emitted if the \a color of the axis labels is changed.
143 */
206 */
144
207
145 /*!
208 /*!
146 \fn void QAxis::maxChanged(qreal max)
209 \fn void QAxis::labelsAngleChanged(int)
147 \brief Axis emits signal when \a max of axis has changed.
210 Emitted if the \a angle of the axis labels is changed.
148 */
211 */
149
212
150 /*!
213 /*!
151 \fn void QAxis::rangeChanged(qreal min, qreal max)
214 \fn void QAxis::shadesVisibleChanged(bool)
152 \brief Axis emits signal when \a min or \a max of axis has changed.
215 Emitted if the visibility of the axis shades is changed to \a visible.
153 */
216 */
154
217
155 /*!
218 /*!
156 \fn int QAxis::ticksCount() const
219 \fn void QAxis::shadesColorChanged(QColor)
157 \brief Return number of ticks on the axis
220 Emitted if the \a color of the axis shades is changed.
158 \sa setTicksCount()
159 */
221 */
160
222
161 /*!
223 /*!
162 \fn QChartAxisCategories* QAxis::categories()
224 \fn void QAxis::shadesBorderColorChanged(QColor)
163 \brief Returns pointer to the list of categories which correspond to the values on the axis.
225 Emitted if the border \a color of the axis shades is changed.
164 */
226 */
165
227
166 /*!
228 /*!
167 \fn void QAxis::ticksCountChanged(int count)
229 \fn void QAxis::ticksCountChanged(int count)
168 \brief Emits the new \a count of ticks on the axis
230 \brief Emits the new \a count of ticks on the axis
169 Signal is emitted when the number of the ticks on the axis has been changed to a different value.
231 Signal is emitted when the number of the ticks on the axis has been changed to a different value.
170 Parementer count\a count is the new number of ticks on the axis.
232 Parementer count\a count is the new number of ticks on the axis.
171 */
233 */
172
234
173 /*!
235 /*!
174 Constructs new axis object which is a child of \a parent. Ownership is taken by
236 \fn void QAxis::niceNumbersEnabledChanged(bool)
175 QChart when axis added.
237 Nice numbers algorithm was \a enabled or disabled.
176 */
238 */
177
239
240 /*!
241 Constructs new axis object which is a child of \a parent. Ownership is taken by
242 QChart when axis added.
243 */
178 QAxis::QAxis(QObject *parent) : QObject(parent),
244 QAxis::QAxis(QObject *parent) : QObject(parent),
179 d_ptr(new QAxisPrivate(this))
245 d_ptr(new QAxisPrivate(this))
180 {
246 {
@@ -182,7 +248,7 d_ptr(new QAxisPrivate(this))
182 }
248 }
183
249
184 /*!
250 /*!
185 Destructor of the axis object. When axis is added to chart, chart object takes ownership.
251 Destructor of the axis object. When axis is added to chart, chart object takes ownership.
186 */
252 */
187
253
188 QAxis::~QAxis()
254 QAxis::~QAxis()
@@ -200,11 +266,29 void QAxis::setAxisPen(const QPen &pen)
200 }
266 }
201 }
267 }
202
268
269 /*!
270 Returns pen used to draw axis and ticks.
271 */
203 QPen QAxis::axisPen() const
272 QPen QAxis::axisPen() const
204 {
273 {
205 return d_ptr->m_axisPen;
274 return d_ptr->m_axisPen;
206 }
275 }
207
276
277 void QAxis::setAxisPenColor(QColor color)
278 {
279 QPen p = d_ptr->m_axisPen;
280 if (p.color() != color) {
281 p.setColor(color);
282 setAxisPen(p);
283 emit colorChanged(color);
284 }
285 }
286
287 QColor QAxis::axisPenColor() const
288 {
289 return d_ptr->m_axisPen.color();
290 }
291
208 /*!
292 /*!
209 Sets if axis and ticks are \a visible.
293 Sets if axis and ticks are \a visible.
210 */
294 */
@@ -213,6 +297,7 void QAxis::setAxisVisible(bool visible)
213 if (d_ptr->m_axisVisible != visible) {
297 if (d_ptr->m_axisVisible != visible) {
214 d_ptr->m_axisVisible = visible;
298 d_ptr->m_axisVisible = visible;
215 emit d_ptr->updated();
299 emit d_ptr->updated();
300 emit visibleChanged(visible);
216 }
301 }
217 }
302 }
218
303
@@ -221,14 +306,12 bool QAxis::isAxisVisible() const
221 return d_ptr->m_axisVisible;
306 return d_ptr->m_axisVisible;
222 }
307 }
223
308
224 /*!
225 Sets if grid line is \a visible.
226 */
227 void QAxis::setGridLineVisible(bool visible)
309 void QAxis::setGridLineVisible(bool visible)
228 {
310 {
229 if (d_ptr->m_gridLineVisible != visible) {
311 if (d_ptr->m_gridLineVisible != visible) {
230 d_ptr->m_gridLineVisible = visible;
312 d_ptr->m_gridLineVisible = visible;
231 emit d_ptr->updated();
313 emit d_ptr->updated();
314 emit gridVisibleChanged(visible);
232 }
315 }
233 }
316 }
234
317
@@ -236,9 +319,10 bool QAxis::isGridLineVisible() const
236 {
319 {
237 return d_ptr->m_gridLineVisible;
320 return d_ptr->m_gridLineVisible;
238 }
321 }
322
239 /*!
323 /*!
240 Sets \a pen used to draw grid line.
324 Sets \a pen used to draw grid line.
241 */
325 */
242 void QAxis::setGridLinePen(const QPen &pen)
326 void QAxis::setGridLinePen(const QPen &pen)
243 {
327 {
244 if (d_ptr->m_gridLinePen != pen) {
328 if (d_ptr->m_gridLinePen != pen) {
@@ -247,6 +331,9 void QAxis::setGridLinePen(const QPen &pen)
247 }
331 }
248 }
332 }
249
333
334 /*!
335 Returns pen used to draw grid.
336 */
250 QPen QAxis::gridLinePen() const
337 QPen QAxis::gridLinePen() const
251 {
338 {
252 return d_ptr->m_gridLinePen;
339 return d_ptr->m_gridLinePen;
@@ -257,6 +344,7 void QAxis::setLabelsVisible(bool visible)
257 if (d_ptr->m_labelsVisible != visible) {
344 if (d_ptr->m_labelsVisible != visible) {
258 d_ptr->m_labelsVisible = visible;
345 d_ptr->m_labelsVisible = visible;
259 emit d_ptr->updated();
346 emit d_ptr->updated();
347 emit labelsVisibleChanged(visible);
260 }
348 }
261 }
349 }
262
350
@@ -264,9 +352,10 bool QAxis::labelsVisible() const
264 {
352 {
265 return d_ptr->m_labelsVisible;
353 return d_ptr->m_labelsVisible;
266 }
354 }
355
267 /*!
356 /*!
268 Sets \a pen used to draw labels.
357 Sets \a pen used to draw labels.
269 */
358 */
270 void QAxis::setLabelsPen(const QPen &pen)
359 void QAxis::setLabelsPen(const QPen &pen)
271 {
360 {
272 if (d_ptr->m_labelsPen != pen) {
361 if (d_ptr->m_labelsPen != pen) {
@@ -275,6 +364,9 void QAxis::setLabelsPen(const QPen &pen)
275 }
364 }
276 }
365 }
277
366
367 /*!
368 Returns the pen used to labels.
369 */
278 QPen QAxis::labelsPen() const
370 QPen QAxis::labelsPen() const
279 {
371 {
280 return d_ptr->m_labelsPen;
372 return d_ptr->m_labelsPen;
@@ -291,6 +383,9 void QAxis::setLabelsBrush(const QBrush &brush)
291 }
383 }
292 }
384 }
293
385
386 /*!
387 Returns brush used to draw labels.
388 */
294 QBrush QAxis::labelsBrush() const
389 QBrush QAxis::labelsBrush() const
295 {
390 {
296 return d_ptr->m_labelsBrush;
391 return d_ptr->m_labelsBrush;
@@ -298,7 +393,7 QBrush QAxis::labelsBrush() const
298
393
299 /*!
394 /*!
300 Sets \a font used to draw labels.
395 Sets \a font used to draw labels.
301 */
396 */
302 void QAxis::setLabelsFont(const QFont &font)
397 void QAxis::setLabelsFont(const QFont &font)
303 {
398 {
304 if (d_ptr->m_labelsFont != font) {
399 if (d_ptr->m_labelsFont != font) {
@@ -307,19 +402,20 void QAxis::setLabelsFont(const QFont &font)
307 }
402 }
308 }
403 }
309
404
405 /*!
406 Returns font used to draw labels.
407 */
310 QFont QAxis::labelsFont() const
408 QFont QAxis::labelsFont() const
311 {
409 {
312 return d_ptr->m_labelsFont;
410 return d_ptr->m_labelsFont;
313 }
411 }
314
412
315 /*!
316 Sets \a angle for all the labels on given axis.
317 */
318 void QAxis::setLabelsAngle(int angle)
413 void QAxis::setLabelsAngle(int angle)
319 {
414 {
320 if (d_ptr->m_labelsAngle != angle) {
415 if (d_ptr->m_labelsAngle != angle) {
321 d_ptr->m_labelsAngle = angle;
416 d_ptr->m_labelsAngle = angle;
322 emit d_ptr->updated();
417 emit d_ptr->updated();
418 emit labelsAngleChanged(angle);
323 }
419 }
324 }
420 }
325
421
@@ -328,14 +424,27 int QAxis::labelsAngle() const
328 return d_ptr->m_labelsAngle;
424 return d_ptr->m_labelsAngle;
329 }
425 }
330
426
331 /*!
427 void QAxis::setLabelsColor(QColor color)
332 Sets if shades are \a visible.
428 {
333 */
429 QBrush b = d_ptr->m_labelsBrush;
430 if (b.color() != color) {
431 b.setColor(color);
432 setLabelsBrush(b);
433 emit labelsColorChanged(color);
434 }
435 }
436
437 QColor QAxis::labelsColor() const
438 {
439 return d_ptr->m_labelsBrush.color();
440 }
441
334 void QAxis::setShadesVisible(bool visible)
442 void QAxis::setShadesVisible(bool visible)
335 {
443 {
336 if (d_ptr->m_shadesVisible != visible) {
444 if (d_ptr->m_shadesVisible != visible) {
337 d_ptr->m_shadesVisible = visible;
445 d_ptr->m_shadesVisible = visible;
338 emit d_ptr->updated();
446 emit d_ptr->updated();
447 emit shadesVisibleChanged(visible);
339 }
448 }
340 }
449 }
341
450
@@ -346,7 +455,7 bool QAxis::shadesVisible() const
346
455
347 /*!
456 /*!
348 Sets \a pen used to draw shades.
457 Sets \a pen used to draw shades.
349 */
458 */
350 void QAxis::setShadesPen(const QPen &pen)
459 void QAxis::setShadesPen(const QPen &pen)
351 {
460 {
352 if (d_ptr->m_shadesPen != pen) {
461 if (d_ptr->m_shadesPen != pen) {
@@ -355,6 +464,9 void QAxis::setShadesPen(const QPen &pen)
355 }
464 }
356 }
465 }
357
466
467 /*!
468 Returns pen used to draw shades.
469 */
358 QPen QAxis::shadesPen() const
470 QPen QAxis::shadesPen() const
359 {
471 {
360 return d_ptr->m_shadesPen;
472 return d_ptr->m_shadesPen;
@@ -362,34 +474,46 QPen QAxis::shadesPen() const
362
474
363 /*!
475 /*!
364 Sets \a brush used to draw shades.
476 Sets \a brush used to draw shades.
365 */
477 */
366 void QAxis::setShadesBrush(const QBrush &brush)
478 void QAxis::setShadesBrush(const QBrush &brush)
367 {
479 {
368 if (d_ptr->m_shadesBrush != brush) {
480 if (d_ptr->m_shadesBrush != brush) {
369 d_ptr->m_shadesBrush = brush;
481 d_ptr->m_shadesBrush = brush;
370 emit d_ptr->updated();
482 emit d_ptr->updated();
371 }
483 emit shadesColorChanged(brush.color());
484 }
372 }
485 }
373
486
487 /*!
488 \brief Returns brush used to draw shades.
489 */
374 QBrush QAxis::shadesBrush() const
490 QBrush QAxis::shadesBrush() const
375 {
491 {
376 return d_ptr->m_shadesBrush;
492 return d_ptr->m_shadesBrush;
377 }
493 }
378
494
379 /*!
495 void QAxis::setShadesColor(QColor color)
380 Sets \a opacity of the shades.
381 */
382 void QAxis::setShadesOpacity(qreal opacity)
383 {
496 {
384 if (d_ptr->m_shadesOpacity != opacity) {
497 QBrush b = d_ptr->m_shadesBrush;
385 d_ptr->m_shadesOpacity=opacity;
498 b.setColor(color);
386 emit d_ptr->updated();
499 setShadesBrush(b);
387 }
500 }
501
502 QColor QAxis::shadesColor() const
503 {
504 return d_ptr->m_shadesBrush.color();
505 }
506
507 void QAxis::setShadesBorderColor(QColor color)
508 {
509 QPen p = d_ptr->m_shadesPen;
510 p.setColor(color);
511 setShadesPen(p);
388 }
512 }
389
513
390 qreal QAxis::shadesOpacity() const
514 QColor QAxis::shadesBorderColor() const
391 {
515 {
392 return d_ptr->m_shadesOpacity;
516 return d_ptr->m_shadesPen.color();
393 }
517 }
394
518
395 void QAxis::setMin(qreal min)
519 void QAxis::setMin(qreal min)
@@ -414,7 +538,7 qreal QAxis::max() const
414
538
415 /*!
539 /*!
416 Sets range from \a min to \a max on the axis.
540 Sets range from \a min to \a max on the axis.
417 */
541 */
418 void QAxis::setRange(qreal min, qreal max)
542 void QAxis::setRange(qreal min, qreal max)
419 {
543 {
420 bool changed = false;
544 bool changed = false;
@@ -438,7 +562,7 void QAxis::setRange(qreal min, qreal max)
438
562
439 /*!
563 /*!
440 Sets \a count for ticks on the axis.
564 Sets \a count for ticks on the axis.
441 */
565 */
442 void QAxis::setTicksCount(int count)
566 void QAxis::setTicksCount(int count)
443 {
567 {
444 if (d_ptr->m_ticksCount != count) {
568 if (d_ptr->m_ticksCount != count) {
@@ -448,6 +572,10 void QAxis::setTicksCount(int count)
448 }
572 }
449 }
573 }
450
574
575 /*!
576 \fn int QAxis::ticksCount() const
577 Return number of ticks on the axis
578 */
451 int QAxis::ticksCount() const
579 int QAxis::ticksCount() const
452 {
580 {
453 return d_ptr->m_ticksCount;
581 return d_ptr->m_ticksCount;
@@ -455,7 +583,7 int QAxis::ticksCount() const
455
583
456 /*!
584 /*!
457 Sets axis, shades, labels and grid lines to be visible.
585 Sets axis, shades, labels and grid lines to be visible.
458 */
586 */
459 void QAxis::show()
587 void QAxis::show()
460 {
588 {
461 d_ptr->m_axisVisible=true;
589 d_ptr->m_axisVisible=true;
@@ -467,7 +595,7 void QAxis::show()
467
595
468 /*!
596 /*!
469 Sets axis, shades, labels and grid lines to not be visible.
597 Sets axis, shades, labels and grid lines to not be visible.
470 */
598 */
471 void QAxis::hide()
599 void QAxis::hide()
472 {
600 {
473 d_ptr->m_axisVisible = false;
601 d_ptr->m_axisVisible = false;
@@ -477,20 +605,15 void QAxis::hide()
477 emit d_ptr->updated();
605 emit d_ptr->updated();
478 }
606 }
479
607
480 /*!
481 Sets the nice numbers state to \a enable
482 */
483 void QAxis::setNiceNumbersEnabled(bool enable)
608 void QAxis::setNiceNumbersEnabled(bool enable)
484 {
609 {
485 if (d_ptr->m_niceNumbers != enable){
610 if (d_ptr->m_niceNumbers != enable){
486 d_ptr->m_niceNumbers = enable;
611 d_ptr->m_niceNumbers = enable;
487 emit d_ptr->changed(d_ptr->m_min, d_ptr->m_max, d_ptr->m_ticksCount, d_ptr->m_niceNumbers);
612 emit d_ptr->changed(d_ptr->m_min, d_ptr->m_max, d_ptr->m_ticksCount, d_ptr->m_niceNumbers);
613 emit niceNumbersEnabledChanged(enable);
488 }
614 }
489 }
615 }
490
616
491 /*!
492 Returns whether nice numbers are enabled or not.
493 */
494 bool QAxis::niceNumbersEnabled() const
617 bool QAxis::niceNumbersEnabled() const
495 {
618 {
496 return d_ptr->m_niceNumbers;
619 return d_ptr->m_niceNumbers;
@@ -504,17 +627,18 QAxisCategories* QAxis::categories()
504 /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
627 /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
505
628
506 QAxisPrivate::QAxisPrivate(QAxis* q):
629 QAxisPrivate::QAxisPrivate(QAxis* q):
507 q_ptr(q),
630 q_ptr(q),
508 m_axisVisible(true),
631 m_axisVisible(true),
509 m_gridLineVisible(true),
632 m_gridLineVisible(true),
510 m_labelsVisible(true),
633 m_labelsVisible(true),
511 m_labelsAngle(0),
634 m_labelsAngle(0),
512 m_shadesVisible(false),
635 m_shadesVisible(false),
513 m_shadesOpacity(1.0),
636 m_shadesBrush(Qt::SolidPattern),
514 m_min(0),
637 m_shadesOpacity(1.0),
515 m_max(0),
638 m_min(0),
516 m_ticksCount(5),
639 m_max(0),
517 m_niceNumbers(false)
640 m_ticksCount(5),
641 m_niceNumbers(false)
518 {
642 {
519
643
520 }
644 }
@@ -530,7 +654,9 void QAxisPrivate::handleAxisRangeChanged(qreal min, qreal max,int count)
530 q_ptr->setTicksCount(count);
654 q_ptr->setTicksCount(count);
531 }
655 }
532
656
657 QTCOMMERCIALCHART_END_NAMESPACE
658
659 QTCOMMERCIALCHART_USE_NAMESPACE
660
533 #include "moc_qaxis.cpp"
661 #include "moc_qaxis.cpp"
534 #include "moc_qaxis_p.cpp"
662 #include "moc_qaxis_p.cpp"
535
536 QTCOMMERCIALCHART_END_NAMESPACE
@@ -33,9 +33,19 class QAxisPrivate;
33 class QTCOMMERCIALCHART_EXPORT QAxis : public QObject
33 class QTCOMMERCIALCHART_EXPORT QAxis : public QObject
34 {
34 {
35 Q_OBJECT
35 Q_OBJECT
36 Q_PROPERTY(bool labelsVisible READ labelsVisible WRITE setLabelsVisible)
36 Q_PROPERTY(bool visible READ isAxisVisible WRITE setAxisVisible NOTIFY visibleChanged)
37 Q_PROPERTY(QColor color READ axisPenColor WRITE setAxisPenColor NOTIFY colorChanged)
38 Q_PROPERTY(bool labelsVisible READ labelsVisible WRITE setLabelsVisible NOTIFY labelsVisibleChanged)
39 Q_PROPERTY(int labelsAngle READ labelsAngle WRITE setLabelsAngle NOTIFY labelsAngleChanged)
40 Q_PROPERTY(QColor labelsColor READ labelsColor WRITE setLabelsColor NOTIFY labelsColorChanged)
41 Q_PROPERTY(bool gridVisible READ isGridLineVisible WRITE setGridLineVisible NOTIFY gridVisibleChanged)
42 Q_PROPERTY(bool shadesVisible READ shadesVisible WRITE setShadesVisible NOTIFY shadesVisibleChanged)
43 Q_PROPERTY(QColor shadesColor READ shadesColor WRITE setShadesColor NOTIFY shadesColorChanged)
44 Q_PROPERTY(QColor shadesBorderColor READ shadesBorderColor WRITE setShadesBorderColor NOTIFY shadesBorderColorChanged)
37 Q_PROPERTY(qreal min READ min WRITE setMin)
45 Q_PROPERTY(qreal min READ min WRITE setMin)
38 Q_PROPERTY(qreal max READ max WRITE setMax)
46 Q_PROPERTY(qreal max READ max WRITE setMax)
47 Q_PROPERTY(int ticksCount READ ticksCount WRITE setTicksCount NOTIFY ticksCountChanged)
48 Q_PROPERTY(bool niceNumbersEnabled READ niceNumbersEnabled WRITE setNiceNumbersEnabled NOTIFY niceNumbersEnabledChanged)
39
49
40 public:
50 public:
41
51
@@ -47,6 +57,8 public:
47 void setAxisVisible(bool visible = true);
57 void setAxisVisible(bool visible = true);
48 void setAxisPen(const QPen &pen);
58 void setAxisPen(const QPen &pen);
49 QPen axisPen() const;
59 QPen axisPen() const;
60 void setAxisPenColor(QColor color);
61 QColor axisPenColor() const;
50
62
51 //grid handling
63 //grid handling
52 bool isGridLineVisible() const;
64 bool isGridLineVisible() const;
@@ -65,6 +77,8 public:
65 QFont labelsFont() const;
77 QFont labelsFont() const;
66 void setLabelsAngle(int angle);
78 void setLabelsAngle(int angle);
67 int labelsAngle() const;
79 int labelsAngle() const;
80 void setLabelsColor(QColor color);
81 QColor labelsColor() const;
68
82
69 //shades handling
83 //shades handling
70 bool shadesVisible() const;
84 bool shadesVisible() const;
@@ -73,8 +87,10 public:
73 QPen shadesPen() const;
87 QPen shadesPen() const;
74 void setShadesBrush(const QBrush &brush);
88 void setShadesBrush(const QBrush &brush);
75 QBrush shadesBrush() const;
89 QBrush shadesBrush() const;
76 void setShadesOpacity(qreal opacity);
90 void setShadesColor(QColor color);
77 qreal shadesOpacity() const;
91 QColor shadesColor() const;
92 void setShadesBorderColor(QColor color);
93 QColor shadesBorderColor() const;
78
94
79 //range handling
95 //range handling
80 void setMin(qreal min);
96 void setMin(qreal min);
@@ -96,14 +112,24 public:
96 void hide();
112 void hide();
97
113
98 Q_SIGNALS:
114 Q_SIGNALS:
115 void visibleChanged(bool visible);
116 void labelsVisibleChanged(bool visible);
117 void gridVisibleChanged(bool visible);
99 void minChanged(qreal min);
118 void minChanged(qreal min);
100 void maxChanged(qreal max);
119 void maxChanged(qreal max);
101 void rangeChanged(qreal min, qreal max);
120 void rangeChanged(qreal min, qreal max);
102 void ticksCountChanged(int count);
121 void colorChanged(QColor color);
122 void labelsColorChanged(QColor color);
123 void labelsAngleChanged(int angle);
124 void shadesVisibleChanged(bool visible);
125 void shadesColorChanged(QColor color);
126 void shadesBorderColorChanged(QColor color);
127 void ticksCountChanged(int count);
128 void niceNumbersEnabledChanged(bool enabled);
103
129
104 private:
130 private:
105 QScopedPointer<QAxisPrivate> d_ptr;
131 QScopedPointer<QAxisPrivate> d_ptr;
106 Q_DISABLE_COPY(QAxis);
132 Q_DISABLE_COPY(QAxis)
107 friend class ChartDataSet;
133 friend class ChartDataSet;
108 friend class ChartAxis;
134 friend class ChartAxis;
109 };
135 };
@@ -29,7 +29,9 Flow {
29 property variant series // TODO: rename to chart
29 property variant series // TODO: rename to chart
30
30
31 onSeriesChanged: {
31 onSeriesChanged: {
32 legendConnections.target = series.legend
32 legendConnections.target = series.legend;
33 axisXConnections.target = series.axisX;
34 axisYConnections.target = series.axisY;
33 }
35 }
34
36
35 Connections {
37 Connections {
@@ -50,6 +52,38 Flow {
50 onVisibleChanged: console.log("legend.onVisibleChanged: " + series.legend.visible);
52 onVisibleChanged: console.log("legend.onVisibleChanged: " + series.legend.visible);
51 }
53 }
52
54
55 Connections {
56 id: axisXConnections
57 ignoreUnknownSignals: true
58 onColorChanged: console.log("axisX.onColorChanged: " + color);
59 onLabelsVisibleChanged: console.log("axisX.onLabelsVisibleChanged: " + visible);
60 onLabelsColorChanged: console.log("axisX.onLabelsColorChanged: " + color);
61 onLabelsAngleChanged: console.log("axisX.onLabelsAngleChanged: " + angle);
62 onVisibleChanged: console.log("axisX.onVisibleChanged: " + visible);
63 onGridVisibleChanged: console.log("axisX.onGridVisibleChanged: " + visible);
64 onShadesVisibleChanged: console.log("axisX.onShadesVisibleChanged: " + visible);
65 onShadesColorChanged: console.log("axisX.onShadesColorChanged: " + color);
66 onShadesBorderColorChanged: console.log("axisX.onShadesBorderColorChanged: " + color);
67 onNiceNumbersEnabledChanged: console.log("axisX.onNiceNumbersEnabledChanged: " + enabled);
68 onTicksCountChanged: console.log("axisX.onTicksCountChanged: " + count);
69 }
70
71 Connections {
72 id: axisYConnections
73 ignoreUnknownSignals: true
74 onColorChanged: console.log("axisY.onColorChanged: " + color);
75 onLabelsVisibleChanged: console.log("axisY.onLabelsVisibleChanged: " + visible);
76 onLabelsColorChanged: console.log("axisY.onLabelsColorChanged: " + color);
77 onLabelsAngleChanged: console.log("axisY.onLabelsAngleChanged: " + angle);
78 onVisibleChanged: console.log("axisY.onVisibleChanged: " + visible);
79 onGridVisibleChanged: console.log("axisY.onGridVisibleChanged: " + visible);
80 onShadesVisibleChanged: console.log("axisY.onShadesVisibleChanged: " + visible);
81 onShadesColorChanged: console.log("axisY.onShadesColorChanged: " + color);
82 onShadesBorderColorChanged: console.log("axisY.onShadesBorderColorChanged: " + color);
83 onNiceNumbersEnabledChanged: console.log("axisY.onNiceNumbersEnabledChanged: " + enabled);
84 onTicksCountChanged: console.log("axisY.onTicksCountChanged: " + count);
85 }
86
53 Button {
87 Button {
54 text: "visible"
88 text: "visible"
55 onClicked: series.visible = !series.visible;
89 onClicked: series.visible = !series.visible;
@@ -63,6 +97,22 Flow {
63 onClicked: series.theme--;
97 onClicked: series.theme--;
64 }
98 }
65 Button {
99 Button {
100 text: "animation opt +"
101 onClicked: series.animationOptions++;
102 }
103 Button {
104 text: "animation opt -"
105 onClicked: series.animationOptions--;
106 }
107 Button {
108 text: "title color"
109 onClicked: series.titleColor = main.nextColor();
110 }
111 Button {
112 text: "background color"
113 onClicked: series.backgroundColor = main.nextColor();
114 }
115 Button {
66 text: "legend top"
116 text: "legend top"
67 onClicked: series.legend.alignment ^= Qt.AlignTop;
117 onClicked: series.legend.alignment ^= Qt.AlignTop;
68 }
118 }
@@ -83,19 +133,107 Flow {
83 onClicked: series.legend.visible = !series.legend.visible;
133 onClicked: series.legend.visible = !series.legend.visible;
84 }
134 }
85 Button {
135 Button {
86 text: "animation opt +"
136 text: "axis X nice nmb"
87 onClicked: series.animationOptions++;
137 onClicked: series.axisX.niceNumbersEnabled = !series.axisX.niceNumbersEnabled;
88 }
138 }
89 Button {
139 Button {
90 text: "animation opt -"
140 text: "axis X visible"
91 onClicked: series.animationOptions--;
141 onClicked: series.axisX.visible = !series.axisX.visible;
92 }
142 }
93 Button {
143 Button {
94 text: "title color"
144 text: "axis X grid visible"
95 onClicked: series.titleColor = main.nextColor();
145 onClicked: series.axisX.gridVisible = !series.axisX.gridVisible;
96 }
146 }
97 Button {
147 Button {
98 text: "background color"
148 text: "axis X labels visible"
99 onClicked: series.backgroundColor = main.nextColor();
149 onClicked: series.axisX.labelsVisible = !series.axisX.labelsVisible;
150 }
151 Button {
152 text: "axis X color"
153 onClicked: series.axisX.color = main.nextColor();
154 }
155 Button {
156 text: "axis X labels color"
157 onClicked: series.axisX.labelsColor = main.nextColor();
158 }
159 Button {
160 text: "axis X labels angle +"
161 onClicked: series.axisX.labelsAngle += 5;
162 }
163 Button {
164 text: "axis X labels angle -"
165 onClicked: series.axisX.labelsAngle -= 5;
166 }
167 Button {
168 text: "axis X shades visible"
169 onClicked: series.axisX.shadesVisible = !series.axisX.shadesVisible;
170 }
171 Button {
172 text: "axis X shades color"
173 onClicked: series.axisX.shadesColor = main.nextColor();
174 }
175 Button {
176 text: "axis X shades bcolor"
177 onClicked: series.axisX.shadesBorderColor = main.nextColor();
178 }
179 Button {
180 text: "axis X ticks count +"
181 onClicked: series.axisX.ticksCount++;
182 }
183 Button {
184 text: "axis X ticks count -"
185 onClicked: series.axisX.ticksCount--;
186 }
187 Button {
188 text: "axis Y nice nmb"
189 onClicked: series.axisY.niceNumbersEnabled = !series.axisY.niceNumbersEnabled;
190 }
191 Button {
192 text: "axis Y visible"
193 onClicked: series.axisY.visible = !series.axisY.visible;
194 }
195 Button {
196 text: "axis Y grid visible"
197 onClicked: series.axisY.gridVisible = !series.axisY.gridVisible;
198 }
199 Button {
200 text: "axis Y labels visible"
201 onClicked: series.axisY.labelsVisible = !series.axisY.labelsVisible;
202 }
203 Button {
204 text: "axis Y color"
205 onClicked: series.axisY.color = main.nextColor();
206 }
207 Button {
208 text: "axis Y labels color"
209 onClicked: series.axisY.labelsColor = main.nextColor();
210 }
211 Button {
212 text: "axis Y labels angle +"
213 onClicked: series.axisY.labelsAngle += 5;
214 }
215 Button {
216 text: "axis Y labels angle -"
217 onClicked: series.axisY.labelsAngle -= 5;
218 }
219 Button {
220 text: "axis Y shades visible"
221 onClicked: series.axisY.shadesVisible = !series.axisY.shadesVisible;
222 }
223 Button {
224 text: "axis Y shades color"
225 onClicked: series.axisY.shadesColor = main.nextColor();
226 }
227 Button {
228 text: "axis Y shades bcolor"
229 onClicked: series.axisY.shadesBorderColor = main.nextColor();
230 }
231 Button {
232 text: "axis Y ticks count +"
233 onClicked: series.axisY.ticksCount++;
234 }
235 Button {
236 text: "axis Y ticks count -"
237 onClicked: series.axisY.ticksCount--;
100 }
238 }
101 }
239 }
General Comments 0
You need to be logged in to leave comments. Login now