##// END OF EJS Templates
Few more fixes to docs
Marek Rosa -
r937:ebc42fa644e2
parent child
Show More
@@ -1,444 +1,444
1 1 /****************************************************************************
2 2 **
3 3 ** Copyright (C) 2012 Digia Plc
4 4 ** All rights reserved.
5 5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 6 **
7 7 ** This file is part of the Qt Commercial Charts Add-on.
8 8 **
9 9 ** $QT_BEGIN_LICENSE$
10 10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 11 ** accordance with the Qt Commercial License Agreement provided with the
12 12 ** Software or, alternatively, in accordance with the terms contained in
13 13 ** a written agreement between you and Digia.
14 14 **
15 15 ** If you have questions regarding the use of this file, please use
16 16 ** contact form at http://qt.digia.com
17 17 ** $QT_END_LICENSE$
18 18 **
19 19 ****************************************************************************/
20 20
21 21 #include "qchartaxis.h"
22 22
23 23 QTCOMMERCIALCHART_BEGIN_NAMESPACE
24 24
25 25 /*!
26 26 \class QChartAxis
27 27 \brief The QChartAxis class is used for manipulating chart's axis
28 28 and for adding optional axes to the chart.
29 29 \mainclass
30 30
31 31 There is only one x Axis, however there can be multiple y axes.
32 32 Each chart series can be bound to exactly one Y axis and the share common X axis.
33 33 Axis can be setup to show axis line with ticks, gird lines and shades.
34 34
35 35 */
36 36
37 37 /*!
38 38 \fn bool QChartAxis::isAxisVisible() const
39 39 \brief Returns if axis is visible
40 40 \sa setAxisVisible()
41 41 */
42 42
43 43 /*!
44 44 \fn QPen QChartAxis::axisPen() const
45 45 \brief Returns pen used to draw axis and ticks.
46 46 \sa setAxisPen()
47 47 */
48 48
49 49
50 50 /*!
51 51 \fn bool QChartAxis::isGridLineVisible() const
52 52 \brief Returns if grid is visible
53 53 \sa setGridLineVisible()
54 54 */
55 55
56 56 /*!
57 57 \fn QPen QChartAxis::gridLinePen() const
58 58 \brief Returns pen used to draw grid.
59 59 \sa setGridLinePen()
60 60 */
61 61
62 62 /*!
63 63 \fn bool QChartAxis::labelsVisible() const
64 64 \brief Returns if grid is visible
65 65 \sa setLabelsVisible()
66 66 */
67 67
68 68 /*!
69 69 \fn QPen QChartAxis::labelsPen() const
70 70 \brief Returns the pen used to labels.
71 71 \sa setLabelsPen()
72 72 */
73 73
74 74 /*!
75 75 \fn QBrush QChartAxis::labelsBrush() const
76 76 \brief Returns brush used to draw labels.
77 77 \sa setLabelsBrush()
78 78 */
79 79
80 80 /*!
81 81 \fn QFont QChartAxis::labelsFont() const
82 82 \brief Returns font used to draw labels.
83 83 \sa setLabelsFont()
84 84 */
85 85
86 86 /*!
87 87 \fn QFont QChartAxis::labelsAngle() const
88 88 \brief Returns angle used to draw labels.
89 89 \sa setLabelsAngle()
90 90 */
91 91
92 92 /*!
93 93 \fn bool QChartAxis::shadesVisible() const
94 94 \brief Returns if shades are visible.
95 95 \sa setShadesVisible()
96 96 */
97 97
98 98 /*!
99 99 \fn qreal QChartAxis::shadesOpacity() const
100 100 \brief Returns opacity of shades.
101 101 */
102 102
103 103 /*!
104 104 \fn QPen QChartAxis::shadesPen() const
105 105 \brief Returns pen used to draw shades.
106 106 \sa setShadesPen()
107 107 */
108 108
109 109 /*!
110 110 \fn QBrush QChartAxis::shadesBrush() const
111 111 \brief Returns brush used to draw shades.
112 112 \sa setShadesBrush()
113 113 */
114 114
115 115 /*!
116 116 \fn qreal QChartAxis::min() const
117 117 \brief Returns minimum value on the axis.
118 118 \sa setMin()
119 119 */
120 120
121 121 /*!
122 122 \fn qreal QChartAxis::max() const
123 123 \brief Returns maximim value on the axis.
124 124 \sa setMax()
125 125 */
126 126
127 127 /*!
128 128 \fn void QChartAxis::minChanged(qreal min)
129 129 \brief Axis emits signal when \a min of axis has changed.
130 130 */
131 131
132 132 /*!
133 133 \fn void QChartAxis::maxChanged(qreal max)
134 134 \brief Axis emits signal when \a max of axis has changed.
135 135 */
136 136
137 137 /*!
138 138 \fn void QChartAxis::rangeChanged(qreal min, qreal max)
139 139 \brief Axis emits signal when \a min or \a max of axis has changed.
140 140 */
141 141
142 142 /*!
143 143 \fn int QChartAxis::ticksCount() const
144 144 \brief Return number of ticks on the axis
145 145 \sa setTicksCount()
146 146 */
147 147
148 148 /*!
149 149 \fn void QChartAxis::updated()
150 150 \brief \internal
151 151 */
152 152
153 153 /*!
154 \fn void changed(qreal min, qreal max, int tickCount,bool niceNumbers)
154 \fn void QChartAxis::changed(qreal min, qreal max, int tickCount,bool niceNumbers)
155 155 \brief \internal
156 156 */
157 157
158 158 /*!
159 159 \fn bool QChartAxis::niceNumbers() const
160 160 \brief Returns whether nice numbers are enabled or not.
161 161 */
162 162
163 163 /*!
164 \fn QChartAxisCategories* categories()
164 \fn QChartAxisCategories* QChartAxis::categories()
165 165 \brief Returns pointer to the list of categories which correspond to the values on the axis.
166 166 */
167 167
168 168 /*!
169 \fn void ticksCountChanged(int count)
169 \fn void QChartAxis::ticksCountChanged(int count)
170 170 \brief Emits the new \a count of ticks on the axis
171 171 Signal is emitted when the number of the ticks on the axis has been changed to a different value.
172 172 Parementer count\a count is the new number of ticks on the axis.
173 173 */
174 174
175 175 /*!
176 176 Constructs new axis object which is a child of \a parent. Ownership is taken by
177 177 QChatView or QChart when axis added.
178 178 */
179 179
180 180 QChartAxis::QChartAxis(QObject *parent) : QObject(parent),
181 181 m_axisVisible(true),
182 182 m_gridLineVisible(true),
183 183 m_labelsVisible(true),
184 184 m_labelsAngle(0),
185 185 m_shadesVisible(false),
186 186 m_shadesOpacity(1.0),
187 187 m_min(0),
188 188 m_max(0),
189 189 m_ticksCount(5),
190 190 m_niceNumbers(false)
191 191 {
192 192
193 193 }
194 194
195 195 /*!
196 196 Destructor of the axis object. When axis is added to chart, chart object takes ownership.
197 197 */
198 198
199 199 QChartAxis::~QChartAxis()
200 200 {
201 201 }
202 202
203 203 /*!
204 204 Sets \a pen used to draw axis line and ticks.
205 205 */
206 206 void QChartAxis::setAxisPen(const QPen &pen)
207 207 {
208 208 if (pen != m_axisPen) {
209 209 m_axisPen = pen;
210 210 emit updated();
211 211 }
212 212 }
213 213
214 214 /*!
215 215 Sets if axis and ticks are \a visible.
216 216 */
217 217 void QChartAxis::setAxisVisible(bool visible)
218 218 {
219 219 if (m_axisVisible != visible) {
220 220 m_axisVisible = visible;
221 221 emit updated();
222 222 }
223 223 }
224 224
225 225 /*!
226 226 Sets if grid line is \a visible.
227 227 */
228 228 void QChartAxis::setGridLineVisible(bool visible)
229 229 {
230 230 if (m_gridLineVisible != visible) {
231 231 m_gridLineVisible = visible;
232 232 emit updated();
233 233 }
234 234 }
235 235
236 236 /*!
237 237 Sets \a pen used to draw grid line.
238 238 */
239 239 void QChartAxis::setGridLinePen(const QPen &pen)
240 240 {
241 241 if (m_gridLinePen != pen) {
242 242 m_gridLinePen = pen;
243 243 emit updated();
244 244 }
245 245 }
246 246
247 247 /*!
248 248 Sets if axis' labels are \a visible.
249 249 */
250 250 void QChartAxis::setLabelsVisible(bool visible)
251 251 {
252 252 if (m_labelsVisible != visible) {
253 253 m_labelsVisible = visible;
254 254 emit updated();
255 255 }
256 256 }
257 257
258 258 /*!
259 259 Sets \a pen used to draw labels.
260 260 */
261 261 void QChartAxis::setLabelsPen(const QPen &pen)
262 262 {
263 263 if (m_labelsPen != pen) {
264 264 m_labelsPen = pen;
265 265 emit updated();
266 266 }
267 267 }
268 268
269 269 /*!
270 270 Sets \a brush used to draw labels.
271 271 */
272 272 void QChartAxis::setLabelsBrush(const QBrush &brush)
273 273 {
274 274 if (m_labelsBrush != brush) {
275 275 m_labelsBrush = brush;
276 276 emit updated();
277 277 }
278 278 }
279 279
280 280 /*!
281 281 Sets \a font used to draw labels.
282 282 */
283 283 void QChartAxis::setLabelsFont(const QFont &font)
284 284 {
285 285 if (m_labelsFont != font) {
286 286 m_labelsFont = font;
287 287 emit updated();
288 288 }
289 289 }
290 290
291 291 /*!
292 292 Sets \a angle for all the labels on given axis.
293 293 */
294 294 void QChartAxis::setLabelsAngle(int angle)
295 295 {
296 296 if (m_labelsAngle != angle) {
297 297 m_labelsAngle = angle;
298 298 emit updated();
299 299 }
300 300 }
301 301
302 302 /*!
303 303 Sets if shades are \a visible.
304 304 */
305 305 void QChartAxis::setShadesVisible(bool visible)
306 306 {
307 307 if (m_shadesVisible != visible) {
308 308 m_shadesVisible = visible;
309 309 emit updated();
310 310 }
311 311 }
312 312
313 313 /*!
314 314 Sets \a pen used to draw shades.
315 315 */
316 316 void QChartAxis::setShadesPen(const QPen &pen)
317 317 {
318 318 if (m_shadesPen != pen) {
319 319 m_shadesPen = pen;
320 320 emit updated();
321 321 }
322 322 }
323 323
324 324 /*!
325 325 Sets \a brush used to draw shades.
326 326 */
327 327 void QChartAxis::setShadesBrush(const QBrush &brush)
328 328 {
329 329 if (m_shadesBrush != brush) {
330 330 m_shadesBrush = brush;
331 331 emit updated();
332 332 }
333 333 }
334 334
335 335 /*!
336 336 Sets \a opacity of the shades.
337 337 */
338 338 void QChartAxis::setShadesOpacity(qreal opacity)
339 339 {
340 340 if (m_shadesOpacity != opacity) {
341 341 m_shadesOpacity=opacity;
342 342 emit updated();
343 343 }
344 344 }
345 345
346 346 /*!
347 347 Sets \a min value on the axis.
348 348 */
349 349 void QChartAxis::setMin(qreal min)
350 350 {
351 351 setRange(min,m_max);
352 352 }
353 353
354 354 /*!
355 355 Sets \a max value on the axis.
356 356 */
357 357 void QChartAxis::setMax(qreal max)
358 358 {
359 359 setRange(m_min,max);
360 360 }
361 361
362 362 /*!
363 363 Sets range from \a min to \a max on the axis.
364 364 */
365 365 void QChartAxis::setRange(qreal min, qreal max)
366 366 {
367 367 bool changed = false;
368 368 if (!qFuzzyIsNull(m_min - min)) {
369 369 m_min = min;
370 370 changed = true;
371 371 emit minChanged(min);
372 372 }
373 373
374 374 if (!qFuzzyIsNull(m_max - max)) {
375 375 m_max = max;
376 376 changed = true;
377 377 emit maxChanged(max);
378 378 }
379 379
380 380 if (changed) {
381 381 emit rangeChanged(m_min,m_max);
382 382 emit this->changed(m_min, m_max, m_ticksCount, m_niceNumbers);
383 383 }
384 384 }
385 385
386 386 /*!
387 387 Sets \a count for ticks on the axis.
388 388 */
389 389 void QChartAxis::setTicksCount(int count)
390 390 {
391 391 if (m_ticksCount != count) {
392 392 m_ticksCount = count;
393 393 emit ticksCountChanged(count);
394 394 emit changed(m_min, m_max, m_ticksCount, m_niceNumbers);
395 395 }
396 396 }
397 397
398 398 /*!
399 399 Sets axis, shades, labels and grid lines to be visible.
400 400 */
401 401 void QChartAxis::show()
402 402 {
403 403 m_axisVisible=true;
404 404 m_gridLineVisible=true;
405 405 m_labelsVisible=true;
406 406 m_shadesVisible=true;
407 407 emit updated();
408 408 }
409 409
410 410 /*!
411 411 Sets axis, shades, labels and grid lines to not be visible.
412 412 */
413 413 void QChartAxis::hide()
414 414 {
415 415 m_axisVisible = false;
416 416 m_gridLineVisible = false;
417 417 m_labelsVisible = false;
418 418 m_shadesVisible = false;
419 419 emit updated();
420 420 }
421 421
422 422 /*!
423 423 \internal
424 424 */
425 425 void QChartAxis::handleAxisRangeChanged(qreal min, qreal max,int count)
426 426 {
427 427 setRange(min,max);
428 428 setTicksCount(count);
429 429 }
430 430
431 431 /*!
432 432 Sets the nice numbers state to \a enable
433 433 */
434 434 void QChartAxis::setNiceNumbers(bool enable)
435 435 {
436 436 if (m_niceNumbers != enable){
437 437 m_niceNumbers = enable;
438 438 emit changed(m_min, m_max, m_ticksCount, m_niceNumbers);
439 439 }
440 440 }
441 441
442 442 #include "moc_qchartaxis.cpp"
443 443
444 444 QTCOMMERCIALCHART_END_NAMESPACE
@@ -1,414 +1,413
1 1 /****************************************************************************
2 2 **
3 3 ** Copyright (C) 2012 Digia Plc
4 4 ** All rights reserved.
5 5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 6 **
7 7 ** This file is part of the Qt Commercial Charts Add-on.
8 8 **
9 9 ** $QT_BEGIN_LICENSE$
10 10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 11 ** accordance with the Qt Commercial License Agreement provided with the
12 12 ** Software or, alternatively, in accordance with the terms contained in
13 13 ** a written agreement between you and Digia.
14 14 **
15 15 ** If you have questions regarding the use of this file, please use
16 16 ** contact form at http://qt.digia.com
17 17 ** $QT_END_LICENSE$
18 18 **
19 19 ****************************************************************************/
20 20
21 21 #include "qchart.h"
22 22 #include "qchart_p.h"
23 23 #include <QGraphicsScene>
24 24 #include <QGraphicsSceneResizeEvent>
25 25
26 26 QTCOMMERCIALCHART_BEGIN_NAMESPACE
27 27
28 28 /*!
29 29 \enum QChart::ChartTheme
30 30
31 31 This enum describes the theme used by the chart.
32 32
33 33 \value ChartThemeLight The default theme
34 34 \value ChartThemeBlueCerulean
35 35 \value ChartThemeDark
36 36 \value ChartThemeBrownSand
37 37 \value ChartThemeBlueNcs
38 38 \value ChartThemeHighContrast
39 39 \value ChartThemeBlueIcy
40 \value ChartThemeCount Not really a theme; the total count of themes.
41 40 */
42 41
43 42 /*!
44 43 \enum QChart::AnimationOption
45 44
46 45 For enabling/disabling animations. Defaults to NoAnimation.
47 46
48 47 \value NoAnimation
49 48 \value GridAxisAnimations
50 49 \value SeriesAnimations
51 50 \value AllAnimations
52 51 */
53 52
54 53 /*!
55 54 \class QChart
56 55 \brief QtCommercial chart API.
57 56
58 57 QChart is a QGraphicsWidget that you can show in a QGraphicsScene. It manages the graphical
59 58 representation of different types of QChartSeries and other chart related objects like
60 59 QChartAxis and QChartLegend. If you simply want to show a chart in a layout, you can use the
61 60 convenience class QChartView instead of QChart.
62 61 \sa QChartView
63 62 */
64 63
65 64 /*!
66 65 Constructs a chart object which is a child of a\a parent. Parameter \a wFlags is passed to the QGraphicsWidget constructor.
67 66 */
68 67 QChart::QChart(QGraphicsItem *parent, Qt::WindowFlags wFlags) : QGraphicsWidget(parent,wFlags),
69 68 d_ptr(new QChartPrivate())
70 69 {
71 70 d_ptr->m_legend = new ScrolledQLegend(this);
72 71 d_ptr->m_legend->setVisible(false);
73 72 d_ptr->m_dataset = new ChartDataSet(this);
74 73 d_ptr->m_presenter = new ChartPresenter(this,d_ptr->m_dataset);
75 74 d_ptr->m_presenter->setTheme(QChart::ChartThemeLight, false);
76 75 d_ptr->createConnections();
77 76 //TODO:fix me setMinimumSize(d_ptr->m_padding.left() * 3, d_ptr->m_padding.top() * 3);
78 77 }
79 78
80 79 /*!
81 80 Destroys the object and it's children, like QChartSeries and QChartAxis object added to it.
82 81 */
83 82 QChart::~QChart()
84 83 {
85 84 //delete first presenter , since this is a root of all the graphical items
86 85 delete d_ptr->m_presenter;
87 86 d_ptr->m_presenter=0;
88 87 }
89 88
90 89 /*!
91 90 Adds the \a series and optional \a axisY onto the chart and takes the ownership of the objects.
92 91 If auto scaling is enabled, re-scales the axes the series is bound to (both the x axis and
93 92 the y axis).
94 93 */
95 94 void QChart::addSeries(QSeries* series, QChartAxis* axisY)
96 95 {
97 96 Q_ASSERT(series);
98 97 d_ptr->m_dataset->addSeries(series, axisY);
99 98 }
100 99
101 100 /*!
102 101 Removes the \a series specified in a perameter from the QChartView.
103 102 It releses its ownership of the specified QChartSeries object.
104 103 It does not delete the pointed QChartSeries data object
105 104 \sa addSeries(), removeAllSeries()
106 105 */
107 106 void QChart::removeSeries(QSeries* series)
108 107 {
109 108 Q_ASSERT(series);
110 109 d_ptr->m_dataset->removeSeries(series);
111 110 }
112 111
113 112 /*!
114 113 Removes all the QChartSeries that have been added to the QChartView
115 114 It also deletes the pointed QChartSeries data objects
116 115 \sa addSeries(), removeSeries()
117 116 */
118 117 void QChart::removeAllSeries()
119 118 {
120 119 d_ptr->m_dataset->removeAllSeries();
121 120 }
122 121
123 122 /*!
124 123 Sets the \a brush that is used for painting the background of the chart area.
125 124 */
126 125 void QChart::setBackgroundBrush(const QBrush& brush)
127 126 {
128 127 //TODO: refactor me
129 128 d_ptr->m_presenter->createChartBackgroundItem();
130 129 d_ptr->m_presenter->m_backgroundItem->setBrush(brush);
131 130 d_ptr->m_presenter->m_backgroundItem->update();
132 131 }
133 132
134 133 /*!
135 134 Gets the brush that is used for painting the background of the chart area.
136 135 */
137 136 QBrush QChart::backgroundBrush() const
138 137 {
139 138 //TODO: refactor me
140 139 if (!d_ptr->m_presenter->m_backgroundItem) return QBrush();
141 140 return (d_ptr->m_presenter->m_backgroundItem)->brush();
142 141 }
143 142
144 143 /*!
145 144 Sets the \a pen that is used for painting the background of the chart area.
146 145 */
147 146 void QChart::setBackgroundPen(const QPen& pen)
148 147 {
149 148 //TODO: refactor me
150 149 d_ptr->m_presenter->createChartBackgroundItem();
151 150 d_ptr->m_presenter->m_backgroundItem->setPen(pen);
152 151 d_ptr->m_presenter->m_backgroundItem->update();
153 152 }
154 153
155 154 /*!
156 155 Gets the pen that is used for painting the background of the chart area.
157 156 */
158 157 QPen QChart::backgroundPen() const
159 158 {
160 159 //TODO: refactor me
161 160 if (!d_ptr->m_presenter->m_backgroundItem) return QPen();
162 161 return d_ptr->m_presenter->m_backgroundItem->pen();
163 162 }
164 163
165 164 /*!
166 165 Sets the chart \a title. The description text that is drawn above the chart.
167 166 */
168 167 void QChart::setTitle(const QString& title)
169 168 {
170 169 //TODO: refactor me
171 170 d_ptr->m_presenter->createChartTitleItem();
172 171 d_ptr->m_presenter->m_titleItem->setText(title);
173 172 d_ptr->m_presenter->updateLayout();
174 173 }
175 174
176 175 /*!
177 176 Returns the chart title. The description text that is drawn above the chart.
178 177 */
179 178 QString QChart::title() const
180 179 {
181 180 //TODO: refactor me
182 181 if (d_ptr->m_presenter->m_titleItem)
183 182 return d_ptr->m_presenter->m_titleItem->text();
184 183 else
185 184 return QString();
186 185 }
187 186
188 187 /*!
189 188 Sets the \a font that is used for drawing the chart description text that is rendered above the chart.
190 189 */
191 190 void QChart::setTitleFont(const QFont& font)
192 191 {
193 192 //TODO: refactor me
194 193 d_ptr->m_presenter->createChartTitleItem();
195 194 d_ptr->m_presenter->m_titleItem->setFont(font);
196 195 d_ptr->m_presenter->updateLayout();
197 196 }
198 197
199 198 /*!
200 199 Gets the font that is used for drawing the chart description text that is rendered above the chart.
201 200 */
202 201 QFont QChart::titleFont() const
203 202 {
204 203 if (d_ptr->m_presenter->m_titleItem)
205 204 return d_ptr->m_presenter->m_titleItem->font();
206 205 else
207 206 return QFont();
208 207 }
209 208
210 209 /*!
211 210 Sets the \a brush used for rendering the title text.
212 211 */
213 212 void QChart::setTitleBrush(const QBrush &brush)
214 213 {
215 214 //TODO: refactor me
216 215 d_ptr->m_presenter->createChartTitleItem();
217 216 d_ptr->m_presenter->m_titleItem->setBrush(brush);
218 217 d_ptr->m_presenter->updateLayout();
219 218 }
220 219
221 220 /*!
222 221 Returns the brush used for rendering the title text.
223 222 */
224 223 QBrush QChart::titleBrush() const
225 224 {
226 225 //TODO: refactor me
227 226 if (!d_ptr->m_presenter->m_titleItem) return QBrush();
228 227 return d_ptr->m_presenter->m_titleItem->brush();
229 228 }
230 229
231 230 /*!
232 231 Sets the \a theme used by the chart for rendering the graphical representation of the data
233 232 \sa theme()
234 233 */
235 234 void QChart::setTheme(QChart::ChartTheme theme)
236 235 {
237 236 d_ptr->m_presenter->setTheme(theme);
238 237 }
239 238
240 239 /*!
241 240 Returns the theme enum used by the chart.
242 241 \sa ChartTheme, setTheme()
243 242 */
244 243 QChart::ChartTheme QChart::theme() const
245 244 {
246 245 return d_ptr->m_presenter->theme();
247 246 }
248 247
249 248 /*!
250 249 Zooms in the view by a factor of 2
251 250 */
252 251 void QChart::zoomIn()
253 252 {
254 253 d_ptr->m_presenter->zoomIn();
255 254 }
256 255
257 256 /*!
258 257 Zooms in the view to a maximum level at which \a rect is still fully visible.
259 258 */
260 259 void QChart::zoomIn(const QRectF& rect)
261 260 {
262 261 if (!rect.isValid()) return;
263 262 d_ptr->m_presenter->zoomIn(rect);
264 263 }
265 264
266 265 /*!
267 266 Restores the view zoom level to the previous one.
268 267 */
269 268 void QChart::zoomOut()
270 269 {
271 270 d_ptr->m_presenter->zoomOut();
272 271 }
273 272
274 273 /*!
275 274 Returns the pointer to the x axis object of the chart
276 275 */
277 276 QChartAxis* QChart::axisX() const
278 277 {
279 278 return d_ptr->m_dataset->axisX();
280 279 }
281 280
282 281 /*!
283 282 Returns the pointer to the y axis object of the \a series
284 283 If no \a series is provided then default Y axis of the chart is returned.
285 284 */
286 285 QChartAxis* QChart::axisY(QSeries* series) const
287 286 {
288 287 return d_ptr->m_dataset->axisY(series);
289 288 }
290 289
291 290 /*!
292 291 Returns the legend object of the chart. Ownership stays in chart.
293 292 */
294 293 QLegend* QChart::legend() const
295 294 {
296 295 return d_ptr->m_legend;
297 296 }
298 297
299 298 /*!
300 299 Returns the rect that contains information about margins (distance between chart widget edge and axes).
301 300 Individual margins can be obtained by calling left, top, right, bottom on the returned rect.
302 301 */
303 302 QRectF QChart::margins() const
304 303 {
305 304 return d_ptr->m_presenter->margins();
306 305 }
307 306
308 307
309 308 /*!
310 309 Resizes and updates the chart area using the \a event data
311 310 */
312 311 void QChart::resizeEvent(QGraphicsSceneResizeEvent *event)
313 312 {
314 313 d_ptr->m_rect = QRectF(QPoint(0,0),event->newSize());
315 314 QGraphicsWidget::resizeEvent(event);
316 315 d_ptr->m_presenter->setGeometry(d_ptr->m_rect);
317 316 }
318 317
319 318 /*!
320 319 Sets animation \a options for the chart
321 320 */
322 321 void QChart::setAnimationOptions(AnimationOptions options)
323 322 {
324 323 d_ptr->m_presenter->setAnimationOptions(options);
325 324 }
326 325
327 326 /*!
328 327 Returns animation options for the chart
329 328 */
330 329 QChart::AnimationOptions QChart::animationOptions() const
331 330 {
332 331 return d_ptr->m_presenter->animationOptions();
333 332 }
334 333
335 334 /*!
336 335 Scrolls the visible area of the chart to the left by the distance between two x axis ticks
337 336 */
338 337 void QChart::scrollLeft()
339 338 {
340 339 d_ptr->m_presenter->scroll(-d_ptr->m_presenter->chartGeometry().width()/(axisX()->ticksCount()-1),0);
341 340 }
342 341
343 342 /*!
344 343 Scrolls the visible area of the chart to the right by the distance between two x axis ticks
345 344 */
346 345 void QChart::scrollRight()
347 346 {
348 347 d_ptr->m_presenter->scroll(d_ptr->m_presenter->chartGeometry().width()/(axisX()->ticksCount()-1),0);
349 348 }
350 349
351 350 /*!
352 351 Scrolls the visible area of the chart up by the distance between two y axis ticks
353 352 */
354 353 void QChart::scrollUp()
355 354 {
356 355 d_ptr->m_presenter->scroll(0,d_ptr->m_presenter->chartGeometry().width()/(axisY()->ticksCount()-1));
357 356 }
358 357
359 358 /*!
360 359 Scrolls the visible area of the chart down by the distance between two y axis ticks
361 360 */
362 361 void QChart::scrollDown()
363 362 {
364 363 d_ptr->m_presenter->scroll(0,-d_ptr->m_presenter->chartGeometry().width()/(axisY()->ticksCount()-1));
365 364 }
366 365
367 366 /*!
368 367 Sets the chart background visibility state to \a visible
369 368 */
370 369 void QChart::setBackgroundVisible(bool visible)
371 370 {
372 371 //TODO: refactor me
373 372 d_ptr->m_presenter->createChartBackgroundItem();
374 373 d_ptr->m_presenter->m_backgroundItem->setVisible(visible);
375 374 }
376 375
377 376 /*!
378 377 Returns the chart's background visibility state
379 378 */
380 379 bool QChart::isBackgroundVisible() const
381 380 {
382 381 //TODO: refactor me
383 382 if (!d_ptr->m_presenter->m_backgroundItem) return false;
384 383 return d_ptr->m_presenter->m_backgroundItem->isVisible();
385 384 }
386 385
387 386 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
388 387
389 388 QChartPrivate::QChartPrivate():
390 389 m_legend(0),
391 390 m_dataset(0),
392 391 m_presenter(0)
393 392 {
394 393
395 394 }
396 395
397 396 QChartPrivate::~QChartPrivate()
398 397 {
399 398
400 399 }
401 400
402 401 void QChartPrivate::createConnections()
403 402 {
404 403 QObject::connect(m_dataset,SIGNAL(seriesAdded(QSeries*,Domain*)),m_legend,SLOT(handleSeriesAdded(QSeries*,Domain*)));
405 404 QObject::connect(m_dataset,SIGNAL(seriesRemoved(QSeries*)),m_legend,SLOT(handleSeriesRemoved(QSeries*)));
406 405 QObject::connect(m_dataset,SIGNAL(seriesAdded(QSeries*,Domain*)),m_presenter,SLOT(handleSeriesAdded(QSeries*,Domain*)));
407 406 QObject::connect(m_dataset,SIGNAL(seriesRemoved(QSeries*)),m_presenter,SLOT(handleSeriesRemoved(QSeries*)));
408 407 QObject::connect(m_dataset,SIGNAL(axisAdded(QChartAxis*,Domain*)),m_presenter,SLOT(handleAxisAdded(QChartAxis*,Domain*)));
409 408 QObject::connect(m_dataset,SIGNAL(axisRemoved(QChartAxis*)),m_presenter,SLOT(handleAxisRemoved(QChartAxis*)));
410 409 }
411 410
412 411 #include "moc_qchart.cpp"
413 412
414 413 QTCOMMERCIALCHART_END_NAMESPACE
General Comments 0
You need to be logged in to leave comments. Login now