##// END OF EJS Templates
Few QChart doc updates
Marek Rosa -
r1633:569878e4ed89
parent child
Show More
@@ -1,440 +1,465
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 "qchart.h"
21 #include "qchart.h"
22 #include "qchart_p.h"
22 #include "qchart_p.h"
23 #include "legendscroller_p.h"
23 #include "legendscroller_p.h"
24 #include "qlegend_p.h"
24 #include "qlegend_p.h"
25 #include "chartbackground_p.h"
25 #include "chartbackground_p.h"
26 #include "qabstractaxis.h"
26 #include "qabstractaxis.h"
27 #include <QGraphicsScene>
27 #include <QGraphicsScene>
28 #include <QGraphicsSceneResizeEvent>
28 #include <QGraphicsSceneResizeEvent>
29 #include <QGraphicsLayout>
29 #include <QGraphicsLayout>
30
30
31 QTCOMMERCIALCHART_BEGIN_NAMESPACE
31 QTCOMMERCIALCHART_BEGIN_NAMESPACE
32
32
33 /*!
33 /*!
34 \enum QChart::ChartTheme
34 \enum QChart::ChartTheme
35
35
36 This enum describes the theme used by the chart.
36 This enum describes the theme used by the chart.
37
37
38 \value ChartThemeLight The default theme
38 \value ChartThemeLight The default theme
39 \value ChartThemeBlueCerulean
39 \value ChartThemeBlueCerulean
40 \value ChartThemeDark
40 \value ChartThemeDark
41 \value ChartThemeBrownSand
41 \value ChartThemeBrownSand
42 \value ChartThemeBlueNcs
42 \value ChartThemeBlueNcs
43 \value ChartThemeHighContrast
43 \value ChartThemeHighContrast
44 \value ChartThemeBlueIcy
44 \value ChartThemeBlueIcy
45 */
45 */
46
46
47 /*!
47 /*!
48 \enum QChart::AnimationOption
48 \enum QChart::AnimationOption
49
49
50 For enabling/disabling animations. Defaults to NoAnimation.
50 For enabling/disabling animations. Defaults to NoAnimation.
51
51
52 \value NoAnimation
52 \value NoAnimation
53 \value GridAxisAnimations
53 \value GridAxisAnimations
54 \value SeriesAnimations
54 \value SeriesAnimations
55 \value AllAnimations
55 \value AllAnimations
56 */
56 */
57
57
58 /*!
58 /*!
59 \class QChart
59 \class QChart
60 \brief QtCommercial chart API.
60 \brief QtCommercial chart API.
61
61
62 QChart is a QGraphicsWidget that you can show in a QGraphicsScene. It manages the graphical
62 QChart is a QGraphicsWidget that you can show in a QGraphicsScene. It manages the graphical
63 representation of different types of series and other chart related objects like
63 representation of different types of series and other chart related objects like
64 QAxis and QLegend. If you simply want to show a chart in a layout, you can use the
64 QAxis and QLegend. If you simply want to show a chart in a layout, you can use the
65 convenience class QChartView instead of QChart.
65 convenience class QChartView instead of QChart.
66 \sa QChartView
66 \sa QChartView
67 */
67 */
68
68
69 /*!
69 /*!
70 \property QChart::animationOptions
70 \property QChart::animationOptions
71 The animation \a options for the chart. Animations are enabled/disabled based on this setting.
71 The animation \a options for the chart. Animations are enabled/disabled based on this setting.
72 */
72 */
73
73
74 /*!
74 /*!
75 \property QChart::backgroundVisible
75 \property QChart::backgroundVisible
76 Whether the chart background is visible or not.
76 Whether the chart background is visible or not.
77 \sa setBackgroundBrush(), setBackgroundPen()
77 \sa setBackgroundBrush(), setBackgroundPen()
78 */
78 */
79
79
80 /*!
80 /*!
81 \property QChart::dropShadowEnabled
81 \property QChart::dropShadowEnabled
82 If set to true, the background drop shadow effect is enabled. If set to false, it is disabled. Note that the drop
82 If set to true, the background drop shadow effect is enabled. If set to false, it is disabled. Note that the drop
83 shadow effect depends on theme, which means the setting may be changed if you switch to another theme.
83 shadow effect depends on theme, which means the setting may be changed if you switch to another theme.
84 */
84 */
85
85
86 /*!
86 /*!
87 \property QChart::margins
87 \property QChart::margins
88 Margins around the plot area. Note that the margin area is used for drawing chart title, legend and axes.
88 Margins around the plot area. Note that the margin area is used for drawing chart title, legend and axes.
89 */
89 */
90
90
91 /*!
91 /*!
92 \property QChart::theme
92 \property QChart::theme
93 Theme is a built-in collection of UI style related settings applied for all visual elements of a chart, like colors,
93 Theme is a built-in collection of UI style related settings applied for all visual elements of a chart, like colors,
94 pens, brushes and fonts of series, axes, title and legend. \l {Chart themes demo} shows an example with a few
94 pens, brushes and fonts of series, axes, title and legend. \l {Chart themes demo} shows an example with a few
95 different themes.
95 different themes.
96 Note: changing the theme will overwrite all customizations previously applied to the series.
96 Note: changing the theme will overwrite all customizations previously applied to the series.
97 */
97 */
98
98
99 /*!
99 /*!
100 \property QChart::title
100 \property QChart::title
101 Title is the name (label) of a chart. It is shown as a headline on top of the chart.
101 Title is the name (label) of a chart. It is shown as a headline on top of the chart.
102 */
102 */
103
103
104 /*!
104 /*!
105 \fn void QChart::marginsChanged(QRectF newMargins)
105 \fn void QChart::marginsChanged(QRectF newMargins)
106 The margins around plot area have changed to \a newMargins. This may happen for example if you change title font size,
106 The margins around plot area have changed to \a newMargins. This may happen for example if you change title font size,
107 modify axes or hide/show legend.
107 modify axes or hide/show legend.
108 */
108 */
109
109
110 /*!
110 /*!
111 Constructs a chart object which is a child of a\a parent. Parameter \a wFlags is passed to the QGraphicsWidget constructor.
111 Constructs a chart object which is a child of a\a parent. Parameter \a wFlags is passed to the QGraphicsWidget constructor.
112 */
112 */
113 QChart::QChart(QGraphicsItem *parent, Qt::WindowFlags wFlags) : QGraphicsWidget(parent,wFlags),
113 QChart::QChart(QGraphicsItem *parent, Qt::WindowFlags wFlags) : QGraphicsWidget(parent,wFlags),
114 d_ptr(new QChartPrivate())
114 d_ptr(new QChartPrivate())
115 {
115 {
116 d_ptr->m_dataset = new ChartDataSet(this);
116 d_ptr->m_dataset = new ChartDataSet(this);
117 d_ptr->m_presenter = new ChartPresenter(this,d_ptr->m_dataset);
117 d_ptr->m_presenter = new ChartPresenter(this,d_ptr->m_dataset);
118 d_ptr->createConnections();
118 d_ptr->createConnections();
119 d_ptr->m_legend = new LegendScroller(this);
119 d_ptr->m_legend = new LegendScroller(this);
120 d_ptr->m_presenter->setTheme(QChart::ChartThemeLight, false);
120 d_ptr->m_presenter->setTheme(QChart::ChartThemeLight, false);
121 //connect(d_ptr->m_presenter, SIGNAL(marginsChanged(QRectF)), this, SIGNAL(marginsChanged(QRectF)));
121 //connect(d_ptr->m_presenter, SIGNAL(marginsChanged(QRectF)), this, SIGNAL(marginsChanged(QRectF)));
122 setLayout(d_ptr->m_presenter->layout());
122 setLayout(d_ptr->m_presenter->layout());
123 }
123 }
124
124
125 /*!
125 /*!
126 Destroys the object and it's children, like series and axis objects added to it.
126 Destroys the object and it's children, like series and axis objects added to it.
127 */
127 */
128 QChart::~QChart()
128 QChart::~QChart()
129 {
129 {
130 //delete first presenter , since this is a root of all the graphical items
130 //delete first presenter , since this is a root of all the graphical items
131 setLayout(0);
131 setLayout(0);
132 delete d_ptr->m_presenter;
132 delete d_ptr->m_presenter;
133 d_ptr->m_presenter=0;
133 d_ptr->m_presenter=0;
134 }
134 }
135
135
136 /*!
136 /*!
137 Adds the \a series onto the chart and takes the ownership of the object.
137 Adds the \a series onto the chart and takes the ownership of the object.
138 If auto scaling is enabled, re-scales the axes the series is bound to (both the x axis and
138 If auto scaling is enabled, re-scales the axes the series is bound to (both the x axis and
139 the y axis).
139 the y axis).
140
140
141 \sa removeSeries(), removeAllSeries()
141 \sa removeSeries(), removeAllSeries()
142 */
142 */
143 void QChart::addSeries(QAbstractSeries *series)
143 void QChart::addSeries(QAbstractSeries *series)
144 {
144 {
145 Q_ASSERT(series);
145 Q_ASSERT(series);
146 d_ptr->m_dataset->addSeries(series);
146 d_ptr->m_dataset->addSeries(series);
147 }
147 }
148
148
149 /*!
149 /*!
150 Removes the \a series specified in a perameter from the QChartView.
150 Removes the \a series specified in a perameter from the QChartView.
151 It releses its ownership of the specified QChartSeries object.
151 It releses its ownership of the specified QChartSeries object.
152 It does not delete the pointed QChartSeries data object
152 It does not delete the pointed QChartSeries data object
153 \sa addSeries(), removeAllSeries()
153 \sa addSeries(), removeAllSeries()
154 */
154 */
155 void QChart::removeSeries(QAbstractSeries *series)
155 void QChart::removeSeries(QAbstractSeries *series)
156 {
156 {
157 Q_ASSERT(series);
157 Q_ASSERT(series);
158 d_ptr->m_dataset->removeSeries(series);
158 d_ptr->m_dataset->removeSeries(series);
159 }
159 }
160
160
161 /*!
161 /*!
162 Removes all the QChartSeries that have been added to the QChartView
162 Removes all the QChartSeries that have been added to the QChartView
163 It also deletes the pointed QChartSeries data objects
163 It also deletes the pointed QChartSeries data objects
164 \sa addSeries(), removeSeries()
164 \sa addSeries(), removeSeries()
165 */
165 */
166 void QChart::removeAllSeries()
166 void QChart::removeAllSeries()
167 {
167 {
168 d_ptr->m_dataset->removeAllSeries();
168 d_ptr->m_dataset->removeAllSeries();
169 }
169 }
170
170
171 /*!
171 /*!
172 Sets the \a brush that is used for painting the background of the chart area.
172 Sets the \a brush that is used for painting the background of the chart area.
173 */
173 */
174 void QChart::setBackgroundBrush(const QBrush& brush)
174 void QChart::setBackgroundBrush(const QBrush& brush)
175 {
175 {
176 d_ptr->m_presenter->setBackgroundBrush(brush);
176 d_ptr->m_presenter->setBackgroundBrush(brush);
177 }
177 }
178
178
179 /*!
179 /*!
180 Gets the brush that is used for painting the background of the chart area.
180 Gets the brush that is used for painting the background of the chart area.
181 */
181 */
182 QBrush QChart::backgroundBrush() const
182 QBrush QChart::backgroundBrush() const
183 {
183 {
184 return d_ptr->m_presenter->backgroundBrush();
184 return d_ptr->m_presenter->backgroundBrush();
185 }
185 }
186
186
187 /*!
187 /*!
188 Sets the \a pen that is used for painting the background of the chart area.
188 Sets the \a pen that is used for painting the background of the chart area.
189 */
189 */
190 void QChart::setBackgroundPen(const QPen& pen)
190 void QChart::setBackgroundPen(const QPen& pen)
191 {
191 {
192 d_ptr->m_presenter->setBackgroundPen(pen);
192 d_ptr->m_presenter->setBackgroundPen(pen);
193 }
193 }
194
194
195 /*!
195 /*!
196 Gets the pen that is used for painting the background of the chart area.
196 Gets the pen that is used for painting the background of the chart area.
197 */
197 */
198 QPen QChart::backgroundPen() const
198 QPen QChart::backgroundPen() const
199 {
199 {
200 return d_ptr->m_presenter->backgroundPen();
200 return d_ptr->m_presenter->backgroundPen();
201 }
201 }
202
202
203 /*!
203 /*!
204 Sets the chart \a title. The description text that is drawn above the chart.
204 Sets the chart \a title. The description text that is drawn above the chart.
205 */
205 */
206 void QChart::setTitle(const QString& title)
206 void QChart::setTitle(const QString& title)
207 {
207 {
208 d_ptr->m_presenter->setTitle(title);
208 d_ptr->m_presenter->setTitle(title);
209 }
209 }
210
210
211 /*!
211 /*!
212 Returns the chart title. The description text that is drawn above the chart.
212 Returns the chart title. The description text that is drawn above the chart.
213 */
213 */
214 QString QChart::title() const
214 QString QChart::title() const
215 {
215 {
216 return d_ptr->m_presenter->title();
216 return d_ptr->m_presenter->title();
217 }
217 }
218
218
219 /*!
219 /*!
220 Sets the \a font that is used for drawing the chart description text that is rendered above the chart.
220 Sets the \a font that is used for drawing the chart description text that is rendered above the chart.
221 */
221 */
222 void QChart::setTitleFont(const QFont& font)
222 void QChart::setTitleFont(const QFont& font)
223 {
223 {
224 d_ptr->m_presenter->setTitleFont(font);
224 d_ptr->m_presenter->setTitleFont(font);
225 }
225 }
226
226
227 /*!
227 /*!
228 Gets the font that is used for drawing the chart description text that is rendered above the chart.
228 Gets the font that is used for drawing the chart description text that is rendered above the chart.
229 */
229 */
230 QFont QChart::titleFont() const
230 QFont QChart::titleFont() const
231 {
231 {
232 return d_ptr->m_presenter->titleFont();
232 return d_ptr->m_presenter->titleFont();
233 }
233 }
234
234
235 /*!
235 /*!
236 Sets the \a brush used for rendering the title text.
236 Sets the \a brush used for rendering the title text.
237 */
237 */
238 void QChart::setTitleBrush(const QBrush &brush)
238 void QChart::setTitleBrush(const QBrush &brush)
239 {
239 {
240 d_ptr->m_presenter->setTitleBrush(brush);
240 d_ptr->m_presenter->setTitleBrush(brush);
241 }
241 }
242
242
243 /*!
243 /*!
244 Returns the brush used for rendering the title text.
244 Returns the brush used for rendering the title text.
245 */
245 */
246 QBrush QChart::titleBrush() const
246 QBrush QChart::titleBrush() const
247 {
247 {
248 return d_ptr->m_presenter->titleBrush();
248 return d_ptr->m_presenter->titleBrush();
249 }
249 }
250
250
251 void QChart::setTheme(QChart::ChartTheme theme)
251 void QChart::setTheme(QChart::ChartTheme theme)
252 {
252 {
253 d_ptr->m_presenter->setTheme(theme);
253 d_ptr->m_presenter->setTheme(theme);
254 }
254 }
255
255
256 QChart::ChartTheme QChart::theme() const
256 QChart::ChartTheme QChart::theme() const
257 {
257 {
258 return d_ptr->m_presenter->theme();
258 return d_ptr->m_presenter->theme();
259 }
259 }
260
260
261 /*!
261 /*!
262 Zooms in the view by a factor of 2
262 Zooms in the view by a factor of 2
263 */
263 */
264 void QChart::zoomIn()
264 void QChart::zoomIn()
265 {
265 {
266 d_ptr->m_presenter->zoomIn(2.0);
266 d_ptr->m_presenter->zoomIn(2.0);
267 }
267 }
268
268
269 /*!
269 /*!
270 Zooms in the view to a maximum level at which \a rect is still fully visible.
270 Zooms in the view to a maximum level at which \a rect is still fully visible.
271 */
271 */
272 void QChart::zoomIn(const QRectF& rect)
272 void QChart::zoomIn(const QRectF& rect)
273 {
273 {
274 if (!rect.isValid()) return;
274 if (!rect.isValid()) return;
275 d_ptr->m_presenter->zoomIn(rect);
275 d_ptr->m_presenter->zoomIn(rect);
276 }
276 }
277
277
278 /*!
278 /*!
279 Restores the view zoom level to the previous one.
279 Restores the view zoom level to the previous one.
280 */
280 */
281 void QChart::zoomOut()
281 void QChart::zoomOut()
282 {
282 {
283 d_ptr->m_presenter->zoomOut(2.0);
283 d_ptr->m_presenter->zoomOut(2.0);
284 }
284 }
285
285
286 /*!
286 /*!
287 Zooms in the view by a \a factor.
287 Zooms in the view by a \a factor.
288
288
289 A factor over 1.0 zooms the view in and factor between 0.0 and 1.0 zooms out.
289 A factor over 1.0 zooms the view in and factor between 0.0 and 1.0 zooms out.
290 */
290 */
291 void QChart::zoom(qreal factor)
291 void QChart::zoom(qreal factor)
292 {
292 {
293 if (qFuzzyIsNull(factor))
293 if (qFuzzyIsNull(factor))
294 return;
294 return;
295
295
296 if (qFuzzyCompare(factor, 1.0))
296 if (qFuzzyCompare(factor, 1.0))
297 return;
297 return;
298
298
299 if (factor < 0)
299 if (factor < 0)
300 return;
300 return;
301
301
302 if (factor > 1.0)
302 if (factor > 1.0)
303 d_ptr->m_presenter->zoomIn(factor);
303 d_ptr->m_presenter->zoomIn(factor);
304 else
304 else
305 d_ptr->m_presenter->zoomOut(1.0 / factor);
305 d_ptr->m_presenter->zoomOut(1.0 / factor);
306 }
306 }
307
307
308 /*!
308 /*!
309 Returns the pointer to the x axis object of the chart
309 Returns the pointer to the x axis object of the chart asociated with the specified \a series
310 */
310 */
311 QAbstractAxis* QChart::axisX(QAbstractSeries* series) const
311 QAbstractAxis* QChart::axisX(QAbstractSeries* series) const
312 {
312 {
313 return d_ptr->m_dataset->axisX(series);
313 return d_ptr->m_dataset->axisX(series);
314 }
314 }
315
315
316 /*!
316 /*!
317 Returns the pointer to the y axis object of the \a series
317 Returns the pointer to the y axis object of the chart asociated with the specified \a series
318 If no \a series is provided then default Y axis of the chart is returned.
319 */
318 */
320 QAbstractAxis* QChart::axisY(QAbstractSeries *series) const
319 QAbstractAxis* QChart::axisY(QAbstractSeries *series) const
321 {
320 {
322 return d_ptr->m_dataset->axisY(series);
321 return d_ptr->m_dataset->axisY(series);
323 }
322 }
324
323
324 /*!
325 NOTICE: This function has to be called after series has been added to the chart if no customized axes are set to the chart. Otherwise axisX(), axisY() calls return NULL.
326
327 Creates the axes for the chart based on the series that has already been added to the chart.
328 If QXYSeries derived series has been added to the chart then QValuesAxes are created as X and Y axes for the series.
329 If QBarSeries or series types derived from it has been added then QBarCategoriesAxis is created as X axis and QValueAxis as Y axis.
330 If there are several QXYSeries derived series added to the chart and no other series type has been added then only one pair of axes is created.
331 If there are sevaral series added of different types then each series gets its own axes pair.
332
333 NOTICE: if there is more than one x and y axes created then no axis is drawn by default and one needs to choose explicitly which axis should be shown.
334
335 Axis specifix to the series can be later obtained from the chart by providing the series as the parameter of axisX(), axisY() function calls.
336 QPieSeries does not create any axes.
337
338 \sa axisX(), axisY(), setAxisX(), setAxisY()
339 */
325 void QChart::createDefaultAxes()
340 void QChart::createDefaultAxes()
326 {
341 {
327 d_ptr->m_dataset->createDefaultAxes();
342 d_ptr->m_dataset->createDefaultAxes();
328 }
343 }
329
344
330 /*!
345 /*!
331 Returns the legend object of the chart. Ownership stays in chart.
346 Returns the legend object of the chart. Ownership stays in chart.
332 */
347 */
333 QLegend* QChart::legend() const
348 QLegend* QChart::legend() const
334 {
349 {
335 return d_ptr->m_legend;
350 return d_ptr->m_legend;
336 }
351 }
337
352
338 /*!
353 /*!
339 Returns the rect that contains information about margins (distance between chart widget edge and axes).
354 Returns the rect that contains information about margins (distance between chart widget edge and axes).
340 Individual margins can be obtained by calling left, top, right, bottom on the returned rect.
355 Individual margins can be obtained by calling left, top, right, bottom on the returned rect.
341 */
356 */
342 QRectF QChart::margins() const
357 QRectF QChart::margins() const
343 {
358 {
344 return d_ptr->m_presenter->margins();
359 return d_ptr->m_presenter->margins();
345 }
360 }
346
361
347 /*!
362 /*!
348 Sets animation \a options for the chart
363 Sets animation \a options for the chart
349 */
364 */
350
365
351 void QChart::setAnimationOptions(AnimationOptions options)
366 void QChart::setAnimationOptions(AnimationOptions options)
352 {
367 {
353 d_ptr->m_presenter->setAnimationOptions(options);
368 d_ptr->m_presenter->setAnimationOptions(options);
354 }
369 }
355
370
356 QChart::AnimationOptions QChart::animationOptions() const
371 QChart::AnimationOptions QChart::animationOptions() const
357 {
372 {
358 return d_ptr->m_presenter->animationOptions();
373 return d_ptr->m_presenter->animationOptions();
359 }
374 }
360
375
361 /*!
376 /*!
362 Scrolls the visible area of the chart by the distance defined in the \a dx and \a dy.
377 Scrolls the visible area of the chart by the distance defined in the \a dx and \a dy.
363 */
378 */
364 void QChart::scroll(qreal dx, qreal dy)
379 void QChart::scroll(qreal dx, qreal dy)
365 {
380 {
366 d_ptr->m_presenter->scroll(dx, dy);
381 d_ptr->m_presenter->scroll(dx, dy);
367 }
382 }
368
383
369 void QChart::setBackgroundVisible(bool visible)
384 void QChart::setBackgroundVisible(bool visible)
370 {
385 {
371 d_ptr->m_presenter->setBackgroundVisible(visible);
386 d_ptr->m_presenter->setBackgroundVisible(visible);
372 }
387 }
373
388
374 bool QChart::isBackgroundVisible() const
389 bool QChart::isBackgroundVisible() const
375 {
390 {
376 return d_ptr->m_presenter->isBackgroundVisible();
391 return d_ptr->m_presenter->isBackgroundVisible();
377 }
392 }
378
393
379 void QChart::setDropShadowEnabled(bool enabled)
394 void QChart::setDropShadowEnabled(bool enabled)
380 {
395 {
381 d_ptr->m_presenter->setBackgroundDropShadowEnabled(enabled);
396 d_ptr->m_presenter->setBackgroundDropShadowEnabled(enabled);
382 }
397 }
383
398
384 bool QChart::isDropShadowEnabled() const
399 bool QChart::isDropShadowEnabled() const
385 {
400 {
386 return d_ptr->m_presenter->isBackgroundDropShadowEnabled();
401 return d_ptr->m_presenter->isBackgroundDropShadowEnabled();
387 }
402 }
388
403
389 /*!
404 /*!
390 Returns all the series that are added to the chart.
405 Returns all the series that are added to the chart.
391
406
392 \sa addSeries(), removeSeries(), removeAllSeries()
407 \sa addSeries(), removeSeries(), removeAllSeries()
393 */
408 */
394 QList<QAbstractSeries*> QChart::series() const
409 QList<QAbstractSeries*> QChart::series() const
395 {
410 {
396 return d_ptr->m_dataset->series();
411 return d_ptr->m_dataset->series();
397 }
412 }
398
413
399 void QChart::setMarginsMinimum(const QRectF& margins)
414 void QChart::setMarginsMinimum(const QRectF& margins)
400 {
415 {
401 d_ptr->m_presenter->setMarginsMinimum(margins);
416 d_ptr->m_presenter->setMarginsMinimum(margins);
402 }
417 }
403
418
419 /*!
420 Sets \a axis to the chart, which will control the presentation of the \a series
421
422 \sa axisX(), axisY(), setAxisY(), createDefaultAxes()
423 */
404 void QChart::setAxisX(QAbstractAxis* axis , QAbstractSeries *series)
424 void QChart::setAxisX(QAbstractAxis* axis , QAbstractSeries *series)
405 {
425 {
406 d_ptr->m_dataset->setAxisX(series,axis);
426 d_ptr->m_dataset->setAxisX(series,axis);
407 }
427 }
408
428
429 /*!
430 Sets \a axis to the chart, which will control the presentation of the \a series
431
432 \sa axisX(), axisY(), setAxisX(), createDefaultAxes()
433 */
409 void QChart::setAxisY( QAbstractAxis* axis , QAbstractSeries *series)
434 void QChart::setAxisY( QAbstractAxis* axis , QAbstractSeries *series)
410 {
435 {
411 d_ptr->m_dataset->setAxisY(series,axis);
436 d_ptr->m_dataset->setAxisY(series,axis);
412 }
437 }
413
438
414 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
439 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
415
440
416 QChartPrivate::QChartPrivate():
441 QChartPrivate::QChartPrivate():
417 m_legend(0),
442 m_legend(0),
418 m_dataset(0),
443 m_dataset(0),
419 m_presenter(0)
444 m_presenter(0)
420 {
445 {
421
446
422 }
447 }
423
448
424 QChartPrivate::~QChartPrivate()
449 QChartPrivate::~QChartPrivate()
425 {
450 {
426
451
427 }
452 }
428
453
429 void QChartPrivate::createConnections()
454 void QChartPrivate::createConnections()
430 {
455 {
431 QObject::connect(m_dataset,SIGNAL(seriesAdded(QAbstractSeries*,Domain*)),m_presenter,SLOT(handleSeriesAdded(QAbstractSeries*,Domain*)));
456 QObject::connect(m_dataset,SIGNAL(seriesAdded(QAbstractSeries*,Domain*)),m_presenter,SLOT(handleSeriesAdded(QAbstractSeries*,Domain*)));
432 QObject::connect(m_dataset,SIGNAL(seriesRemoved(QAbstractSeries*)),m_presenter,SLOT(handleSeriesRemoved(QAbstractSeries*)));
457 QObject::connect(m_dataset,SIGNAL(seriesRemoved(QAbstractSeries*)),m_presenter,SLOT(handleSeriesRemoved(QAbstractSeries*)));
433 QObject::connect(m_dataset,SIGNAL(axisAdded(QAbstractAxis*,Domain*)),m_presenter,SLOT(handleAxisAdded(QAbstractAxis*,Domain*)));
458 QObject::connect(m_dataset,SIGNAL(axisAdded(QAbstractAxis*,Domain*)),m_presenter,SLOT(handleAxisAdded(QAbstractAxis*,Domain*)));
434 QObject::connect(m_dataset,SIGNAL(axisRemoved(QAbstractAxis*)),m_presenter,SLOT(handleAxisRemoved(QAbstractAxis*)));
459 QObject::connect(m_dataset,SIGNAL(axisRemoved(QAbstractAxis*)),m_presenter,SLOT(handleAxisRemoved(QAbstractAxis*)));
435 //QObject::connect(m_presenter, SIGNAL(marginsChanged(QRectF)), q_ptr, SIGNAL(marginsChanged(QRectF)));
460 //QObject::connect(m_presenter, SIGNAL(marginsChanged(QRectF)), q_ptr, SIGNAL(marginsChanged(QRectF)));
436 }
461 }
437
462
438 #include "moc_qchart.cpp"
463 #include "moc_qchart.cpp"
439
464
440 QTCOMMERCIALCHART_END_NAMESPACE
465 QTCOMMERCIALCHART_END_NAMESPACE
General Comments 0
You need to be logged in to leave comments. Login now