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