##// END OF EJS Templates
Added missing properties to QAxis
Tero Ahola -
r1449:e88bf0c8e17d
parent child
Show More
@@ -1,14 +1,15
1 /*!
1 /*!
2 \page qml.html
2 \page qml.html
3 \title QtCommercial Charts QML API
3 \title QtCommercial Charts QML API
4 \keyword Charts QML API
4 \keyword Charts QML API
5
5
6 Charts QML API is an intuitive and simple way to use QtCommercial Charts in your QML applications.
6 Charts QML API is an intuitive and simple way to use QtCommercial Charts in your QML applications.
7
7
8 \raw HTML
8 \raw HTML
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 */
@@ -1,361 +1,361
1 /****************************************************************************
1 /****************************************************************************
2 **
2 **
3 ** Copyright (C) 2012 Digia Plc
3 ** Copyright (C) 2012 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 Commercial Charts Add-on.
7 ** This file is part of the Qt Commercial Charts Add-on.
8 **
8 **
9 ** $QT_BEGIN_LICENSE$
9 ** $QT_BEGIN_LICENSE$
10 ** Licensees holding valid Qt Commercial licenses may use this file in
10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 ** accordance with the Qt Commercial License Agreement provided with the
11 ** accordance with the Qt Commercial 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 "chartaxis_p.h"
21 #include "chartaxis_p.h"
22 #include "qaxis.h"
22 #include "qaxis.h"
23 #include "qaxis_p.h"
23 #include "qaxis_p.h"
24 #include "qaxiscategories_p.h"
24 #include "qaxiscategories_p.h"
25 #include "chartpresenter_p.h"
25 #include "chartpresenter_p.h"
26 #include "chartanimator_p.h"
26 #include "chartanimator_p.h"
27 #include <QPainter>
27 #include <QPainter>
28 #include <QDebug>
28 #include <QDebug>
29 #include <cmath>
29 #include <cmath>
30
30
31 QTCOMMERCIALCHART_BEGIN_NAMESPACE
31 QTCOMMERCIALCHART_BEGIN_NAMESPACE
32
32
33 ChartAxis::ChartAxis(QAxis *axis,ChartPresenter *presenter) : Chart(presenter),
33 ChartAxis::ChartAxis(QAxis *axis,ChartPresenter *presenter) : Chart(presenter),
34 m_chartAxis(axis),
34 m_chartAxis(axis),
35 m_labelsAngle(0),
35 m_labelsAngle(0),
36 m_grid(new QGraphicsItemGroup(presenter->rootItem())),
36 m_grid(new QGraphicsItemGroup(presenter->rootItem())),
37 m_shades(new QGraphicsItemGroup(presenter->rootItem())),
37 m_shades(new QGraphicsItemGroup(presenter->rootItem())),
38 m_labels(new QGraphicsItemGroup(presenter->rootItem())),
38 m_labels(new QGraphicsItemGroup(presenter->rootItem())),
39 m_axis(new QGraphicsItemGroup(presenter->rootItem())),
39 m_axis(new QGraphicsItemGroup(presenter->rootItem())),
40 m_min(0),
40 m_min(0),
41 m_max(0),
41 m_max(0),
42 m_ticksCount(0),
42 m_ticksCount(0),
43 m_animation(0)
43 m_animation(0)
44 {
44 {
45 //initial initialization
45 //initial initialization
46 m_axis->setZValue(ChartPresenter::AxisZValue);
46 m_axis->setZValue(ChartPresenter::AxisZValue);
47 m_axis->setHandlesChildEvents(false);
47 m_axis->setHandlesChildEvents(false);
48
48
49 m_shades->setZValue(ChartPresenter::ShadesZValue);
49 m_shades->setZValue(ChartPresenter::ShadesZValue);
50 m_grid->setZValue(ChartPresenter::GridZValue);
50 m_grid->setZValue(ChartPresenter::GridZValue);
51
51
52 QObject::connect(m_chartAxis->d_ptr.data(),SIGNAL(updated()),this,SLOT(handleAxisUpdated()));
52 QObject::connect(m_chartAxis->d_ptr.data(),SIGNAL(updated()),this,SLOT(handleAxisUpdated()));
53 QObject::connect(m_chartAxis->categories()->d_ptr.data(),SIGNAL(updated()),this,SLOT(handleAxisCategoriesUpdated()));
53 QObject::connect(m_chartAxis->categories()->d_ptr.data(),SIGNAL(updated()),this,SLOT(handleAxisCategoriesUpdated()));
54
54
55 handleAxisUpdated();
55 handleAxisUpdated();
56 }
56 }
57
57
58 ChartAxis::~ChartAxis()
58 ChartAxis::~ChartAxis()
59 {
59 {
60 }
60 }
61
61
62 void ChartAxis::setAnimation(AxisAnimation* animation)
62 void ChartAxis::setAnimation(AxisAnimation* animation)
63 {
63 {
64 m_animation=animation;
64 m_animation=animation;
65 }
65 }
66
66
67 void ChartAxis::setLayout(QVector<qreal> &layout)
67 void ChartAxis::setLayout(QVector<qreal> &layout)
68 {
68 {
69 m_layoutVector=layout;
69 m_layoutVector=layout;
70 }
70 }
71
71
72 void ChartAxis::createItems(int count)
72 void ChartAxis::createItems(int count)
73 {
73 {
74 if (m_axis->children().size() == 0)
74 if (m_axis->children().size() == 0)
75 m_axis->addToGroup(new AxisItem(this));
75 m_axis->addToGroup(new AxisItem(this));
76 for (int i = 0; i < count; ++i) {
76 for (int i = 0; i < count; ++i) {
77 m_grid->addToGroup(new QGraphicsLineItem());
77 m_grid->addToGroup(new QGraphicsLineItem());
78 m_labels->addToGroup(new QGraphicsSimpleTextItem());
78 m_labels->addToGroup(new QGraphicsSimpleTextItem());
79 m_axis->addToGroup(new QGraphicsLineItem());
79 m_axis->addToGroup(new QGraphicsLineItem());
80 if ((m_grid->childItems().size())%2 && m_grid->childItems().size()>2) m_shades->addToGroup(new QGraphicsRectItem());
80 if ((m_grid->childItems().size())%2 && m_grid->childItems().size()>2) m_shades->addToGroup(new QGraphicsRectItem());
81 }
81 }
82 }
82 }
83
83
84 void ChartAxis::deleteItems(int count)
84 void ChartAxis::deleteItems(int count)
85 {
85 {
86 QList<QGraphicsItem *> lines = m_grid->childItems();
86 QList<QGraphicsItem *> lines = m_grid->childItems();
87 QList<QGraphicsItem *> labels = m_labels->childItems();
87 QList<QGraphicsItem *> labels = m_labels->childItems();
88 QList<QGraphicsItem *> shades = m_shades->childItems();
88 QList<QGraphicsItem *> shades = m_shades->childItems();
89 QList<QGraphicsItem *> axis = m_axis->childItems();
89 QList<QGraphicsItem *> axis = m_axis->childItems();
90
90
91 for (int i = 0; i < count; ++i) {
91 for (int i = 0; i < count; ++i) {
92 if (lines.size()%2 && lines.size() > 1) delete(shades.takeLast());
92 if (lines.size()%2 && lines.size() > 1) delete(shades.takeLast());
93 delete(lines.takeLast());
93 delete(lines.takeLast());
94 delete(labels.takeLast());
94 delete(labels.takeLast());
95 delete(axis.takeLast());
95 delete(axis.takeLast());
96 }
96 }
97 }
97 }
98
98
99 void ChartAxis::updateLayout(QVector<qreal> &layout)
99 void ChartAxis::updateLayout(QVector<qreal> &layout)
100 {
100 {
101 int diff = m_layoutVector.size() - layout.size();
101 int diff = m_layoutVector.size() - layout.size();
102
102
103 if (diff>0) {
103 if (diff>0) {
104 deleteItems(diff);
104 deleteItems(diff);
105 }
105 }
106 else if (diff<0) {
106 else if (diff<0) {
107 createItems(-diff);
107 createItems(-diff);
108 }
108 }
109
109
110 if( diff!=0) handleAxisUpdated();
110 if( diff!=0) handleAxisUpdated();
111
111
112 if (m_animation) {
112 if (m_animation) {
113 switch(presenter()->state()){
113 switch(presenter()->state()){
114 case ChartPresenter::ZoomInState:
114 case ChartPresenter::ZoomInState:
115 m_animation->setAnimationType(AxisAnimation::ZoomInAnimation);
115 m_animation->setAnimationType(AxisAnimation::ZoomInAnimation);
116 m_animation->setAnimationPoint(presenter()->statePoint());
116 m_animation->setAnimationPoint(presenter()->statePoint());
117 break;
117 break;
118 case ChartPresenter::ZoomOutState:
118 case ChartPresenter::ZoomOutState:
119 m_animation->setAnimationType(AxisAnimation::ZoomOutAnimation);
119 m_animation->setAnimationType(AxisAnimation::ZoomOutAnimation);
120 m_animation->setAnimationPoint(presenter()->statePoint());
120 m_animation->setAnimationPoint(presenter()->statePoint());
121 break;
121 break;
122 case ChartPresenter::ScrollUpState:
122 case ChartPresenter::ScrollUpState:
123 case ChartPresenter::ScrollLeftState:
123 case ChartPresenter::ScrollLeftState:
124 m_animation->setAnimationType(AxisAnimation::MoveBackwordAnimation);
124 m_animation->setAnimationType(AxisAnimation::MoveBackwordAnimation);
125 break;
125 break;
126 case ChartPresenter::ScrollDownState:
126 case ChartPresenter::ScrollDownState:
127 case ChartPresenter::ScrollRightState:
127 case ChartPresenter::ScrollRightState:
128 m_animation->setAnimationType(AxisAnimation::MoveForwardAnimation);
128 m_animation->setAnimationType(AxisAnimation::MoveForwardAnimation);
129 break;
129 break;
130 case ChartPresenter::ShowState:
130 case ChartPresenter::ShowState:
131 m_animation->setAnimationType(AxisAnimation::DefaultAnimation);
131 m_animation->setAnimationType(AxisAnimation::DefaultAnimation);
132 break;
132 break;
133 }
133 }
134 m_animation->setValues(m_layoutVector,layout);
134 m_animation->setValues(m_layoutVector,layout);
135 presenter()->startAnimation(m_animation);
135 presenter()->startAnimation(m_animation);
136 }
136 }
137 else {
137 else {
138 setLayout(layout);
138 setLayout(layout);
139 updateGeometry();
139 updateGeometry();
140 }
140 }
141 }
141 }
142
142
143 bool ChartAxis::createLabels(QStringList &labels,qreal min, qreal max,int ticks) const
143 bool ChartAxis::createLabels(QStringList &labels,qreal min, qreal max,int ticks) const
144 {
144 {
145 Q_ASSERT(max>min);
145 Q_ASSERT(max>min);
146 Q_ASSERT(ticks>1);
146 Q_ASSERT(ticks>1);
147
147
148 QAxisCategories* categories = m_chartAxis->categories();
148 QAxisCategories* categories = m_chartAxis->categories();
149
149
150 bool category = categories->count()>0;
150 bool category = categories->count()>0;
151
151
152 if (!category) {
152 if (!category) {
153 int n = qMax(int(-floor(log10((max-min)/(ticks-1)))),0);
153 int n = qMax(int(-floor(log10((max-min)/(ticks-1)))),0);
154 n++;
154 n++;
155 for (int i=0; i< ticks; i++) {
155 for (int i=0; i< ticks; i++) {
156 qreal value = min + (i * (max - min)/ (ticks-1));
156 qreal value = min + (i * (max - min)/ (ticks-1));
157 Q_UNUSED(value);
157 Q_UNUSED(value);
158 labels << QString::number(value,'f',n);
158 labels << QString::number(value,'f',n);
159 }
159 }
160 } else {
160 } else {
161 QList<qreal> values = categories->values();
161 QList<qreal> values = categories->values();
162 for (int i=0; i< ticks; i++) {
162 for (int i=0; i< ticks; i++) {
163 qreal value = (min + (i * (max - min)/ (ticks-1)));
163 qreal value = (min + (i * (max - min)/ (ticks-1)));
164 int j=0;
164 int j=0;
165 for (; j<values.count(); j++) {
165 for (; j<values.count(); j++) {
166 if (values.at(j) > value) break;
166 if (values.at(j) > value) break;
167 }
167 }
168 if (j!=0) value=values.at(j-1);
168 if (j!=0) value=values.at(j-1);
169
169
170 QString label = categories->label(value);
170 QString label = categories->label(value);
171 labels << label;
171 labels << label;
172 }
172 }
173 }
173 }
174
174
175 return category;
175 return category;
176 }
176 }
177
177
178 void ChartAxis::setAxisOpacity(qreal opacity)
178 void ChartAxis::setAxisOpacity(qreal opacity)
179 {
179 {
180 m_axis->setOpacity(opacity);
180 m_axis->setOpacity(opacity);
181 }
181 }
182
182
183 qreal ChartAxis::axisOpacity() const
183 qreal ChartAxis::axisOpacity() const
184 {
184 {
185 return m_axis->opacity();
185 return m_axis->opacity();
186 }
186 }
187
187
188 void ChartAxis::setGridOpacity(qreal opacity)
188 void ChartAxis::setGridOpacity(qreal opacity)
189 {
189 {
190 m_grid->setOpacity(opacity);
190 m_grid->setOpacity(opacity);
191 }
191 }
192
192
193 qreal ChartAxis::gridOpacity() const
193 qreal ChartAxis::gridOpacity() const
194 {
194 {
195 return m_grid->opacity();
195 return m_grid->opacity();
196 }
196 }
197
197
198 void ChartAxis::setLabelsOpacity(qreal opacity)
198 void ChartAxis::setLabelsOpacity(qreal opacity)
199 {
199 {
200 m_labels->setOpacity(opacity);
200 m_labels->setOpacity(opacity);
201 }
201 }
202
202
203 qreal ChartAxis::labelsOpacity() const
203 qreal ChartAxis::labelsOpacity() const
204 {
204 {
205 return m_labels->opacity();
205 return m_labels->opacity();
206 }
206 }
207
207
208 void ChartAxis::setShadesOpacity(qreal opacity)
208 void ChartAxis::setShadesOpacity(qreal opacity)
209 {
209 {
210 m_shades->setOpacity(opacity);
210 m_shades->setOpacity(opacity);
211 }
211 }
212
212
213 qreal ChartAxis::shadesOpacity() const
213 qreal ChartAxis::shadesOpacity() const
214 {
214 {
215 return m_shades->opacity();
215 return m_shades->opacity();
216 }
216 }
217
217
218 void ChartAxis::setLabelsAngle(int angle)
218 void ChartAxis::setLabelsAngle(int angle)
219 {
219 {
220 foreach(QGraphicsItem* item , m_labels->childItems()) {
220 foreach(QGraphicsItem* item , m_labels->childItems()) {
221 item->setRotation(angle);
221 item->setRotation(angle);
222 }
222 }
223
223
224 m_labelsAngle=angle;
224 m_labelsAngle=angle;
225 }
225 }
226
226
227 void ChartAxis::setLabelsPen(const QPen &pen)
227 void ChartAxis::setLabelsPen(const QPen &pen)
228 {
228 {
229 foreach(QGraphicsItem* item , m_labels->childItems()) {
229 foreach(QGraphicsItem* item , m_labels->childItems()) {
230 static_cast<QGraphicsSimpleTextItem*>(item)->setPen(pen);
230 static_cast<QGraphicsSimpleTextItem*>(item)->setPen(pen);
231 }
231 }
232 }
232 }
233
233
234 void ChartAxis::setLabelsBrush(const QBrush &brush)
234 void ChartAxis::setLabelsBrush(const QBrush &brush)
235 {
235 {
236 foreach(QGraphicsItem* item , m_labels->childItems()) {
236 foreach(QGraphicsItem* item , m_labels->childItems()) {
237 static_cast<QGraphicsSimpleTextItem*>(item)->setBrush(brush);
237 static_cast<QGraphicsSimpleTextItem*>(item)->setBrush(brush);
238 }
238 }
239 }
239 }
240
240
241 void ChartAxis::setLabelsFont(const QFont &font)
241 void ChartAxis::setLabelsFont(const QFont &font)
242 {
242 {
243 foreach(QGraphicsItem* item , m_labels->childItems()) {
243 foreach(QGraphicsItem* item , m_labels->childItems()) {
244 static_cast<QGraphicsSimpleTextItem*>(item)->setFont(font);
244 static_cast<QGraphicsSimpleTextItem*>(item)->setFont(font);
245 }
245 }
246 }
246 }
247
247
248 void ChartAxis::setShadesBrush(const QBrush &brush)
248 void ChartAxis::setShadesBrush(const QBrush &brush)
249 {
249 {
250 foreach(QGraphicsItem* item , m_shades->childItems()) {
250 foreach(QGraphicsItem* item , m_shades->childItems()) {
251 static_cast<QGraphicsRectItem*>(item)->setBrush(brush);
251 static_cast<QGraphicsRectItem*>(item)->setBrush(brush);
252 }
252 }
253 }
253 }
254
254
255 void ChartAxis::setShadesPen(const QPen &pen)
255 void ChartAxis::setShadesPen(const QPen &pen)
256 {
256 {
257 foreach(QGraphicsItem* item , m_shades->childItems()) {
257 foreach(QGraphicsItem* item , m_shades->childItems()) {
258 static_cast<QGraphicsRectItem*>(item)->setPen(pen);
258 static_cast<QGraphicsRectItem*>(item)->setPen(pen);
259 }
259 }
260 }
260 }
261
261
262 void ChartAxis::setAxisPen(const QPen &pen)
262 void ChartAxis::setAxisPen(const QPen &pen)
263 {
263 {
264 foreach(QGraphicsItem* item , m_axis->childItems()) {
264 foreach(QGraphicsItem* item , m_axis->childItems()) {
265 static_cast<QGraphicsLineItem*>(item)->setPen(pen);
265 static_cast<QGraphicsLineItem*>(item)->setPen(pen);
266 }
266 }
267 }
267 }
268
268
269 void ChartAxis::setGridPen(const QPen &pen)
269 void ChartAxis::setGridPen(const QPen &pen)
270 {
270 {
271 foreach(QGraphicsItem* item , m_grid->childItems()) {
271 foreach(QGraphicsItem* item , m_grid->childItems()) {
272 static_cast<QGraphicsLineItem*>(item)->setPen(pen);
272 static_cast<QGraphicsLineItem*>(item)->setPen(pen);
273 }
273 }
274 }
274 }
275
275
276 bool ChartAxis::isEmpty()
276 bool ChartAxis::isEmpty()
277 {
277 {
278 return m_rect.isEmpty() || qFuzzyIsNull(m_min - m_max) || m_ticksCount==0;
278 return m_rect.isEmpty() || qFuzzyIsNull(m_min - m_max) || m_ticksCount==0;
279 }
279 }
280
280
281 //handlers
281 //handlers
282
282
283 void ChartAxis::handleAxisCategoriesUpdated()
283 void ChartAxis::handleAxisCategoriesUpdated()
284 {
284 {
285 if (isEmpty()) return;
285 if (isEmpty()) return;
286 updateLayout(m_layoutVector);
286 updateLayout(m_layoutVector);
287 }
287 }
288
288
289 void ChartAxis::handleAxisUpdated()
289 void ChartAxis::handleAxisUpdated()
290 {
290 {
291
291
292 if (isEmpty()) return;
292 if (isEmpty()) return;
293
293
294 if (m_chartAxis->isAxisVisible()) {
294 if (m_chartAxis->isAxisVisible()) {
295 setAxisOpacity(100);
295 setAxisOpacity(100);
296 } else {
296 } else {
297 setAxisOpacity(0);
297 setAxisOpacity(0);
298 }
298 }
299
299
300 if (m_chartAxis->isGridLineVisible()) {
300 if (m_chartAxis->isGridLineVisible()) {
301 setGridOpacity(100);
301 setGridOpacity(100);
302 } else {
302 } else {
303 setGridOpacity(0);
303 setGridOpacity(0);
304 }
304 }
305
305
306 if (m_chartAxis->labelsVisible()) {
306 if (m_chartAxis->labelsVisible()) {
307 setLabelsOpacity(100);
307 setLabelsOpacity(100);
308 } else {
308 } else {
309 setLabelsOpacity(0);
309 setLabelsOpacity(0);
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 }
317
317
318 setLabelsAngle(m_chartAxis->labelsAngle());
318 setLabelsAngle(m_chartAxis->labelsAngle());
319 setAxisPen(m_chartAxis->axisPen());
319 setAxisPen(m_chartAxis->axisPen());
320 setLabelsPen(m_chartAxis->labelsPen());
320 setLabelsPen(m_chartAxis->labelsPen());
321 setLabelsBrush(m_chartAxis->labelsBrush());
321 setLabelsBrush(m_chartAxis->labelsBrush());
322 setLabelsFont(m_chartAxis->labelsFont());
322 setLabelsFont(m_chartAxis->labelsFont());
323 setGridPen(m_chartAxis->gridLinePen());
323 setGridPen(m_chartAxis->gridLinePen());
324 setShadesPen(m_chartAxis->shadesPen());
324 setShadesPen(m_chartAxis->shadesPen());
325 setShadesBrush(m_chartAxis->shadesBrush());
325 setShadesBrush(m_chartAxis->shadesBrush());
326
326
327 }
327 }
328
328
329 void ChartAxis::handleRangeChanged(qreal min, qreal max,int tickCount)
329 void ChartAxis::handleRangeChanged(qreal min, qreal max,int tickCount)
330 {
330 {
331 if (qFuzzyIsNull(min - max) || tickCount < 2)
331 if (qFuzzyIsNull(min - max) || tickCount < 2)
332 return;
332 return;
333
333
334 m_min = min;
334 m_min = min;
335 m_max = max;
335 m_max = max;
336 m_ticksCount= tickCount;
336 m_ticksCount= tickCount;
337
337
338 if (isEmpty()) return;
338 if (isEmpty()) return;
339 QVector<qreal> layout = calculateLayout();
339 QVector<qreal> layout = calculateLayout();
340 updateLayout(layout);
340 updateLayout(layout);
341 }
341 }
342
342
343 void ChartAxis::handleGeometryChanged(const QRectF &rect)
343 void ChartAxis::handleGeometryChanged(const QRectF &rect)
344 {
344 {
345 if(m_rect != rect)
345 if(m_rect != rect)
346 {
346 {
347 m_rect = rect;
347 m_rect = rect;
348 if (isEmpty()) return;
348 if (isEmpty()) return;
349 QVector<qreal> layout = calculateLayout();
349 QVector<qreal> layout = calculateLayout();
350 updateLayout(layout);
350 updateLayout(layout);
351 }
351 }
352 }
352 }
353
353
354 void ChartAxis::axisSelected()
354 void ChartAxis::axisSelected()
355 {
355 {
356 qDebug()<<"TODO: axis clicked";
356 qDebug()<<"TODO: axis clicked";
357 }
357 }
358
358
359 #include "moc_chartaxis_p.cpp"
359 #include "moc_chartaxis_p.cpp"
360
360
361 QTCOMMERCIALCHART_END_NAMESPACE
361 QTCOMMERCIALCHART_END_NAMESPACE
@@ -1,536 +1,662
1 /****************************************************************************
1 /****************************************************************************
2 **
2 **
3 ** Copyright (C) 2012 Digia Plc
3 ** Copyright (C) 2012 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 Commercial Charts Add-on.
7 ** This file is part of the Qt Commercial Charts Add-on.
8 **
8 **
9 ** $QT_BEGIN_LICENSE$
9 ** $QT_BEGIN_LICENSE$
10 ** Licensees holding valid Qt Commercial licenses may use this file in
10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 ** accordance with the Qt Commercial License Agreement provided with the
11 ** accordance with the Qt Commercial 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 "qaxis.h"
21 #include "qaxis.h"
22 #include "qaxis_p.h"
22 #include "qaxis_p.h"
23
23
24 QTCOMMERCIALCHART_BEGIN_NAMESPACE
24 QTCOMMERCIALCHART_BEGIN_NAMESPACE
25
25
26 /*!
26 /*!
27 \class QAxis
27 \class QAxis
28 \brief The QAxis class is used for manipulating chart's axis
28 \brief The QAxis class is used for manipulating chart's axis
29 and for adding optional axes to the chart.
29 and for adding optional axes to the chart.
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 {
181
247
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()
189 {
255 {
190 }
256 }
191
257
192 /*!
258 /*!
193 Sets \a pen used to draw axis line and ticks.
259 Sets \a pen used to draw axis line and ticks.
194 */
260 */
195 void QAxis::setAxisPen(const QPen &pen)
261 void QAxis::setAxisPen(const QPen &pen)
196 {
262 {
197 if (d_ptr->m_axisPen!=pen) {
263 if (d_ptr->m_axisPen!=pen) {
198 d_ptr->m_axisPen = pen;
264 d_ptr->m_axisPen = pen;
199 emit d_ptr->updated();
265 emit d_ptr->updated();
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 */
211 void QAxis::setAxisVisible(bool visible)
295 void QAxis::setAxisVisible(bool visible)
212 {
296 {
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
219 bool QAxis::isAxisVisible() const
304 bool QAxis::isAxisVisible() const
220 {
305 {
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
235 bool QAxis::isGridLineVisible() const
318 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) {
245 d_ptr->m_gridLinePen = pen;
329 d_ptr->m_gridLinePen = pen;
246 emit d_ptr->updated();
330 emit d_ptr->updated();
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;
253 }
340 }
254
341
255 void QAxis::setLabelsVisible(bool visible)
342 void QAxis::setLabelsVisible(bool visible)
256 {
343 {
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
263 bool QAxis::labelsVisible() const
351 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) {
273 d_ptr->m_labelsPen = pen;
362 d_ptr->m_labelsPen = pen;
274 emit d_ptr->updated();
363 emit d_ptr->updated();
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;
281 }
373 }
282
374
283 /*!
375 /*!
284 Sets \a brush used to draw labels.
376 Sets \a brush used to draw labels.
285 */
377 */
286 void QAxis::setLabelsBrush(const QBrush &brush)
378 void QAxis::setLabelsBrush(const QBrush &brush)
287 {
379 {
288 if (d_ptr->m_labelsBrush != brush) {
380 if (d_ptr->m_labelsBrush != brush) {
289 d_ptr->m_labelsBrush = brush;
381 d_ptr->m_labelsBrush = brush;
290 emit d_ptr->updated();
382 emit d_ptr->updated();
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;
297 }
392 }
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) {
305 d_ptr->m_labelsFont = font;
400 d_ptr->m_labelsFont = font;
306 emit d_ptr->updated();
401 emit d_ptr->updated();
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
326 int QAxis::labelsAngle() const
422 int QAxis::labelsAngle() const
327 {
423 {
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
342 bool QAxis::shadesVisible() const
451 bool QAxis::shadesVisible() const
343 {
452 {
344 return d_ptr->m_shadesVisible;
453 return d_ptr->m_shadesVisible;
345 }
454 }
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) {
353 d_ptr->m_shadesPen = pen;
462 d_ptr->m_shadesPen = pen;
354 emit d_ptr->updated();
463 emit d_ptr->updated();
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;
361 }
473 }
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)
396 {
520 {
397 setRange(min,d_ptr->m_max);
521 setRange(min,d_ptr->m_max);
398 }
522 }
399
523
400 qreal QAxis::min() const
524 qreal QAxis::min() const
401 {
525 {
402 return d_ptr->m_min;
526 return d_ptr->m_min;
403 }
527 }
404
528
405 void QAxis::setMax(qreal max)
529 void QAxis::setMax(qreal max)
406 {
530 {
407 setRange(d_ptr->m_min,max);
531 setRange(d_ptr->m_min,max);
408 }
532 }
409
533
410 qreal QAxis::max() const
534 qreal QAxis::max() const
411 {
535 {
412 return d_ptr->m_max;
536 return d_ptr->m_max;
413 }
537 }
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;
421 if (!qFuzzyIsNull(d_ptr->m_min - min)) {
545 if (!qFuzzyIsNull(d_ptr->m_min - min)) {
422 d_ptr->m_min = min;
546 d_ptr->m_min = min;
423 changed = true;
547 changed = true;
424 emit minChanged(min);
548 emit minChanged(min);
425 }
549 }
426
550
427 if (!qFuzzyIsNull(d_ptr->m_max - max)) {
551 if (!qFuzzyIsNull(d_ptr->m_max - max)) {
428 d_ptr->m_max = max;
552 d_ptr->m_max = max;
429 changed = true;
553 changed = true;
430 emit maxChanged(max);
554 emit maxChanged(max);
431 }
555 }
432
556
433 if (changed) {
557 if (changed) {
434 emit rangeChanged(d_ptr->m_min,d_ptr->m_max);
558 emit rangeChanged(d_ptr->m_min,d_ptr->m_max);
435 emit d_ptr->changed(d_ptr->m_min, d_ptr->m_max, d_ptr->m_ticksCount, d_ptr->m_niceNumbers);
559 emit d_ptr->changed(d_ptr->m_min, d_ptr->m_max, d_ptr->m_ticksCount, d_ptr->m_niceNumbers);
436 }
560 }
437 }
561 }
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) {
445 d_ptr->m_ticksCount = count;
569 d_ptr->m_ticksCount = count;
446 emit ticksCountChanged(count);
570 emit ticksCountChanged(count);
447 emit d_ptr->changed(d_ptr->m_min, d_ptr->m_max, d_ptr->m_ticksCount, d_ptr->m_niceNumbers);
571 emit d_ptr->changed(d_ptr->m_min, d_ptr->m_max, d_ptr->m_ticksCount, d_ptr->m_niceNumbers);
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;
454 }
582 }
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;
462 d_ptr->m_gridLineVisible=true;
590 d_ptr->m_gridLineVisible=true;
463 d_ptr->m_labelsVisible=true;
591 d_ptr->m_labelsVisible=true;
464 d_ptr->m_shadesVisible=true;
592 d_ptr->m_shadesVisible=true;
465 emit d_ptr->updated();
593 emit d_ptr->updated();
466 }
594 }
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;
474 d_ptr->m_gridLineVisible = false;
602 d_ptr->m_gridLineVisible = false;
475 d_ptr->m_labelsVisible = false;
603 d_ptr->m_labelsVisible = false;
476 d_ptr->m_shadesVisible = false;
604 d_ptr->m_shadesVisible = false;
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;
497 }
620 }
498
621
499 QAxisCategories* QAxis::categories()
622 QAxisCategories* QAxis::categories()
500 {
623 {
501 return &d_ptr->m_category;
624 return &d_ptr->m_category;
502 }
625 }
503
626
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 }
521
645
522 QAxisPrivate::~QAxisPrivate()
646 QAxisPrivate::~QAxisPrivate()
523 {
647 {
524
648
525 }
649 }
526
650
527 void QAxisPrivate::handleAxisRangeChanged(qreal min, qreal max,int count)
651 void QAxisPrivate::handleAxisRangeChanged(qreal min, qreal max,int count)
528 {
652 {
529 q_ptr->setRange(min,max);
653 q_ptr->setRange(min,max);
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
@@ -1,112 +1,138
1 /****************************************************************************
1 /****************************************************************************
2 **
2 **
3 ** Copyright (C) 2012 Digia Plc
3 ** Copyright (C) 2012 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 Commercial Charts Add-on.
7 ** This file is part of the Qt Commercial Charts Add-on.
8 **
8 **
9 ** $QT_BEGIN_LICENSE$
9 ** $QT_BEGIN_LICENSE$
10 ** Licensees holding valid Qt Commercial licenses may use this file in
10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 ** accordance with the Qt Commercial License Agreement provided with the
11 ** accordance with the Qt Commercial 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 QAXIS_H
21 #ifndef QAXIS_H
22 #define QAXIS_H
22 #define QAXIS_H
23
23
24 #include <qchartglobal.h>
24 #include <qchartglobal.h>
25 #include <qaxiscategories.h>
25 #include <qaxiscategories.h>
26 #include <QPen>
26 #include <QPen>
27 #include <QFont>
27 #include <QFont>
28
28
29 QTCOMMERCIALCHART_BEGIN_NAMESPACE
29 QTCOMMERCIALCHART_BEGIN_NAMESPACE
30
30
31 class QAxisPrivate;
31 class QAxisPrivate;
32
32
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
42 QAxis(QObject *parent =0);
52 QAxis(QObject *parent =0);
43 ~QAxis();
53 ~QAxis();
44
54
45 //axis handling
55 //axis handling
46 bool isAxisVisible() const;
56 bool isAxisVisible() const;
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;
53 void setGridLineVisible(bool visible = true);
65 void setGridLineVisible(bool visible = true);
54 void setGridLinePen(const QPen &pen);
66 void setGridLinePen(const QPen &pen);
55 QPen gridLinePen() const;
67 QPen gridLinePen() const;
56
68
57 //labels handling
69 //labels handling
58 bool labelsVisible() const;
70 bool labelsVisible() const;
59 void setLabelsVisible(bool visible = true);
71 void setLabelsVisible(bool visible = true);
60 void setLabelsPen(const QPen &pen);
72 void setLabelsPen(const QPen &pen);
61 QPen labelsPen() const;
73 QPen labelsPen() const;
62 void setLabelsBrush(const QBrush &brush);
74 void setLabelsBrush(const QBrush &brush);
63 QBrush labelsBrush() const;
75 QBrush labelsBrush() const;
64 void setLabelsFont(const QFont &font);
76 void setLabelsFont(const QFont &font);
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;
71 void setShadesVisible(bool visible = true);
85 void setShadesVisible(bool visible = true);
72 void setShadesPen(const QPen &pen);
86 void setShadesPen(const QPen &pen);
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);
81 qreal min() const;
97 qreal min() const;
82 void setMax(qreal max);
98 void setMax(qreal max);
83 qreal max() const;
99 qreal max() const;
84 void setRange(qreal min, qreal max);
100 void setRange(qreal min, qreal max);
85
101
86 //ticks handling
102 //ticks handling
87 void setTicksCount(int count);
103 void setTicksCount(int count);
88 int ticksCount() const;
104 int ticksCount() const;
89
105
90 void setNiceNumbersEnabled(bool enable = true);
106 void setNiceNumbersEnabled(bool enable = true);
91 bool niceNumbersEnabled() const;
107 bool niceNumbersEnabled() const;
92
108
93 QAxisCategories* categories();
109 QAxisCategories* categories();
94
110
95 void show();
111 void show();
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 };
110
136
111 QTCOMMERCIALCHART_END_NAMESPACE
137 QTCOMMERCIALCHART_END_NAMESPACE
112 #endif /* QCHARTAXIS_H_ */
138 #endif /* QCHARTAXIS_H_ */
@@ -1,101 +1,239
1 /****************************************************************************
1 /****************************************************************************
2 **
2 **
3 ** Copyright (C) 2012 Digia Plc
3 ** Copyright (C) 2012 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 Commercial Charts Add-on.
7 ** This file is part of the Qt Commercial Charts Add-on.
8 **
8 **
9 ** $QT_BEGIN_LICENSE$
9 ** $QT_BEGIN_LICENSE$
10 ** Licensees holding valid Qt Commercial licenses may use this file in
10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 ** accordance with the Qt Commercial License Agreement provided with the
11 ** accordance with the Qt Commercial 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 import QtQuick 1.0
21 import QtQuick 1.0
22 import QtCommercial.Chart 1.0
22 import QtCommercial.Chart 1.0
23
23
24
24
25 Flow {
25 Flow {
26 id: flow
26 id: flow
27 spacing: 5
27 spacing: 5
28 flow: Flow.TopToBottom
28 flow: Flow.TopToBottom
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 {
36 target: series
38 target: series
37 ignoreUnknownSignals: true
39 ignoreUnknownSignals: true
38 onVisibleChanged: console.log("chart.onVisibleChanged: " + series.visible);
40 onVisibleChanged: console.log("chart.onVisibleChanged: " + series.visible);
39 onThemeChanged: console.log("chart.onThemeChanged: " + series.theme);
41 onThemeChanged: console.log("chart.onThemeChanged: " + series.theme);
40 onLegendChanged: console.log("chart.onLegendChanged: " + series.legend);
42 onLegendChanged: console.log("chart.onLegendChanged: " + series.legend);
41 onAnimationOptionsChanged: console.log("chart.onAnimationOptionsChanged: " + series.animationOptions);
43 onAnimationOptionsChanged: console.log("chart.onAnimationOptionsChanged: " + series.animationOptions);
42 onTitleColorChanged: console.log("chart.onTitleColorChanged: " + series.titleColor);
44 onTitleColorChanged: console.log("chart.onTitleColorChanged: " + series.titleColor);
43 onBackgroundColorChanged: console.log("chart.onBackgroundColorChanged: " + series.backgroundColor);
45 onBackgroundColorChanged: console.log("chart.onBackgroundColorChanged: " + series.backgroundColor);
44 }
46 }
45
47
46 Connections {
48 Connections {
47 id: legendConnections
49 id: legendConnections
48 ignoreUnknownSignals: true
50 ignoreUnknownSignals: true
49 onAlignmentChanged: console.log("legend.onAlignmentChanged: " + series.legend.alignment);
51 onAlignmentChanged: console.log("legend.onAlignmentChanged: " + series.legend.alignment);
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;
56 }
90 }
57 Button {
91 Button {
58 text: "theme +"
92 text: "theme +"
59 onClicked: series.theme++;
93 onClicked: series.theme++;
60 }
94 }
61 Button {
95 Button {
62 text: "theme -"
96 text: "theme -"
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 }
69 Button {
119 Button {
70 text: "legend bottom"
120 text: "legend bottom"
71 onClicked: series.legend.alignment ^= Qt.AlignBottom;
121 onClicked: series.legend.alignment ^= Qt.AlignBottom;
72 }
122 }
73 Button {
123 Button {
74 text: "legend left"
124 text: "legend left"
75 onClicked: series.legend.alignment ^= Qt.AlignLeft;
125 onClicked: series.legend.alignment ^= Qt.AlignLeft;
76 }
126 }
77 Button {
127 Button {
78 text: "legend right"
128 text: "legend right"
79 onClicked: series.legend.alignment ^= Qt.AlignRight;
129 onClicked: series.legend.alignment ^= Qt.AlignRight;
80 }
130 }
81 Button {
131 Button {
82 text: "legend visible"
132 text: "legend visible"
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