@@ -1,505 +1,526 | |||||
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 "chartlayout_p.h" |
|
27 | #include "chartlayout_p.h" | |
28 | #include <QGraphicsScene> |
|
28 | #include <QGraphicsScene> | |
29 | #include <QGraphicsSceneResizeEvent> |
|
29 | #include <QGraphicsSceneResizeEvent> | |
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::minimumMargins |
|
87 | \property QChart::minimumMargins | |
88 | Minimum margins between the plot area (axes) and the edge of the chart widget. |
|
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 | 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. | |
106 | */ |
|
106 | */ | |
107 | QChart::QChart(QGraphicsItem *parent, Qt::WindowFlags wFlags) |
|
107 | QChart::QChart(QGraphicsItem *parent, Qt::WindowFlags wFlags) | |
108 | : QGraphicsWidget(parent, wFlags), |
|
108 | : QGraphicsWidget(parent, wFlags), | |
109 | d_ptr(new QChartPrivate()) |
|
109 | d_ptr(new QChartPrivate()) | |
110 | { |
|
110 | { | |
111 | d_ptr->m_dataset = new ChartDataSet(this); |
|
111 | d_ptr->m_dataset = new ChartDataSet(this); | |
112 | d_ptr->m_presenter = new ChartPresenter(this, d_ptr->m_dataset); |
|
112 | d_ptr->m_presenter = new ChartPresenter(this, d_ptr->m_dataset); | |
113 | d_ptr->createConnections(); |
|
113 | d_ptr->createConnections(); | |
114 | d_ptr->m_legend = new LegendScroller(this); |
|
114 | d_ptr->m_legend = new LegendScroller(this); | |
115 | d_ptr->m_presenter->setTheme(QChart::ChartThemeLight, false); |
|
115 | d_ptr->m_presenter->setTheme(QChart::ChartThemeLight, false); | |
116 | //connect(d_ptr->m_presenter, SIGNAL(marginsChanged(QRectF)), this, SIGNAL(marginsChanged(QRectF))); |
|
116 | //connect(d_ptr->m_presenter, SIGNAL(marginsChanged(QRectF)), this, SIGNAL(marginsChanged(QRectF))); | |
117 | setLayout(d_ptr->m_presenter->layout()); |
|
117 | setLayout(d_ptr->m_presenter->layout()); | |
118 | } |
|
118 | } | |
119 |
|
119 | |||
120 | /*! |
|
120 | /*! | |
121 | Destroys the object and it's children, like series and axis objects added to it. |
|
121 | Destroys the object and it's children, like series and axis objects added to it. | |
122 | */ |
|
122 | */ | |
123 | QChart::~QChart() |
|
123 | QChart::~QChart() | |
124 | { |
|
124 | { | |
125 | //delete first presenter , since this is a root of all the graphical items |
|
125 | //delete first presenter , since this is a root of all the graphical items | |
126 | setLayout(0); |
|
126 | setLayout(0); | |
127 | delete d_ptr->m_presenter; |
|
127 | delete d_ptr->m_presenter; | |
128 | d_ptr->m_presenter = 0; |
|
128 | d_ptr->m_presenter = 0; | |
129 | } |
|
129 | } | |
130 |
|
130 | |||
131 | /*! |
|
131 | /*! | |
132 | Adds the \a series onto the chart and takes the ownership of the object. |
|
132 | Adds the \a series onto the chart and takes the ownership of the object. | |
133 | If auto scaling is enabled, re-scales the axes the series is bound to (both the x axis and |
|
133 | If auto scaling is enabled, re-scales the axes the series is bound to (both the x axis and | |
134 | the y axis). |
|
134 | the y axis). | |
135 |
|
135 | |||
136 | \sa removeSeries(), removeAllSeries() |
|
136 | \sa removeSeries(), removeAllSeries() | |
137 | */ |
|
137 | */ | |
138 | void QChart::addSeries(QAbstractSeries *series) |
|
138 | void QChart::addSeries(QAbstractSeries *series) | |
139 | { |
|
139 | { | |
140 | Q_ASSERT(series); |
|
140 | Q_ASSERT(series); | |
141 | d_ptr->m_dataset->addSeries(series); |
|
141 | d_ptr->m_dataset->addSeries(series); | |
142 | } |
|
142 | } | |
143 |
|
143 | |||
144 | /*! |
|
144 | /*! | |
145 | Removes the \a series specified in a perameter from the QChartView. |
|
145 | Removes the \a series specified in a perameter from the QChartView. | |
146 | It releses its ownership of the specified QChartSeries object. |
|
146 | It releses its ownership of the specified QChartSeries object. | |
147 | It does not delete the pointed QChartSeries data object |
|
147 | It does not delete the pointed QChartSeries data object | |
148 | \sa addSeries(), removeAllSeries() |
|
148 | \sa addSeries(), removeAllSeries() | |
149 | */ |
|
149 | */ | |
150 | void QChart::removeSeries(QAbstractSeries *series) |
|
150 | void QChart::removeSeries(QAbstractSeries *series) | |
151 | { |
|
151 | { | |
152 | Q_ASSERT(series); |
|
152 | Q_ASSERT(series); | |
153 | d_ptr->m_dataset->removeSeries(series); |
|
153 | d_ptr->m_dataset->removeSeries(series); | |
154 | } |
|
154 | } | |
155 |
|
155 | |||
156 | /*! |
|
156 | /*! | |
157 | Removes all the QChartSeries that have been added to the QChartView |
|
157 | Removes all the QChartSeries that have been added to the QChartView | |
158 | It also deletes the pointed QChartSeries data objects |
|
158 | It also deletes the pointed QChartSeries data objects | |
159 | \sa addSeries(), removeSeries() |
|
159 | \sa addSeries(), removeSeries() | |
160 | */ |
|
160 | */ | |
161 | void QChart::removeAllSeries() |
|
161 | void QChart::removeAllSeries() | |
162 | { |
|
162 | { | |
163 | d_ptr->m_dataset->removeAllSeries(); |
|
163 | d_ptr->m_dataset->removeAllSeries(); | |
164 | } |
|
164 | } | |
165 |
|
165 | |||
166 | /*! |
|
166 | /*! | |
167 | Sets the \a brush that is used for painting the background of the chart area. |
|
167 | Sets the \a brush that is used for painting the background of the chart area. | |
168 | */ |
|
168 | */ | |
169 | void QChart::setBackgroundBrush(const QBrush &brush) |
|
169 | void QChart::setBackgroundBrush(const QBrush &brush) | |
170 | { |
|
170 | { | |
171 | d_ptr->m_presenter->setBackgroundBrush(brush); |
|
171 | d_ptr->m_presenter->setBackgroundBrush(brush); | |
172 | } |
|
172 | } | |
173 |
|
173 | |||
174 | /*! |
|
174 | /*! | |
175 | Gets the brush that is used for painting the background of the chart area. |
|
175 | Gets the brush that is used for painting the background of the chart area. | |
176 | */ |
|
176 | */ | |
177 | QBrush QChart::backgroundBrush() const |
|
177 | QBrush QChart::backgroundBrush() const | |
178 | { |
|
178 | { | |
179 | return d_ptr->m_presenter->backgroundBrush(); |
|
179 | return d_ptr->m_presenter->backgroundBrush(); | |
180 | } |
|
180 | } | |
181 |
|
181 | |||
182 | /*! |
|
182 | /*! | |
183 | Sets the \a pen that is used for painting the background of the chart area. |
|
183 | Sets the \a pen that is used for painting the background of the chart area. | |
184 | */ |
|
184 | */ | |
185 | void QChart::setBackgroundPen(const QPen &pen) |
|
185 | void QChart::setBackgroundPen(const QPen &pen) | |
186 | { |
|
186 | { | |
187 | d_ptr->m_presenter->setBackgroundPen(pen); |
|
187 | d_ptr->m_presenter->setBackgroundPen(pen); | |
188 | } |
|
188 | } | |
189 |
|
189 | |||
190 | /*! |
|
190 | /*! | |
191 | Gets the pen that is used for painting the background of the chart area. |
|
191 | Gets the pen that is used for painting the background of the chart area. | |
192 | */ |
|
192 | */ | |
193 | QPen QChart::backgroundPen() const |
|
193 | QPen QChart::backgroundPen() const | |
194 | { |
|
194 | { | |
195 | return d_ptr->m_presenter->backgroundPen(); |
|
195 | return d_ptr->m_presenter->backgroundPen(); | |
196 | } |
|
196 | } | |
197 |
|
197 | |||
198 | /*! |
|
198 | /*! | |
199 | Sets the chart \a title. The description text that is drawn above the chart. |
|
199 | Sets the chart \a title. The description text that is drawn above the chart. | |
200 | */ |
|
200 | */ | |
201 | void QChart::setTitle(const QString &title) |
|
201 | void QChart::setTitle(const QString &title) | |
202 | { |
|
202 | { | |
203 | d_ptr->m_presenter->setTitle(title); |
|
203 | d_ptr->m_presenter->setTitle(title); | |
204 | } |
|
204 | } | |
205 |
|
205 | |||
206 | /*! |
|
206 | /*! | |
207 | Returns the chart title. The description text that is drawn above the chart. |
|
207 | Returns the chart title. The description text that is drawn above the chart. | |
208 | */ |
|
208 | */ | |
209 | QString QChart::title() const |
|
209 | QString QChart::title() const | |
210 | { |
|
210 | { | |
211 | return d_ptr->m_presenter->title(); |
|
211 | return d_ptr->m_presenter->title(); | |
212 | } |
|
212 | } | |
213 |
|
213 | |||
214 | /*! |
|
214 | /*! | |
215 | Sets the \a font that is used for drawing the chart description text that is rendered above the chart. |
|
215 | Sets the \a font that is used for drawing the chart description text that is rendered above the chart. | |
216 | */ |
|
216 | */ | |
217 | void QChart::setTitleFont(const QFont &font) |
|
217 | void QChart::setTitleFont(const QFont &font) | |
218 | { |
|
218 | { | |
219 | d_ptr->m_presenter->setTitleFont(font); |
|
219 | d_ptr->m_presenter->setTitleFont(font); | |
220 | } |
|
220 | } | |
221 |
|
221 | |||
222 | /*! |
|
222 | /*! | |
223 | Gets the font that is used for drawing the chart description text that is rendered above the chart. |
|
223 | Gets the font that is used for drawing the chart description text that is rendered above the chart. | |
224 | */ |
|
224 | */ | |
225 | QFont QChart::titleFont() const |
|
225 | QFont QChart::titleFont() const | |
226 | { |
|
226 | { | |
227 | return d_ptr->m_presenter->titleFont(); |
|
227 | return d_ptr->m_presenter->titleFont(); | |
228 | } |
|
228 | } | |
229 |
|
229 | |||
230 | /*! |
|
230 | /*! | |
231 | Sets the \a brush used for rendering the title text. |
|
231 | Sets the \a brush used for rendering the title text. | |
232 | */ |
|
232 | */ | |
233 | void QChart::setTitleBrush(const QBrush &brush) |
|
233 | void QChart::setTitleBrush(const QBrush &brush) | |
234 | { |
|
234 | { | |
235 | d_ptr->m_presenter->setTitleBrush(brush); |
|
235 | d_ptr->m_presenter->setTitleBrush(brush); | |
236 | } |
|
236 | } | |
237 |
|
237 | |||
238 | /*! |
|
238 | /*! | |
239 | Returns the brush used for rendering the title text. |
|
239 | Returns the brush used for rendering the title text. | |
240 | */ |
|
240 | */ | |
241 | QBrush QChart::titleBrush() const |
|
241 | QBrush QChart::titleBrush() const | |
242 | { |
|
242 | { | |
243 | return d_ptr->m_presenter->titleBrush(); |
|
243 | return d_ptr->m_presenter->titleBrush(); | |
244 | } |
|
244 | } | |
245 |
|
245 | |||
246 | void QChart::setTheme(QChart::ChartTheme theme) |
|
246 | void QChart::setTheme(QChart::ChartTheme theme) | |
247 | { |
|
247 | { | |
248 | d_ptr->m_presenter->setTheme(theme); |
|
248 | d_ptr->m_presenter->setTheme(theme); | |
249 | } |
|
249 | } | |
250 |
|
250 | |||
251 | QChart::ChartTheme QChart::theme() const |
|
251 | QChart::ChartTheme QChart::theme() const | |
252 | { |
|
252 | { | |
253 | return d_ptr->m_presenter->theme(); |
|
253 | return d_ptr->m_presenter->theme(); | |
254 | } |
|
254 | } | |
255 |
|
255 | |||
256 | /*! |
|
256 | /*! | |
257 | Zooms in the view by a factor of 2 |
|
257 | Zooms in the view by a factor of 2 | |
258 | */ |
|
258 | */ | |
259 | void QChart::zoomIn() |
|
259 | void QChart::zoomIn() | |
260 | { |
|
260 | { | |
261 | d_ptr->m_presenter->zoomIn(2.0); |
|
261 | d_ptr->m_presenter->zoomIn(2.0); | |
262 | } |
|
262 | } | |
263 |
|
263 | |||
264 | /*! |
|
264 | /*! | |
265 | Zooms in the view to a maximum level at which \a rect is still fully visible. |
|
265 | Zooms in the view to a maximum level at which \a rect is still fully visible. | |
266 | */ |
|
266 | */ | |
267 | void QChart::zoomIn(const QRectF &rect) |
|
267 | void QChart::zoomIn(const QRectF &rect) | |
268 | { |
|
268 | { | |
269 | if (!rect.isValid()) |
|
269 | if (!rect.isValid()) | |
270 | return; |
|
270 | return; | |
271 | d_ptr->m_presenter->zoomIn(rect); |
|
271 | d_ptr->m_presenter->zoomIn(rect); | |
272 | } |
|
272 | } | |
273 |
|
273 | |||
274 | /*! |
|
274 | /*! | |
275 | Restores the view zoom level to the previous one. |
|
275 | Restores the view zoom level to the previous one. | |
276 | */ |
|
276 | */ | |
277 | void QChart::zoomOut() |
|
277 | void QChart::zoomOut() | |
278 | { |
|
278 | { | |
279 | d_ptr->m_presenter->zoomOut(2.0); |
|
279 | d_ptr->m_presenter->zoomOut(2.0); | |
280 | } |
|
280 | } | |
281 |
|
281 | |||
282 | /*! |
|
282 | /*! | |
283 | Zooms in the view by a \a factor. |
|
283 | Zooms in the view by a \a factor. | |
284 |
|
284 | |||
285 | A factor over 1.0 zooms the view in and factor between 0.0 and 1.0 zooms out. |
|
285 | A factor over 1.0 zooms the view in and factor between 0.0 and 1.0 zooms out. | |
286 | */ |
|
286 | */ | |
287 | void QChart::zoom(qreal factor) |
|
287 | void QChart::zoom(qreal factor) | |
288 | { |
|
288 | { | |
289 | if (qFuzzyCompare(factor, 0)) |
|
289 | if (qFuzzyCompare(factor, 0)) | |
290 | return; |
|
290 | return; | |
291 |
|
291 | |||
292 | if (qFuzzyCompare(factor, (qreal)1.0)) |
|
292 | if (qFuzzyCompare(factor, (qreal)1.0)) | |
293 | return; |
|
293 | return; | |
294 |
|
294 | |||
295 | if (factor < 0) |
|
295 | if (factor < 0) | |
296 | return; |
|
296 | return; | |
297 |
|
297 | |||
298 | if (factor > 1.0) |
|
298 | if (factor > 1.0) | |
299 | d_ptr->m_presenter->zoomIn(factor); |
|
299 | d_ptr->m_presenter->zoomIn(factor); | |
300 | else |
|
300 | else | |
301 | d_ptr->m_presenter->zoomOut(1.0 / factor); |
|
301 | d_ptr->m_presenter->zoomOut(1.0 / factor); | |
302 | } |
|
302 | } | |
303 |
|
303 | |||
304 | /*! |
|
304 | /*! | |
305 | Returns the pointer to the x axis object of the chart asociated with the specified \a series |
|
305 | Returns the pointer to the x axis object of the chart asociated with the specified \a series | |
306 | If no series is provided then pointer to currently visible axis is provided |
|
306 | If no series is provided then pointer to currently visible axis is provided | |
307 | */ |
|
307 | */ | |
308 | QAbstractAxis *QChart::axisX(QAbstractSeries *series) const |
|
308 | QAbstractAxis *QChart::axisX(QAbstractSeries *series) const | |
309 | { |
|
309 | { | |
310 | return d_ptr->m_dataset->axisX(series); |
|
310 | return d_ptr->m_dataset->axisX(series); | |
311 | } |
|
311 | } | |
312 |
|
312 | |||
313 | /*! |
|
313 | /*! | |
314 | Returns the pointer to the y axis object of the chart asociated with the specified \a series |
|
314 | Returns the pointer to the y axis object of the chart asociated with the specified \a series | |
315 | If no series is provided then pointer to currently visible axis is provided |
|
315 | If no series is provided then pointer to currently visible axis is provided | |
316 | */ |
|
316 | */ | |
317 | QAbstractAxis *QChart::axisY(QAbstractSeries *series) const |
|
317 | QAbstractAxis *QChart::axisY(QAbstractSeries *series) const | |
318 | { |
|
318 | { | |
319 | return d_ptr->m_dataset->axisY(series); |
|
319 | return d_ptr->m_dataset->axisY(series); | |
320 | } |
|
320 | } | |
321 |
|
321 | |||
322 | /*! |
|
322 | /*! | |
323 | 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. |
|
323 | 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. | |
324 |
|
324 | |||
325 | Creates the axes for the chart based on the series that has already been added to the chart. |
|
325 | Creates the axes for the chart based on the series that has already been added to the chart. | |
326 |
|
326 | |||
327 | \table |
|
327 | \table | |
328 | \header |
|
328 | \header | |
329 | \o Series type |
|
329 | \o Series type | |
330 | \o X-axis |
|
330 | \o X-axis | |
331 | \o Y-axis |
|
331 | \o Y-axis | |
332 | \row |
|
332 | \row | |
333 | \o QXYSeries |
|
333 | \o QXYSeries | |
334 | \o QValueAxis |
|
334 | \o QValueAxis | |
335 | \o QValueAxis |
|
335 | \o QValueAxis | |
336 | \row |
|
336 | \row | |
337 | \o QBarSeries |
|
337 | \o QBarSeries | |
338 | \o QBarCategoryAxis |
|
338 | \o QBarCategoryAxis | |
339 | \o QValueAxis |
|
339 | \o QValueAxis | |
340 | \row |
|
340 | \row | |
341 | \o QPieSeries |
|
341 | \o QPieSeries | |
342 | \o None |
|
342 | \o None | |
343 | \o None |
|
343 | \o None | |
344 | \endtable |
|
344 | \endtable | |
345 |
|
345 | |||
346 | 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. |
|
346 | 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. | |
347 | If there are sevaral series added of different types then each series gets its own axes pair. |
|
347 | If there are sevaral series added of different types then each series gets its own axes pair. | |
348 |
|
348 | |||
349 | 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. |
|
349 | 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. | |
350 |
|
350 | |||
351 | Axis specifix to the series can be later obtained from the chart by providing the series as the parameter of axisX(), axisY() function calls. |
|
351 | Axis specifix to the series can be later obtained from the chart by providing the series as the parameter of axisX(), axisY() function calls. | |
352 | QPieSeries does not create any axes. |
|
352 | QPieSeries does not create any axes. | |
353 |
|
353 | |||
354 | \sa axisX(), axisY(), setAxisX(), setAxisY() |
|
354 | \sa axisX(), axisY(), setAxisX(), setAxisY() | |
355 | */ |
|
355 | */ | |
356 | void QChart::createDefaultAxes() |
|
356 | void QChart::createDefaultAxes() | |
357 | { |
|
357 | { | |
358 | d_ptr->m_dataset->createDefaultAxes(); |
|
358 | d_ptr->m_dataset->createDefaultAxes(); | |
359 | } |
|
359 | } | |
360 |
|
360 | |||
361 | /*! |
|
361 | /*! | |
362 | Returns the legend object of the chart. Ownership stays in chart. |
|
362 | Returns the legend object of the chart. Ownership stays in chart. | |
363 | */ |
|
363 | */ | |
364 | QLegend *QChart::legend() const |
|
364 | QLegend *QChart::legend() const | |
365 | { |
|
365 | { | |
366 | return d_ptr->m_legend; |
|
366 | return d_ptr->m_legend; | |
367 | } |
|
367 | } | |
368 |
|
368 | |||
369 | /*! |
|
369 | /*! | |
370 | Sets the minimum \a margins between the plot area (axes) and the edge of the chart widget. |
|
370 | Sets the minimum \a margins between the plot area (axes) and the edge of the chart widget. | |
|
371 | Deprecated. Use setMargins(). | |||
|
372 | */ | |||
|
373 | void QChart::setMinimumMargins(const QMargins &margins) | |||
|
374 | { | |||
|
375 | qWarning() << "QChart::setMinimumMargins is deprecated. Use QChart::setMargins instead."; | |||
|
376 | d_ptr->m_presenter->layout()->setMargins(margins); | |||
|
377 | } | |||
|
378 | ||||
|
379 | /*! | |||
|
380 | Returns the rect that contains information about margins (distance between chart widget edge and axes). | |||
|
381 | Individual margins can be obtained by calling left, top, right, bottom on the returned rect. | |||
|
382 | Deprecated. Use margins(). | |||
|
383 | */ | |||
|
384 | QMargins QChart::minimumMargins() const | |||
|
385 | { | |||
|
386 | qWarning() << "QChart::minimumMargins is deprecated. Use QChart::margins instead."; | |||
|
387 | return d_ptr->m_presenter->layout()->margins(); | |||
|
388 | } | |||
|
389 | ||||
|
390 | /*! | |||
|
391 | Sets the minimum \a margins between the plot area (axes) and the edge of the chart widget. | |||
371 | */ |
|
392 | */ | |
372 | void QChart::setMargins(const QMargins &margins) |
|
393 | void QChart::setMargins(const QMargins &margins) | |
373 | { |
|
394 | { | |
374 | d_ptr->m_presenter->layout()->setMargins(margins); |
|
395 | d_ptr->m_presenter->layout()->setMargins(margins); | |
375 | } |
|
396 | } | |
376 |
|
397 | |||
377 | /*! |
|
398 | /*! | |
378 | Returns the rect that contains information about margins (distance between chart widget edge and axes). |
|
399 | Returns the rect that contains information about margins (distance between chart widget edge and axes). | |
379 | Individual margins can be obtained by calling left, top, right, bottom on the returned rect. |
|
400 | Individual margins can be obtained by calling left, top, right, bottom on the returned rect. | |
380 | */ |
|
401 | */ | |
381 | QMargins QChart::margins() const |
|
402 | QMargins QChart::margins() const | |
382 | { |
|
403 | { | |
383 | return d_ptr->m_presenter->layout()->margins(); |
|
404 | return d_ptr->m_presenter->layout()->margins(); | |
384 | } |
|
405 | } | |
385 |
|
406 | |||
386 | /*! |
|
407 | /*! | |
387 | Returns the the rect within which the drawing of the chart is done. |
|
408 | Returns the the rect within which the drawing of the chart is done. | |
388 | It does not include the area defines by margins. |
|
409 | It does not include the area defines by margins. | |
389 | */ |
|
410 | */ | |
390 | QRectF QChart::plotArea() const |
|
411 | QRectF QChart::plotArea() const | |
391 | { |
|
412 | { | |
392 | return d_ptr->m_presenter->layout()->chartsGeometry(); |
|
413 | return d_ptr->m_presenter->layout()->chartsGeometry(); | |
393 | } |
|
414 | } | |
394 |
|
415 | |||
395 | ///*! |
|
416 | ///*! | |
396 | // TODO: Dummy. |
|
417 | // TODO: Dummy. | |
397 | // Adjest the ranges of the axes so that all the data of the specified \a series is visible |
|
418 | // Adjest the ranges of the axes so that all the data of the specified \a series is visible | |
398 | // */ |
|
419 | // */ | |
399 | //void QChart::adjustViewToSeries(QAbstractSeries* series) |
|
420 | //void QChart::adjustViewToSeries(QAbstractSeries* series) | |
400 | //{ |
|
421 | //{ | |
401 | // // |
|
422 | // // | |
402 | //} |
|
423 | //} | |
403 |
|
424 | |||
404 | /*! |
|
425 | /*! | |
405 | Sets animation \a options for the chart |
|
426 | Sets animation \a options for the chart | |
406 | */ |
|
427 | */ | |
407 | void QChart::setAnimationOptions(AnimationOptions options) |
|
428 | void QChart::setAnimationOptions(AnimationOptions options) | |
408 | { |
|
429 | { | |
409 | d_ptr->m_presenter->setAnimationOptions(options); |
|
430 | d_ptr->m_presenter->setAnimationOptions(options); | |
410 | } |
|
431 | } | |
411 |
|
432 | |||
412 | QChart::AnimationOptions QChart::animationOptions() const |
|
433 | QChart::AnimationOptions QChart::animationOptions() const | |
413 | { |
|
434 | { | |
414 | return d_ptr->m_presenter->animationOptions(); |
|
435 | return d_ptr->m_presenter->animationOptions(); | |
415 | } |
|
436 | } | |
416 |
|
437 | |||
417 | /*! |
|
438 | /*! | |
418 | Scrolls the visible area of the chart by the distance defined in the \a dx and \a dy. |
|
439 | Scrolls the visible area of the chart by the distance defined in the \a dx and \a dy. | |
419 | */ |
|
440 | */ | |
420 | void QChart::scroll(qreal dx, qreal dy) |
|
441 | void QChart::scroll(qreal dx, qreal dy) | |
421 | { |
|
442 | { | |
422 | d_ptr->m_presenter->scroll(dx, dy); |
|
443 | d_ptr->m_presenter->scroll(dx, dy); | |
423 | } |
|
444 | } | |
424 |
|
445 | |||
425 | void QChart::setBackgroundVisible(bool visible) |
|
446 | void QChart::setBackgroundVisible(bool visible) | |
426 | { |
|
447 | { | |
427 | d_ptr->m_presenter->setBackgroundVisible(visible); |
|
448 | d_ptr->m_presenter->setBackgroundVisible(visible); | |
428 | } |
|
449 | } | |
429 |
|
450 | |||
430 | bool QChart::isBackgroundVisible() const |
|
451 | bool QChart::isBackgroundVisible() const | |
431 | { |
|
452 | { | |
432 | return d_ptr->m_presenter->isBackgroundVisible(); |
|
453 | return d_ptr->m_presenter->isBackgroundVisible(); | |
433 | } |
|
454 | } | |
434 |
|
455 | |||
435 | void QChart::setDropShadowEnabled(bool enabled) |
|
456 | void QChart::setDropShadowEnabled(bool enabled) | |
436 | { |
|
457 | { | |
437 | d_ptr->m_presenter->setBackgroundDropShadowEnabled(enabled); |
|
458 | d_ptr->m_presenter->setBackgroundDropShadowEnabled(enabled); | |
438 | } |
|
459 | } | |
439 |
|
460 | |||
440 | bool QChart::isDropShadowEnabled() const |
|
461 | bool QChart::isDropShadowEnabled() const | |
441 | { |
|
462 | { | |
442 | return d_ptr->m_presenter->isBackgroundDropShadowEnabled(); |
|
463 | return d_ptr->m_presenter->isBackgroundDropShadowEnabled(); | |
443 | } |
|
464 | } | |
444 |
|
465 | |||
445 | /*! |
|
466 | /*! | |
446 | Returns all the series that are added to the chart. |
|
467 | Returns all the series that are added to the chart. | |
447 |
|
468 | |||
448 | \sa addSeries(), removeSeries(), removeAllSeries() |
|
469 | \sa addSeries(), removeSeries(), removeAllSeries() | |
449 | */ |
|
470 | */ | |
450 | QList<QAbstractSeries *> QChart::series() const |
|
471 | QList<QAbstractSeries *> QChart::series() const | |
451 | { |
|
472 | { | |
452 | return d_ptr->m_dataset->series(); |
|
473 | return d_ptr->m_dataset->series(); | |
453 | } |
|
474 | } | |
454 |
|
475 | |||
455 | /*! |
|
476 | /*! | |
456 | Sets \a axis to the chart, which will control the presentation of the \a series |
|
477 | Sets \a axis to the chart, which will control the presentation of the \a series | |
457 |
|
478 | |||
458 | \sa axisX(), axisY(), setAxisY(), createDefaultAxes() |
|
479 | \sa axisX(), axisY(), setAxisY(), createDefaultAxes() | |
459 | */ |
|
480 | */ | |
460 | void QChart::setAxisX(QAbstractAxis *axis , QAbstractSeries *series) |
|
481 | void QChart::setAxisX(QAbstractAxis *axis , QAbstractSeries *series) | |
461 | { |
|
482 | { | |
462 | if (axis->alignment() == Qt::AlignLeft || axis->alignment() == Qt::AlignRight) |
|
483 | if (axis->alignment() == Qt::AlignLeft || axis->alignment() == Qt::AlignRight) | |
463 | return; |
|
484 | return; | |
464 | d_ptr->m_dataset->setAxis(series, axis, Qt::Horizontal); |
|
485 | d_ptr->m_dataset->setAxis(series, axis, Qt::Horizontal); | |
465 | } |
|
486 | } | |
466 |
|
487 | |||
467 | /*! |
|
488 | /*! | |
468 | Sets \a axis to the chart, which will control the presentation of the \a series |
|
489 | Sets \a axis to the chart, which will control the presentation of the \a series | |
469 |
|
490 | |||
470 | \sa axisX(), axisY(), setAxisX(), createDefaultAxes() |
|
491 | \sa axisX(), axisY(), setAxisX(), createDefaultAxes() | |
471 | */ |
|
492 | */ | |
472 | void QChart::setAxisY(QAbstractAxis *axis , QAbstractSeries *series) |
|
493 | void QChart::setAxisY(QAbstractAxis *axis , QAbstractSeries *series) | |
473 | { |
|
494 | { | |
474 | if (axis->alignment() == Qt::AlignTop || axis->alignment() == Qt::AlignBottom) |
|
495 | if (axis->alignment() == Qt::AlignTop || axis->alignment() == Qt::AlignBottom) | |
475 | return; |
|
496 | return; | |
476 | d_ptr->m_dataset->setAxis(series, axis, Qt::Vertical); |
|
497 | d_ptr->m_dataset->setAxis(series, axis, Qt::Vertical); | |
477 | } |
|
498 | } | |
478 |
|
499 | |||
479 | ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
|
500 | ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |
480 |
|
501 | |||
481 | QChartPrivate::QChartPrivate(): |
|
502 | QChartPrivate::QChartPrivate(): | |
482 | m_legend(0), |
|
503 | m_legend(0), | |
483 | m_dataset(0), |
|
504 | m_dataset(0), | |
484 | m_presenter(0) |
|
505 | m_presenter(0) | |
485 | { |
|
506 | { | |
486 |
|
507 | |||
487 | } |
|
508 | } | |
488 |
|
509 | |||
489 | QChartPrivate::~QChartPrivate() |
|
510 | QChartPrivate::~QChartPrivate() | |
490 | { |
|
511 | { | |
491 |
|
512 | |||
492 | } |
|
513 | } | |
493 |
|
514 | |||
494 | void QChartPrivate::createConnections() |
|
515 | void QChartPrivate::createConnections() | |
495 | { |
|
516 | { | |
496 | QObject::connect(m_dataset, SIGNAL(seriesAdded(QAbstractSeries*,Domain*)), m_presenter, SLOT(handleSeriesAdded(QAbstractSeries*,Domain*))); |
|
517 | 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*))); |
|
518 | 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*))); |
|
519 | 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*))); |
|
520 | 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))); |
|
521 | //QObject::connect(m_presenter, SIGNAL(marginsChanged(QRectF)), q_ptr, SIGNAL(marginsChanged(QRectF))); | |
501 | } |
|
522 | } | |
502 |
|
523 | |||
503 | #include "moc_qchart.cpp" |
|
524 | #include "moc_qchart.cpp" | |
504 |
|
525 | |||
505 | QTCOMMERCIALCHART_END_NAMESPACE |
|
526 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -1,133 +1,136 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2012 Digia Plc |
|
3 | ** Copyright (C) 2012 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
8 | ** |
|
8 | ** | |
9 | ** $QT_BEGIN_LICENSE$ |
|
9 | ** $QT_BEGIN_LICENSE$ | |
10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and Digia. |
|
13 | ** a written agreement between you and Digia. | |
14 | ** |
|
14 | ** | |
15 | ** If you have questions regarding the use of this file, please use |
|
15 | ** If you have questions regarding the use of this file, please use | |
16 | ** contact form at http://qt.digia.com |
|
16 | ** contact form at http://qt.digia.com | |
17 | ** $QT_END_LICENSE$ |
|
17 | ** $QT_END_LICENSE$ | |
18 | ** |
|
18 | ** | |
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 | #ifndef QCHART_H |
|
21 | #ifndef QCHART_H | |
22 | #define QCHART_H |
|
22 | #define QCHART_H | |
23 |
|
23 | |||
24 | #include <QAbstractSeries> |
|
24 | #include <QAbstractSeries> | |
25 | #include <QLegend> |
|
25 | #include <QLegend> | |
26 | #include <QGraphicsWidget> |
|
26 | #include <QGraphicsWidget> | |
27 | #include <QMargins> |
|
27 | #include <QMargins> | |
28 |
|
28 | |||
29 | class QGraphicsSceneResizeEvent; |
|
29 | class QGraphicsSceneResizeEvent; | |
30 |
|
30 | |||
31 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
31 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
32 |
|
32 | |||
33 | class QAbstractSeries; |
|
33 | class QAbstractSeries; | |
34 | class QAbstractAxis; |
|
34 | class QAbstractAxis; | |
35 | class QLegend; |
|
35 | class QLegend; | |
36 | struct QChartPrivate; |
|
36 | struct QChartPrivate; | |
37 |
|
37 | |||
38 | class QTCOMMERCIALCHART_EXPORT QChart : public QGraphicsWidget |
|
38 | class QTCOMMERCIALCHART_EXPORT QChart : public QGraphicsWidget | |
39 | { |
|
39 | { | |
40 | Q_OBJECT |
|
40 | Q_OBJECT | |
41 | Q_PROPERTY(QChart::ChartTheme theme READ theme WRITE setTheme) |
|
41 | Q_PROPERTY(QChart::ChartTheme theme READ theme WRITE setTheme) | |
42 | Q_PROPERTY(QString title READ title WRITE setTitle) |
|
42 | Q_PROPERTY(QString title READ title WRITE setTitle) | |
43 | Q_PROPERTY(bool backgroundVisible READ isBackgroundVisible WRITE setBackgroundVisible) |
|
43 | Q_PROPERTY(bool backgroundVisible READ isBackgroundVisible WRITE setBackgroundVisible) | |
44 | Q_PROPERTY(bool dropShadowEnabled READ isDropShadowEnabled WRITE setDropShadowEnabled) |
|
44 | Q_PROPERTY(bool dropShadowEnabled READ isDropShadowEnabled WRITE setDropShadowEnabled) | |
45 | Q_PROPERTY(QChart::AnimationOptions animationOptions READ animationOptions WRITE setAnimationOptions) |
|
45 | Q_PROPERTY(QChart::AnimationOptions animationOptions READ animationOptions WRITE setAnimationOptions) | |
46 | Q_PROPERTY(QMargins margins READ margins WRITE setMargins) |
|
46 | Q_PROPERTY(QMargins margins READ margins WRITE setMargins) | |
47 | Q_ENUMS(ChartTheme) |
|
47 | Q_ENUMS(ChartTheme) | |
48 | Q_ENUMS(AnimationOption) |
|
48 | Q_ENUMS(AnimationOption) | |
49 |
|
49 | |||
50 | public: |
|
50 | public: | |
51 | enum ChartTheme { |
|
51 | enum ChartTheme { | |
52 | ChartThemeLight = 0, |
|
52 | ChartThemeLight = 0, | |
53 | ChartThemeBlueCerulean, |
|
53 | ChartThemeBlueCerulean, | |
54 | ChartThemeDark, |
|
54 | ChartThemeDark, | |
55 | ChartThemeBrownSand, |
|
55 | ChartThemeBrownSand, | |
56 | ChartThemeBlueNcs, |
|
56 | ChartThemeBlueNcs, | |
57 | ChartThemeHighContrast, |
|
57 | ChartThemeHighContrast, | |
58 | ChartThemeBlueIcy |
|
58 | ChartThemeBlueIcy | |
59 | }; |
|
59 | }; | |
60 |
|
60 | |||
61 | enum AnimationOption { |
|
61 | enum AnimationOption { | |
62 | NoAnimation = 0x0, |
|
62 | NoAnimation = 0x0, | |
63 | GridAxisAnimations = 0x1, |
|
63 | GridAxisAnimations = 0x1, | |
64 | SeriesAnimations = 0x2, |
|
64 | SeriesAnimations = 0x2, | |
65 | AllAnimations = 0x3 |
|
65 | AllAnimations = 0x3 | |
66 | }; |
|
66 | }; | |
67 |
|
67 | |||
68 | Q_DECLARE_FLAGS(AnimationOptions, AnimationOption) |
|
68 | Q_DECLARE_FLAGS(AnimationOptions, AnimationOption) | |
69 |
|
69 | |||
70 | public: |
|
70 | public: | |
71 | explicit QChart(QGraphicsItem *parent = 0, Qt::WindowFlags wFlags = 0); |
|
71 | explicit QChart(QGraphicsItem *parent = 0, Qt::WindowFlags wFlags = 0); | |
72 | ~QChart(); |
|
72 | ~QChart(); | |
73 |
|
73 | |||
74 | void addSeries(QAbstractSeries *series); |
|
74 | void addSeries(QAbstractSeries *series); | |
75 | void removeSeries(QAbstractSeries *series); |
|
75 | void removeSeries(QAbstractSeries *series); | |
76 | void removeAllSeries(); |
|
76 | void removeAllSeries(); | |
77 | QList<QAbstractSeries *> series() const; |
|
77 | QList<QAbstractSeries *> series() const; | |
78 |
|
78 | |||
79 | void setAxisX(QAbstractAxis *axis, QAbstractSeries *series = 0); |
|
79 | void setAxisX(QAbstractAxis *axis, QAbstractSeries *series = 0); | |
80 | void setAxisY(QAbstractAxis *axis, QAbstractSeries *series = 0); |
|
80 | void setAxisY(QAbstractAxis *axis, QAbstractSeries *series = 0); | |
81 |
|
81 | |||
82 | QAbstractAxis *axisX(QAbstractSeries *series = 0) const; |
|
82 | QAbstractAxis *axisX(QAbstractSeries *series = 0) const; | |
83 | QAbstractAxis *axisY(QAbstractSeries *series = 0) const; |
|
83 | QAbstractAxis *axisY(QAbstractSeries *series = 0) const; | |
84 |
|
84 | |||
85 | void createDefaultAxes(); |
|
85 | void createDefaultAxes(); | |
86 |
|
86 | |||
87 | void setTheme(QChart::ChartTheme theme); |
|
87 | void setTheme(QChart::ChartTheme theme); | |
88 | QChart::ChartTheme theme() const; |
|
88 | QChart::ChartTheme theme() const; | |
89 |
|
89 | |||
90 | void setTitle(const QString &title); |
|
90 | void setTitle(const QString &title); | |
91 | QString title() const; |
|
91 | QString title() const; | |
92 | void setTitleFont(const QFont &font); |
|
92 | void setTitleFont(const QFont &font); | |
93 | QFont titleFont() const; |
|
93 | QFont titleFont() const; | |
94 | void setTitleBrush(const QBrush &brush); |
|
94 | void setTitleBrush(const QBrush &brush); | |
95 | QBrush titleBrush() const; |
|
95 | QBrush titleBrush() const; | |
96 |
|
96 | |||
97 | void setBackgroundBrush(const QBrush &brush); |
|
97 | void setBackgroundBrush(const QBrush &brush); | |
98 | QBrush backgroundBrush() const; |
|
98 | QBrush backgroundBrush() const; | |
99 | void setBackgroundPen(const QPen &pen); |
|
99 | void setBackgroundPen(const QPen &pen); | |
100 | QPen backgroundPen() const; |
|
100 | QPen backgroundPen() const; | |
101 | void setBackgroundVisible(bool visible = true); |
|
101 | void setBackgroundVisible(bool visible = true); | |
102 | bool isBackgroundVisible() const; |
|
102 | bool isBackgroundVisible() const; | |
103 |
|
103 | |||
104 | void setDropShadowEnabled(bool enabled = true); |
|
104 | void setDropShadowEnabled(bool enabled = true); | |
105 | bool isDropShadowEnabled() const; |
|
105 | bool isDropShadowEnabled() const; | |
106 | void setAnimationOptions(AnimationOptions options); |
|
106 | void setAnimationOptions(AnimationOptions options); | |
107 | AnimationOptions animationOptions() const; |
|
107 | AnimationOptions animationOptions() const; | |
108 |
|
108 | |||
109 | void zoomIn(); |
|
109 | void zoomIn(); | |
110 | void zoomIn(const QRectF &rect); |
|
110 | void zoomIn(const QRectF &rect); | |
111 | void zoomOut(); |
|
111 | void zoomOut(); | |
112 | void zoom(qreal factor); |
|
112 | void zoom(qreal factor); | |
113 | void scroll(qreal dx, qreal dy); |
|
113 | void scroll(qreal dx, qreal dy); | |
114 |
|
114 | |||
115 | QLegend *legend() const; |
|
115 | QLegend *legend() const; | |
116 |
|
116 | |||
|
117 | void setMinimumMargins(const QMargins& margins); | |||
|
118 | QMargins minimumMargins() const; | |||
|
119 | ||||
117 | void setMargins(const QMargins &margins); |
|
120 | void setMargins(const QMargins &margins); | |
118 | QMargins margins() const; |
|
121 | QMargins margins() const; | |
119 |
|
122 | |||
120 | QRectF plotArea() const; |
|
123 | QRectF plotArea() const; | |
121 |
|
124 | |||
122 | protected: |
|
125 | protected: | |
123 | QScopedPointer<QChartPrivate> d_ptr; |
|
126 | QScopedPointer<QChartPrivate> d_ptr; | |
124 | friend class QLegend; |
|
127 | friend class QLegend; | |
125 | friend class DeclarativeChart; |
|
128 | friend class DeclarativeChart; | |
126 | Q_DISABLE_COPY(QChart) |
|
129 | Q_DISABLE_COPY(QChart) | |
127 | }; |
|
130 | }; | |
128 |
|
131 | |||
129 | QTCOMMERCIALCHART_END_NAMESPACE |
|
132 | QTCOMMERCIALCHART_END_NAMESPACE | |
130 |
|
133 | |||
131 | Q_DECLARE_OPERATORS_FOR_FLAGS(QTCOMMERCIALCHART_NAMESPACE::QChart::AnimationOptions) |
|
134 | Q_DECLARE_OPERATORS_FOR_FLAGS(QTCOMMERCIALCHART_NAMESPACE::QChart::AnimationOptions) | |
132 |
|
135 | |||
133 | #endif // QCHART_H |
|
136 | #endif // QCHART_H |
General Comments 0
You need to be logged in to leave comments.
Login now