##// END OF EJS Templates
Updated QChart margins documentation
sauimone -
r1982:ef813a54f504
parent child
Show More
@@ -1,505 +1,499
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::minimumMargins
88 Margins around the plot area. Note that the margin area is used for drawing chart title, legend and axes.
88 Minimum margins between the plot area (axes) and the edge of the chart widget.
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)
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.
108 */
109
110 /*!
111 Constructs a chart object which is a child of a\a parent. Parameter \a wFlags is passed to the QGraphicsWidget constructor.
105 Constructs a chart object which is a child of a\a parent. Parameter \a wFlags is passed to the QGraphicsWidget constructor.
112 */
106 */
113 QChart::QChart(QGraphicsItem *parent, Qt::WindowFlags wFlags) : QGraphicsWidget(parent,wFlags),
107 QChart::QChart(QGraphicsItem *parent, Qt::WindowFlags wFlags) : QGraphicsWidget(parent,wFlags),
114 d_ptr(new QChartPrivate())
108 d_ptr(new QChartPrivate())
115 {
109 {
116 d_ptr->m_dataset = new ChartDataSet(this);
110 d_ptr->m_dataset = new ChartDataSet(this);
117 d_ptr->m_presenter = new ChartPresenter(this,d_ptr->m_dataset);
111 d_ptr->m_presenter = new ChartPresenter(this,d_ptr->m_dataset);
118 d_ptr->createConnections();
112 d_ptr->createConnections();
119 d_ptr->m_legend = new LegendScroller(this);
113 d_ptr->m_legend = new LegendScroller(this);
120 d_ptr->m_presenter->setTheme(QChart::ChartThemeLight, false);
114 d_ptr->m_presenter->setTheme(QChart::ChartThemeLight, false);
121 //connect(d_ptr->m_presenter, SIGNAL(marginsChanged(QRectF)), this, SIGNAL(marginsChanged(QRectF)));
115 //connect(d_ptr->m_presenter, SIGNAL(marginsChanged(QRectF)), this, SIGNAL(marginsChanged(QRectF)));
122 setLayout(d_ptr->m_presenter->layout());
116 setLayout(d_ptr->m_presenter->layout());
123 }
117 }
124
118
125 /*!
119 /*!
126 Destroys the object and it's children, like series and axis objects added to it.
120 Destroys the object and it's children, like series and axis objects added to it.
127 */
121 */
128 QChart::~QChart()
122 QChart::~QChart()
129 {
123 {
130 //delete first presenter , since this is a root of all the graphical items
124 //delete first presenter , since this is a root of all the graphical items
131 setLayout(0);
125 setLayout(0);
132 delete d_ptr->m_presenter;
126 delete d_ptr->m_presenter;
133 d_ptr->m_presenter=0;
127 d_ptr->m_presenter=0;
134 }
128 }
135
129
136 /*!
130 /*!
137 Adds the \a series onto the chart and takes the ownership of the object.
131 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
132 If auto scaling is enabled, re-scales the axes the series is bound to (both the x axis and
139 the y axis).
133 the y axis).
140
134
141 \sa removeSeries(), removeAllSeries()
135 \sa removeSeries(), removeAllSeries()
142 */
136 */
143 void QChart::addSeries(QAbstractSeries *series)
137 void QChart::addSeries(QAbstractSeries *series)
144 {
138 {
145 Q_ASSERT(series);
139 Q_ASSERT(series);
146 d_ptr->m_dataset->addSeries(series);
140 d_ptr->m_dataset->addSeries(series);
147 }
141 }
148
142
149 /*!
143 /*!
150 Removes the \a series specified in a perameter from the QChartView.
144 Removes the \a series specified in a perameter from the QChartView.
151 It releses its ownership of the specified QChartSeries object.
145 It releses its ownership of the specified QChartSeries object.
152 It does not delete the pointed QChartSeries data object
146 It does not delete the pointed QChartSeries data object
153 \sa addSeries(), removeAllSeries()
147 \sa addSeries(), removeAllSeries()
154 */
148 */
155 void QChart::removeSeries(QAbstractSeries *series)
149 void QChart::removeSeries(QAbstractSeries *series)
156 {
150 {
157 Q_ASSERT(series);
151 Q_ASSERT(series);
158 d_ptr->m_dataset->removeSeries(series);
152 d_ptr->m_dataset->removeSeries(series);
159 }
153 }
160
154
161 /*!
155 /*!
162 Removes all the QChartSeries that have been added to the QChartView
156 Removes all the QChartSeries that have been added to the QChartView
163 It also deletes the pointed QChartSeries data objects
157 It also deletes the pointed QChartSeries data objects
164 \sa addSeries(), removeSeries()
158 \sa addSeries(), removeSeries()
165 */
159 */
166 void QChart::removeAllSeries()
160 void QChart::removeAllSeries()
167 {
161 {
168 d_ptr->m_dataset->removeAllSeries();
162 d_ptr->m_dataset->removeAllSeries();
169 }
163 }
170
164
171 /*!
165 /*!
172 Sets the \a brush that is used for painting the background of the chart area.
166 Sets the \a brush that is used for painting the background of the chart area.
173 */
167 */
174 void QChart::setBackgroundBrush(const QBrush& brush)
168 void QChart::setBackgroundBrush(const QBrush& brush)
175 {
169 {
176 d_ptr->m_presenter->setBackgroundBrush(brush);
170 d_ptr->m_presenter->setBackgroundBrush(brush);
177 }
171 }
178
172
179 /*!
173 /*!
180 Gets the brush that is used for painting the background of the chart area.
174 Gets the brush that is used for painting the background of the chart area.
181 */
175 */
182 QBrush QChart::backgroundBrush() const
176 QBrush QChart::backgroundBrush() const
183 {
177 {
184 return d_ptr->m_presenter->backgroundBrush();
178 return d_ptr->m_presenter->backgroundBrush();
185 }
179 }
186
180
187 /*!
181 /*!
188 Sets the \a pen that is used for painting the background of the chart area.
182 Sets the \a pen that is used for painting the background of the chart area.
189 */
183 */
190 void QChart::setBackgroundPen(const QPen& pen)
184 void QChart::setBackgroundPen(const QPen& pen)
191 {
185 {
192 d_ptr->m_presenter->setBackgroundPen(pen);
186 d_ptr->m_presenter->setBackgroundPen(pen);
193 }
187 }
194
188
195 /*!
189 /*!
196 Gets the pen that is used for painting the background of the chart area.
190 Gets the pen that is used for painting the background of the chart area.
197 */
191 */
198 QPen QChart::backgroundPen() const
192 QPen QChart::backgroundPen() const
199 {
193 {
200 return d_ptr->m_presenter->backgroundPen();
194 return d_ptr->m_presenter->backgroundPen();
201 }
195 }
202
196
203 /*!
197 /*!
204 Sets the chart \a title. The description text that is drawn above the chart.
198 Sets the chart \a title. The description text that is drawn above the chart.
205 */
199 */
206 void QChart::setTitle(const QString& title)
200 void QChart::setTitle(const QString& title)
207 {
201 {
208 d_ptr->m_presenter->setTitle(title);
202 d_ptr->m_presenter->setTitle(title);
209 }
203 }
210
204
211 /*!
205 /*!
212 Returns the chart title. The description text that is drawn above the chart.
206 Returns the chart title. The description text that is drawn above the chart.
213 */
207 */
214 QString QChart::title() const
208 QString QChart::title() const
215 {
209 {
216 return d_ptr->m_presenter->title();
210 return d_ptr->m_presenter->title();
217 }
211 }
218
212
219 /*!
213 /*!
220 Sets the \a font that is used for drawing the chart description text that is rendered above the chart.
214 Sets the \a font that is used for drawing the chart description text that is rendered above the chart.
221 */
215 */
222 void QChart::setTitleFont(const QFont& font)
216 void QChart::setTitleFont(const QFont& font)
223 {
217 {
224 d_ptr->m_presenter->setTitleFont(font);
218 d_ptr->m_presenter->setTitleFont(font);
225 }
219 }
226
220
227 /*!
221 /*!
228 Gets the font that is used for drawing the chart description text that is rendered above the chart.
222 Gets the font that is used for drawing the chart description text that is rendered above the chart.
229 */
223 */
230 QFont QChart::titleFont() const
224 QFont QChart::titleFont() const
231 {
225 {
232 return d_ptr->m_presenter->titleFont();
226 return d_ptr->m_presenter->titleFont();
233 }
227 }
234
228
235 /*!
229 /*!
236 Sets the \a brush used for rendering the title text.
230 Sets the \a brush used for rendering the title text.
237 */
231 */
238 void QChart::setTitleBrush(const QBrush &brush)
232 void QChart::setTitleBrush(const QBrush &brush)
239 {
233 {
240 d_ptr->m_presenter->setTitleBrush(brush);
234 d_ptr->m_presenter->setTitleBrush(brush);
241 }
235 }
242
236
243 /*!
237 /*!
244 Returns the brush used for rendering the title text.
238 Returns the brush used for rendering the title text.
245 */
239 */
246 QBrush QChart::titleBrush() const
240 QBrush QChart::titleBrush() const
247 {
241 {
248 return d_ptr->m_presenter->titleBrush();
242 return d_ptr->m_presenter->titleBrush();
249 }
243 }
250
244
251 void QChart::setTheme(QChart::ChartTheme theme)
245 void QChart::setTheme(QChart::ChartTheme theme)
252 {
246 {
253 d_ptr->m_presenter->setTheme(theme);
247 d_ptr->m_presenter->setTheme(theme);
254 }
248 }
255
249
256 QChart::ChartTheme QChart::theme() const
250 QChart::ChartTheme QChart::theme() const
257 {
251 {
258 return d_ptr->m_presenter->theme();
252 return d_ptr->m_presenter->theme();
259 }
253 }
260
254
261 /*!
255 /*!
262 Zooms in the view by a factor of 2
256 Zooms in the view by a factor of 2
263 */
257 */
264 void QChart::zoomIn()
258 void QChart::zoomIn()
265 {
259 {
266 d_ptr->m_presenter->zoomIn(2.0);
260 d_ptr->m_presenter->zoomIn(2.0);
267 }
261 }
268
262
269 /*!
263 /*!
270 Zooms in the view to a maximum level at which \a rect is still fully visible.
264 Zooms in the view to a maximum level at which \a rect is still fully visible.
271 */
265 */
272 void QChart::zoomIn(const QRectF& rect)
266 void QChart::zoomIn(const QRectF& rect)
273 {
267 {
274 if (!rect.isValid()) return;
268 if (!rect.isValid()) return;
275 d_ptr->m_presenter->zoomIn(rect);
269 d_ptr->m_presenter->zoomIn(rect);
276 }
270 }
277
271
278 /*!
272 /*!
279 Restores the view zoom level to the previous one.
273 Restores the view zoom level to the previous one.
280 */
274 */
281 void QChart::zoomOut()
275 void QChart::zoomOut()
282 {
276 {
283 d_ptr->m_presenter->zoomOut(2.0);
277 d_ptr->m_presenter->zoomOut(2.0);
284 }
278 }
285
279
286 /*!
280 /*!
287 Zooms in the view by a \a factor.
281 Zooms in the view by a \a factor.
288
282
289 A factor over 1.0 zooms the view in and factor between 0.0 and 1.0 zooms out.
283 A factor over 1.0 zooms the view in and factor between 0.0 and 1.0 zooms out.
290 */
284 */
291 void QChart::zoom(qreal factor)
285 void QChart::zoom(qreal factor)
292 {
286 {
293 if (qFuzzyIsNull(factor))
287 if (qFuzzyIsNull(factor))
294 return;
288 return;
295
289
296 if (qFuzzyCompare(factor, (qreal)1.0))
290 if (qFuzzyCompare(factor, (qreal)1.0))
297 return;
291 return;
298
292
299 if (factor < 0)
293 if (factor < 0)
300 return;
294 return;
301
295
302 if (factor > 1.0)
296 if (factor > 1.0)
303 d_ptr->m_presenter->zoomIn(factor);
297 d_ptr->m_presenter->zoomIn(factor);
304 else
298 else
305 d_ptr->m_presenter->zoomOut(1.0 / factor);
299 d_ptr->m_presenter->zoomOut(1.0 / factor);
306 }
300 }
307
301
308 /*!
302 /*!
309 Returns the pointer to the x axis object of the chart asociated with the specified \a series
303 Returns the pointer to the x axis object of the chart asociated with the specified \a series
310 If no series is provided then pointer to currently visible axis is provided
304 If no series is provided then pointer to currently visible axis is provided
311 */
305 */
312 QAbstractAxis* QChart::axisX(QAbstractSeries* series) const
306 QAbstractAxis* QChart::axisX(QAbstractSeries* series) const
313 {
307 {
314 return d_ptr->m_dataset->axisX(series);
308 return d_ptr->m_dataset->axisX(series);
315 }
309 }
316
310
317 /*!
311 /*!
318 Returns the pointer to the y axis object of the chart asociated with the specified \a series
312 Returns the pointer to the y axis object of the chart asociated with the specified \a series
319 If no series is provided then pointer to currently visible axis is provided
313 If no series is provided then pointer to currently visible axis is provided
320 */
314 */
321 QAbstractAxis* QChart::axisY(QAbstractSeries *series) const
315 QAbstractAxis* QChart::axisY(QAbstractSeries *series) const
322 {
316 {
323 return d_ptr->m_dataset->axisY(series);
317 return d_ptr->m_dataset->axisY(series);
324 }
318 }
325
319
326 /*!
320 /*!
327 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.
321 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.
328
322
329 Creates the axes for the chart based on the series that has already been added to the chart.
323 Creates the axes for the chart based on the series that has already been added to the chart.
330
324
331 \table
325 \table
332 \header
326 \header
333 \o Series type
327 \o Series type
334 \o X-axis
328 \o X-axis
335 \o Y-axis
329 \o Y-axis
336 \row
330 \row
337 \o QXYSeries
331 \o QXYSeries
338 \o QValueAxis
332 \o QValueAxis
339 \o QValueAxis
333 \o QValueAxis
340 \row
334 \row
341 \o QBarSeries
335 \o QBarSeries
342 \o QBarCategoryAxis
336 \o QBarCategoryAxis
343 \o QValueAxis
337 \o QValueAxis
344 \row
338 \row
345 \o QPieSeries
339 \o QPieSeries
346 \o None
340 \o None
347 \o None
341 \o None
348 \endtable
342 \endtable
349
343
350 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.
344 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.
351 If there are sevaral series added of different types then each series gets its own axes pair.
345 If there are sevaral series added of different types then each series gets its own axes pair.
352
346
353 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.
347 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.
354
348
355 Axis specifix to the series can be later obtained from the chart by providing the series as the parameter of axisX(), axisY() function calls.
349 Axis specifix to the series can be later obtained from the chart by providing the series as the parameter of axisX(), axisY() function calls.
356 QPieSeries does not create any axes.
350 QPieSeries does not create any axes.
357
351
358 \sa axisX(), axisY(), setAxisX(), setAxisY()
352 \sa axisX(), axisY(), setAxisX(), setAxisY()
359 */
353 */
360 void QChart::createDefaultAxes()
354 void QChart::createDefaultAxes()
361 {
355 {
362 d_ptr->m_dataset->createDefaultAxes();
356 d_ptr->m_dataset->createDefaultAxes();
363 }
357 }
364
358
365 /*!
359 /*!
366 Returns the legend object of the chart. Ownership stays in chart.
360 Returns the legend object of the chart. Ownership stays in chart.
367 */
361 */
368 QLegend* QChart::legend() const
362 QLegend* QChart::legend() const
369 {
363 {
370 return d_ptr->m_legend;
364 return d_ptr->m_legend;
371 }
365 }
372
366
373 /*!
367 /*!
374 Sets the minimum \a margins between the plot area (axes) and the edge of the chart widget.
368 Sets the minimum \a margins between the plot area (axes) and the edge of the chart widget.
375 */
369 */
376 void QChart::setMargins(const QMargins& margins)
370 void QChart::setMargins(const QMargins& margins)
377 {
371 {
378 d_ptr->m_presenter->setMargins(margins);
372 d_ptr->m_presenter->setMargins(margins);
379 }
373 }
380
374
381 /*!
375 /*!
382 Returns the rect that contains information about margins (distance between chart widget edge and axes).
376 Returns the rect that contains information about margins (distance between chart widget edge and axes).
383 Individual margins can be obtained by calling left, top, right, bottom on the returned rect.
377 Individual margins can be obtained by calling left, top, right, bottom on the returned rect.
384 */
378 */
385 QMargins QChart::margins() const
379 QMargins QChart::margins() const
386 {
380 {
387 return d_ptr->m_presenter->margins();
381 return d_ptr->m_presenter->margins();
388 }
382 }
389
383
390 /*!
384 /*!
391 Returns the the rect within which the drawing of the chart is done.
385 Returns the the rect within which the drawing of the chart is done.
392 It does not include the area defines by margins.
386 It does not include the area defines by margins.
393 */
387 */
394 QRectF QChart::plotArea() const
388 QRectF QChart::plotArea() const
395 {
389 {
396 return d_ptr->m_presenter->chartsGeometry();
390 return d_ptr->m_presenter->chartsGeometry();
397 }
391 }
398
392
399 ///*!
393 ///*!
400 // TODO: Dummy.
394 // TODO: Dummy.
401 // Adjest the ranges of the axes so that all the data of the specified \a series is visible
395 // Adjest the ranges of the axes so that all the data of the specified \a series is visible
402 // */
396 // */
403 //void QChart::adjustViewToSeries(QAbstractSeries* series)
397 //void QChart::adjustViewToSeries(QAbstractSeries* series)
404 //{
398 //{
405 // //
399 // //
406 //}
400 //}
407
401
408 /*!
402 /*!
409 Sets animation \a options for the chart
403 Sets animation \a options for the chart
410 */
404 */
411 void QChart::setAnimationOptions(AnimationOptions options)
405 void QChart::setAnimationOptions(AnimationOptions options)
412 {
406 {
413 d_ptr->m_presenter->setAnimationOptions(options);
407 d_ptr->m_presenter->setAnimationOptions(options);
414 }
408 }
415
409
416 QChart::AnimationOptions QChart::animationOptions() const
410 QChart::AnimationOptions QChart::animationOptions() const
417 {
411 {
418 return d_ptr->m_presenter->animationOptions();
412 return d_ptr->m_presenter->animationOptions();
419 }
413 }
420
414
421 /*!
415 /*!
422 Scrolls the visible area of the chart by the distance defined in the \a dx and \a dy.
416 Scrolls the visible area of the chart by the distance defined in the \a dx and \a dy.
423 */
417 */
424 void QChart::scroll(qreal dx, qreal dy)
418 void QChart::scroll(qreal dx, qreal dy)
425 {
419 {
426 d_ptr->m_presenter->scroll(dx, dy);
420 d_ptr->m_presenter->scroll(dx, dy);
427 }
421 }
428
422
429 void QChart::setBackgroundVisible(bool visible)
423 void QChart::setBackgroundVisible(bool visible)
430 {
424 {
431 d_ptr->m_presenter->setBackgroundVisible(visible);
425 d_ptr->m_presenter->setBackgroundVisible(visible);
432 }
426 }
433
427
434 bool QChart::isBackgroundVisible() const
428 bool QChart::isBackgroundVisible() const
435 {
429 {
436 return d_ptr->m_presenter->isBackgroundVisible();
430 return d_ptr->m_presenter->isBackgroundVisible();
437 }
431 }
438
432
439 void QChart::setDropShadowEnabled(bool enabled)
433 void QChart::setDropShadowEnabled(bool enabled)
440 {
434 {
441 d_ptr->m_presenter->setBackgroundDropShadowEnabled(enabled);
435 d_ptr->m_presenter->setBackgroundDropShadowEnabled(enabled);
442 }
436 }
443
437
444 bool QChart::isDropShadowEnabled() const
438 bool QChart::isDropShadowEnabled() const
445 {
439 {
446 return d_ptr->m_presenter->isBackgroundDropShadowEnabled();
440 return d_ptr->m_presenter->isBackgroundDropShadowEnabled();
447 }
441 }
448
442
449 /*!
443 /*!
450 Returns all the series that are added to the chart.
444 Returns all the series that are added to the chart.
451
445
452 \sa addSeries(), removeSeries(), removeAllSeries()
446 \sa addSeries(), removeSeries(), removeAllSeries()
453 */
447 */
454 QList<QAbstractSeries*> QChart::series() const
448 QList<QAbstractSeries*> QChart::series() const
455 {
449 {
456 return d_ptr->m_dataset->series();
450 return d_ptr->m_dataset->series();
457 }
451 }
458
452
459 /*!
453 /*!
460 Sets \a axis to the chart, which will control the presentation of the \a series
454 Sets \a axis to the chart, which will control the presentation of the \a series
461
455
462 \sa axisX(), axisY(), setAxisY(), createDefaultAxes()
456 \sa axisX(), axisY(), setAxisY(), createDefaultAxes()
463 */
457 */
464 void QChart::setAxisX(QAbstractAxis* axis , QAbstractSeries *series)
458 void QChart::setAxisX(QAbstractAxis* axis , QAbstractSeries *series)
465 {
459 {
466 d_ptr->m_dataset->setAxis(series,axis,Qt::Horizontal);
460 d_ptr->m_dataset->setAxis(series,axis,Qt::Horizontal);
467 }
461 }
468
462
469 /*!
463 /*!
470 Sets \a axis to the chart, which will control the presentation of the \a series
464 Sets \a axis to the chart, which will control the presentation of the \a series
471
465
472 \sa axisX(), axisY(), setAxisX(), createDefaultAxes()
466 \sa axisX(), axisY(), setAxisX(), createDefaultAxes()
473 */
467 */
474 void QChart::setAxisY( QAbstractAxis* axis , QAbstractSeries *series)
468 void QChart::setAxisY( QAbstractAxis* axis , QAbstractSeries *series)
475 {
469 {
476 d_ptr->m_dataset->setAxis(series,axis,Qt::Vertical);
470 d_ptr->m_dataset->setAxis(series,axis,Qt::Vertical);
477 }
471 }
478
472
479 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
473 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
480
474
481 QChartPrivate::QChartPrivate():
475 QChartPrivate::QChartPrivate():
482 m_legend(0),
476 m_legend(0),
483 m_dataset(0),
477 m_dataset(0),
484 m_presenter(0)
478 m_presenter(0)
485 {
479 {
486
480
487 }
481 }
488
482
489 QChartPrivate::~QChartPrivate()
483 QChartPrivate::~QChartPrivate()
490 {
484 {
491
485
492 }
486 }
493
487
494 void QChartPrivate::createConnections()
488 void QChartPrivate::createConnections()
495 {
489 {
496 QObject::connect(m_dataset,SIGNAL(seriesAdded(QAbstractSeries*,Domain*)),m_presenter,SLOT(handleSeriesAdded(QAbstractSeries*,Domain*)));
490 QObject::connect(m_dataset,SIGNAL(seriesAdded(QAbstractSeries*,Domain*)),m_presenter,SLOT(handleSeriesAdded(QAbstractSeries*,Domain*)));
497 QObject::connect(m_dataset,SIGNAL(seriesRemoved(QAbstractSeries*)),m_presenter,SLOT(handleSeriesRemoved(QAbstractSeries*)));
491 QObject::connect(m_dataset,SIGNAL(seriesRemoved(QAbstractSeries*)),m_presenter,SLOT(handleSeriesRemoved(QAbstractSeries*)));
498 QObject::connect(m_dataset,SIGNAL(axisAdded(QAbstractAxis*,Domain*)),m_presenter,SLOT(handleAxisAdded(QAbstractAxis*,Domain*)));
492 QObject::connect(m_dataset,SIGNAL(axisAdded(QAbstractAxis*,Domain*)),m_presenter,SLOT(handleAxisAdded(QAbstractAxis*,Domain*)));
499 QObject::connect(m_dataset,SIGNAL(axisRemoved(QAbstractAxis*)),m_presenter,SLOT(handleAxisRemoved(QAbstractAxis*)));
493 QObject::connect(m_dataset,SIGNAL(axisRemoved(QAbstractAxis*)),m_presenter,SLOT(handleAxisRemoved(QAbstractAxis*)));
500 //QObject::connect(m_presenter, SIGNAL(marginsChanged(QRectF)), q_ptr, SIGNAL(marginsChanged(QRectF)));
494 //QObject::connect(m_presenter, SIGNAL(marginsChanged(QRectF)), q_ptr, SIGNAL(marginsChanged(QRectF)));
501 }
495 }
502
496
503 #include "moc_qchart.cpp"
497 #include "moc_qchart.cpp"
504
498
505 QTCOMMERCIALCHART_END_NAMESPACE
499 QTCOMMERCIALCHART_END_NAMESPACE
General Comments 0
You need to be logged in to leave comments. Login now