##// END OF EJS Templates
Add API to specify plot area background....
Miikka Heikkinen -
r2498:e824058bc192
parent child
Show More
@@ -1,900 +1,924
1 /****************************************************************************
1 /****************************************************************************
2 **
2 **
3 ** Copyright (C) 2013 Digia Plc
3 ** Copyright (C) 2013 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 "declarativechart.h"
21 #include "declarativechart.h"
22 #include <QPainter>
22 #include <QPainter>
23 #include "declarativelineseries.h"
23 #include "declarativelineseries.h"
24 #include "declarativeareaseries.h"
24 #include "declarativeareaseries.h"
25 #include "declarativebarseries.h"
25 #include "declarativebarseries.h"
26 #include "declarativepieseries.h"
26 #include "declarativepieseries.h"
27 #include "declarativesplineseries.h"
27 #include "declarativesplineseries.h"
28 #include "declarativescatterseries.h"
28 #include "declarativescatterseries.h"
29 #include "qbarcategoryaxis.h"
29 #include "qbarcategoryaxis.h"
30 #include "qvalueaxis.h"
30 #include "qvalueaxis.h"
31 #include "qlogvalueaxis.h"
31 #include "qlogvalueaxis.h"
32 #include "qcategoryaxis.h"
32 #include "qcategoryaxis.h"
33 #include "qabstractseries_p.h"
33 #include "qabstractseries_p.h"
34 #include "declarativemargins.h"
34 #include "declarativemargins.h"
35 #include "chartdataset_p.h"
35 #include "chartdataset_p.h"
36 #include "declarativeaxes.h"
36 #include "declarativeaxes.h"
37 #include "qchart_p.h"
37 #include "qchart_p.h"
38 #include "qpolarchart.h"
38 #include "qpolarchart.h"
39
39
40 #ifndef QT_ON_ARM
40 #ifndef QT_ON_ARM
41 #include "qdatetimeaxis.h"
41 #include "qdatetimeaxis.h"
42 #endif
42 #endif
43
43
44 #ifdef CHARTS_FOR_QUICK2
44 #ifdef CHARTS_FOR_QUICK2
45 #include <QGraphicsSceneMouseEvent>
45 #include <QGraphicsSceneMouseEvent>
46 #include <QGraphicsSceneHoverEvent>
46 #include <QGraphicsSceneHoverEvent>
47 #include <QApplication>
47 #include <QApplication>
48 #endif
48 #endif
49
49
50 QTCOMMERCIALCHART_BEGIN_NAMESPACE
50 QTCOMMERCIALCHART_BEGIN_NAMESPACE
51
51
52 /*!
52 /*!
53 \qmlclass ChartView DeclarativeChart
53 \qmlclass ChartView DeclarativeChart
54
54
55 ChartView element is the parent that is responsible for showing different chart series types.
55 ChartView element is the parent that is responsible for showing different chart series types.
56
56
57 The following QML shows how to create a simple chart with one pie series:
57 The following QML shows how to create a simple chart with one pie series:
58 \snippet ../examples/qmlpiechart/qml/qmlpiechart/main.qml 1
58 \snippet ../examples/qmlpiechart/qml/qmlpiechart/main.qml 1
59 \snippet ../examples/qmlpiechart/qml/qmlpiechart/main.qml 2
59 \snippet ../examples/qmlpiechart/qml/qmlpiechart/main.qml 2
60 \snippet ../examples/qmlpiechart/qml/qmlpiechart/main.qml 3
60 \snippet ../examples/qmlpiechart/qml/qmlpiechart/main.qml 3
61
61
62 \beginfloatleft
62 \beginfloatleft
63 \image examples_qmlpiechart.png
63 \image examples_qmlpiechart.png
64 \endfloat
64 \endfloat
65 \clearfloat
65 \clearfloat
66 */
66 */
67
67
68 /*!
68 /*!
69 \qmlproperty Theme ChartView::theme
69 \qmlproperty Theme ChartView::theme
70 Theme defines the visual appearance of the chart, including for example colors, fonts, line
70 Theme defines the visual appearance of the chart, including for example colors, fonts, line
71 widths and chart background.
71 widths and chart background.
72 */
72 */
73
73
74 /*!
74 /*!
75 \qmlproperty Animation ChartView::animationOptions
75 \qmlproperty Animation ChartView::animationOptions
76 Animation configuration of the chart. One of ChartView.NoAnimation, ChartView.GridAxisAnimations,
76 Animation configuration of the chart. One of ChartView.NoAnimation, ChartView.GridAxisAnimations,
77 ChartView.SeriesAnimations or ChartView.AllAnimations.
77 ChartView.SeriesAnimations or ChartView.AllAnimations.
78 */
78 */
79
79
80 /*!
80 /*!
81 \qmlproperty Font ChartView::titleFont
81 \qmlproperty Font ChartView::titleFont
82 The title font of the chart
82 The title font of the chart
83
83
84 See the \l {Font} {QML Font Element} for detailed documentation.
84 See the \l {Font} {QML Font Element} for detailed documentation.
85 */
85 */
86
86
87 /*!
87 /*!
88 \qmlproperty string ChartView::title
88 \qmlproperty string ChartView::title
89 The title of the chart, shown on top of the chart.
89 The title of the chart, shown on top of the chart.
90 \sa ChartView::titleColor
90 \sa ChartView::titleColor
91 */
91 */
92
92
93 /*!
93 /*!
94 \qmlproperty color ChartView::titleColor
94 \qmlproperty color ChartView::titleColor
95 The color of the title text.
95 The color of the title text.
96 */
96 */
97
97
98 /*!
98 /*!
99 \qmlproperty Legend ChartView::legend
99 \qmlproperty Legend ChartView::legend
100 The legend of the chart. Legend lists all the series, pie slices and bar sets added on the chart.
100 The legend of the chart. Legend lists all the series, pie slices and bar sets added on the chart.
101 */
101 */
102
102
103 /*!
103 /*!
104 \qmlproperty int ChartView::count
104 \qmlproperty int ChartView::count
105 The count of series added to the chart.
105 The count of series added to the chart.
106 */
106 */
107
107
108 /*!
108 /*!
109 \qmlproperty color ChartView::backgroundColor
109 \qmlproperty color ChartView::backgroundColor
110 The color of the chart's background. By default background color is defined by chart theme.
110 The color of the chart's background. By default background color is defined by chart theme.
111 \sa ChartView::theme
111 \sa ChartView::theme
112 */
112 */
113
113
114 /*!
114 /*!
115 \qmlproperty color ChartView::plotAreaColor
116 The color of the background of the chart's plot area. By default plot area background uses chart's
117 background color.
118 \sa ChartView::backgroundColor
119 */
120
121 /*!
115 \qmlproperty bool ChartView::dropShadowEnabled
122 \qmlproperty bool ChartView::dropShadowEnabled
116 The chart's border drop shadow. Set to true to enable drop shadow.
123 The chart's border drop shadow. Set to true to enable drop shadow.
117 */
124 */
118
125
119 /*!
126 /*!
120 \qmlproperty real ChartView::topMargin
127 \qmlproperty real ChartView::topMargin
121 */
128 */
122
129
123 /*!
130 /*!
124 \qmlproperty real ChartView::bottomMargin
131 \qmlproperty real ChartView::bottomMargin
125 */
132 */
126
133
127 /*!
134 /*!
128 \qmlproperty real ChartView::leftMargin
135 \qmlproperty real ChartView::leftMargin
129 */
136 */
130
137
131 /*!
138 /*!
132 \qmlproperty real ChartView::rightMargin
139 \qmlproperty real ChartView::rightMargin
133 */
140 */
134
141
135 /*!
142 /*!
136 \qmlproperty Margins ChartView::minimumMargins
143 \qmlproperty Margins ChartView::minimumMargins
137 Deprecated; use margins instead.
144 Deprecated; use margins instead.
138 The minimum margins allowed between the outer bounds and the plotArea of the ChartView. Margins
145 The minimum margins allowed between the outer bounds and the plotArea of the ChartView. Margins
139 area of ChartView is used for drawing title, axes and legend. Please note that setting the
146 area of ChartView is used for drawing title, axes and legend. Please note that setting the
140 properties of minimumMargins may be bigger than the defined value, depending on other ChartView
147 properties of minimumMargins may be bigger than the defined value, depending on other ChartView
141 properties that affect it's layout. If you need to know the actual plotting area used at any
148 properties that affect it's layout. If you need to know the actual plotting area used at any
142 given time, you can check ChartView::plotArea instead.
149 given time, you can check ChartView::plotArea instead.
143 */
150 */
144
151
145 /*!
152 /*!
146 \qmlproperty rect ChartView::plotArea
153 \qmlproperty rect ChartView::plotArea
147 The area on the ChartView that is used for drawing series. This is the ChartView rect without the
154 The area on the ChartView that is used for drawing series. This is the ChartView rect without the
148 margins.
155 margins.
149 \sa ChartView::minimumMargins
156 \sa ChartView::minimumMargins
150 */
157 */
151
158
152 /*!
159 /*!
153 \qmlproperty Margins ChartView::margins
160 \qmlproperty Margins ChartView::margins
154 The minimum margins allowed between the outer bounds and the plotArea of the ChartView. Margins
161 The minimum margins allowed between the outer bounds and the plotArea of the ChartView. Margins
155 area of ChartView is used for drawing title, axes and legend.
162 area of ChartView is used for drawing title, axes and legend.
156 */
163 */
157
164
158 /*!
165 /*!
159 \qmlmethod AbstractSeries ChartView::series(int index)
166 \qmlmethod AbstractSeries ChartView::series(int index)
160 Returns the series with \a index on the chart. This allows you to loop through the series of a chart together with
167 Returns the series with \a index on the chart. This allows you to loop through the series of a chart together with
161 the count property of the chart.
168 the count property of the chart.
162 */
169 */
163
170
164 /*!
171 /*!
165 \qmlmethod AbstractSeries ChartView::series(string name)
172 \qmlmethod AbstractSeries ChartView::series(string name)
166 Returns the first series on the chart with \a name. If there is no series with that name, returns null.
173 Returns the first series on the chart with \a name. If there is no series with that name, returns null.
167 */
174 */
168
175
169 /*!
176 /*!
170 \qmlmethod AbstractSeries ChartView::createSeries(SeriesType type, string name, AbstractAxis axisX, AbstractAxis axisY)
177 \qmlmethod AbstractSeries ChartView::createSeries(SeriesType type, string name, AbstractAxis axisX, AbstractAxis axisY)
171 Creates a series object of \a type to the chart with name \a name, optional axis \a axisX and
178 Creates a series object of \a type to the chart with name \a name, optional axis \a axisX and
172 optional axis \a axisY. For example:
179 optional axis \a axisY. For example:
173 \code
180 \code
174 // lineSeries is a LineSeries object that has already been added to the ChartView; re-use it's axes
181 // lineSeries is a LineSeries object that has already been added to the ChartView; re-use it's axes
175 var myAxisX = chartView.axisX(lineSeries);
182 var myAxisX = chartView.axisX(lineSeries);
176 var myAxisY = chartView.axisY(lineSeries);
183 var myAxisY = chartView.axisY(lineSeries);
177 var scatter = chartView.createSeries(ChartView.SeriesTypeScatter, "scatter series", myAxisX, myAxisY);
184 var scatter = chartView.createSeries(ChartView.SeriesTypeScatter, "scatter series", myAxisX, myAxisY);
178 \endcode
185 \endcode
179 */
186 */
180
187
181 /*!
188 /*!
182 \qmlmethod ChartView::removeSeries(AbstractSeries series)
189 \qmlmethod ChartView::removeSeries(AbstractSeries series)
183 Removes the \a series from the chart. The series object is also destroyed.
190 Removes the \a series from the chart. The series object is also destroyed.
184 */
191 */
185
192
186 /*!
193 /*!
187 \qmlmethod ChartView::removeAllSeries()
194 \qmlmethod ChartView::removeAllSeries()
188 Removes all series from the chart. All the series objects are also destroyed.
195 Removes all series from the chart. All the series objects are also destroyed.
189 */
196 */
190
197
191 /*!
198 /*!
192 \qmlmethod Axis ChartView::axisX(AbstractSeries series)
199 \qmlmethod Axis ChartView::axisX(AbstractSeries series)
193 The x-axis of the series.
200 The x-axis of the series.
194 */
201 */
195
202
196 /*!
203 /*!
197 \qmlmethod Axis ChartView::axisY(AbstractSeries series)
204 \qmlmethod Axis ChartView::axisY(AbstractSeries series)
198 The y-axis of the series.
205 The y-axis of the series.
199 */
206 */
200
207
201 /*!
208 /*!
202 \qmlmethod ChartView::zoomY(real factor)
209 \qmlmethod ChartView::zoomY(real factor)
203 Zooms in by \a factor on the center of the chart.
210 Zooms in by \a factor on the center of the chart.
204 */
211 */
205
212
206 /*!
213 /*!
207 \qmlmethod ChartView::scrollLeft(real pixels)
214 \qmlmethod ChartView::scrollLeft(real pixels)
208 Scrolls to left by \a pixels. This is a convenience function that suits for example for key navigation.
215 Scrolls to left by \a pixels. This is a convenience function that suits for example for key navigation.
209 */
216 */
210
217
211 /*!
218 /*!
212 \qmlmethod ChartView::scrollRight(real pixels)
219 \qmlmethod ChartView::scrollRight(real pixels)
213 Scrolls to right by \a pixels. This is a convenience function that suits for example for key navigation.
220 Scrolls to right by \a pixels. This is a convenience function that suits for example for key navigation.
214 */
221 */
215
222
216 /*!
223 /*!
217 \qmlmethod ChartView::scrollUp(real pixels)
224 \qmlmethod ChartView::scrollUp(real pixels)
218 Scrolls up by \a pixels. This is a convenience function that suits for example for key navigation.
225 Scrolls up by \a pixels. This is a convenience function that suits for example for key navigation.
219 */
226 */
220
227
221 /*!
228 /*!
222 \qmlmethod ChartView::scrollDown(real pixels)
229 \qmlmethod ChartView::scrollDown(real pixels)
223 Scrolls down by \a pixels. This is a convenience function that suits for example for key navigation.
230 Scrolls down by \a pixels. This is a convenience function that suits for example for key navigation.
224 */
231 */
225
232
226 /*!
233 /*!
227 \qmlsignal ChartView::onPlotAreaChanged(rect plotArea)
234 \qmlsignal ChartView::onPlotAreaChanged(rect plotArea)
228 The plot area of the chart has changed. This may happen for example, if you modify minimumMargins
235 The plot area of the chart has changed. This may happen for example, if you modify minimumMargins
229 or if you resize the chart, or if you modify font size related properties of the legend or chart
236 or if you resize the chart, or if you modify font size related properties of the legend or chart
230 title.
237 title.
231 */
238 */
232
239
233 /*!
240 /*!
234 \qmlsignal ChartView::seriesAdded(AbstractSeries series)
241 \qmlsignal ChartView::seriesAdded(AbstractSeries series)
235 The \a series has been added to the chart.
242 The \a series has been added to the chart.
236 */
243 */
237
244
238 /*!
245 /*!
239 \qmlsignal ChartView::seriesRemoved(AbstractSeries series)
246 \qmlsignal ChartView::seriesRemoved(AbstractSeries series)
240 The \a series has been removed from the chart. Please note that \a series is no longer a valid
247 The \a series has been removed from the chart. Please note that \a series is no longer a valid
241 object after the signal handler has completed.
248 object after the signal handler has completed.
242 */
249 */
243
250
244 DeclarativeChart::DeclarativeChart(QDECLARATIVE_ITEM *parent)
251 DeclarativeChart::DeclarativeChart(QDECLARATIVE_ITEM *parent)
245 : QDECLARATIVE_PAINTED_ITEM(parent)
252 : QDECLARATIVE_PAINTED_ITEM(parent)
246 {
253 {
247 initChart(QChart::ChartTypeCartesian);
254 initChart(QChart::ChartTypeCartesian);
248 }
255 }
249
256
250 DeclarativeChart::DeclarativeChart(QChart::ChartType type, QDECLARATIVE_ITEM *parent)
257 DeclarativeChart::DeclarativeChart(QChart::ChartType type, QDECLARATIVE_ITEM *parent)
251 : QDECLARATIVE_PAINTED_ITEM(parent)
258 : QDECLARATIVE_PAINTED_ITEM(parent)
252 {
259 {
253 initChart(type);
260 initChart(type);
254 }
261 }
255
262
256 void DeclarativeChart::initChart(QChart::ChartType type)
263 void DeclarativeChart::initChart(QChart::ChartType type)
257 {
264 {
258 #ifdef CHARTS_FOR_QUICK2
265 #ifdef CHARTS_FOR_QUICK2
259 if (type == QChart::ChartTypePolar)
266 if (type == QChart::ChartTypePolar)
260 m_chart = new QPolarChart();
267 m_chart = new QPolarChart();
261 else
268 else
262 m_chart = new QChart();
269 m_chart = new QChart();
263
270
264 m_scene = new QGraphicsScene(this);
271 m_scene = new QGraphicsScene(this);
265 m_scene->addItem(m_chart);
272 m_scene->addItem(m_chart);
266
273
267 setAntialiasing(QQuickItem::antialiasing());
274 setAntialiasing(QQuickItem::antialiasing());
268 connect(m_scene, SIGNAL(changed(QList<QRectF>)), this, SLOT(update()));
275 connect(m_scene, SIGNAL(changed(QList<QRectF>)), this, SLOT(update()));
269 connect(this, SIGNAL(antialiasingChanged(bool)), this, SLOT(handleAntialiasingChanged(bool)));
276 connect(this, SIGNAL(antialiasingChanged(bool)), this, SLOT(handleAntialiasingChanged(bool)));
270
277
271 setAcceptedMouseButtons(Qt::AllButtons);
278 setAcceptedMouseButtons(Qt::AllButtons);
272 setAcceptHoverEvents(true);
279 setAcceptHoverEvents(true);
273 #else
280 #else
274 if (type == QChart::ChartTypePolar)
281 if (type == QChart::ChartTypePolar)
275 m_chart = new QPolarChart(this);
282 m_chart = new QPolarChart(this);
276 else
283 else
277 m_chart = new QChart(this);
284 m_chart = new QChart(this);
278
285
279 setFlag(QGraphicsItem::ItemHasNoContents, false);
286 setFlag(QGraphicsItem::ItemHasNoContents, false);
280 #endif
287 #endif
281
288
282 m_margins = new DeclarativeMargins(this);
289 m_margins = new DeclarativeMargins(this);
283 m_margins->setTop(m_chart->margins().top());
290 m_margins->setTop(m_chart->margins().top());
284 m_margins->setLeft(m_chart->margins().left());
291 m_margins->setLeft(m_chart->margins().left());
285 m_margins->setRight(m_chart->margins().right());
292 m_margins->setRight(m_chart->margins().right());
286 m_margins->setBottom(m_chart->margins().bottom());
293 m_margins->setBottom(m_chart->margins().bottom());
287 connect(m_margins, SIGNAL(topChanged(int,int,int,int)), this, SLOT(changeMinimumMargins(int,int,int,int)));
294 connect(m_margins, SIGNAL(topChanged(int,int,int,int)), this, SLOT(changeMinimumMargins(int,int,int,int)));
288 connect(m_margins, SIGNAL(bottomChanged(int,int,int,int)), this, SLOT(changeMinimumMargins(int,int,int,int)));
295 connect(m_margins, SIGNAL(bottomChanged(int,int,int,int)), this, SLOT(changeMinimumMargins(int,int,int,int)));
289 connect(m_margins, SIGNAL(leftChanged(int,int,int,int)), this, SLOT(changeMinimumMargins(int,int,int,int)));
296 connect(m_margins, SIGNAL(leftChanged(int,int,int,int)), this, SLOT(changeMinimumMargins(int,int,int,int)));
290 connect(m_margins, SIGNAL(rightChanged(int,int,int,int)), this, SLOT(changeMinimumMargins(int,int,int,int)));
297 connect(m_margins, SIGNAL(rightChanged(int,int,int,int)), this, SLOT(changeMinimumMargins(int,int,int,int)));
291 connect(m_chart->d_ptr->m_dataset, SIGNAL(seriesAdded(QAbstractSeries*)), this, SLOT(handleSeriesAdded(QAbstractSeries*)));
298 connect(m_chart->d_ptr->m_dataset, SIGNAL(seriesAdded(QAbstractSeries*)), this, SLOT(handleSeriesAdded(QAbstractSeries*)));
292 connect(m_chart->d_ptr->m_dataset, SIGNAL(seriesRemoved(QAbstractSeries*)), this, SIGNAL(seriesRemoved(QAbstractSeries*)));
299 connect(m_chart->d_ptr->m_dataset, SIGNAL(seriesRemoved(QAbstractSeries*)), this, SIGNAL(seriesRemoved(QAbstractSeries*)));
293 }
300 }
294
301
295 void DeclarativeChart::handleSeriesAdded(QAbstractSeries *series)
302 void DeclarativeChart::handleSeriesAdded(QAbstractSeries *series)
296 {
303 {
297 emit seriesAdded(series);
304 emit seriesAdded(series);
298 }
305 }
299
306
300 void DeclarativeChart::changeMinimumMargins(int top, int bottom, int left, int right)
307 void DeclarativeChart::changeMinimumMargins(int top, int bottom, int left, int right)
301 {
308 {
302 m_chart->setMargins(QMargins(left, top, right, bottom));
309 m_chart->setMargins(QMargins(left, top, right, bottom));
303 emit minimumMarginsChanged();
310 emit minimumMarginsChanged();
304 emit plotAreaChanged(m_chart->plotArea());
311 emit plotAreaChanged(m_chart->plotArea());
305 }
312 }
306
313
307 DeclarativeChart::~DeclarativeChart()
314 DeclarativeChart::~DeclarativeChart()
308 {
315 {
309 delete m_chart;
316 delete m_chart;
310 }
317 }
311
318
312 void DeclarativeChart::childEvent(QChildEvent *event)
319 void DeclarativeChart::childEvent(QChildEvent *event)
313 {
320 {
314 if (event->type() == QEvent::ChildAdded) {
321 if (event->type() == QEvent::ChildAdded) {
315 if (qobject_cast<QAbstractSeries *>(event->child())) {
322 if (qobject_cast<QAbstractSeries *>(event->child())) {
316 m_chart->addSeries(qobject_cast<QAbstractSeries *>(event->child()));
323 m_chart->addSeries(qobject_cast<QAbstractSeries *>(event->child()));
317 }
324 }
318 }
325 }
319 }
326 }
320
327
321 void DeclarativeChart::componentComplete()
328 void DeclarativeChart::componentComplete()
322 {
329 {
323 foreach (QObject *child, children()) {
330 foreach (QObject *child, children()) {
324 if (qobject_cast<QAbstractSeries *>(child)) {
331 if (qobject_cast<QAbstractSeries *>(child)) {
325 // Add series to the chart
332 // Add series to the chart
326 QAbstractSeries *series = qobject_cast<QAbstractSeries *>(child);
333 QAbstractSeries *series = qobject_cast<QAbstractSeries *>(child);
327 m_chart->addSeries(series);
334 m_chart->addSeries(series);
328
335
329 // Connect to axis changed signals (unless this is a pie series)
336 // Connect to axis changed signals (unless this is a pie series)
330 if (!qobject_cast<DeclarativePieSeries *>(series)) {
337 if (!qobject_cast<DeclarativePieSeries *>(series)) {
331 connect(series, SIGNAL(axisXChanged(QAbstractAxis*)), this, SLOT(handleAxisXSet(QAbstractAxis*)));
338 connect(series, SIGNAL(axisXChanged(QAbstractAxis*)), this, SLOT(handleAxisXSet(QAbstractAxis*)));
332 connect(series, SIGNAL(axisXTopChanged(QAbstractAxis*)), this, SLOT(handleAxisXSet(QAbstractAxis*)));
339 connect(series, SIGNAL(axisXTopChanged(QAbstractAxis*)), this, SLOT(handleAxisXSet(QAbstractAxis*)));
333 connect(series, SIGNAL(axisYChanged(QAbstractAxis*)), this, SLOT(handleAxisYSet(QAbstractAxis*)));
340 connect(series, SIGNAL(axisYChanged(QAbstractAxis*)), this, SLOT(handleAxisYSet(QAbstractAxis*)));
334 connect(series, SIGNAL(axisYRightChanged(QAbstractAxis*)), this, SLOT(handleAxisYRightSet(QAbstractAxis*)));
341 connect(series, SIGNAL(axisYRightChanged(QAbstractAxis*)), this, SLOT(handleAxisYRightSet(QAbstractAxis*)));
335 }
342 }
336
343
337 initializeAxes(series);
344 initializeAxes(series);
338 }
345 }
339 }
346 }
340
347
341 QDECLARATIVE_ITEM::componentComplete();
348 QDECLARATIVE_ITEM::componentComplete();
342 }
349 }
343
350
344 void DeclarativeChart::handleAxisXSet(QAbstractAxis *axis)
351 void DeclarativeChart::handleAxisXSet(QAbstractAxis *axis)
345 {
352 {
346 QAbstractSeries *s = qobject_cast<QAbstractSeries *>(sender());
353 QAbstractSeries *s = qobject_cast<QAbstractSeries *>(sender());
347 if (axis && s) {
354 if (axis && s) {
348 if (!m_chart->axes(Qt::Horizontal).contains(axis))
355 if (!m_chart->axes(Qt::Horizontal).contains(axis))
349 m_chart->addAxis(axis, Qt::AlignBottom);
356 m_chart->addAxis(axis, Qt::AlignBottom);
350 if (!s->attachedAxes().contains(axis))
357 if (!s->attachedAxes().contains(axis))
351 s->attachAxis(axis);
358 s->attachAxis(axis);
352 } else {
359 } else {
353 qWarning() << "Trying to set axisX to null.";
360 qWarning() << "Trying to set axisX to null.";
354 }
361 }
355 }
362 }
356
363
357 void DeclarativeChart::handleAxisXTopSet(QAbstractAxis *axis)
364 void DeclarativeChart::handleAxisXTopSet(QAbstractAxis *axis)
358 {
365 {
359 QAbstractSeries *s = qobject_cast<QAbstractSeries *>(sender());
366 QAbstractSeries *s = qobject_cast<QAbstractSeries *>(sender());
360 if (axis && s) {
367 if (axis && s) {
361 if (!m_chart->axes(Qt::Horizontal).contains(axis))
368 if (!m_chart->axes(Qt::Horizontal).contains(axis))
362 m_chart->addAxis(axis, Qt::AlignTop);
369 m_chart->addAxis(axis, Qt::AlignTop);
363 if (!s->attachedAxes().contains(axis))
370 if (!s->attachedAxes().contains(axis))
364 s->attachAxis(axis);
371 s->attachAxis(axis);
365 } else {
372 } else {
366 qWarning() << "Trying to set axisXTop to null.";
373 qWarning() << "Trying to set axisXTop to null.";
367 }
374 }
368 }
375 }
369
376
370 void DeclarativeChart::handleAxisYSet(QAbstractAxis *axis)
377 void DeclarativeChart::handleAxisYSet(QAbstractAxis *axis)
371 {
378 {
372 QAbstractSeries *s = qobject_cast<QAbstractSeries *>(sender());
379 QAbstractSeries *s = qobject_cast<QAbstractSeries *>(sender());
373 if (axis && s) {
380 if (axis && s) {
374 if (!m_chart->axes(Qt::Vertical).contains(axis))
381 if (!m_chart->axes(Qt::Vertical).contains(axis))
375 m_chart->addAxis(axis, Qt::AlignLeft);
382 m_chart->addAxis(axis, Qt::AlignLeft);
376 if (!s->attachedAxes().contains(axis))
383 if (!s->attachedAxes().contains(axis))
377 s->attachAxis(axis);
384 s->attachAxis(axis);
378 } else {
385 } else {
379 qWarning() << "Trying to set axisY to null.";
386 qWarning() << "Trying to set axisY to null.";
380 }
387 }
381 }
388 }
382
389
383 void DeclarativeChart::handleAxisYRightSet(QAbstractAxis *axis)
390 void DeclarativeChart::handleAxisYRightSet(QAbstractAxis *axis)
384 {
391 {
385 QAbstractSeries *s = qobject_cast<QAbstractSeries *>(sender());
392 QAbstractSeries *s = qobject_cast<QAbstractSeries *>(sender());
386 if (axis && s) {
393 if (axis && s) {
387 if (!m_chart->axes(Qt::Vertical).contains(axis))
394 if (!m_chart->axes(Qt::Vertical).contains(axis))
388 m_chart->addAxis(axis, Qt::AlignRight);
395 m_chart->addAxis(axis, Qt::AlignRight);
389 if (!s->attachedAxes().contains(axis))
396 if (!s->attachedAxes().contains(axis))
390 s->attachAxis(axis);
397 s->attachAxis(axis);
391 } else {
398 } else {
392 qWarning() << "Trying to set axisYRight to null.";
399 qWarning() << "Trying to set axisYRight to null.";
393 }
400 }
394 }
401 }
395
402
396 void DeclarativeChart::geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry)
403 void DeclarativeChart::geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry)
397 {
404 {
398 if (newGeometry.isValid()) {
405 if (newGeometry.isValid()) {
399 if (newGeometry.width() > 0 && newGeometry.height() > 0) {
406 if (newGeometry.width() > 0 && newGeometry.height() > 0) {
400 m_chart->resize(newGeometry.width(), newGeometry.height());
407 m_chart->resize(newGeometry.width(), newGeometry.height());
401 }
408 }
402 }
409 }
403 QDECLARATIVE_ITEM::geometryChanged(newGeometry, oldGeometry);
410 QDECLARATIVE_ITEM::geometryChanged(newGeometry, oldGeometry);
404
411
405 // It would be better to trigger the plotAreaChanged signal from QChart::plotAreaChanged or
412 // It would be better to trigger the plotAreaChanged signal from QChart::plotAreaChanged or
406 // similar. Since that kind of a signal is not clearly needed in the C++ API the work-around is
413 // similar. Since that kind of a signal is not clearly needed in the C++ API the work-around is
407 // to implement it here for the QML API purposes.
414 // to implement it here for the QML API purposes.
408 emit plotAreaChanged(m_chart->plotArea());
415 emit plotAreaChanged(m_chart->plotArea());
409 }
416 }
410
417
411 #ifdef CHARTS_FOR_QUICK2
418 #ifdef CHARTS_FOR_QUICK2
412 void DeclarativeChart::paint(QPainter *painter)
419 void DeclarativeChart::paint(QPainter *painter)
413 {
420 {
414 QRectF renderRect(QPointF(0, 0), m_chart->size());
421 QRectF renderRect(QPointF(0, 0), m_chart->size());
415 m_scene->render(painter, renderRect, renderRect);
422 m_scene->render(painter, renderRect, renderRect);
416 }
423 }
417
424
418 void DeclarativeChart::mousePressEvent(QMouseEvent *event)
425 void DeclarativeChart::mousePressEvent(QMouseEvent *event)
419 {
426 {
420 m_mousePressScenePoint = event->pos();
427 m_mousePressScenePoint = event->pos();
421 m_mousePressScreenPoint = event->globalPos();
428 m_mousePressScreenPoint = event->globalPos();
422 m_lastMouseMoveScenePoint = m_mousePressScenePoint;
429 m_lastMouseMoveScenePoint = m_mousePressScenePoint;
423 m_lastMouseMoveScreenPoint = m_mousePressScreenPoint;
430 m_lastMouseMoveScreenPoint = m_mousePressScreenPoint;
424 m_mousePressButton = event->button();
431 m_mousePressButton = event->button();
425 m_mousePressButtons = event->buttons();
432 m_mousePressButtons = event->buttons();
426
433
427 QGraphicsSceneMouseEvent mouseEvent(QEvent::GraphicsSceneMousePress);
434 QGraphicsSceneMouseEvent mouseEvent(QEvent::GraphicsSceneMousePress);
428 mouseEvent.setWidget(0);
435 mouseEvent.setWidget(0);
429 mouseEvent.setButtonDownScenePos(m_mousePressButton, m_mousePressScenePoint);
436 mouseEvent.setButtonDownScenePos(m_mousePressButton, m_mousePressScenePoint);
430 mouseEvent.setButtonDownScreenPos(m_mousePressButton, m_mousePressScreenPoint);
437 mouseEvent.setButtonDownScreenPos(m_mousePressButton, m_mousePressScreenPoint);
431 mouseEvent.setScenePos(m_mousePressScenePoint);
438 mouseEvent.setScenePos(m_mousePressScenePoint);
432 mouseEvent.setScreenPos(m_mousePressScreenPoint);
439 mouseEvent.setScreenPos(m_mousePressScreenPoint);
433 mouseEvent.setLastScenePos(m_lastMouseMoveScenePoint);
440 mouseEvent.setLastScenePos(m_lastMouseMoveScenePoint);
434 mouseEvent.setLastScreenPos(m_lastMouseMoveScreenPoint);
441 mouseEvent.setLastScreenPos(m_lastMouseMoveScreenPoint);
435 mouseEvent.setButtons(m_mousePressButtons);
442 mouseEvent.setButtons(m_mousePressButtons);
436 mouseEvent.setButton(m_mousePressButton);
443 mouseEvent.setButton(m_mousePressButton);
437 mouseEvent.setModifiers(event->modifiers());
444 mouseEvent.setModifiers(event->modifiers());
438 mouseEvent.setAccepted(false);
445 mouseEvent.setAccepted(false);
439
446
440 QApplication::sendEvent(m_scene, &mouseEvent);
447 QApplication::sendEvent(m_scene, &mouseEvent);
441 }
448 }
442
449
443 void DeclarativeChart::mouseReleaseEvent(QMouseEvent *event)
450 void DeclarativeChart::mouseReleaseEvent(QMouseEvent *event)
444 {
451 {
445 QGraphicsSceneMouseEvent mouseEvent(QEvent::GraphicsSceneMouseRelease);
452 QGraphicsSceneMouseEvent mouseEvent(QEvent::GraphicsSceneMouseRelease);
446 mouseEvent.setWidget(0);
453 mouseEvent.setWidget(0);
447 mouseEvent.setButtonDownScenePos(m_mousePressButton, m_mousePressScenePoint);
454 mouseEvent.setButtonDownScenePos(m_mousePressButton, m_mousePressScenePoint);
448 mouseEvent.setButtonDownScreenPos(m_mousePressButton, m_mousePressScreenPoint);
455 mouseEvent.setButtonDownScreenPos(m_mousePressButton, m_mousePressScreenPoint);
449 mouseEvent.setScenePos(event->pos());
456 mouseEvent.setScenePos(event->pos());
450 mouseEvent.setScreenPos(event->globalPos());
457 mouseEvent.setScreenPos(event->globalPos());
451 mouseEvent.setLastScenePos(m_lastMouseMoveScenePoint);
458 mouseEvent.setLastScenePos(m_lastMouseMoveScenePoint);
452 mouseEvent.setLastScreenPos(m_lastMouseMoveScreenPoint);
459 mouseEvent.setLastScreenPos(m_lastMouseMoveScreenPoint);
453 mouseEvent.setButtons(event->buttons());
460 mouseEvent.setButtons(event->buttons());
454 mouseEvent.setButton(event->button());
461 mouseEvent.setButton(event->button());
455 mouseEvent.setModifiers(event->modifiers());
462 mouseEvent.setModifiers(event->modifiers());
456 mouseEvent.setAccepted(false);
463 mouseEvent.setAccepted(false);
457
464
458 QApplication::sendEvent(m_scene, &mouseEvent);
465 QApplication::sendEvent(m_scene, &mouseEvent);
459
466
460 m_mousePressButtons = event->buttons();
467 m_mousePressButtons = event->buttons();
461 m_mousePressButton = Qt::NoButton;
468 m_mousePressButton = Qt::NoButton;
462 }
469 }
463
470
464 void DeclarativeChart::hoverMoveEvent(QHoverEvent *event)
471 void DeclarativeChart::hoverMoveEvent(QHoverEvent *event)
465 {
472 {
466 // Convert hover move to mouse move, since we don't seem to get actual mouse move events.
473 // Convert hover move to mouse move, since we don't seem to get actual mouse move events.
467 // QGraphicsScene generates hover events from mouse move events, so we don't need
474 // QGraphicsScene generates hover events from mouse move events, so we don't need
468 // to pass hover events there.
475 // to pass hover events there.
469 QGraphicsSceneMouseEvent mouseEvent(QEvent::GraphicsSceneMouseMove);
476 QGraphicsSceneMouseEvent mouseEvent(QEvent::GraphicsSceneMouseMove);
470 mouseEvent.setWidget(0);
477 mouseEvent.setWidget(0);
471 mouseEvent.setButtonDownScenePos(m_mousePressButton, m_mousePressScenePoint);
478 mouseEvent.setButtonDownScenePos(m_mousePressButton, m_mousePressScenePoint);
472 mouseEvent.setButtonDownScreenPos(m_mousePressButton, m_mousePressScreenPoint);
479 mouseEvent.setButtonDownScreenPos(m_mousePressButton, m_mousePressScreenPoint);
473 mouseEvent.setScenePos(event->pos());
480 mouseEvent.setScenePos(event->pos());
474 // Hover events do not have global pos in them, and the screen position doesn't seem to
481 // Hover events do not have global pos in them, and the screen position doesn't seem to
475 // matter anyway in this use case, so just pass event pos instead of trying to
482 // matter anyway in this use case, so just pass event pos instead of trying to
476 // calculate the real screen position.
483 // calculate the real screen position.
477 mouseEvent.setScreenPos(event->pos());
484 mouseEvent.setScreenPos(event->pos());
478 mouseEvent.setLastScenePos(m_lastMouseMoveScenePoint);
485 mouseEvent.setLastScenePos(m_lastMouseMoveScenePoint);
479 mouseEvent.setLastScreenPos(m_lastMouseMoveScreenPoint);
486 mouseEvent.setLastScreenPos(m_lastMouseMoveScreenPoint);
480 mouseEvent.setButtons(m_mousePressButtons);
487 mouseEvent.setButtons(m_mousePressButtons);
481 mouseEvent.setButton(m_mousePressButton);
488 mouseEvent.setButton(m_mousePressButton);
482 mouseEvent.setModifiers(event->modifiers());
489 mouseEvent.setModifiers(event->modifiers());
483 m_lastMouseMoveScenePoint = mouseEvent.scenePos();
490 m_lastMouseMoveScenePoint = mouseEvent.scenePos();
484 m_lastMouseMoveScreenPoint = mouseEvent.screenPos();
491 m_lastMouseMoveScreenPoint = mouseEvent.screenPos();
485 mouseEvent.setAccepted(false);
492 mouseEvent.setAccepted(false);
486
493
487 QApplication::sendEvent(m_scene, &mouseEvent);
494 QApplication::sendEvent(m_scene, &mouseEvent);
488 }
495 }
489
496
490 void DeclarativeChart::handleAntialiasingChanged(bool enable)
497 void DeclarativeChart::handleAntialiasingChanged(bool enable)
491 {
498 {
492 setAntialiasing(enable);
499 setAntialiasing(enable);
493 }
500 }
494 #endif
501 #endif
495
502
496 void DeclarativeChart::setTheme(DeclarativeChart::Theme theme)
503 void DeclarativeChart::setTheme(DeclarativeChart::Theme theme)
497 {
504 {
498 QChart::ChartTheme chartTheme = (QChart::ChartTheme) theme;
505 QChart::ChartTheme chartTheme = (QChart::ChartTheme) theme;
499 if (chartTheme != m_chart->theme())
506 if (chartTheme != m_chart->theme())
500 m_chart->setTheme(chartTheme);
507 m_chart->setTheme(chartTheme);
501 }
508 }
502
509
503 DeclarativeChart::Theme DeclarativeChart::theme()
510 DeclarativeChart::Theme DeclarativeChart::theme()
504 {
511 {
505 return (DeclarativeChart::Theme) m_chart->theme();
512 return (DeclarativeChart::Theme) m_chart->theme();
506 }
513 }
507
514
508 void DeclarativeChart::setAnimationOptions(DeclarativeChart::Animation animations)
515 void DeclarativeChart::setAnimationOptions(DeclarativeChart::Animation animations)
509 {
516 {
510 QChart::AnimationOption animationOptions = (QChart::AnimationOption) animations;
517 QChart::AnimationOption animationOptions = (QChart::AnimationOption) animations;
511 if (animationOptions != m_chart->animationOptions())
518 if (animationOptions != m_chart->animationOptions())
512 m_chart->setAnimationOptions(animationOptions);
519 m_chart->setAnimationOptions(animationOptions);
513 }
520 }
514
521
515 DeclarativeChart::Animation DeclarativeChart::animationOptions()
522 DeclarativeChart::Animation DeclarativeChart::animationOptions()
516 {
523 {
517 if (m_chart->animationOptions().testFlag(QChart::AllAnimations))
524 if (m_chart->animationOptions().testFlag(QChart::AllAnimations))
518 return DeclarativeChart::AllAnimations;
525 return DeclarativeChart::AllAnimations;
519 else if (m_chart->animationOptions().testFlag(QChart::GridAxisAnimations))
526 else if (m_chart->animationOptions().testFlag(QChart::GridAxisAnimations))
520 return DeclarativeChart::GridAxisAnimations;
527 return DeclarativeChart::GridAxisAnimations;
521 else if (m_chart->animationOptions().testFlag(QChart::SeriesAnimations))
528 else if (m_chart->animationOptions().testFlag(QChart::SeriesAnimations))
522 return DeclarativeChart::SeriesAnimations;
529 return DeclarativeChart::SeriesAnimations;
523 else
530 else
524 return DeclarativeChart::NoAnimation;
531 return DeclarativeChart::NoAnimation;
525 }
532 }
526
533
527 void DeclarativeChart::setTitle(QString title)
534 void DeclarativeChart::setTitle(QString title)
528 {
535 {
529 if (title != m_chart->title())
536 if (title != m_chart->title())
530 m_chart->setTitle(title);
537 m_chart->setTitle(title);
531 }
538 }
532 QString DeclarativeChart::title()
539 QString DeclarativeChart::title()
533 {
540 {
534 return m_chart->title();
541 return m_chart->title();
535 }
542 }
536
543
537 QAbstractAxis *DeclarativeChart::axisX(QAbstractSeries *series)
544 QAbstractAxis *DeclarativeChart::axisX(QAbstractSeries *series)
538 {
545 {
539 QList<QAbstractAxis *> axes = m_chart->axes(Qt::Horizontal, series);
546 QList<QAbstractAxis *> axes = m_chart->axes(Qt::Horizontal, series);
540 if (axes.count())
547 if (axes.count())
541 return axes[0];
548 return axes[0];
542 return 0;
549 return 0;
543 }
550 }
544
551
545 QAbstractAxis *DeclarativeChart::axisY(QAbstractSeries *series)
552 QAbstractAxis *DeclarativeChart::axisY(QAbstractSeries *series)
546 {
553 {
547 QList<QAbstractAxis *> axes = m_chart->axes(Qt::Vertical, series);
554 QList<QAbstractAxis *> axes = m_chart->axes(Qt::Vertical, series);
548 if (axes.count())
555 if (axes.count())
549 return axes[0];
556 return axes[0];
550 return 0;
557 return 0;
551 }
558 }
552
559
553 QLegend *DeclarativeChart::legend()
560 QLegend *DeclarativeChart::legend()
554 {
561 {
555 return m_chart->legend();
562 return m_chart->legend();
556 }
563 }
557
564
558 void DeclarativeChart::setTitleColor(QColor color)
565 void DeclarativeChart::setTitleColor(QColor color)
559 {
566 {
560 QBrush b = m_chart->titleBrush();
567 QBrush b = m_chart->titleBrush();
561 if (color != b.color()) {
568 if (color != b.color()) {
562 b.setColor(color);
569 b.setColor(color);
563 m_chart->setTitleBrush(b);
570 m_chart->setTitleBrush(b);
564 emit titleColorChanged(color);
571 emit titleColorChanged(color);
565 }
572 }
566 }
573 }
567
574
568 QFont DeclarativeChart::titleFont() const
575 QFont DeclarativeChart::titleFont() const
569 {
576 {
570 return m_chart->titleFont();
577 return m_chart->titleFont();
571 }
578 }
572
579
573 void DeclarativeChart::setTitleFont(const QFont &font)
580 void DeclarativeChart::setTitleFont(const QFont &font)
574 {
581 {
575 m_chart->setTitleFont(font);
582 m_chart->setTitleFont(font);
576 }
583 }
577
584
578 QColor DeclarativeChart::titleColor()
585 QColor DeclarativeChart::titleColor()
579 {
586 {
580 return m_chart->titleBrush().color();
587 return m_chart->titleBrush().color();
581 }
588 }
582
589
583 void DeclarativeChart::setBackgroundColor(QColor color)
590 void DeclarativeChart::setBackgroundColor(QColor color)
584 {
591 {
585 QBrush b = m_chart->backgroundBrush();
592 QBrush b = m_chart->backgroundBrush();
586 if (b.style() != Qt::SolidPattern || color != b.color()) {
593 if (b.style() != Qt::SolidPattern || color != b.color()) {
587 b.setStyle(Qt::SolidPattern);
594 b.setStyle(Qt::SolidPattern);
588 b.setColor(color);
595 b.setColor(color);
589 m_chart->setBackgroundBrush(b);
596 m_chart->setBackgroundBrush(b);
590 emit backgroundColorChanged();
597 emit backgroundColorChanged();
591 }
598 }
592 }
599 }
593
600
594 QColor DeclarativeChart::backgroundColor()
601 QColor DeclarativeChart::backgroundColor()
595 {
602 {
596 return m_chart->backgroundBrush().color();
603 return m_chart->backgroundBrush().color();
597 }
604 }
598
605
606 void QtCommercialChart::DeclarativeChart::setPlotAreaColor(QColor color)
607 {
608 QBrush b = m_chart->plotAreaBackgroundBrush();
609 if (b.style() != Qt::SolidPattern || color != b.color()) {
610 b.setStyle(Qt::SolidPattern);
611 b.setColor(color);
612 m_chart->setPlotAreaBackgroundBrush(b);
613 m_chart->setPlotAreaBackgroundVisible(true);
614 emit plotAreaColorChanged();
615 }
616 }
617
618 QColor QtCommercialChart::DeclarativeChart::plotAreaColor()
619 {
620 return m_chart->plotAreaBackgroundBrush().color();
621 }
622
599 int DeclarativeChart::count()
623 int DeclarativeChart::count()
600 {
624 {
601 return m_chart->series().count();
625 return m_chart->series().count();
602 }
626 }
603
627
604 void DeclarativeChart::setDropShadowEnabled(bool enabled)
628 void DeclarativeChart::setDropShadowEnabled(bool enabled)
605 {
629 {
606 if (enabled != m_chart->isDropShadowEnabled()) {
630 if (enabled != m_chart->isDropShadowEnabled()) {
607 m_chart->setDropShadowEnabled(enabled);
631 m_chart->setDropShadowEnabled(enabled);
608 dropShadowEnabledChanged(enabled);
632 dropShadowEnabledChanged(enabled);
609 }
633 }
610 }
634 }
611
635
612 bool DeclarativeChart::dropShadowEnabled()
636 bool DeclarativeChart::dropShadowEnabled()
613 {
637 {
614 return m_chart->isDropShadowEnabled();
638 return m_chart->isDropShadowEnabled();
615 }
639 }
616
640
617 qreal DeclarativeChart::topMargin()
641 qreal DeclarativeChart::topMargin()
618 {
642 {
619 qWarning() << "ChartView.topMargin is deprecated. Use margins instead.";
643 qWarning() << "ChartView.topMargin is deprecated. Use margins instead.";
620 return m_chart->margins().top();
644 return m_chart->margins().top();
621 }
645 }
622
646
623 qreal DeclarativeChart::bottomMargin()
647 qreal DeclarativeChart::bottomMargin()
624 {
648 {
625 qWarning() << "ChartView.bottomMargin is deprecated. Use margins instead.";
649 qWarning() << "ChartView.bottomMargin is deprecated. Use margins instead.";
626 return m_chart->margins().bottom();
650 return m_chart->margins().bottom();
627 }
651 }
628
652
629 qreal DeclarativeChart::leftMargin()
653 qreal DeclarativeChart::leftMargin()
630 {
654 {
631 qWarning() << "ChartView.leftMargin is deprecated. Use margins instead.";
655 qWarning() << "ChartView.leftMargin is deprecated. Use margins instead.";
632 return m_chart->margins().left();
656 return m_chart->margins().left();
633 }
657 }
634
658
635 qreal DeclarativeChart::rightMargin()
659 qreal DeclarativeChart::rightMargin()
636 {
660 {
637 qWarning() << "ChartView.rightMargin is deprecated. Use margins instead.";
661 qWarning() << "ChartView.rightMargin is deprecated. Use margins instead.";
638 return m_chart->margins().right();
662 return m_chart->margins().right();
639 }
663 }
640
664
641 void DeclarativeChart::zoom(qreal factor)
665 void DeclarativeChart::zoom(qreal factor)
642 {
666 {
643 m_chart->zoom(factor);
667 m_chart->zoom(factor);
644 }
668 }
645
669
646 void DeclarativeChart::scrollLeft(qreal pixels)
670 void DeclarativeChart::scrollLeft(qreal pixels)
647 {
671 {
648 m_chart->scroll(-pixels, 0);
672 m_chart->scroll(-pixels, 0);
649 }
673 }
650
674
651 void DeclarativeChart::scrollRight(qreal pixels)
675 void DeclarativeChart::scrollRight(qreal pixels)
652 {
676 {
653 m_chart->scroll(pixels, 0);
677 m_chart->scroll(pixels, 0);
654 }
678 }
655
679
656 void DeclarativeChart::scrollUp(qreal pixels)
680 void DeclarativeChart::scrollUp(qreal pixels)
657 {
681 {
658 m_chart->scroll(0, pixels);
682 m_chart->scroll(0, pixels);
659 }
683 }
660
684
661 void DeclarativeChart::scrollDown(qreal pixels)
685 void DeclarativeChart::scrollDown(qreal pixels)
662 {
686 {
663 m_chart->scroll(0, -pixels);
687 m_chart->scroll(0, -pixels);
664 }
688 }
665
689
666 QDECLARATIVE_LIST_PROPERTY<QAbstractAxis> DeclarativeChart::axes()
690 QDECLARATIVE_LIST_PROPERTY<QAbstractAxis> DeclarativeChart::axes()
667 {
691 {
668 return QDECLARATIVE_LIST_PROPERTY<QAbstractAxis>(this, 0,
692 return QDECLARATIVE_LIST_PROPERTY<QAbstractAxis>(this, 0,
669 &DeclarativeChart::axesAppendFunc,
693 &DeclarativeChart::axesAppendFunc,
670 &DeclarativeChart::axesCountFunc,
694 &DeclarativeChart::axesCountFunc,
671 #ifdef CHARTS_FOR_QUICK2
695 #ifdef CHARTS_FOR_QUICK2
672 &DeclarativeChart::axesAtFunc,
696 &DeclarativeChart::axesAtFunc,
673 &DeclarativeChart::axesClearFunc);
697 &DeclarativeChart::axesClearFunc);
674 #else
698 #else
675 &DeclarativeChart::axesAtFunc);
699 &DeclarativeChart::axesAtFunc);
676 #endif
700 #endif
677 }
701 }
678
702
679 void DeclarativeChart::axesAppendFunc(QDECLARATIVE_LIST_PROPERTY<QAbstractAxis> *list, QAbstractAxis *element)
703 void DeclarativeChart::axesAppendFunc(QDECLARATIVE_LIST_PROPERTY<QAbstractAxis> *list, QAbstractAxis *element)
680 {
704 {
681 // Empty implementation
705 // Empty implementation
682 Q_UNUSED(list);
706 Q_UNUSED(list);
683 Q_UNUSED(element);
707 Q_UNUSED(element);
684 }
708 }
685
709
686 int DeclarativeChart::axesCountFunc(QDECLARATIVE_LIST_PROPERTY<QAbstractAxis> *list)
710 int DeclarativeChart::axesCountFunc(QDECLARATIVE_LIST_PROPERTY<QAbstractAxis> *list)
687 {
711 {
688 if (qobject_cast<DeclarativeChart *>(list->object)) {
712 if (qobject_cast<DeclarativeChart *>(list->object)) {
689 DeclarativeChart *chart = qobject_cast<DeclarativeChart *>(list->object);
713 DeclarativeChart *chart = qobject_cast<DeclarativeChart *>(list->object);
690 return chart->m_chart->axes(Qt::Horizontal | Qt::Vertical).count();
714 return chart->m_chart->axes(Qt::Horizontal | Qt::Vertical).count();
691 }
715 }
692 return 0;
716 return 0;
693 }
717 }
694
718
695 QAbstractAxis *DeclarativeChart::axesAtFunc(QDECLARATIVE_LIST_PROPERTY<QAbstractAxis> *list, int index)
719 QAbstractAxis *DeclarativeChart::axesAtFunc(QDECLARATIVE_LIST_PROPERTY<QAbstractAxis> *list, int index)
696 {
720 {
697 if (qobject_cast<DeclarativeChart *>(list->object)) {
721 if (qobject_cast<DeclarativeChart *>(list->object)) {
698 DeclarativeChart *chart = qobject_cast<DeclarativeChart *>(list->object);
722 DeclarativeChart *chart = qobject_cast<DeclarativeChart *>(list->object);
699 QList<QAbstractAxis *> axes = chart->m_chart->axes(Qt::Horizontal | Qt::Vertical, chart->m_chart->series()[0]);
723 QList<QAbstractAxis *> axes = chart->m_chart->axes(Qt::Horizontal | Qt::Vertical, chart->m_chart->series()[0]);
700 return axes.at(index);
724 return axes.at(index);
701 }
725 }
702 return 0;
726 return 0;
703 }
727 }
704
728
705 void DeclarativeChart::axesClearFunc(QDECLARATIVE_LIST_PROPERTY<QAbstractAxis> *list)
729 void DeclarativeChart::axesClearFunc(QDECLARATIVE_LIST_PROPERTY<QAbstractAxis> *list)
706 {
730 {
707 // Empty implementation
731 // Empty implementation
708 Q_UNUSED(list);
732 Q_UNUSED(list);
709 }
733 }
710
734
711
735
712 QAbstractSeries *DeclarativeChart::series(int index)
736 QAbstractSeries *DeclarativeChart::series(int index)
713 {
737 {
714 if (index < m_chart->series().count()) {
738 if (index < m_chart->series().count()) {
715 return m_chart->series().at(index);
739 return m_chart->series().at(index);
716 }
740 }
717 return 0;
741 return 0;
718 }
742 }
719
743
720 QAbstractSeries *DeclarativeChart::series(QString seriesName)
744 QAbstractSeries *DeclarativeChart::series(QString seriesName)
721 {
745 {
722 foreach (QAbstractSeries *series, m_chart->series()) {
746 foreach (QAbstractSeries *series, m_chart->series()) {
723 if (series->name() == seriesName)
747 if (series->name() == seriesName)
724 return series;
748 return series;
725 }
749 }
726 return 0;
750 return 0;
727 }
751 }
728
752
729 QAbstractSeries *DeclarativeChart::createSeries(int type, QString name, QAbstractAxis *axisX, QAbstractAxis *axisY)
753 QAbstractSeries *DeclarativeChart::createSeries(int type, QString name, QAbstractAxis *axisX, QAbstractAxis *axisY)
730 {
754 {
731 QAbstractSeries *series = 0;
755 QAbstractSeries *series = 0;
732
756
733 switch (type) {
757 switch (type) {
734 case DeclarativeChart::SeriesTypeLine:
758 case DeclarativeChart::SeriesTypeLine:
735 series = new DeclarativeLineSeries();
759 series = new DeclarativeLineSeries();
736 break;
760 break;
737 case DeclarativeChart::SeriesTypeArea: {
761 case DeclarativeChart::SeriesTypeArea: {
738 DeclarativeAreaSeries *area = new DeclarativeAreaSeries();
762 DeclarativeAreaSeries *area = new DeclarativeAreaSeries();
739 area->setUpperSeries(new DeclarativeLineSeries());
763 area->setUpperSeries(new DeclarativeLineSeries());
740 series = area;
764 series = area;
741 break;
765 break;
742 }
766 }
743 case DeclarativeChart::SeriesTypeStackedBar:
767 case DeclarativeChart::SeriesTypeStackedBar:
744 series = new DeclarativeStackedBarSeries();
768 series = new DeclarativeStackedBarSeries();
745 break;
769 break;
746 case DeclarativeChart::SeriesTypePercentBar:
770 case DeclarativeChart::SeriesTypePercentBar:
747 series = new DeclarativePercentBarSeries();
771 series = new DeclarativePercentBarSeries();
748 break;
772 break;
749 case DeclarativeChart::SeriesTypeBar:
773 case DeclarativeChart::SeriesTypeBar:
750 series = new DeclarativeBarSeries();
774 series = new DeclarativeBarSeries();
751 break;
775 break;
752 case DeclarativeChart::SeriesTypeHorizontalBar:
776 case DeclarativeChart::SeriesTypeHorizontalBar:
753 series = new DeclarativeHorizontalBarSeries();
777 series = new DeclarativeHorizontalBarSeries();
754 break;
778 break;
755 case DeclarativeChart::SeriesTypeHorizontalPercentBar:
779 case DeclarativeChart::SeriesTypeHorizontalPercentBar:
756 series = new DeclarativeHorizontalPercentBarSeries();
780 series = new DeclarativeHorizontalPercentBarSeries();
757 break;
781 break;
758 case DeclarativeChart::SeriesTypeHorizontalStackedBar:
782 case DeclarativeChart::SeriesTypeHorizontalStackedBar:
759 series = new DeclarativeHorizontalStackedBarSeries();
783 series = new DeclarativeHorizontalStackedBarSeries();
760 break;
784 break;
761 case DeclarativeChart::SeriesTypePie:
785 case DeclarativeChart::SeriesTypePie:
762 series = new DeclarativePieSeries();
786 series = new DeclarativePieSeries();
763 break;
787 break;
764 case DeclarativeChart::SeriesTypeScatter:
788 case DeclarativeChart::SeriesTypeScatter:
765 series = new DeclarativeScatterSeries();
789 series = new DeclarativeScatterSeries();
766 break;
790 break;
767 case DeclarativeChart::SeriesTypeSpline:
791 case DeclarativeChart::SeriesTypeSpline:
768 series = new DeclarativeSplineSeries();
792 series = new DeclarativeSplineSeries();
769 break;
793 break;
770 default:
794 default:
771 qWarning() << "Illegal series type";
795 qWarning() << "Illegal series type";
772 }
796 }
773
797
774 if (series) {
798 if (series) {
775 // Connect to axis changed signals (unless this is a pie series)
799 // Connect to axis changed signals (unless this is a pie series)
776 if (!qobject_cast<DeclarativePieSeries *>(series)) {
800 if (!qobject_cast<DeclarativePieSeries *>(series)) {
777 connect(series, SIGNAL(axisXChanged(QAbstractAxis*)), this, SLOT(handleAxisXSet(QAbstractAxis*)));
801 connect(series, SIGNAL(axisXChanged(QAbstractAxis*)), this, SLOT(handleAxisXSet(QAbstractAxis*)));
778 connect(series, SIGNAL(axisXTopChanged(QAbstractAxis*)), this, SLOT(handleAxisXSet(QAbstractAxis*)));
802 connect(series, SIGNAL(axisXTopChanged(QAbstractAxis*)), this, SLOT(handleAxisXSet(QAbstractAxis*)));
779 connect(series, SIGNAL(axisYChanged(QAbstractAxis*)), this, SLOT(handleAxisYSet(QAbstractAxis*)));
803 connect(series, SIGNAL(axisYChanged(QAbstractAxis*)), this, SLOT(handleAxisYSet(QAbstractAxis*)));
780 connect(series, SIGNAL(axisYRightChanged(QAbstractAxis*)), this, SLOT(handleAxisYRightSet(QAbstractAxis*)));
804 connect(series, SIGNAL(axisYRightChanged(QAbstractAxis*)), this, SLOT(handleAxisYRightSet(QAbstractAxis*)));
781 }
805 }
782
806
783 series->setName(name);
807 series->setName(name);
784 m_chart->addSeries(series);
808 m_chart->addSeries(series);
785
809
786 if (axisX)
810 if (axisX)
787 setAxisX(axisX, series);
811 setAxisX(axisX, series);
788 if (axisY)
812 if (axisY)
789 setAxisY(axisY, series);
813 setAxisY(axisY, series);
790
814
791 if (series->attachedAxes().count() < 2)
815 if (series->attachedAxes().count() < 2)
792 initializeAxes(series);
816 initializeAxes(series);
793 }
817 }
794
818
795 return series;
819 return series;
796 }
820 }
797
821
798 void DeclarativeChart::removeSeries(QAbstractSeries *series)
822 void DeclarativeChart::removeSeries(QAbstractSeries *series)
799 {
823 {
800 if (series)
824 if (series)
801 m_chart->removeSeries(series);
825 m_chart->removeSeries(series);
802 else
826 else
803 qWarning("removeSeries: cannot remove null");
827 qWarning("removeSeries: cannot remove null");
804 }
828 }
805
829
806 void DeclarativeChart::setAxisX(QAbstractAxis *axis, QAbstractSeries *series)
830 void DeclarativeChart::setAxisX(QAbstractAxis *axis, QAbstractSeries *series)
807 {
831 {
808 if (axis)
832 if (axis)
809 m_chart->setAxisX(axis, series);
833 m_chart->setAxisX(axis, series);
810 }
834 }
811
835
812 void DeclarativeChart::setAxisY(QAbstractAxis *axis, QAbstractSeries *series)
836 void DeclarativeChart::setAxisY(QAbstractAxis *axis, QAbstractSeries *series)
813 {
837 {
814 if (axis)
838 if (axis)
815 m_chart->setAxisY(axis, series);
839 m_chart->setAxisY(axis, series);
816 }
840 }
817
841
818 void DeclarativeChart::createDefaultAxes()
842 void DeclarativeChart::createDefaultAxes()
819 {
843 {
820 qWarning() << "ChartView.createDefaultAxes() is deprecated. Axes are created automatically.";
844 qWarning() << "ChartView.createDefaultAxes() is deprecated. Axes are created automatically.";
821 }
845 }
822
846
823 QAbstractAxis *DeclarativeChart::defaultAxis(Qt::Orientation orientation, QAbstractSeries *series)
847 QAbstractAxis *DeclarativeChart::defaultAxis(Qt::Orientation orientation, QAbstractSeries *series)
824 {
848 {
825 if (!series) {
849 if (!series) {
826 qWarning() << "No axis type defined for null series";
850 qWarning() << "No axis type defined for null series";
827 return 0;
851 return 0;
828 }
852 }
829
853
830 foreach (QAbstractAxis *existingAxis, m_chart->axes(orientation)) {
854 foreach (QAbstractAxis *existingAxis, m_chart->axes(orientation)) {
831 if (existingAxis->type() == series->d_ptr->defaultAxisType(orientation))
855 if (existingAxis->type() == series->d_ptr->defaultAxisType(orientation))
832 return existingAxis;
856 return existingAxis;
833 }
857 }
834
858
835 switch (series->d_ptr->defaultAxisType(orientation)) {
859 switch (series->d_ptr->defaultAxisType(orientation)) {
836 case QAbstractAxis::AxisTypeValue:
860 case QAbstractAxis::AxisTypeValue:
837 return new QValueAxis(this);
861 return new QValueAxis(this);
838 case QAbstractAxis::AxisTypeBarCategory:
862 case QAbstractAxis::AxisTypeBarCategory:
839 return new QBarCategoryAxis(this);
863 return new QBarCategoryAxis(this);
840 case QAbstractAxis::AxisTypeCategory:
864 case QAbstractAxis::AxisTypeCategory:
841 return new QCategoryAxis(this);
865 return new QCategoryAxis(this);
842 #ifndef QT_ON_ARM
866 #ifndef QT_ON_ARM
843 case QAbstractAxis::AxisTypeDateTime:
867 case QAbstractAxis::AxisTypeDateTime:
844 return new QDateTimeAxis(this);
868 return new QDateTimeAxis(this);
845 #endif
869 #endif
846 case QAbstractAxis::AxisTypeLogValue:
870 case QAbstractAxis::AxisTypeLogValue:
847 return new QLogValueAxis(this);
871 return new QLogValueAxis(this);
848 default:
872 default:
849 // assume AxisTypeNoAxis
873 // assume AxisTypeNoAxis
850 return 0;
874 return 0;
851 }
875 }
852 }
876 }
853
877
854 void DeclarativeChart::initializeAxes(QAbstractSeries *series)
878 void DeclarativeChart::initializeAxes(QAbstractSeries *series)
855 {
879 {
856 if (qobject_cast<DeclarativeLineSeries *>(series))
880 if (qobject_cast<DeclarativeLineSeries *>(series))
857 doInitializeAxes(series, qobject_cast<DeclarativeLineSeries *>(series)->m_axes);
881 doInitializeAxes(series, qobject_cast<DeclarativeLineSeries *>(series)->m_axes);
858 else if (qobject_cast<DeclarativeScatterSeries *>(series))
882 else if (qobject_cast<DeclarativeScatterSeries *>(series))
859 doInitializeAxes(series, qobject_cast<DeclarativeScatterSeries *>(series)->m_axes);
883 doInitializeAxes(series, qobject_cast<DeclarativeScatterSeries *>(series)->m_axes);
860 else if (qobject_cast<DeclarativeSplineSeries *>(series))
884 else if (qobject_cast<DeclarativeSplineSeries *>(series))
861 doInitializeAxes(series, qobject_cast<DeclarativeSplineSeries *>(series)->m_axes);
885 doInitializeAxes(series, qobject_cast<DeclarativeSplineSeries *>(series)->m_axes);
862 else if (qobject_cast<DeclarativeAreaSeries *>(series))
886 else if (qobject_cast<DeclarativeAreaSeries *>(series))
863 doInitializeAxes(series, qobject_cast<DeclarativeAreaSeries *>(series)->m_axes);
887 doInitializeAxes(series, qobject_cast<DeclarativeAreaSeries *>(series)->m_axes);
864 else if (qobject_cast<DeclarativeBarSeries *>(series))
888 else if (qobject_cast<DeclarativeBarSeries *>(series))
865 doInitializeAxes(series, qobject_cast<DeclarativeBarSeries *>(series)->m_axes);
889 doInitializeAxes(series, qobject_cast<DeclarativeBarSeries *>(series)->m_axes);
866 else if (qobject_cast<DeclarativeStackedBarSeries *>(series))
890 else if (qobject_cast<DeclarativeStackedBarSeries *>(series))
867 doInitializeAxes(series, qobject_cast<DeclarativeStackedBarSeries *>(series)->m_axes);
891 doInitializeAxes(series, qobject_cast<DeclarativeStackedBarSeries *>(series)->m_axes);
868 else if (qobject_cast<DeclarativePercentBarSeries *>(series))
892 else if (qobject_cast<DeclarativePercentBarSeries *>(series))
869 doInitializeAxes(series, qobject_cast<DeclarativePercentBarSeries *>(series)->m_axes);
893 doInitializeAxes(series, qobject_cast<DeclarativePercentBarSeries *>(series)->m_axes);
870 else if (qobject_cast<DeclarativeHorizontalBarSeries *>(series))
894 else if (qobject_cast<DeclarativeHorizontalBarSeries *>(series))
871 doInitializeAxes(series, qobject_cast<DeclarativeHorizontalBarSeries *>(series)->m_axes);
895 doInitializeAxes(series, qobject_cast<DeclarativeHorizontalBarSeries *>(series)->m_axes);
872 else if (qobject_cast<DeclarativeHorizontalStackedBarSeries *>(series))
896 else if (qobject_cast<DeclarativeHorizontalStackedBarSeries *>(series))
873 doInitializeAxes(series, qobject_cast<DeclarativeHorizontalStackedBarSeries *>(series)->m_axes);
897 doInitializeAxes(series, qobject_cast<DeclarativeHorizontalStackedBarSeries *>(series)->m_axes);
874 else if (qobject_cast<DeclarativeHorizontalPercentBarSeries *>(series))
898 else if (qobject_cast<DeclarativeHorizontalPercentBarSeries *>(series))
875 doInitializeAxes(series, qobject_cast<DeclarativeHorizontalPercentBarSeries *>(series)->m_axes);
899 doInitializeAxes(series, qobject_cast<DeclarativeHorizontalPercentBarSeries *>(series)->m_axes);
876 // else: do nothing
900 // else: do nothing
877 }
901 }
878
902
879 void DeclarativeChart::doInitializeAxes(QAbstractSeries *series, DeclarativeAxes *axes)
903 void DeclarativeChart::doInitializeAxes(QAbstractSeries *series, DeclarativeAxes *axes)
880 {
904 {
881 // Initialize axis X
905 // Initialize axis X
882 if (axes->axisX())
906 if (axes->axisX())
883 axes->emitAxisXChanged();
907 axes->emitAxisXChanged();
884 else if (axes->axisXTop())
908 else if (axes->axisXTop())
885 axes->emitAxisXTopChanged();
909 axes->emitAxisXTopChanged();
886 else
910 else
887 axes->setAxisX(defaultAxis(Qt::Horizontal, series));
911 axes->setAxisX(defaultAxis(Qt::Horizontal, series));
888
912
889 // Initialize axis Y
913 // Initialize axis Y
890 if (axes->axisY())
914 if (axes->axisY())
891 axes->emitAxisYChanged();
915 axes->emitAxisYChanged();
892 else if (axes->axisYRight())
916 else if (axes->axisYRight())
893 axes->emitAxisYRightChanged();
917 axes->emitAxisYRightChanged();
894 else
918 else
895 axes->setAxisY(defaultAxis(Qt::Vertical, series));
919 axes->setAxisY(defaultAxis(Qt::Vertical, series));
896 }
920 }
897
921
898 #include "moc_declarativechart.cpp"
922 #include "moc_declarativechart.cpp"
899
923
900 QTCOMMERCIALCHART_END_NAMESPACE
924 QTCOMMERCIALCHART_END_NAMESPACE
@@ -1,217 +1,221
1 /****************************************************************************
1 /****************************************************************************
2 **
2 **
3 ** Copyright (C) 2013 Digia Plc
3 ** Copyright (C) 2013 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 DECLARATIVECHART_H
21 #ifndef DECLARATIVECHART_H
22 #define DECLARATIVECHART_H
22 #define DECLARATIVECHART_H
23
23
24 #include <QtCore/QtGlobal>
24 #include <QtCore/QtGlobal>
25 #include "shared_defines.h"
25 #include "shared_defines.h"
26
26
27 #ifdef CHARTS_FOR_QUICK2
27 #ifdef CHARTS_FOR_QUICK2
28 #include <QtQuick/QQuickItem>
28 #include <QtQuick/QQuickItem>
29 #include <QtQuick/QQuickPaintedItem>
29 #include <QtQuick/QQuickPaintedItem>
30 #include <QtWidgets/QGraphicsScene>
30 #include <QtWidgets/QGraphicsScene>
31 #else
31 #else
32 #include <QtDeclarative/QDeclarativeItem>
32 #include <QtDeclarative/QDeclarativeItem>
33 #endif
33 #endif
34
34
35 #include "qchart.h"
35 #include "qchart.h"
36
36
37 QTCOMMERCIALCHART_BEGIN_NAMESPACE
37 QTCOMMERCIALCHART_BEGIN_NAMESPACE
38
38
39 class DeclarativeMargins;
39 class DeclarativeMargins;
40 class Domain;
40 class Domain;
41 class DeclarativeAxes;
41 class DeclarativeAxes;
42
42
43 class DeclarativeChart : public QDECLARATIVE_PAINTED_ITEM
43 class DeclarativeChart : public QDECLARATIVE_PAINTED_ITEM
44 {
44 {
45 Q_OBJECT
45 Q_OBJECT
46 Q_PROPERTY(Theme theme READ theme WRITE setTheme)
46 Q_PROPERTY(Theme theme READ theme WRITE setTheme)
47 Q_PROPERTY(Animation animationOptions READ animationOptions WRITE setAnimationOptions)
47 Q_PROPERTY(Animation animationOptions READ animationOptions WRITE setAnimationOptions)
48 Q_PROPERTY(QString title READ title WRITE setTitle)
48 Q_PROPERTY(QString title READ title WRITE setTitle)
49 Q_PROPERTY(QFont titleFont READ titleFont WRITE setTitleFont)
49 Q_PROPERTY(QFont titleFont READ titleFont WRITE setTitleFont)
50 Q_PROPERTY(QColor titleColor READ titleColor WRITE setTitleColor NOTIFY titleColorChanged)
50 Q_PROPERTY(QColor titleColor READ titleColor WRITE setTitleColor NOTIFY titleColorChanged)
51 Q_PROPERTY(QLegend *legend READ legend)
51 Q_PROPERTY(QLegend *legend READ legend)
52 Q_PROPERTY(int count READ count)
52 Q_PROPERTY(int count READ count)
53 Q_PROPERTY(QColor backgroundColor READ backgroundColor WRITE setBackgroundColor NOTIFY backgroundColorChanged)
53 Q_PROPERTY(QColor backgroundColor READ backgroundColor WRITE setBackgroundColor NOTIFY backgroundColorChanged)
54 Q_PROPERTY(bool dropShadowEnabled READ dropShadowEnabled WRITE setDropShadowEnabled NOTIFY dropShadowEnabledChanged)
54 Q_PROPERTY(bool dropShadowEnabled READ dropShadowEnabled WRITE setDropShadowEnabled NOTIFY dropShadowEnabledChanged)
55 Q_PROPERTY(qreal topMargin READ topMargin)
55 Q_PROPERTY(qreal topMargin READ topMargin)
56 Q_PROPERTY(qreal bottomMargin READ bottomMargin)
56 Q_PROPERTY(qreal bottomMargin READ bottomMargin)
57 Q_PROPERTY(qreal leftMargin READ leftMargin)
57 Q_PROPERTY(qreal leftMargin READ leftMargin)
58 Q_PROPERTY(qreal rightMargin READ rightMargin)
58 Q_PROPERTY(qreal rightMargin READ rightMargin)
59 Q_PROPERTY(DeclarativeMargins *minimumMargins READ minimumMargins NOTIFY minimumMarginsChanged REVISION 1)
59 Q_PROPERTY(DeclarativeMargins *minimumMargins READ minimumMargins NOTIFY minimumMarginsChanged REVISION 1)
60 Q_PROPERTY(DeclarativeMargins *margins READ margins NOTIFY marginsChanged REVISION 2)
60 Q_PROPERTY(DeclarativeMargins *margins READ margins NOTIFY marginsChanged REVISION 2)
61 Q_PROPERTY(QRectF plotArea READ plotArea NOTIFY plotAreaChanged REVISION 1)
61 Q_PROPERTY(QRectF plotArea READ plotArea NOTIFY plotAreaChanged REVISION 1)
62 Q_PROPERTY(QColor plotAreaColor READ plotAreaColor WRITE setPlotAreaColor NOTIFY plotAreaColorChanged REVISION 3)
62 #ifdef CHARTS_FOR_QUICK2
63 #ifdef CHARTS_FOR_QUICK2
63 Q_PROPERTY(QQmlListProperty<QAbstractAxis> axes READ axes REVISION 2)
64 Q_PROPERTY(QQmlListProperty<QAbstractAxis> axes READ axes REVISION 2)
64 #else
65 #else
65 Q_PROPERTY(QDeclarativeListProperty<QAbstractAxis> axes READ axes REVISION 2)
66 Q_PROPERTY(QDeclarativeListProperty<QAbstractAxis> axes READ axes REVISION 2)
66 #endif
67 #endif
67 Q_ENUMS(Animation)
68 Q_ENUMS(Animation)
68 Q_ENUMS(Theme)
69 Q_ENUMS(Theme)
69 Q_ENUMS(SeriesType)
70 Q_ENUMS(SeriesType)
70
71
71 public:
72 public:
72 // duplicating enums from QChart to make the QML api namings 1-to-1 with the C++ api
73 // duplicating enums from QChart to make the QML api namings 1-to-1 with the C++ api
73 enum Theme {
74 enum Theme {
74 ChartThemeLight = 0,
75 ChartThemeLight = 0,
75 ChartThemeBlueCerulean,
76 ChartThemeBlueCerulean,
76 ChartThemeDark,
77 ChartThemeDark,
77 ChartThemeBrownSand,
78 ChartThemeBrownSand,
78 ChartThemeBlueNcs,
79 ChartThemeBlueNcs,
79 ChartThemeHighContrast,
80 ChartThemeHighContrast,
80 ChartThemeBlueIcy
81 ChartThemeBlueIcy
81 };
82 };
82
83
83 enum Animation {
84 enum Animation {
84 NoAnimation = 0x0,
85 NoAnimation = 0x0,
85 GridAxisAnimations = 0x1,
86 GridAxisAnimations = 0x1,
86 SeriesAnimations = 0x2,
87 SeriesAnimations = 0x2,
87 AllAnimations = 0x3
88 AllAnimations = 0x3
88 };
89 };
89
90
90 enum SeriesType {
91 enum SeriesType {
91 SeriesTypeLine,
92 SeriesTypeLine,
92 SeriesTypeArea,
93 SeriesTypeArea,
93 SeriesTypeBar,
94 SeriesTypeBar,
94 SeriesTypeStackedBar,
95 SeriesTypeStackedBar,
95 SeriesTypePercentBar,
96 SeriesTypePercentBar,
96 SeriesTypePie,
97 SeriesTypePie,
97 SeriesTypeScatter,
98 SeriesTypeScatter,
98 SeriesTypeSpline,
99 SeriesTypeSpline,
99 SeriesTypeHorizontalBar,
100 SeriesTypeHorizontalBar,
100 SeriesTypeHorizontalStackedBar,
101 SeriesTypeHorizontalStackedBar,
101 SeriesTypeHorizontalPercentBar
102 SeriesTypeHorizontalPercentBar
102 };
103 };
103
104
104 public:
105 public:
105 DeclarativeChart(QDECLARATIVE_ITEM *parent = 0);
106 DeclarativeChart(QDECLARATIVE_ITEM *parent = 0);
106 ~DeclarativeChart();
107 ~DeclarativeChart();
107
108
108 public: // From parent classes
109 public: // From parent classes
109 void childEvent(QChildEvent *event);
110 void childEvent(QChildEvent *event);
110 void componentComplete();
111 void componentComplete();
111 void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry);
112 void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry);
112 #ifdef CHARTS_FOR_QUICK2
113 #ifdef CHARTS_FOR_QUICK2
113 void paint(QPainter *painter);
114 void paint(QPainter *painter);
114 protected:
115 protected:
115 void mousePressEvent(QMouseEvent *event);
116 void mousePressEvent(QMouseEvent *event);
116 void mouseReleaseEvent(QMouseEvent *event);
117 void mouseReleaseEvent(QMouseEvent *event);
117 void hoverMoveEvent(QHoverEvent *event);
118 void hoverMoveEvent(QHoverEvent *event);
118 private Q_SLOTS:
119 private Q_SLOTS:
119 void handleAntialiasingChanged(bool enable);
120 void handleAntialiasingChanged(bool enable);
120 #endif
121 #endif
121
122
122 public:
123 public:
123 void setTheme(DeclarativeChart::Theme theme);
124 void setTheme(DeclarativeChart::Theme theme);
124 DeclarativeChart::Theme theme();
125 DeclarativeChart::Theme theme();
125 void setAnimationOptions(DeclarativeChart::Animation animations);
126 void setAnimationOptions(DeclarativeChart::Animation animations);
126 DeclarativeChart::Animation animationOptions();
127 DeclarativeChart::Animation animationOptions();
127 void setTitle(QString title);
128 void setTitle(QString title);
128 QString title();
129 QString title();
129 QLegend *legend();
130 QLegend *legend();
130 QFont titleFont() const;
131 QFont titleFont() const;
131 void setTitleFont(const QFont &font);
132 void setTitleFont(const QFont &font);
132 void setTitleColor(QColor color);
133 void setTitleColor(QColor color);
133 QColor titleColor();
134 QColor titleColor();
134 void setBackgroundColor(QColor color);
135 void setBackgroundColor(QColor color);
135 QColor backgroundColor();
136 QColor backgroundColor();
137 Q_REVISION(3) void setPlotAreaColor(QColor color);
138 Q_REVISION(3) QColor plotAreaColor();
136 int count();
139 int count();
137 void setDropShadowEnabled(bool enabled);
140 void setDropShadowEnabled(bool enabled);
138 bool dropShadowEnabled();
141 bool dropShadowEnabled();
139
142
140 // Margins & plotArea
143 // Margins & plotArea
141 qreal topMargin();
144 qreal topMargin();
142 qreal bottomMargin();
145 qreal bottomMargin();
143 qreal leftMargin();
146 qreal leftMargin();
144 qreal rightMargin();
147 qreal rightMargin();
145 DeclarativeMargins *minimumMargins() { return m_margins; }
148 DeclarativeMargins *minimumMargins() { return m_margins; }
146 Q_REVISION(2) DeclarativeMargins *margins() { return m_margins; }
149 Q_REVISION(2) DeclarativeMargins *margins() { return m_margins; }
147 QRectF plotArea() { return m_chart->plotArea(); }
150 QRectF plotArea() { return m_chart->plotArea(); }
148
151
149 // Axis handling
152 // Axis handling
150 QAbstractAxis *defaultAxis(Qt::Orientation orientation, QAbstractSeries *series);
153 QAbstractAxis *defaultAxis(Qt::Orientation orientation, QAbstractSeries *series);
151 void initializeAxes(QAbstractSeries *series);
154 void initializeAxes(QAbstractSeries *series);
152 void doInitializeAxes(QAbstractSeries *series, DeclarativeAxes *axes);
155 void doInitializeAxes(QAbstractSeries *series, DeclarativeAxes *axes);
153 QDECLARATIVE_LIST_PROPERTY<QAbstractAxis> axes();
156 QDECLARATIVE_LIST_PROPERTY<QAbstractAxis> axes();
154 static void axesAppendFunc(QDECLARATIVE_LIST_PROPERTY<QAbstractAxis> *list, QAbstractAxis *element);
157 static void axesAppendFunc(QDECLARATIVE_LIST_PROPERTY<QAbstractAxis> *list, QAbstractAxis *element);
155 static int axesCountFunc(QDECLARATIVE_LIST_PROPERTY<QAbstractAxis> *list);
158 static int axesCountFunc(QDECLARATIVE_LIST_PROPERTY<QAbstractAxis> *list);
156 static QAbstractAxis *axesAtFunc(QDECLARATIVE_LIST_PROPERTY<QAbstractAxis> *list, int index);
159 static QAbstractAxis *axesAtFunc(QDECLARATIVE_LIST_PROPERTY<QAbstractAxis> *list, int index);
157 static void axesClearFunc(QDECLARATIVE_LIST_PROPERTY<QAbstractAxis> *list);
160 static void axesClearFunc(QDECLARATIVE_LIST_PROPERTY<QAbstractAxis> *list);
158
161
159 public:
162 public:
160 Q_INVOKABLE QAbstractSeries *series(int index);
163 Q_INVOKABLE QAbstractSeries *series(int index);
161 Q_INVOKABLE QAbstractSeries *series(QString seriesName);
164 Q_INVOKABLE QAbstractSeries *series(QString seriesName);
162 Q_INVOKABLE QAbstractSeries *createSeries(int type, QString name = "", QAbstractAxis *axisX = 0, QAbstractAxis *axisY = 0);
165 Q_INVOKABLE QAbstractSeries *createSeries(int type, QString name = "", QAbstractAxis *axisX = 0, QAbstractAxis *axisY = 0);
163 Q_INVOKABLE void removeSeries(QAbstractSeries *series);
166 Q_INVOKABLE void removeSeries(QAbstractSeries *series);
164 Q_INVOKABLE void removeAllSeries() { m_chart->removeAllSeries(); }
167 Q_INVOKABLE void removeAllSeries() { m_chart->removeAllSeries(); }
165 Q_INVOKABLE void setAxisX(QAbstractAxis *axis, QAbstractSeries *series = 0);
168 Q_INVOKABLE void setAxisX(QAbstractAxis *axis, QAbstractSeries *series = 0);
166 Q_INVOKABLE void setAxisY(QAbstractAxis *axis, QAbstractSeries *series = 0);
169 Q_INVOKABLE void setAxisY(QAbstractAxis *axis, QAbstractSeries *series = 0);
167 Q_INVOKABLE void createDefaultAxes();
170 Q_INVOKABLE void createDefaultAxes();
168 Q_INVOKABLE QAbstractAxis *axisX(QAbstractSeries *series = 0);
171 Q_INVOKABLE QAbstractAxis *axisX(QAbstractSeries *series = 0);
169 Q_INVOKABLE QAbstractAxis *axisY(QAbstractSeries *series = 0);
172 Q_INVOKABLE QAbstractAxis *axisY(QAbstractSeries *series = 0);
170 Q_INVOKABLE void zoom(qreal factor);
173 Q_INVOKABLE void zoom(qreal factor);
171 Q_INVOKABLE void scrollLeft(qreal pixels);
174 Q_INVOKABLE void scrollLeft(qreal pixels);
172 Q_INVOKABLE void scrollRight(qreal pixels);
175 Q_INVOKABLE void scrollRight(qreal pixels);
173 Q_INVOKABLE void scrollUp(qreal pixels);
176 Q_INVOKABLE void scrollUp(qreal pixels);
174 Q_INVOKABLE void scrollDown(qreal pixels);
177 Q_INVOKABLE void scrollDown(qreal pixels);
175
178
176 Q_SIGNALS:
179 Q_SIGNALS:
177 void axisLabelsChanged();
180 void axisLabelsChanged();
178 void titleColorChanged(QColor color);
181 void titleColorChanged(QColor color);
179 void backgroundColorChanged();
182 void backgroundColorChanged();
180 void dropShadowEnabledChanged(bool enabled);
183 void dropShadowEnabledChanged(bool enabled);
181 void minimumMarginsChanged();
184 void minimumMarginsChanged();
182 Q_REVISION(2) void marginsChanged();
185 Q_REVISION(2) void marginsChanged();
183 void plotAreaChanged(QRectF plotArea);
186 void plotAreaChanged(QRectF plotArea);
184 void seriesAdded(QAbstractSeries *series);
187 void seriesAdded(QAbstractSeries *series);
185 void seriesRemoved(QAbstractSeries *series);
188 void seriesRemoved(QAbstractSeries *series);
189 Q_REVISION(3) void plotAreaColorChanged();
186
190
187 private Q_SLOTS:
191 private Q_SLOTS:
188 void changeMinimumMargins(int top, int bottom, int left, int right);
192 void changeMinimumMargins(int top, int bottom, int left, int right);
189 void handleAxisXSet(QAbstractAxis *axis);
193 void handleAxisXSet(QAbstractAxis *axis);
190 void handleAxisYSet(QAbstractAxis *axis);
194 void handleAxisYSet(QAbstractAxis *axis);
191 void handleAxisXTopSet(QAbstractAxis *axis);
195 void handleAxisXTopSet(QAbstractAxis *axis);
192 void handleAxisYRightSet(QAbstractAxis *axis);
196 void handleAxisYRightSet(QAbstractAxis *axis);
193 void handleSeriesAdded(QAbstractSeries *series);
197 void handleSeriesAdded(QAbstractSeries *series);
194
198
195 protected:
199 protected:
196 explicit DeclarativeChart(QChart::ChartType type, QDECLARATIVE_ITEM *parent);
200 explicit DeclarativeChart(QChart::ChartType type, QDECLARATIVE_ITEM *parent);
197
201
198 private:
202 private:
199 void initChart(QChart::ChartType type);
203 void initChart(QChart::ChartType type);
200 // Extending QChart with DeclarativeChart is not possible because QObject does not support
204 // Extending QChart with DeclarativeChart is not possible because QObject does not support
201 // multi inheritance, so we now have a QChart as a member instead
205 // multi inheritance, so we now have a QChart as a member instead
202 QChart *m_chart;
206 QChart *m_chart;
203 #ifdef CHARTS_FOR_QUICK2
207 #ifdef CHARTS_FOR_QUICK2
204 QGraphicsScene *m_scene;
208 QGraphicsScene *m_scene;
205 QPointF m_mousePressScenePoint;
209 QPointF m_mousePressScenePoint;
206 QPoint m_mousePressScreenPoint;
210 QPoint m_mousePressScreenPoint;
207 QPointF m_lastMouseMoveScenePoint;
211 QPointF m_lastMouseMoveScenePoint;
208 QPoint m_lastMouseMoveScreenPoint;
212 QPoint m_lastMouseMoveScreenPoint;
209 Qt::MouseButton m_mousePressButton;
213 Qt::MouseButton m_mousePressButton;
210 Qt::MouseButtons m_mousePressButtons;
214 Qt::MouseButtons m_mousePressButtons;
211 #endif
215 #endif
212 DeclarativeMargins *m_margins;
216 DeclarativeMargins *m_margins;
213 };
217 };
214
218
215 QTCOMMERCIALCHART_END_NAMESPACE
219 QTCOMMERCIALCHART_END_NAMESPACE
216
220
217 #endif // DECLARATIVECHART_H
221 #endif // DECLARATIVECHART_H
@@ -1,249 +1,250
1 /****************************************************************************
1 /****************************************************************************
2 **
2 **
3 ** Copyright (C) 2013 Digia Plc
3 ** Copyright (C) 2013 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 "qabstractaxis.h"
22 #include "qabstractaxis.h"
23 #include "qvalueaxis.h"
23 #include "qvalueaxis.h"
24 #include "qlogvalueaxis.h"
24 #include "qlogvalueaxis.h"
25 #include "declarativecategoryaxis.h"
25 #include "declarativecategoryaxis.h"
26 #include "qbarcategoryaxis.h"
26 #include "qbarcategoryaxis.h"
27 #include "declarativechart.h"
27 #include "declarativechart.h"
28 #include "declarativepolarchart.h"
28 #include "declarativepolarchart.h"
29 #include "declarativexypoint.h"
29 #include "declarativexypoint.h"
30 #include "declarativelineseries.h"
30 #include "declarativelineseries.h"
31 #include "declarativesplineseries.h"
31 #include "declarativesplineseries.h"
32 #include "declarativeareaseries.h"
32 #include "declarativeareaseries.h"
33 #include "declarativescatterseries.h"
33 #include "declarativescatterseries.h"
34 #include "declarativebarseries.h"
34 #include "declarativebarseries.h"
35 #include "declarativepieseries.h"
35 #include "declarativepieseries.h"
36 #include "declarativeaxes.h"
36 #include "declarativeaxes.h"
37 #include "qvxymodelmapper.h"
37 #include "qvxymodelmapper.h"
38 #include "qhxymodelmapper.h"
38 #include "qhxymodelmapper.h"
39 #include "qhpiemodelmapper.h"
39 #include "qhpiemodelmapper.h"
40 #include "qvpiemodelmapper.h"
40 #include "qvpiemodelmapper.h"
41 #include "qhbarmodelmapper.h"
41 #include "qhbarmodelmapper.h"
42 #include "qvbarmodelmapper.h"
42 #include "qvbarmodelmapper.h"
43 #include "declarativemargins.h"
43 #include "declarativemargins.h"
44 #include "qarealegendmarker.h"
44 #include "qarealegendmarker.h"
45 #include "qbarlegendmarker.h"
45 #include "qbarlegendmarker.h"
46 #include "qpielegendmarker.h"
46 #include "qpielegendmarker.h"
47 #include "qxylegendmarker.h"
47 #include "qxylegendmarker.h"
48 #ifndef QT_ON_ARM
48 #ifndef QT_ON_ARM
49 #include "qdatetimeaxis.h"
49 #include "qdatetimeaxis.h"
50 #endif
50 #endif
51 #include "shared_defines.h"
51 #include "shared_defines.h"
52 #include <QAbstractItemModel>
52 #include <QAbstractItemModel>
53 #ifdef CHARTS_FOR_QUICK2
53 #ifdef CHARTS_FOR_QUICK2
54 #include <QtQml/QQmlExtensionPlugin>
54 #include <QtQml/QQmlExtensionPlugin>
55 #else
55 #else
56 #include <QtDeclarative/qdeclarativeextensionplugin.h>
56 #include <QtDeclarative/qdeclarativeextensionplugin.h>
57 #include <QtDeclarative/qdeclarative.h>
57 #include <QtDeclarative/qdeclarative.h>
58 #endif
58 #endif
59
59
60 QTCOMMERCIALCHART_USE_NAMESPACE
60 QTCOMMERCIALCHART_USE_NAMESPACE
61
61
62 Q_DECLARE_METATYPE(QList<QPieSlice *>)
62 Q_DECLARE_METATYPE(QList<QPieSlice *>)
63 Q_DECLARE_METATYPE(QList<QBarSet *>)
63 Q_DECLARE_METATYPE(QList<QBarSet *>)
64 Q_DECLARE_METATYPE(QList<QAbstractAxis *>)
64 Q_DECLARE_METATYPE(QList<QAbstractAxis *>)
65
65
66 #if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
66 #if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
67
67
68 // NOTE: Hackish fixes for Qt5 (beta2).
68 // NOTE: Hackish fixes for Qt5 (beta2).
69 // These should not be needed or at least they are not needed in Qt4.
69 // These should not be needed or at least they are not needed in Qt4.
70
70
71 Q_DECLARE_METATYPE(DeclarativeChart *)
71 Q_DECLARE_METATYPE(DeclarativeChart *)
72 Q_DECLARE_METATYPE(DeclarativePolarChart *)
72 Q_DECLARE_METATYPE(DeclarativePolarChart *)
73 Q_DECLARE_METATYPE(DeclarativeMargins *)
73 Q_DECLARE_METATYPE(DeclarativeMargins *)
74 Q_DECLARE_METATYPE(DeclarativeAreaSeries *)
74 Q_DECLARE_METATYPE(DeclarativeAreaSeries *)
75 Q_DECLARE_METATYPE(DeclarativeBarSeries *)
75 Q_DECLARE_METATYPE(DeclarativeBarSeries *)
76 Q_DECLARE_METATYPE(DeclarativeBarSet *)
76 Q_DECLARE_METATYPE(DeclarativeBarSet *)
77 Q_DECLARE_METATYPE(DeclarativeLineSeries *)
77 Q_DECLARE_METATYPE(DeclarativeLineSeries *)
78 Q_DECLARE_METATYPE(DeclarativePieSeries *)
78 Q_DECLARE_METATYPE(DeclarativePieSeries *)
79 Q_DECLARE_METATYPE(DeclarativeScatterSeries *)
79 Q_DECLARE_METATYPE(DeclarativeScatterSeries *)
80 Q_DECLARE_METATYPE(DeclarativeSplineSeries *)
80 Q_DECLARE_METATYPE(DeclarativeSplineSeries *)
81
81
82 Q_DECLARE_METATYPE(QAbstractAxis *)
82 Q_DECLARE_METATYPE(QAbstractAxis *)
83 Q_DECLARE_METATYPE(QValueAxis *)
83 Q_DECLARE_METATYPE(QValueAxis *)
84 Q_DECLARE_METATYPE(QBarCategoryAxis *)
84 Q_DECLARE_METATYPE(QBarCategoryAxis *)
85 Q_DECLARE_METATYPE(QCategoryAxis *)
85 Q_DECLARE_METATYPE(QCategoryAxis *)
86 Q_DECLARE_METATYPE(QDateTimeAxis *)
86 Q_DECLARE_METATYPE(QDateTimeAxis *)
87 Q_DECLARE_METATYPE(QLogValueAxis *)
87 Q_DECLARE_METATYPE(QLogValueAxis *)
88
88
89 Q_DECLARE_METATYPE(QLegend *)
89 Q_DECLARE_METATYPE(QLegend *)
90 Q_DECLARE_METATYPE(QLegendMarker *)
90 Q_DECLARE_METATYPE(QLegendMarker *)
91 Q_DECLARE_METATYPE(QAreaLegendMarker *)
91 Q_DECLARE_METATYPE(QAreaLegendMarker *)
92 Q_DECLARE_METATYPE(QBarLegendMarker *)
92 Q_DECLARE_METATYPE(QBarLegendMarker *)
93 Q_DECLARE_METATYPE(QPieLegendMarker *)
93 Q_DECLARE_METATYPE(QPieLegendMarker *)
94
94
95 Q_DECLARE_METATYPE(QHPieModelMapper *)
95 Q_DECLARE_METATYPE(QHPieModelMapper *)
96 Q_DECLARE_METATYPE(QHXYModelMapper *)
96 Q_DECLARE_METATYPE(QHXYModelMapper *)
97 Q_DECLARE_METATYPE(QPieModelMapper *)
97 Q_DECLARE_METATYPE(QPieModelMapper *)
98 Q_DECLARE_METATYPE(QHBarModelMapper *)
98 Q_DECLARE_METATYPE(QHBarModelMapper *)
99 Q_DECLARE_METATYPE(QBarModelMapper *)
99 Q_DECLARE_METATYPE(QBarModelMapper *)
100 Q_DECLARE_METATYPE(QVBarModelMapper *)
100 Q_DECLARE_METATYPE(QVBarModelMapper *)
101 Q_DECLARE_METATYPE(QVPieModelMapper *)
101 Q_DECLARE_METATYPE(QVPieModelMapper *)
102 Q_DECLARE_METATYPE(QVXYModelMapper *)
102 Q_DECLARE_METATYPE(QVXYModelMapper *)
103 Q_DECLARE_METATYPE(QXYLegendMarker *)
103 Q_DECLARE_METATYPE(QXYLegendMarker *)
104 Q_DECLARE_METATYPE(QXYModelMapper *)
104 Q_DECLARE_METATYPE(QXYModelMapper *)
105
105
106 Q_DECLARE_METATYPE(QAbstractSeries *)
106 Q_DECLARE_METATYPE(QAbstractSeries *)
107 Q_DECLARE_METATYPE(QXYSeries *)
107 Q_DECLARE_METATYPE(QXYSeries *)
108 Q_DECLARE_METATYPE(QAbstractBarSeries *)
108 Q_DECLARE_METATYPE(QAbstractBarSeries *)
109 Q_DECLARE_METATYPE(QBarSeries *)
109 Q_DECLARE_METATYPE(QBarSeries *)
110 Q_DECLARE_METATYPE(QBarSet *)
110 Q_DECLARE_METATYPE(QBarSet *)
111 Q_DECLARE_METATYPE(QAreaSeries *)
111 Q_DECLARE_METATYPE(QAreaSeries *)
112 Q_DECLARE_METATYPE(QHorizontalBarSeries *)
112 Q_DECLARE_METATYPE(QHorizontalBarSeries *)
113 Q_DECLARE_METATYPE(QHorizontalPercentBarSeries *)
113 Q_DECLARE_METATYPE(QHorizontalPercentBarSeries *)
114 Q_DECLARE_METATYPE(QHorizontalStackedBarSeries *)
114 Q_DECLARE_METATYPE(QHorizontalStackedBarSeries *)
115 Q_DECLARE_METATYPE(QLineSeries *)
115 Q_DECLARE_METATYPE(QLineSeries *)
116 Q_DECLARE_METATYPE(QPercentBarSeries *)
116 Q_DECLARE_METATYPE(QPercentBarSeries *)
117 Q_DECLARE_METATYPE(QPieSeries *)
117 Q_DECLARE_METATYPE(QPieSeries *)
118 Q_DECLARE_METATYPE(QPieSlice *)
118 Q_DECLARE_METATYPE(QPieSlice *)
119 Q_DECLARE_METATYPE(QScatterSeries *)
119 Q_DECLARE_METATYPE(QScatterSeries *)
120 Q_DECLARE_METATYPE(QSplineSeries *)
120 Q_DECLARE_METATYPE(QSplineSeries *)
121 Q_DECLARE_METATYPE(QStackedBarSeries *)
121 Q_DECLARE_METATYPE(QStackedBarSeries *)
122
122
123 #endif
123 #endif
124
124
125 QTCOMMERCIALCHART_BEGIN_NAMESPACE
125 QTCOMMERCIALCHART_BEGIN_NAMESPACE
126
126
127 class ChartQmlPlugin : public QDECLARATIVE_EXTENSION_PLUGIN
127 class ChartQmlPlugin : public QDECLARATIVE_EXTENSION_PLUGIN
128 {
128 {
129 Q_OBJECT
129 Q_OBJECT
130
130
131 #ifdef CHARTS_FOR_QUICK2
131 #ifdef CHARTS_FOR_QUICK2
132 Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface")
132 Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface")
133 #else
133 #else
134 # if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
134 # if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
135 Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QDeclarativeExtensionInterface")
135 Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QDeclarativeExtensionInterface")
136 # endif
136 # endif
137 #endif
137 #endif
138
138
139 public:
139 public:
140 virtual void registerTypes(const char *uri)
140 virtual void registerTypes(const char *uri)
141 {
141 {
142 Q_ASSERT(QLatin1String(uri) == QLatin1String("QtCommercial.Chart"));
142 Q_ASSERT(QLatin1String(uri) == QLatin1String("QtCommercial.Chart"));
143
143
144 qRegisterMetaType<QList<QPieSlice *> >();
144 qRegisterMetaType<QList<QPieSlice *> >();
145 qRegisterMetaType<QList<QBarSet *> >();
145 qRegisterMetaType<QList<QBarSet *> >();
146 qRegisterMetaType<QList<QAbstractAxis *> >();
146 qRegisterMetaType<QList<QAbstractAxis *> >();
147
147
148 // QtCommercial.Chart 1.0
148 // QtCommercial.Chart 1.0
149 qmlRegisterType<DeclarativeChart>(uri, 1, 0, "ChartView");
149 qmlRegisterType<DeclarativeChart>(uri, 1, 0, "ChartView");
150 qmlRegisterType<DeclarativeXYPoint>(uri, 1, 0, "XYPoint");
150 qmlRegisterType<DeclarativeXYPoint>(uri, 1, 0, "XYPoint");
151 qmlRegisterType<DeclarativeScatterSeries>(uri, 1, 0, "ScatterSeries");
151 qmlRegisterType<DeclarativeScatterSeries>(uri, 1, 0, "ScatterSeries");
152 qmlRegisterType<DeclarativeLineSeries>(uri, 1, 0, "LineSeries");
152 qmlRegisterType<DeclarativeLineSeries>(uri, 1, 0, "LineSeries");
153 qmlRegisterType<DeclarativeSplineSeries>(uri, 1, 0, "SplineSeries");
153 qmlRegisterType<DeclarativeSplineSeries>(uri, 1, 0, "SplineSeries");
154 qmlRegisterType<DeclarativeAreaSeries>(uri, 1, 0, "AreaSeries");
154 qmlRegisterType<DeclarativeAreaSeries>(uri, 1, 0, "AreaSeries");
155 qmlRegisterType<DeclarativeBarSeries>(uri, 1, 0, "BarSeries");
155 qmlRegisterType<DeclarativeBarSeries>(uri, 1, 0, "BarSeries");
156 qmlRegisterType<DeclarativeStackedBarSeries>(uri, 1, 0, "StackedBarSeries");
156 qmlRegisterType<DeclarativeStackedBarSeries>(uri, 1, 0, "StackedBarSeries");
157 qmlRegisterType<DeclarativePercentBarSeries>(uri, 1, 0, "PercentBarSeries");
157 qmlRegisterType<DeclarativePercentBarSeries>(uri, 1, 0, "PercentBarSeries");
158 qmlRegisterType<DeclarativePieSeries>(uri, 1, 0, "PieSeries");
158 qmlRegisterType<DeclarativePieSeries>(uri, 1, 0, "PieSeries");
159 qmlRegisterType<QPieSlice>(uri, 1, 0, "PieSlice");
159 qmlRegisterType<QPieSlice>(uri, 1, 0, "PieSlice");
160 qmlRegisterType<DeclarativeBarSet>(uri, 1, 0, "BarSet");
160 qmlRegisterType<DeclarativeBarSet>(uri, 1, 0, "BarSet");
161 qmlRegisterType<QHXYModelMapper>(uri, 1, 0, "HXYModelMapper");
161 qmlRegisterType<QHXYModelMapper>(uri, 1, 0, "HXYModelMapper");
162 qmlRegisterType<QVXYModelMapper>(uri, 1, 0, "VXYModelMapper");
162 qmlRegisterType<QVXYModelMapper>(uri, 1, 0, "VXYModelMapper");
163 qmlRegisterType<QHPieModelMapper>(uri, 1, 0, "HPieModelMapper");
163 qmlRegisterType<QHPieModelMapper>(uri, 1, 0, "HPieModelMapper");
164 qmlRegisterType<QVPieModelMapper>(uri, 1, 0, "VPieModelMapper");
164 qmlRegisterType<QVPieModelMapper>(uri, 1, 0, "VPieModelMapper");
165 qmlRegisterType<QHBarModelMapper>(uri, 1, 0, "HBarModelMapper");
165 qmlRegisterType<QHBarModelMapper>(uri, 1, 0, "HBarModelMapper");
166 qmlRegisterType<QVBarModelMapper>(uri, 1, 0, "VBarModelMapper");
166 qmlRegisterType<QVBarModelMapper>(uri, 1, 0, "VBarModelMapper");
167 qmlRegisterType<QValueAxis>(uri, 1, 0, "ValuesAxis");
167 qmlRegisterType<QValueAxis>(uri, 1, 0, "ValuesAxis");
168 qmlRegisterType<QBarCategoryAxis>(uri, 1, 0, "BarCategoriesAxis");
168 qmlRegisterType<QBarCategoryAxis>(uri, 1, 0, "BarCategoriesAxis");
169 qmlRegisterUncreatableType<QLegend>(uri, 1, 0, "Legend",
169 qmlRegisterUncreatableType<QLegend>(uri, 1, 0, "Legend",
170 QLatin1String("Trying to create uncreatable: Legend."));
170 QLatin1String("Trying to create uncreatable: Legend."));
171 qmlRegisterUncreatableType<QXYSeries>(uri, 1, 0, "XYSeries",
171 qmlRegisterUncreatableType<QXYSeries>(uri, 1, 0, "XYSeries",
172 QLatin1String("Trying to create uncreatable: XYSeries."));
172 QLatin1String("Trying to create uncreatable: XYSeries."));
173 qmlRegisterUncreatableType<QAbstractItemModel>(uri, 1, 0, "AbstractItemModel",
173 qmlRegisterUncreatableType<QAbstractItemModel>(uri, 1, 0, "AbstractItemModel",
174 QLatin1String("Trying to create uncreatable: AbstractItemModel."));
174 QLatin1String("Trying to create uncreatable: AbstractItemModel."));
175 qmlRegisterUncreatableType<QXYModelMapper>(uri, 1, 0, "XYModelMapper",
175 qmlRegisterUncreatableType<QXYModelMapper>(uri, 1, 0, "XYModelMapper",
176 QLatin1String("Trying to create uncreatable: XYModelMapper."));
176 QLatin1String("Trying to create uncreatable: XYModelMapper."));
177 qmlRegisterUncreatableType<QPieModelMapper>(uri, 1, 0, "PieModelMapper",
177 qmlRegisterUncreatableType<QPieModelMapper>(uri, 1, 0, "PieModelMapper",
178 QLatin1String("Trying to create uncreatable: PieModelMapper."));
178 QLatin1String("Trying to create uncreatable: PieModelMapper."));
179 qmlRegisterUncreatableType<QBarModelMapper>(uri, 1, 0, "BarModelMapper",
179 qmlRegisterUncreatableType<QBarModelMapper>(uri, 1, 0, "BarModelMapper",
180 QLatin1String("Trying to create uncreatable: BarModelMapper."));
180 QLatin1String("Trying to create uncreatable: BarModelMapper."));
181 qmlRegisterUncreatableType<QAbstractSeries>(uri, 1, 0, "AbstractSeries",
181 qmlRegisterUncreatableType<QAbstractSeries>(uri, 1, 0, "AbstractSeries",
182 QLatin1String("Trying to create uncreatable: AbstractSeries."));
182 QLatin1String("Trying to create uncreatable: AbstractSeries."));
183 qmlRegisterUncreatableType<QAbstractBarSeries>(uri, 1, 0, "AbstractBarSeries",
183 qmlRegisterUncreatableType<QAbstractBarSeries>(uri, 1, 0, "AbstractBarSeries",
184 QLatin1String("Trying to create uncreatable: AbstractBarSeries."));
184 QLatin1String("Trying to create uncreatable: AbstractBarSeries."));
185 qmlRegisterUncreatableType<QAbstractAxis>(uri, 1, 0, "AbstractAxis",
185 qmlRegisterUncreatableType<QAbstractAxis>(uri, 1, 0, "AbstractAxis",
186 QLatin1String("Trying to create uncreatable: AbstractAxis. Use specific types of axis instead."));
186 QLatin1String("Trying to create uncreatable: AbstractAxis. Use specific types of axis instead."));
187 qmlRegisterUncreatableType<QBarSet>(uri, 1, 0, "BarSetBase",
187 qmlRegisterUncreatableType<QBarSet>(uri, 1, 0, "BarSetBase",
188 QLatin1String("Trying to create uncreatable: BarsetBase."));
188 QLatin1String("Trying to create uncreatable: BarsetBase."));
189 qmlRegisterUncreatableType<QPieSeries>(uri, 1, 0, "QPieSeries",
189 qmlRegisterUncreatableType<QPieSeries>(uri, 1, 0, "QPieSeries",
190 QLatin1String("Trying to create uncreatable: QPieSeries. Use PieSeries instead."));
190 QLatin1String("Trying to create uncreatable: QPieSeries. Use PieSeries instead."));
191 qmlRegisterUncreatableType<DeclarativeAxes>(uri, 1, 0, "DeclarativeAxes",
191 qmlRegisterUncreatableType<DeclarativeAxes>(uri, 1, 0, "DeclarativeAxes",
192 QLatin1String("Trying to create uncreatable: DeclarativeAxes."));
192 QLatin1String("Trying to create uncreatable: DeclarativeAxes."));
193
193
194 // QtCommercial.Chart 1.1
194 // QtCommercial.Chart 1.1
195 qmlRegisterType<DeclarativeChart, 1>(uri, 1, 1, "ChartView");
195 qmlRegisterType<DeclarativeChart, 1>(uri, 1, 1, "ChartView");
196 qmlRegisterType<DeclarativeScatterSeries, 1>(uri, 1, 1, "ScatterSeries");
196 qmlRegisterType<DeclarativeScatterSeries, 1>(uri, 1, 1, "ScatterSeries");
197 qmlRegisterType<DeclarativeLineSeries, 1>(uri, 1, 1, "LineSeries");
197 qmlRegisterType<DeclarativeLineSeries, 1>(uri, 1, 1, "LineSeries");
198 qmlRegisterType<DeclarativeSplineSeries, 1>(uri, 1, 1, "SplineSeries");
198 qmlRegisterType<DeclarativeSplineSeries, 1>(uri, 1, 1, "SplineSeries");
199 qmlRegisterType<DeclarativeAreaSeries, 1>(uri, 1, 1, "AreaSeries");
199 qmlRegisterType<DeclarativeAreaSeries, 1>(uri, 1, 1, "AreaSeries");
200 qmlRegisterType<DeclarativeBarSeries, 1>(uri, 1, 1, "BarSeries");
200 qmlRegisterType<DeclarativeBarSeries, 1>(uri, 1, 1, "BarSeries");
201 qmlRegisterType<DeclarativeStackedBarSeries, 1>(uri, 1, 1, "StackedBarSeries");
201 qmlRegisterType<DeclarativeStackedBarSeries, 1>(uri, 1, 1, "StackedBarSeries");
202 qmlRegisterType<DeclarativePercentBarSeries, 1>(uri, 1, 1, "PercentBarSeries");
202 qmlRegisterType<DeclarativePercentBarSeries, 1>(uri, 1, 1, "PercentBarSeries");
203 qmlRegisterType<DeclarativeHorizontalBarSeries, 1>(uri, 1, 1, "HorizontalBarSeries");
203 qmlRegisterType<DeclarativeHorizontalBarSeries, 1>(uri, 1, 1, "HorizontalBarSeries");
204 qmlRegisterType<DeclarativeHorizontalStackedBarSeries, 1>(uri, 1, 1, "HorizontalStackedBarSeries");
204 qmlRegisterType<DeclarativeHorizontalStackedBarSeries, 1>(uri, 1, 1, "HorizontalStackedBarSeries");
205 qmlRegisterType<DeclarativeHorizontalPercentBarSeries, 1>(uri, 1, 1, "HorizontalPercentBarSeries");
205 qmlRegisterType<DeclarativeHorizontalPercentBarSeries, 1>(uri, 1, 1, "HorizontalPercentBarSeries");
206 qmlRegisterType<DeclarativePieSeries>(uri, 1, 1, "PieSeries");
206 qmlRegisterType<DeclarativePieSeries>(uri, 1, 1, "PieSeries");
207 qmlRegisterType<DeclarativeBarSet>(uri, 1, 1, "BarSet");
207 qmlRegisterType<DeclarativeBarSet>(uri, 1, 1, "BarSet");
208 qmlRegisterType<QValueAxis>(uri, 1, 1, "ValueAxis");
208 qmlRegisterType<QValueAxis>(uri, 1, 1, "ValueAxis");
209 #ifndef QT_ON_ARM
209 #ifndef QT_ON_ARM
210 qmlRegisterType<QDateTimeAxis>(uri, 1, 1, "DateTimeAxis");
210 qmlRegisterType<QDateTimeAxis>(uri, 1, 1, "DateTimeAxis");
211 #endif
211 #endif
212 qmlRegisterType<DeclarativeCategoryAxis>(uri, 1, 1, "CategoryAxis");
212 qmlRegisterType<DeclarativeCategoryAxis>(uri, 1, 1, "CategoryAxis");
213 qmlRegisterType<DeclarativeCategoryRange>(uri, 1, 1, "CategoryRange");
213 qmlRegisterType<DeclarativeCategoryRange>(uri, 1, 1, "CategoryRange");
214 qmlRegisterType<QBarCategoryAxis>(uri, 1, 1, "BarCategoryAxis");
214 qmlRegisterType<QBarCategoryAxis>(uri, 1, 1, "BarCategoryAxis");
215 qmlRegisterUncreatableType<DeclarativeMargins>(uri, 1, 1, "Margins",
215 qmlRegisterUncreatableType<DeclarativeMargins>(uri, 1, 1, "Margins",
216 QLatin1String("Trying to create uncreatable: Margins."));
216 QLatin1String("Trying to create uncreatable: Margins."));
217
217
218 // QtCommercial.Chart 1.2
218 // QtCommercial.Chart 1.2
219 qmlRegisterType<DeclarativeChart, 2>(uri, 1, 2, "ChartView");
219 qmlRegisterType<DeclarativeChart, 2>(uri, 1, 2, "ChartView");
220 qmlRegisterType<DeclarativeScatterSeries, 2>(uri, 1, 2, "ScatterSeries");
220 qmlRegisterType<DeclarativeScatterSeries, 2>(uri, 1, 2, "ScatterSeries");
221 qmlRegisterType<DeclarativeLineSeries, 2>(uri, 1, 2, "LineSeries");
221 qmlRegisterType<DeclarativeLineSeries, 2>(uri, 1, 2, "LineSeries");
222 qmlRegisterType<DeclarativeSplineSeries, 2>(uri, 1, 2, "SplineSeries");
222 qmlRegisterType<DeclarativeSplineSeries, 2>(uri, 1, 2, "SplineSeries");
223 qmlRegisterType<DeclarativeAreaSeries, 2>(uri, 1, 2, "AreaSeries");
223 qmlRegisterType<DeclarativeAreaSeries, 2>(uri, 1, 2, "AreaSeries");
224 qmlRegisterType<DeclarativeBarSeries, 2>(uri, 1, 2, "BarSeries");
224 qmlRegisterType<DeclarativeBarSeries, 2>(uri, 1, 2, "BarSeries");
225 qmlRegisterType<DeclarativeStackedBarSeries, 2>(uri, 1, 2, "StackedBarSeries");
225 qmlRegisterType<DeclarativeStackedBarSeries, 2>(uri, 1, 2, "StackedBarSeries");
226 qmlRegisterType<DeclarativePercentBarSeries, 2>(uri, 1, 2, "PercentBarSeries");
226 qmlRegisterType<DeclarativePercentBarSeries, 2>(uri, 1, 2, "PercentBarSeries");
227 qmlRegisterType<DeclarativeHorizontalBarSeries, 2>(uri, 1, 2, "HorizontalBarSeries");
227 qmlRegisterType<DeclarativeHorizontalBarSeries, 2>(uri, 1, 2, "HorizontalBarSeries");
228 qmlRegisterType<DeclarativeHorizontalStackedBarSeries, 2>(uri, 1, 2, "HorizontalStackedBarSeries");
228 qmlRegisterType<DeclarativeHorizontalStackedBarSeries, 2>(uri, 1, 2, "HorizontalStackedBarSeries");
229 qmlRegisterType<DeclarativeHorizontalPercentBarSeries, 2>(uri, 1, 2, "HorizontalPercentBarSeries");
229 qmlRegisterType<DeclarativeHorizontalPercentBarSeries, 2>(uri, 1, 2, "HorizontalPercentBarSeries");
230
230
231 // QtCommercial.Chart 1.3
231 // QtCommercial.Chart 1.3
232 qmlRegisterType<DeclarativeChart, 3>(uri, 1, 3, "ChartView");
232 qmlRegisterType<DeclarativePolarChart, 1>(uri, 1, 3, "PolarChartView");
233 qmlRegisterType<DeclarativePolarChart, 1>(uri, 1, 3, "PolarChartView");
233 qmlRegisterType<DeclarativeSplineSeries, 3>(uri, 1, 3, "SplineSeries");
234 qmlRegisterType<DeclarativeSplineSeries, 3>(uri, 1, 3, "SplineSeries");
234 qmlRegisterType<DeclarativeScatterSeries, 3>(uri, 1, 3, "ScatterSeries");
235 qmlRegisterType<DeclarativeScatterSeries, 3>(uri, 1, 3, "ScatterSeries");
235 qmlRegisterType<DeclarativeLineSeries, 3>(uri, 1, 3, "LineSeries");
236 qmlRegisterType<DeclarativeLineSeries, 3>(uri, 1, 3, "LineSeries");
236 qmlRegisterType<DeclarativeAreaSeries, 3>(uri, 1, 3, "AreaSeries");
237 qmlRegisterType<DeclarativeAreaSeries, 3>(uri, 1, 3, "AreaSeries");
237 qmlRegisterType<QLogValueAxis>(uri, 1, 3, "LogValueAxis");
238 qmlRegisterType<QLogValueAxis>(uri, 1, 3, "LogValueAxis");
238 }
239 }
239 };
240 };
240
241
241 #include "plugin.moc"
242 #include "plugin.moc"
242
243
243 QTCOMMERCIALCHART_END_NAMESPACE
244 QTCOMMERCIALCHART_END_NAMESPACE
244
245
245 QTCOMMERCIALCHART_USE_NAMESPACE
246 QTCOMMERCIALCHART_USE_NAMESPACE
246
247
247 #if (QT_VERSION < QT_VERSION_CHECK(5, 0, 0))
248 #if (QT_VERSION < QT_VERSION_CHECK(5, 0, 0))
248 Q_EXPORT_PLUGIN2(qtcommercialchartqml, QT_PREPEND_NAMESPACE(ChartQmlPlugin))
249 Q_EXPORT_PLUGIN2(qtcommercialchartqml, QT_PREPEND_NAMESPACE(ChartQmlPlugin))
249 #endif
250 #endif
@@ -1,319 +1,382
1 /****************************************************************************
1 /****************************************************************************
2 **
2 **
3 ** Copyright (C) 2013 Digia Plc
3 ** Copyright (C) 2013 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 #include "chartpresenter_p.h"
20 #include "chartpresenter_p.h"
21 #include "qchart.h"
21 #include "qchart.h"
22 #include "chartitem_p.h"
22 #include "chartitem_p.h"
23 #include "qchart_p.h"
23 #include "qchart_p.h"
24 #include "qabstractaxis.h"
24 #include "qabstractaxis.h"
25 #include "qabstractaxis_p.h"
25 #include "qabstractaxis_p.h"
26 #include "chartdataset_p.h"
26 #include "chartdataset_p.h"
27 #include "chartanimation_p.h"
27 #include "chartanimation_p.h"
28 #include "qabstractseries_p.h"
28 #include "qabstractseries_p.h"
29 #include "qareaseries.h"
29 #include "qareaseries.h"
30 #include "chartaxiselement_p.h"
30 #include "chartaxiselement_p.h"
31 #include "chartbackground_p.h"
31 #include "chartbackground_p.h"
32 #include "cartesianchartlayout_p.h"
32 #include "cartesianchartlayout_p.h"
33 #include "polarchartlayout_p.h"
33 #include "polarchartlayout_p.h"
34 #include "charttitle_p.h"
34 #include "charttitle_p.h"
35 #include <QTimer>
35 #include <QTimer>
36
36
37 QTCOMMERCIALCHART_BEGIN_NAMESPACE
37 QTCOMMERCIALCHART_BEGIN_NAMESPACE
38
38
39 ChartPresenter::ChartPresenter(QChart *chart, QChart::ChartType type)
39 ChartPresenter::ChartPresenter(QChart *chart, QChart::ChartType type)
40 : QObject(chart),
40 : QObject(chart),
41 m_chart(chart),
41 m_chart(chart),
42 m_options(QChart::NoAnimation),
42 m_options(QChart::NoAnimation),
43 m_state(ShowState),
43 m_state(ShowState),
44 m_background(0),
44 m_background(0),
45 m_plotAreaBackground(0),
45 m_title(0)
46 m_title(0)
46 {
47 {
47 if (type == QChart::ChartTypeCartesian)
48 if (type == QChart::ChartTypeCartesian)
48 m_layout = new CartesianChartLayout(this);
49 m_layout = new CartesianChartLayout(this);
49 else if (type == QChart::ChartTypePolar)
50 else if (type == QChart::ChartTypePolar)
50 m_layout = new PolarChartLayout(this);
51 m_layout = new PolarChartLayout(this);
51 Q_ASSERT(m_layout);
52 Q_ASSERT(m_layout);
52 }
53 }
53
54
54 ChartPresenter::~ChartPresenter()
55 ChartPresenter::~ChartPresenter()
55 {
56 {
56
57
57 }
58 }
58
59
59 void ChartPresenter::setGeometry(const QRectF rect)
60 void ChartPresenter::setGeometry(const QRectF rect)
60 {
61 {
61 if (m_rect != rect) {
62 if (m_rect != rect) {
62 m_rect = rect;
63 m_rect = rect;
63 foreach (ChartItem *chart, m_chartItems) {
64 foreach (ChartItem *chart, m_chartItems) {
64 chart->domain()->setSize(rect.size());
65 chart->domain()->setSize(rect.size());
65 chart->setPos(rect.topLeft());
66 chart->setPos(rect.topLeft());
66 }
67 }
67 }
68 }
68 }
69 }
69
70
70 QRectF ChartPresenter::geometry() const
71 QRectF ChartPresenter::geometry() const
71 {
72 {
72 return m_rect;
73 return m_rect;
73 }
74 }
74
75
75 void ChartPresenter::handleAxisAdded(QAbstractAxis *axis)
76 void ChartPresenter::handleAxisAdded(QAbstractAxis *axis)
76 {
77 {
77 axis->d_ptr->initializeGraphics(rootItem());
78 axis->d_ptr->initializeGraphics(rootItem());
78 axis->d_ptr->initializeAnimations(m_options);
79 axis->d_ptr->initializeAnimations(m_options);
79 ChartAxisElement *item = axis->d_ptr->axisItem();
80 ChartAxisElement *item = axis->d_ptr->axisItem();
80 item->setPresenter(this);
81 item->setPresenter(this);
81 item->setThemeManager(m_chart->d_ptr->m_themeManager);
82 item->setThemeManager(m_chart->d_ptr->m_themeManager);
82 m_axisItems<<item;
83 m_axisItems<<item;
83 m_axes<<axis;
84 m_axes<<axis;
84 m_layout->invalidate();
85 m_layout->invalidate();
85 }
86 }
86
87
87 void ChartPresenter::handleAxisRemoved(QAbstractAxis *axis)
88 void ChartPresenter::handleAxisRemoved(QAbstractAxis *axis)
88 {
89 {
89 ChartAxisElement *item = axis->d_ptr->m_item.take();
90 ChartAxisElement *item = axis->d_ptr->m_item.take();
90 item->hide();
91 item->hide();
91 item->disconnect();
92 item->disconnect();
92 item->deleteLater();
93 item->deleteLater();
93 m_axisItems.removeAll(item);
94 m_axisItems.removeAll(item);
94 m_axes.removeAll(axis);
95 m_axes.removeAll(axis);
95 m_layout->invalidate();
96 m_layout->invalidate();
96 }
97 }
97
98
98
99
99 void ChartPresenter::handleSeriesAdded(QAbstractSeries *series)
100 void ChartPresenter::handleSeriesAdded(QAbstractSeries *series)
100 {
101 {
101 series->d_ptr->initializeGraphics(rootItem());
102 series->d_ptr->initializeGraphics(rootItem());
102 series->d_ptr->initializeAnimations(m_options);
103 series->d_ptr->initializeAnimations(m_options);
103 ChartItem *chart = series->d_ptr->chartItem();
104 ChartItem *chart = series->d_ptr->chartItem();
104 chart->setPresenter(this);
105 chart->setPresenter(this);
105 chart->setThemeManager(m_chart->d_ptr->m_themeManager);
106 chart->setThemeManager(m_chart->d_ptr->m_themeManager);
106 chart->domain()->setSize(m_rect.size());
107 chart->domain()->setSize(m_rect.size());
107 chart->setPos(m_rect.topLeft());
108 chart->setPos(m_rect.topLeft());
108 chart->handleDomainUpdated(); //this could be moved to intializeGraphics when animator is refactored
109 chart->handleDomainUpdated(); //this could be moved to intializeGraphics when animator is refactored
109 m_chartItems<<chart;
110 m_chartItems<<chart;
110 m_series<<series;
111 m_series<<series;
111 m_layout->invalidate();
112 m_layout->invalidate();
112 }
113 }
113
114
114 void ChartPresenter::handleSeriesRemoved(QAbstractSeries *series)
115 void ChartPresenter::handleSeriesRemoved(QAbstractSeries *series)
115 {
116 {
116 ChartItem *chart = series->d_ptr->m_item.take();
117 ChartItem *chart = series->d_ptr->m_item.take();
117 chart->hide();
118 chart->hide();
118 chart->disconnect();
119 chart->disconnect();
119 chart->deleteLater();
120 chart->deleteLater();
120 m_chartItems.removeAll(chart);
121 m_chartItems.removeAll(chart);
121 m_series.removeAll(series);
122 m_series.removeAll(series);
122 m_layout->invalidate();
123 m_layout->invalidate();
123 }
124 }
124
125
125 void ChartPresenter::setAnimationOptions(QChart::AnimationOptions options)
126 void ChartPresenter::setAnimationOptions(QChart::AnimationOptions options)
126 {
127 {
127 if (m_options != options) {
128 if (m_options != options) {
128 m_options = options;
129 m_options = options;
129
130
130 foreach(QAbstractSeries* series, m_series){
131 foreach(QAbstractSeries* series, m_series){
131 series->d_ptr->initializeAnimations(m_options);
132 series->d_ptr->initializeAnimations(m_options);
132 }
133 }
133 foreach(QAbstractAxis* axis, m_axes){
134 foreach(QAbstractAxis* axis, m_axes){
134 axis->d_ptr->initializeAnimations(m_options);
135 axis->d_ptr->initializeAnimations(m_options);
135 }
136 }
136 }
137 }
137 }
138 }
138
139
139 void ChartPresenter::setState(State state,QPointF point)
140 void ChartPresenter::setState(State state,QPointF point)
140 {
141 {
141 m_state=state;
142 m_state=state;
142 m_statePoint=point;
143 m_statePoint=point;
143 }
144 }
144
145
145 QChart::AnimationOptions ChartPresenter::animationOptions() const
146 QChart::AnimationOptions ChartPresenter::animationOptions() const
146 {
147 {
147 return m_options;
148 return m_options;
148 }
149 }
149
150
150 void ChartPresenter::createBackgroundItem()
151 void ChartPresenter::createBackgroundItem()
151 {
152 {
152 if (!m_background) {
153 if (!m_background) {
153 m_background = new ChartBackground(rootItem());
154 m_background = new ChartBackground(rootItem());
154 m_background->setPen(Qt::NoPen);
155 m_background->setPen(Qt::NoPen);
155 m_background->setZValue(ChartPresenter::BackgroundZValue);
156 m_background->setZValue(ChartPresenter::BackgroundZValue);
156 }
157 }
157 }
158 }
158
159
160 void ChartPresenter::createPlotAreaBackgroundItem()
161 {
162 if (!m_plotAreaBackground) {
163 if (m_chart->chartType() == QChart::ChartTypeCartesian)
164 m_plotAreaBackground = new QGraphicsRectItem(rootItem());
165 else
166 m_plotAreaBackground = new QGraphicsEllipseItem(rootItem());
167 // Use transparent pen instead of Qt::NoPen, as Qt::NoPen causes
168 // antialising artifacts with axis lines for some reason.
169 m_plotAreaBackground->setPen(QPen(Qt::transparent));
170 m_plotAreaBackground->setBrush(Qt::NoBrush);
171 m_plotAreaBackground->setZValue(ChartPresenter::PlotAreaZValue);
172 m_plotAreaBackground->setVisible(false);
173 }
174 }
175
159 void ChartPresenter::createTitleItem()
176 void ChartPresenter::createTitleItem()
160 {
177 {
161 if (!m_title) {
178 if (!m_title) {
162 m_title = new ChartTitle(rootItem());
179 m_title = new ChartTitle(rootItem());
163 m_title->setZValue(ChartPresenter::BackgroundZValue);
180 m_title->setZValue(ChartPresenter::BackgroundZValue);
164 }
181 }
165 }
182 }
166
183
167
184
168 void ChartPresenter::handleAnimationFinished()
185 void ChartPresenter::handleAnimationFinished()
169 {
186 {
170 m_animations.removeAll(qobject_cast<ChartAnimation *>(sender()));
187 m_animations.removeAll(qobject_cast<ChartAnimation *>(sender()));
171 if (m_animations.empty())
188 if (m_animations.empty())
172 emit animationsFinished();
189 emit animationsFinished();
173 }
190 }
174
191
175 void ChartPresenter::startAnimation(ChartAnimation *animation)
192 void ChartPresenter::startAnimation(ChartAnimation *animation)
176 {
193 {
177 if (animation->state() != QAbstractAnimation::Stopped) animation->stop();
194 if (animation->state() != QAbstractAnimation::Stopped) animation->stop();
178 QObject::connect(animation, SIGNAL(finished()), this, SLOT(handleAnimationFinished()), Qt::UniqueConnection);
195 QObject::connect(animation, SIGNAL(finished()), this, SLOT(handleAnimationFinished()), Qt::UniqueConnection);
179 if (!m_animations.isEmpty())
196 if (!m_animations.isEmpty())
180 m_animations.append(animation);
197 m_animations.append(animation);
181 QTimer::singleShot(0, animation, SLOT(start()));
198 QTimer::singleShot(0, animation, SLOT(start()));
182 }
199 }
183
200
184 void ChartPresenter::setBackgroundBrush(const QBrush &brush)
201 void ChartPresenter::setBackgroundBrush(const QBrush &brush)
185 {
202 {
186 createBackgroundItem();
203 createBackgroundItem();
187 m_background->setBrush(brush);
204 m_background->setBrush(brush);
188 m_layout->invalidate();
205 m_layout->invalidate();
189 }
206 }
190
207
191 QBrush ChartPresenter::backgroundBrush() const
208 QBrush ChartPresenter::backgroundBrush() const
192 {
209 {
193 if (!m_background)
210 if (!m_background)
194 return QBrush();
211 return QBrush();
195 return m_background->brush();
212 return m_background->brush();
196 }
213 }
197
214
198 void ChartPresenter::setBackgroundPen(const QPen &pen)
215 void ChartPresenter::setBackgroundPen(const QPen &pen)
199 {
216 {
200 createBackgroundItem();
217 createBackgroundItem();
201 m_background->setPen(pen);
218 m_background->setPen(pen);
202 m_layout->invalidate();
219 m_layout->invalidate();
203 }
220 }
204
221
205 QPen ChartPresenter::backgroundPen() const
222 QPen ChartPresenter::backgroundPen() const
206 {
223 {
207 if (!m_background)
224 if (!m_background)
208 return QPen();
225 return QPen();
209 return m_background->pen();
226 return m_background->pen();
210 }
227 }
211
228
229 void ChartPresenter::setPlotAreaBackgroundBrush(const QBrush &brush)
230 {
231 createPlotAreaBackgroundItem();
232 m_plotAreaBackground->setBrush(brush);
233 m_layout->invalidate();
234 }
235
236 QBrush ChartPresenter::plotAreaBackgroundBrush() const
237 {
238 if (!m_plotAreaBackground)
239 return QBrush();
240 return m_plotAreaBackground->brush();
241 }
242
243 void ChartPresenter::setPlotAreaBackgroundPen(const QPen &pen)
244 {
245 createPlotAreaBackgroundItem();
246 m_plotAreaBackground->setPen(pen);
247 m_layout->invalidate();
248 }
249
250 QPen ChartPresenter::plotAreaBackgroundPen() const
251 {
252 if (!m_plotAreaBackground)
253 return QPen();
254 return m_plotAreaBackground->pen();
255 }
256
212 void ChartPresenter::setTitle(const QString &title)
257 void ChartPresenter::setTitle(const QString &title)
213 {
258 {
214 createTitleItem();
259 createTitleItem();
215 m_title->setText(title);
260 m_title->setText(title);
216 m_layout->invalidate();
261 m_layout->invalidate();
217 }
262 }
218
263
219 QString ChartPresenter::title() const
264 QString ChartPresenter::title() const
220 {
265 {
221 if (!m_title)
266 if (!m_title)
222 return QString();
267 return QString();
223 return m_title->text();
268 return m_title->text();
224 }
269 }
225
270
226 void ChartPresenter::setTitleFont(const QFont &font)
271 void ChartPresenter::setTitleFont(const QFont &font)
227 {
272 {
228 createTitleItem();
273 createTitleItem();
229 m_title->setFont(font);
274 m_title->setFont(font);
230 m_layout->invalidate();
275 m_layout->invalidate();
231 }
276 }
232
277
233 QFont ChartPresenter::titleFont() const
278 QFont ChartPresenter::titleFont() const
234 {
279 {
235 if (!m_title)
280 if (!m_title)
236 return QFont();
281 return QFont();
237 return m_title->font();
282 return m_title->font();
238 }
283 }
239
284
240 void ChartPresenter::setTitleBrush(const QBrush &brush)
285 void ChartPresenter::setTitleBrush(const QBrush &brush)
241 {
286 {
242 createTitleItem();
287 createTitleItem();
243 m_title->setBrush(brush);
288 m_title->setBrush(brush);
244 m_layout->invalidate();
289 m_layout->invalidate();
245 }
290 }
246
291
247 QBrush ChartPresenter::titleBrush() const
292 QBrush ChartPresenter::titleBrush() const
248 {
293 {
249 if (!m_title)
294 if (!m_title)
250 return QBrush();
295 return QBrush();
251 return m_title->brush();
296 return m_title->brush();
252 }
297 }
253
298
254 void ChartPresenter::setBackgroundVisible(bool visible)
299 void ChartPresenter::setBackgroundVisible(bool visible)
255 {
300 {
256 createBackgroundItem();
301 createBackgroundItem();
257 m_background->setVisible(visible);
302 m_background->setVisible(visible);
258 }
303 }
259
304
260
305
261 bool ChartPresenter::isBackgroundVisible() const
306 bool ChartPresenter::isBackgroundVisible() const
262 {
307 {
263 if (!m_background)
308 if (!m_background)
264 return false;
309 return false;
265 return m_background->isVisible();
310 return m_background->isVisible();
266 }
311 }
267
312
313 void ChartPresenter::setPlotAreaBackgroundVisible(bool visible)
314 {
315 createPlotAreaBackgroundItem();
316 m_plotAreaBackground->setVisible(visible);
317 }
318
319 bool ChartPresenter::isPlotAreaBackgroundVisible() const
320 {
321 if (!m_plotAreaBackground)
322 return false;
323 return m_plotAreaBackground->isVisible();
324 }
325
268 void ChartPresenter::setBackgroundDropShadowEnabled(bool enabled)
326 void ChartPresenter::setBackgroundDropShadowEnabled(bool enabled)
269 {
327 {
270 createBackgroundItem();
328 createBackgroundItem();
271 m_background->setDropShadowEnabled(enabled);
329 m_background->setDropShadowEnabled(enabled);
272 }
330 }
273
331
274 bool ChartPresenter::isBackgroundDropShadowEnabled() const
332 bool ChartPresenter::isBackgroundDropShadowEnabled() const
275 {
333 {
276 if (!m_background)
334 if (!m_background)
277 return false;
335 return false;
278 return m_background->isDropShadowEnabled();
336 return m_background->isDropShadowEnabled();
279 }
337 }
280
338
281
339
282 AbstractChartLayout *ChartPresenter::layout()
340 AbstractChartLayout *ChartPresenter::layout()
283 {
341 {
284 return m_layout;
342 return m_layout;
285 }
343 }
286
344
287 QLegend *ChartPresenter::legend()
345 QLegend *ChartPresenter::legend()
288 {
346 {
289 return m_chart->legend();
347 return m_chart->legend();
290 }
348 }
291
349
292 void ChartPresenter::setVisible(bool visible)
350 void ChartPresenter::setVisible(bool visible)
293 {
351 {
294 m_chart->setVisible(visible);
352 m_chart->setVisible(visible);
295 }
353 }
296
354
297 ChartBackground *ChartPresenter::backgroundElement()
355 ChartBackground *ChartPresenter::backgroundElement()
298 {
356 {
299 return m_background;
357 return m_background;
300 }
358 }
301
359
360 QAbstractGraphicsShapeItem *ChartPresenter::plotAreaElement()
361 {
362 return m_plotAreaBackground;
363 }
364
302 QList<ChartAxisElement *> ChartPresenter::axisItems() const
365 QList<ChartAxisElement *> ChartPresenter::axisItems() const
303 {
366 {
304 return m_axisItems;
367 return m_axisItems;
305 }
368 }
306
369
307 QList<ChartItem *> ChartPresenter::chartItems() const
370 QList<ChartItem *> ChartPresenter::chartItems() const
308 {
371 {
309 return m_chartItems;
372 return m_chartItems;
310 }
373 }
311
374
312 ChartTitle *ChartPresenter::titleElement()
375 ChartTitle *ChartPresenter::titleElement()
313 {
376 {
314 return m_title;
377 return m_title;
315 }
378 }
316
379
317 #include "moc_chartpresenter_p.cpp"
380 #include "moc_chartpresenter_p.cpp"
318
381
319 QTCOMMERCIALCHART_END_NAMESPACE
382 QTCOMMERCIALCHART_END_NAMESPACE
@@ -1,166 +1,180
1 /****************************************************************************
1 /****************************************************************************
2 **
2 **
3 ** Copyright (C) 2013 Digia Plc
3 ** Copyright (C) 2013 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 // W A R N I N G
21 // W A R N I N G
22 // -------------
22 // -------------
23 //
23 //
24 // This file is not part of the QtCommercial Chart API. It exists purely as an
24 // This file is not part of the QtCommercial Chart API. It exists purely as an
25 // implementation detail. This header file may change from version to
25 // implementation detail. This header file may change from version to
26 // version without notice, or even be removed.
26 // version without notice, or even be removed.
27 //
27 //
28 // We mean it.
28 // We mean it.
29
29
30 #ifndef CHARTPRESENTER_H
30 #ifndef CHARTPRESENTER_H
31 #define CHARTPRESENTER_H
31 #define CHARTPRESENTER_H
32
32
33 #include "qchartglobal.h"
33 #include "qchartglobal.h"
34 #include "qchart.h" //because of QChart::ChartThemeId
34 #include "qchart.h" //because of QChart::ChartThemeId
35 #include <QRectF>
35 #include <QRectF>
36 #include <QMargins>
36 #include <QMargins>
37
37
38 QTCOMMERCIALCHART_BEGIN_NAMESPACE
38 QTCOMMERCIALCHART_BEGIN_NAMESPACE
39
39
40 class ChartItem;
40 class ChartItem;
41 class AxisItem;
41 class AxisItem;
42 class QAbstractSeries;
42 class QAbstractSeries;
43 class ChartDataSet;
43 class ChartDataSet;
44 class AbstractDomain;
44 class AbstractDomain;
45 class ChartAxisElement;
45 class ChartAxisElement;
46 class ChartAnimator;
46 class ChartAnimator;
47 class ChartBackground;
47 class ChartBackground;
48 class ChartTitle;
48 class ChartTitle;
49 class ChartAnimation;
49 class ChartAnimation;
50 class AbstractChartLayout;
50 class AbstractChartLayout;
51
51
52 class ChartPresenter: public QObject
52 class ChartPresenter: public QObject
53 {
53 {
54 Q_OBJECT
54 Q_OBJECT
55 public:
55 public:
56 enum ZValues {
56 enum ZValues {
57 BackgroundZValue = -1,
57 BackgroundZValue = -1,
58 ShadesZValue ,
58 PlotAreaZValue,
59 ShadesZValue,
59 GridZValue,
60 GridZValue,
60 AxisZValue,
61 AxisZValue,
61 SeriesZValue,
62 SeriesZValue,
62 LineChartZValue = SeriesZValue,
63 LineChartZValue = SeriesZValue,
63 SplineChartZValue = SeriesZValue,
64 SplineChartZValue = SeriesZValue,
64 BarSeriesZValue = SeriesZValue,
65 BarSeriesZValue = SeriesZValue,
65 ScatterSeriesZValue = SeriesZValue,
66 ScatterSeriesZValue = SeriesZValue,
66 PieSeriesZValue = SeriesZValue,
67 PieSeriesZValue = SeriesZValue,
67 LegendZValue,
68 LegendZValue,
68 TopMostZValue
69 TopMostZValue
69 };
70 };
70
71
71 enum State {
72 enum State {
72 ShowState,
73 ShowState,
73 ScrollUpState,
74 ScrollUpState,
74 ScrollDownState,
75 ScrollDownState,
75 ScrollLeftState,
76 ScrollLeftState,
76 ScrollRightState,
77 ScrollRightState,
77 ZoomInState,
78 ZoomInState,
78 ZoomOutState
79 ZoomOutState
79 };
80 };
80
81
81 ChartPresenter(QChart *chart, QChart::ChartType type);
82 ChartPresenter(QChart *chart, QChart::ChartType type);
82 virtual ~ChartPresenter();
83 virtual ~ChartPresenter();
83
84
84
85
85 void setGeometry(QRectF rect);
86 void setGeometry(QRectF rect);
86 QRectF geometry() const;
87 QRectF geometry() const;
87
88
88 QGraphicsItem *rootItem(){ return m_chart; }
89 QGraphicsItem *rootItem(){ return m_chart; }
89 ChartBackground *backgroundElement();
90 ChartBackground *backgroundElement();
91 QAbstractGraphicsShapeItem *plotAreaElement();
90 ChartTitle *titleElement();
92 ChartTitle *titleElement();
91 QList<ChartAxisElement *> axisItems() const;
93 QList<ChartAxisElement *> axisItems() const;
92 QList<ChartItem *> chartItems() const;
94 QList<ChartItem *> chartItems() const;
93
95
94 QLegend *legend();
96 QLegend *legend();
95
97
96 void setBackgroundBrush(const QBrush &brush);
98 void setBackgroundBrush(const QBrush &brush);
97 QBrush backgroundBrush() const;
99 QBrush backgroundBrush() const;
98
100
99 void setBackgroundPen(const QPen &pen);
101 void setBackgroundPen(const QPen &pen);
100 QPen backgroundPen() const;
102 QPen backgroundPen() const;
101
103
104 void setPlotAreaBackgroundBrush(const QBrush &brush);
105 QBrush plotAreaBackgroundBrush() const;
106
107 void setPlotAreaBackgroundPen(const QPen &pen);
108 QPen plotAreaBackgroundPen() const;
109
102 void setTitle(const QString &title);
110 void setTitle(const QString &title);
103 QString title() const;
111 QString title() const;
104
112
105 void setTitleFont(const QFont &font);
113 void setTitleFont(const QFont &font);
106 QFont titleFont() const;
114 QFont titleFont() const;
107
115
108 void setTitleBrush(const QBrush &brush);
116 void setTitleBrush(const QBrush &brush);
109 QBrush titleBrush() const;
117 QBrush titleBrush() const;
110
118
111 void setBackgroundVisible(bool visible);
119 void setBackgroundVisible(bool visible);
112 bool isBackgroundVisible() const;
120 bool isBackgroundVisible() const;
113
121
122 void setPlotAreaBackgroundVisible(bool visible);
123 bool isPlotAreaBackgroundVisible() const;
124
114 void setBackgroundDropShadowEnabled(bool enabled);
125 void setBackgroundDropShadowEnabled(bool enabled);
115 bool isBackgroundDropShadowEnabled() const;
126 bool isBackgroundDropShadowEnabled() const;
116
127
117 void setVisible(bool visible);
128 void setVisible(bool visible);
118
129
119 void setAnimationOptions(QChart::AnimationOptions options);
130 void setAnimationOptions(QChart::AnimationOptions options);
120 QChart::AnimationOptions animationOptions() const;
131 QChart::AnimationOptions animationOptions() const;
121
132
122 void startAnimation(ChartAnimation *animation);
133 void startAnimation(ChartAnimation *animation);
123
134
124 //TODO refactor
135 //TODO refactor
125 void setState(State state,QPointF point);
136 void setState(State state,QPointF point);
126 State state() const { return m_state; }
137 State state() const { return m_state; }
127 QPointF statePoint() const { return m_statePoint; }
138 QPointF statePoint() const { return m_statePoint; }
128 AbstractChartLayout *layout();
139 AbstractChartLayout *layout();
129
140
130 QChart::ChartType chartType() const { return m_chart->chartType(); }
141 QChart::ChartType chartType() const { return m_chart->chartType(); }
142 QChart *chart() { return m_chart; }
131
143
132 private:
144 private:
133 void createBackgroundItem();
145 void createBackgroundItem();
146 void createPlotAreaBackgroundItem();
134 void createTitleItem();
147 void createTitleItem();
135
148
136 public Q_SLOTS:
149 public Q_SLOTS:
137 void handleSeriesAdded(QAbstractSeries *series);
150 void handleSeriesAdded(QAbstractSeries *series);
138 void handleSeriesRemoved(QAbstractSeries *series);
151 void handleSeriesRemoved(QAbstractSeries *series);
139 void handleAxisAdded(QAbstractAxis *axis);
152 void handleAxisAdded(QAbstractAxis *axis);
140 void handleAxisRemoved(QAbstractAxis *axis);
153 void handleAxisRemoved(QAbstractAxis *axis);
141
154
142 private Q_SLOTS:
155 private Q_SLOTS:
143 void handleAnimationFinished();
156 void handleAnimationFinished();
144
157
145 Q_SIGNALS:
158 Q_SIGNALS:
146 void animationsFinished();
159 void animationsFinished();
147
160
148 private:
161 private:
149 QChart *m_chart;
162 QChart *m_chart;
150 QList<ChartItem *> m_chartItems;
163 QList<ChartItem *> m_chartItems;
151 QList<ChartAxisElement *> m_axisItems;
164 QList<ChartAxisElement *> m_axisItems;
152 QList<QAbstractSeries *> m_series;
165 QList<QAbstractSeries *> m_series;
153 QList<QAbstractAxis *> m_axes;
166 QList<QAbstractAxis *> m_axes;
154 QChart::AnimationOptions m_options;
167 QChart::AnimationOptions m_options;
155 State m_state;
168 State m_state;
156 QPointF m_statePoint;
169 QPointF m_statePoint;
157 QList<ChartAnimation *> m_animations;
170 QList<ChartAnimation *> m_animations;
158 AbstractChartLayout *m_layout;
171 AbstractChartLayout *m_layout;
159 ChartBackground *m_background;
172 ChartBackground *m_background;
173 QAbstractGraphicsShapeItem *m_plotAreaBackground;
160 ChartTitle *m_title;
174 ChartTitle *m_title;
161 QRectF m_rect;
175 QRectF m_rect;
162 };
176 };
163
177
164 QTCOMMERCIALCHART_END_NAMESPACE
178 QTCOMMERCIALCHART_END_NAMESPACE
165
179
166 #endif /* CHARTPRESENTER_H */
180 #endif /* CHARTPRESENTER_H */
@@ -1,259 +1,267
1 /****************************************************************************
1 /****************************************************************************
2 **
2 **
3 ** Copyright (C) 2013 Digia Plc
3 ** Copyright (C) 2013 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 #include "qabstractseries_p.h"
20 #include "qabstractseries_p.h"
21 #include "qabstractaxis_p.h"
21 #include "qabstractaxis_p.h"
22 #include <QTime>
22 #include <QTime>
23 //themes
23 //themes
24 #include "chartthemesystem_p.h"
24 #include "chartthemesystem_p.h"
25 #include "chartthemelight_p.h"
25 #include "chartthemelight_p.h"
26 #include "chartthemebluecerulean_p.h"
26 #include "chartthemebluecerulean_p.h"
27 #include "chartthemedark_p.h"
27 #include "chartthemedark_p.h"
28 #include "chartthemebrownsand_p.h"
28 #include "chartthemebrownsand_p.h"
29 #include "chartthemebluencs_p.h"
29 #include "chartthemebluencs_p.h"
30 #include "chartthemehighcontrast_p.h"
30 #include "chartthemehighcontrast_p.h"
31 #include "chartthemeblueicy_p.h"
31 #include "chartthemeblueicy_p.h"
32
32
33 QTCOMMERCIALCHART_BEGIN_NAMESPACE
33 QTCOMMERCIALCHART_BEGIN_NAMESPACE
34
34
35 ChartThemeManager::ChartThemeManager(QChart* chart) :
35 ChartThemeManager::ChartThemeManager(QChart* chart) :
36 m_chart(chart)
36 m_chart(chart)
37 {
37 {
38 qsrand(QTime(0, 0, 0).secsTo(QTime::currentTime()));
38 qsrand(QTime(0, 0, 0).secsTo(QTime::currentTime()));
39 }
39 }
40
40
41
41
42 void ChartThemeManager::setTheme(QChart::ChartTheme theme)
42 void ChartThemeManager::setTheme(QChart::ChartTheme theme)
43 {
43 {
44 if(m_theme.isNull() || theme != m_theme->id())
44 if(m_theme.isNull() || theme != m_theme->id())
45 {
45 {
46 switch (theme) {
46 switch (theme) {
47 case QChart::ChartThemeLight:
47 case QChart::ChartThemeLight:
48 m_theme.reset(new ChartThemeLight());
48 m_theme.reset(new ChartThemeLight());
49 break;
49 break;
50 case QChart::ChartThemeBlueCerulean:
50 case QChart::ChartThemeBlueCerulean:
51 m_theme.reset(new ChartThemeBlueCerulean());
51 m_theme.reset(new ChartThemeBlueCerulean());
52 break;
52 break;
53 case QChart::ChartThemeDark:
53 case QChart::ChartThemeDark:
54 m_theme.reset(new ChartThemeDark());
54 m_theme.reset(new ChartThemeDark());
55 break;
55 break;
56 case QChart::ChartThemeBrownSand:
56 case QChart::ChartThemeBrownSand:
57 m_theme.reset(new ChartThemeBrownSand());
57 m_theme.reset(new ChartThemeBrownSand());
58 break;
58 break;
59 case QChart::ChartThemeBlueNcs:
59 case QChart::ChartThemeBlueNcs:
60 m_theme.reset(new ChartThemeBlueNcs());
60 m_theme.reset(new ChartThemeBlueNcs());
61 break;
61 break;
62 case QChart::ChartThemeHighContrast:
62 case QChart::ChartThemeHighContrast:
63 m_theme.reset(new ChartThemeHighContrast());
63 m_theme.reset(new ChartThemeHighContrast());
64 break;
64 break;
65 case QChart::ChartThemeBlueIcy:
65 case QChart::ChartThemeBlueIcy:
66 m_theme.reset(new ChartThemeBlueIcy());
66 m_theme.reset(new ChartThemeBlueIcy());
67 break;
67 break;
68 default:
68 default:
69 m_theme.reset(new ChartThemeSystem());
69 m_theme.reset(new ChartThemeSystem());
70 break;
70 break;
71 }
71 }
72
72
73 if(!m_theme.isNull())
73 if(!m_theme.isNull())
74 {
74 {
75 decorateChart(m_chart,m_theme.data(),true);
75 decorateChart(m_chart,m_theme.data(),true);
76 decorateLegend(m_chart->legend(),m_theme.data(),true);
76 decorateLegend(m_chart->legend(),m_theme.data(),true);
77 foreach(QAbstractAxis* axis, m_axisList) {
77 foreach(QAbstractAxis* axis, m_axisList) {
78 axis->d_ptr->initializeTheme(m_theme.data(),true);
78 axis->d_ptr->initializeTheme(m_theme.data(),true);
79 }
79 }
80 foreach(QAbstractSeries* series, m_seriesMap.keys()) {
80 foreach(QAbstractSeries* series, m_seriesMap.keys()) {
81 series->d_ptr->initializeTheme(m_seriesMap[series],m_theme.data(),true);
81 series->d_ptr->initializeTheme(m_seriesMap[series],m_theme.data(),true);
82 }
82 }
83
83
84 }
84 }
85 }
85 }
86 }
86 }
87
87
88 void ChartThemeManager::decorateChart(QChart *chart,ChartTheme* theme,bool force) const
88 void ChartThemeManager::decorateChart(QChart *chart,ChartTheme* theme,bool force) const
89 {
89 {
90 QBrush brush;
90 QBrush brush;
91
91
92 if (force || brush == chart->backgroundBrush())
92 if (force || brush == chart->backgroundBrush())
93 chart->setBackgroundBrush(theme->chartBackgroundGradient());
93 chart->setBackgroundBrush(theme->chartBackgroundGradient());
94
94
95 if (force) {
96 // Always clear plotArea brush when forced update, do not touch otherwise
97 QPen pen(Qt::transparent);
98 chart->setPlotAreaBackgroundBrush(brush);
99 chart->setPlotAreaBackgroundPen(pen);
100 chart->setPlotAreaBackgroundVisible(false);
101 }
102
95 chart->setTitleFont(theme->masterFont());
103 chart->setTitleFont(theme->masterFont());
96 chart->setTitleBrush(theme->labelBrush());
104 chart->setTitleBrush(theme->labelBrush());
97 chart->setDropShadowEnabled(theme->isBackgroundDropShadowEnabled());
105 chart->setDropShadowEnabled(theme->isBackgroundDropShadowEnabled());
98 }
106 }
99
107
100 void ChartThemeManager::decorateLegend(QLegend *legend, ChartTheme* theme, bool force) const
108 void ChartThemeManager::decorateLegend(QLegend *legend, ChartTheme* theme, bool force) const
101 {
109 {
102 QPen pen;
110 QPen pen;
103 QBrush brush;
111 QBrush brush;
104 QFont font;
112 QFont font;
105
113
106 if (force || pen == legend->pen())
114 if (force || pen == legend->pen())
107 legend->setPen(theme->axisLinePen());
115 legend->setPen(theme->axisLinePen());
108
116
109 if (force || brush == legend->brush())
117 if (force || brush == legend->brush())
110 legend->setBrush(theme->chartBackgroundGradient());
118 legend->setBrush(theme->chartBackgroundGradient());
111
119
112 if (force || font == legend->font())
120 if (force || font == legend->font())
113 legend->setFont(theme->labelFont());
121 legend->setFont(theme->labelFont());
114
122
115 if (force || brush == legend->labelBrush())
123 if (force || brush == legend->labelBrush())
116 legend->setLabelBrush(theme->labelBrush());
124 legend->setLabelBrush(theme->labelBrush());
117 }
125 }
118
126
119 int ChartThemeManager::createIndexKey(QList<int> keys) const
127 int ChartThemeManager::createIndexKey(QList<int> keys) const
120 {
128 {
121 qSort(keys);
129 qSort(keys);
122
130
123 int key = 0;
131 int key = 0;
124 QList<int>::iterator i;
132 QList<int>::iterator i;
125 i = keys.begin();
133 i = keys.begin();
126
134
127 while (i != keys.end()) {
135 while (i != keys.end()) {
128 if (*i != key)
136 if (*i != key)
129 break;
137 break;
130 key++;
138 key++;
131 i++;
139 i++;
132 }
140 }
133
141
134 return key;
142 return key;
135 }
143 }
136
144
137 int ChartThemeManager::seriesCount(QAbstractSeries::SeriesType type) const
145 int ChartThemeManager::seriesCount(QAbstractSeries::SeriesType type) const
138 {
146 {
139 int count = 0;
147 int count = 0;
140 QList<QAbstractSeries *> series = m_seriesMap.keys();
148 QList<QAbstractSeries *> series = m_seriesMap.keys();
141 foreach(QAbstractSeries *s, series) {
149 foreach(QAbstractSeries *s, series) {
142 if (s->type() == type)
150 if (s->type() == type)
143 count++;
151 count++;
144 }
152 }
145 return count;
153 return count;
146 }
154 }
147
155
148 void ChartThemeManager::handleSeriesAdded(QAbstractSeries *series)
156 void ChartThemeManager::handleSeriesAdded(QAbstractSeries *series)
149 {
157 {
150 int key = createIndexKey(m_seriesMap.values());
158 int key = createIndexKey(m_seriesMap.values());
151 m_seriesMap.insert(series,key);
159 m_seriesMap.insert(series,key);
152 series->d_ptr->initializeTheme(key,m_theme.data(),false);
160 series->d_ptr->initializeTheme(key,m_theme.data(),false);
153 }
161 }
154
162
155 void ChartThemeManager::handleSeriesRemoved(QAbstractSeries *series)
163 void ChartThemeManager::handleSeriesRemoved(QAbstractSeries *series)
156 {
164 {
157 m_seriesMap.remove(series);
165 m_seriesMap.remove(series);
158 }
166 }
159
167
160 void ChartThemeManager::handleAxisAdded(QAbstractAxis *axis)
168 void ChartThemeManager::handleAxisAdded(QAbstractAxis *axis)
161 {
169 {
162 m_axisList.append(axis);
170 m_axisList.append(axis);
163 axis->d_ptr->initializeTheme(m_theme.data(),false);
171 axis->d_ptr->initializeTheme(m_theme.data(),false);
164 }
172 }
165
173
166 void ChartThemeManager::handleAxisRemoved(QAbstractAxis *axis)
174 void ChartThemeManager::handleAxisRemoved(QAbstractAxis *axis)
167 {
175 {
168 m_axisList.removeAll(axis);
176 m_axisList.removeAll(axis);
169 }
177 }
170
178
171 void ChartThemeManager::updateSeries(QAbstractSeries *series)
179 void ChartThemeManager::updateSeries(QAbstractSeries *series)
172 {
180 {
173 if(m_seriesMap.contains(series)){
181 if(m_seriesMap.contains(series)){
174 series->d_ptr->initializeTheme(m_seriesMap[series],m_theme.data(),false);
182 series->d_ptr->initializeTheme(m_seriesMap[series],m_theme.data(),false);
175 }
183 }
176 }
184 }
177 QList<QGradient> ChartThemeManager::generateSeriesGradients(const QList<QColor>& colors)
185 QList<QGradient> ChartThemeManager::generateSeriesGradients(const QList<QColor>& colors)
178 {
186 {
179 QList<QGradient> result;
187 QList<QGradient> result;
180 // Generate gradients in HSV color space
188 // Generate gradients in HSV color space
181 foreach (const QColor &color, colors) {
189 foreach (const QColor &color, colors) {
182 QLinearGradient g;
190 QLinearGradient g;
183 qreal h = color.hsvHueF();
191 qreal h = color.hsvHueF();
184 qreal s = color.hsvSaturationF();
192 qreal s = color.hsvSaturationF();
185
193
186 // TODO: tune the algorithm to give nice results with most base colors defined in
194 // TODO: tune the algorithm to give nice results with most base colors defined in
187 // most themes. The rest of the gradients we can define manually in theme specific
195 // most themes. The rest of the gradients we can define manually in theme specific
188 // implementation.
196 // implementation.
189 QColor start = color;
197 QColor start = color;
190 start.setHsvF(h, 0.0, 1.0);
198 start.setHsvF(h, 0.0, 1.0);
191 g.setColorAt(0.0, start);
199 g.setColorAt(0.0, start);
192
200
193 g.setColorAt(0.5, color);
201 g.setColorAt(0.5, color);
194
202
195 QColor end = color;
203 QColor end = color;
196 end.setHsvF(h, s, 0.25);
204 end.setHsvF(h, s, 0.25);
197 g.setColorAt(1.0, end);
205 g.setColorAt(1.0, end);
198
206
199 result << g;
207 result << g;
200 }
208 }
201
209
202 return result;
210 return result;
203 }
211 }
204
212
205
213
206 QColor ChartThemeManager::colorAt(const QColor &start, const QColor &end, qreal pos)
214 QColor ChartThemeManager::colorAt(const QColor &start, const QColor &end, qreal pos)
207 {
215 {
208 Q_ASSERT(pos >= 0.0 && pos <= 1.0);
216 Q_ASSERT(pos >= 0.0 && pos <= 1.0);
209 qreal r = start.redF() + ((end.redF() - start.redF()) * pos);
217 qreal r = start.redF() + ((end.redF() - start.redF()) * pos);
210 qreal g = start.greenF() + ((end.greenF() - start.greenF()) * pos);
218 qreal g = start.greenF() + ((end.greenF() - start.greenF()) * pos);
211 qreal b = start.blueF() + ((end.blueF() - start.blueF()) * pos);
219 qreal b = start.blueF() + ((end.blueF() - start.blueF()) * pos);
212 QColor c;
220 QColor c;
213 c.setRgbF(r, g, b);
221 c.setRgbF(r, g, b);
214 return c;
222 return c;
215 }
223 }
216
224
217 QColor ChartThemeManager::colorAt(const QGradient &gradient, qreal pos)
225 QColor ChartThemeManager::colorAt(const QGradient &gradient, qreal pos)
218 {
226 {
219 Q_ASSERT(pos >= 0 && pos <= 1.0);
227 Q_ASSERT(pos >= 0 && pos <= 1.0);
220
228
221 QGradientStops stops = gradient.stops();
229 QGradientStops stops = gradient.stops();
222 int count = stops.count();
230 int count = stops.count();
223
231
224 // find previous stop relative to position
232 // find previous stop relative to position
225 QGradientStop prev = stops.first();
233 QGradientStop prev = stops.first();
226 for (int i = 0; i < count; i++) {
234 for (int i = 0; i < count; i++) {
227 QGradientStop stop = stops.at(i);
235 QGradientStop stop = stops.at(i);
228 if (pos > stop.first)
236 if (pos > stop.first)
229 prev = stop;
237 prev = stop;
230
238
231 // given position is actually a stop position?
239 // given position is actually a stop position?
232 if (pos == stop.first) {
240 if (pos == stop.first) {
233 //qDebug() << "stop color" << pos;
241 //qDebug() << "stop color" << pos;
234 return stop.second;
242 return stop.second;
235 }
243 }
236 }
244 }
237
245
238 // find next stop relative to position
246 // find next stop relative to position
239 QGradientStop next = stops.last();
247 QGradientStop next = stops.last();
240 for (int i = count - 1; i >= 0; i--) {
248 for (int i = count - 1; i >= 0; i--) {
241 QGradientStop stop = stops.at(i);
249 QGradientStop stop = stops.at(i);
242 if (pos < stop.first)
250 if (pos < stop.first)
243 next = stop;
251 next = stop;
244 }
252 }
245
253
246 //qDebug() << "prev" << prev.first << "pos" << pos << "next" << next.first;
254 //qDebug() << "prev" << prev.first << "pos" << pos << "next" << next.first;
247
255
248 qreal range = next.first - prev.first;
256 qreal range = next.first - prev.first;
249 qreal posDelta = pos - prev.first;
257 qreal posDelta = pos - prev.first;
250 qreal relativePos = posDelta / range;
258 qreal relativePos = posDelta / range;
251
259
252 //qDebug() << "range" << range << "posDelta" << posDelta << "relativePos" << relativePos;
260 //qDebug() << "range" << range << "posDelta" << posDelta << "relativePos" << relativePos;
253
261
254 return colorAt(prev.second, next.second, relativePos);
262 return colorAt(prev.second, next.second, relativePos);
255 }
263 }
256
264
257 #include "moc_chartthememanager_p.cpp"
265 #include "moc_chartthememanager_p.cpp"
258
266
259 QTCOMMERCIALCHART_END_NAMESPACE
267 QTCOMMERCIALCHART_END_NAMESPACE
@@ -1,197 +1,201
1 /****************************************************************************
1 /****************************************************************************
2 **
2 **
3 ** Copyright (C) 2013 Digia Plc
3 ** Copyright (C) 2013 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 "abstractchartlayout_p.h"
21 #include "abstractchartlayout_p.h"
22 #include "chartpresenter_p.h"
22 #include "chartpresenter_p.h"
23 #include "qlegend_p.h"
23 #include "qlegend_p.h"
24 #include "chartaxiselement_p.h"
24 #include "chartaxiselement_p.h"
25 #include "charttitle_p.h"
25 #include "charttitle_p.h"
26 #include "chartbackground_p.h"
26 #include "chartbackground_p.h"
27 #include <QDebug>
27 #include <QDebug>
28
28
29 QTCOMMERCIALCHART_BEGIN_NAMESPACE
29 QTCOMMERCIALCHART_BEGIN_NAMESPACE
30
30
31 static const qreal golden_ratio = 0.4;
31 static const qreal golden_ratio = 0.4;
32
32
33 AbstractChartLayout::AbstractChartLayout(ChartPresenter *presenter)
33 AbstractChartLayout::AbstractChartLayout(ChartPresenter *presenter)
34 : m_presenter(presenter),
34 : m_presenter(presenter),
35 m_margins(20, 20, 20, 20),
35 m_margins(20, 20, 20, 20),
36 m_minChartRect(0, 0, 200, 200)
36 m_minChartRect(0, 0, 200, 200)
37 {
37 {
38 }
38 }
39
39
40 AbstractChartLayout::~AbstractChartLayout()
40 AbstractChartLayout::~AbstractChartLayout()
41 {
41 {
42 }
42 }
43
43
44 void AbstractChartLayout::setGeometry(const QRectF &rect)
44 void AbstractChartLayout::setGeometry(const QRectF &rect)
45 {
45 {
46 if (!rect.isValid())
46 if (!rect.isValid())
47 return;
47 return;
48
48
49 QList<ChartAxisElement *> axes = m_presenter->axisItems();
49 QList<ChartAxisElement *> axes = m_presenter->axisItems();
50 ChartTitle *title = m_presenter->titleElement();
50 ChartTitle *title = m_presenter->titleElement();
51 QLegend *legend = m_presenter->legend();
51 QLegend *legend = m_presenter->legend();
52 ChartBackground *background = m_presenter->backgroundElement();
52 ChartBackground *background = m_presenter->backgroundElement();
53
53
54 QRectF contentGeometry = calculateBackgroundGeometry(rect, background);
54 QRectF contentGeometry = calculateBackgroundGeometry(rect, background);
55
55
56 contentGeometry = calculateContentGeometry(contentGeometry);
56 contentGeometry = calculateContentGeometry(contentGeometry);
57
57
58 if (title && title->isVisible())
58 if (title && title->isVisible())
59 contentGeometry = calculateTitleGeometry(contentGeometry, title);
59 contentGeometry = calculateTitleGeometry(contentGeometry, title);
60
60
61 if (legend->isAttachedToChart() && legend->isVisible())
61 if (legend->isAttachedToChart() && legend->isVisible())
62 contentGeometry = calculateLegendGeometry(contentGeometry, legend);
62 contentGeometry = calculateLegendGeometry(contentGeometry, legend);
63
63
64 contentGeometry = calculateAxisGeometry(contentGeometry, axes);
64 contentGeometry = calculateAxisGeometry(contentGeometry, axes);
65
65
66 m_presenter->setGeometry(contentGeometry);
66 m_presenter->setGeometry(contentGeometry);
67 if (m_presenter->chart()->chartType() == QChart::ChartTypeCartesian)
68 static_cast<QGraphicsRectItem *>(m_presenter->plotAreaElement())->setRect(contentGeometry);
69 else
70 static_cast<QGraphicsEllipseItem *>(m_presenter->plotAreaElement())->setRect(contentGeometry);
67
71
68 QGraphicsLayout::setGeometry(rect);
72 QGraphicsLayout::setGeometry(rect);
69 }
73 }
70
74
71 QRectF AbstractChartLayout::calculateContentGeometry(const QRectF &geometry) const
75 QRectF AbstractChartLayout::calculateContentGeometry(const QRectF &geometry) const
72 {
76 {
73 return geometry.adjusted(m_margins.left(), m_margins.top(), -m_margins.right(), -m_margins.bottom());
77 return geometry.adjusted(m_margins.left(), m_margins.top(), -m_margins.right(), -m_margins.bottom());
74 }
78 }
75
79
76 QRectF AbstractChartLayout::calculateContentMinimum(const QRectF &minimum) const
80 QRectF AbstractChartLayout::calculateContentMinimum(const QRectF &minimum) const
77 {
81 {
78 return minimum.adjusted(0, 0, m_margins.left() + m_margins.right(), m_margins.top() + m_margins.bottom());
82 return minimum.adjusted(0, 0, m_margins.left() + m_margins.right(), m_margins.top() + m_margins.bottom());
79 }
83 }
80
84
81
85
82 QRectF AbstractChartLayout::calculateBackgroundGeometry(const QRectF &geometry, ChartBackground *background) const
86 QRectF AbstractChartLayout::calculateBackgroundGeometry(const QRectF &geometry, ChartBackground *background) const
83 {
87 {
84 qreal left;
88 qreal left;
85 qreal top;
89 qreal top;
86 qreal right;
90 qreal right;
87 qreal bottom;
91 qreal bottom;
88 getContentsMargins(&left, &top, &right, &bottom);
92 getContentsMargins(&left, &top, &right, &bottom);
89 QRectF backgroundGeometry = geometry.adjusted(left, top, -right, -bottom);
93 QRectF backgroundGeometry = geometry.adjusted(left, top, -right, -bottom);
90 if (background)
94 if (background)
91 background->setRect(backgroundGeometry);
95 background->setRect(backgroundGeometry);
92 return backgroundGeometry;
96 return backgroundGeometry;
93 }
97 }
94
98
95 QRectF AbstractChartLayout::calculateBackgroundMinimum(const QRectF &minimum) const
99 QRectF AbstractChartLayout::calculateBackgroundMinimum(const QRectF &minimum) const
96 {
100 {
97 qreal left;
101 qreal left;
98 qreal top;
102 qreal top;
99 qreal right;
103 qreal right;
100 qreal bottom;
104 qreal bottom;
101 getContentsMargins(&left, &top, &right, &bottom);
105 getContentsMargins(&left, &top, &right, &bottom);
102 return minimum.adjusted(0, 0, left + right, top + bottom);
106 return minimum.adjusted(0, 0, left + right, top + bottom);
103 }
107 }
104
108
105 QRectF AbstractChartLayout::calculateLegendGeometry(const QRectF &geometry, QLegend *legend) const
109 QRectF AbstractChartLayout::calculateLegendGeometry(const QRectF &geometry, QLegend *legend) const
106 {
110 {
107 QSizeF size = legend->effectiveSizeHint(Qt::PreferredSize, QSizeF(-1, -1));
111 QSizeF size = legend->effectiveSizeHint(Qt::PreferredSize, QSizeF(-1, -1));
108 QRectF legendRect;
112 QRectF legendRect;
109 QRectF result;
113 QRectF result;
110
114
111 switch (legend->alignment()) {
115 switch (legend->alignment()) {
112 case Qt::AlignTop: {
116 case Qt::AlignTop: {
113 legendRect = QRectF(geometry.topLeft(), QSizeF(geometry.width(), size.height()));
117 legendRect = QRectF(geometry.topLeft(), QSizeF(geometry.width(), size.height()));
114 result = geometry.adjusted(0, legendRect.height(), 0, 0);
118 result = geometry.adjusted(0, legendRect.height(), 0, 0);
115 break;
119 break;
116 }
120 }
117 case Qt::AlignBottom: {
121 case Qt::AlignBottom: {
118 legendRect = QRectF(QPointF(geometry.left(), geometry.bottom() - size.height()), QSizeF(geometry.width(), size.height()));
122 legendRect = QRectF(QPointF(geometry.left(), geometry.bottom() - size.height()), QSizeF(geometry.width(), size.height()));
119 result = geometry.adjusted(0, 0, 0, -legendRect.height());
123 result = geometry.adjusted(0, 0, 0, -legendRect.height());
120 break;
124 break;
121 }
125 }
122 case Qt::AlignLeft: {
126 case Qt::AlignLeft: {
123 qreal width = qMin(size.width(), geometry.width() * golden_ratio);
127 qreal width = qMin(size.width(), geometry.width() * golden_ratio);
124 legendRect = QRectF(geometry.topLeft(), QSizeF(width, geometry.height()));
128 legendRect = QRectF(geometry.topLeft(), QSizeF(width, geometry.height()));
125 result = geometry.adjusted(width, 0, 0, 0);
129 result = geometry.adjusted(width, 0, 0, 0);
126 break;
130 break;
127 }
131 }
128 case Qt::AlignRight: {
132 case Qt::AlignRight: {
129 qreal width = qMin(size.width(), geometry.width() * golden_ratio);
133 qreal width = qMin(size.width(), geometry.width() * golden_ratio);
130 legendRect = QRectF(QPointF(geometry.right() - width, geometry.top()), QSizeF(width, geometry.height()));
134 legendRect = QRectF(QPointF(geometry.right() - width, geometry.top()), QSizeF(width, geometry.height()));
131 result = geometry.adjusted(0, 0, -width, 0);
135 result = geometry.adjusted(0, 0, -width, 0);
132 break;
136 break;
133 }
137 }
134 default: {
138 default: {
135 legendRect = QRectF(0, 0, 0, 0);
139 legendRect = QRectF(0, 0, 0, 0);
136 result = geometry;
140 result = geometry;
137 break;
141 break;
138 }
142 }
139 }
143 }
140
144
141 legend->setGeometry(legendRect);
145 legend->setGeometry(legendRect);
142
146
143 return result;
147 return result;
144 }
148 }
145
149
146 QRectF AbstractChartLayout::calculateLegendMinimum(const QRectF &geometry, QLegend *legend) const
150 QRectF AbstractChartLayout::calculateLegendMinimum(const QRectF &geometry, QLegend *legend) const
147 {
151 {
148 QSizeF minSize = legend->effectiveSizeHint(Qt::MinimumSize, QSizeF(-1, -1));
152 QSizeF minSize = legend->effectiveSizeHint(Qt::MinimumSize, QSizeF(-1, -1));
149 return geometry.adjusted(0, 0, minSize.width(), minSize.height());
153 return geometry.adjusted(0, 0, minSize.width(), minSize.height());
150 }
154 }
151
155
152 QRectF AbstractChartLayout::calculateTitleGeometry(const QRectF &geometry, ChartTitle *title) const
156 QRectF AbstractChartLayout::calculateTitleGeometry(const QRectF &geometry, ChartTitle *title) const
153 {
157 {
154 title->setGeometry(geometry);
158 title->setGeometry(geometry);
155 QPointF center = geometry.center() - title->boundingRect().center();
159 QPointF center = geometry.center() - title->boundingRect().center();
156 title->setPos(center.x(), title->pos().y());
160 title->setPos(center.x(), title->pos().y());
157 return geometry.adjusted(0, title->boundingRect().height()+1, 0, 0);
161 return geometry.adjusted(0, title->boundingRect().height()+1, 0, 0);
158 }
162 }
159
163
160 QRectF AbstractChartLayout::calculateTitleMinimum(const QRectF &minimum, ChartTitle *title) const
164 QRectF AbstractChartLayout::calculateTitleMinimum(const QRectF &minimum, ChartTitle *title) const
161 {
165 {
162 QSizeF min = title->sizeHint(Qt::MinimumSize);
166 QSizeF min = title->sizeHint(Qt::MinimumSize);
163 return minimum.adjusted(0, 0, min.width(), min.height());
167 return minimum.adjusted(0, 0, min.width(), min.height());
164 }
168 }
165
169
166 QSizeF AbstractChartLayout::sizeHint(Qt::SizeHint which, const QSizeF &constraint) const
170 QSizeF AbstractChartLayout::sizeHint(Qt::SizeHint which, const QSizeF &constraint) const
167 {
171 {
168 Q_UNUSED(constraint);
172 Q_UNUSED(constraint);
169 if (which == Qt::MinimumSize) {
173 if (which == Qt::MinimumSize) {
170 QList<ChartAxisElement *> axes = m_presenter->axisItems();
174 QList<ChartAxisElement *> axes = m_presenter->axisItems();
171 ChartTitle *title = m_presenter->titleElement();
175 ChartTitle *title = m_presenter->titleElement();
172 QLegend *legend = m_presenter->legend();
176 QLegend *legend = m_presenter->legend();
173 QRectF minimumRect(0, 0, 0, 0);
177 QRectF minimumRect(0, 0, 0, 0);
174 minimumRect = calculateBackgroundMinimum(minimumRect);
178 minimumRect = calculateBackgroundMinimum(minimumRect);
175 minimumRect = calculateContentMinimum(minimumRect);
179 minimumRect = calculateContentMinimum(minimumRect);
176 minimumRect = calculateTitleMinimum(minimumRect, title);
180 minimumRect = calculateTitleMinimum(minimumRect, title);
177 minimumRect = calculateLegendMinimum(minimumRect, legend);
181 minimumRect = calculateLegendMinimum(minimumRect, legend);
178 minimumRect = calculateAxisMinimum(minimumRect, axes);
182 minimumRect = calculateAxisMinimum(minimumRect, axes);
179 return minimumRect.united(m_minChartRect).size().toSize();
183 return minimumRect.united(m_minChartRect).size().toSize();
180 }
184 }
181 return QSize(-1, -1);
185 return QSize(-1, -1);
182 }
186 }
183
187
184 void AbstractChartLayout::setMargins(const QMargins &margins)
188 void AbstractChartLayout::setMargins(const QMargins &margins)
185 {
189 {
186 if (m_margins != margins) {
190 if (m_margins != margins) {
187 m_margins = margins;
191 m_margins = margins;
188 updateGeometry();
192 updateGeometry();
189 }
193 }
190 }
194 }
191
195
192 QMargins AbstractChartLayout::margins() const
196 QMargins AbstractChartLayout::margins() const
193 {
197 {
194 return m_margins;
198 return m_margins;
195 }
199 }
196
200
197 QTCOMMERCIALCHART_END_NAMESPACE
201 QTCOMMERCIALCHART_END_NAMESPACE
@@ -1,696 +1,754
1 /****************************************************************************
1 /****************************************************************************
2 **
2 **
3 ** Copyright (C) 2013 Digia Plc
3 ** Copyright (C) 2013 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 "abstractchartlayout_p.h"
27 #include "abstractchartlayout_p.h"
28 #include "charttheme_p.h"
28 #include "charttheme_p.h"
29 #include "chartpresenter_p.h"
29 #include "chartpresenter_p.h"
30 #include "chartdataset_p.h"
30 #include "chartdataset_p.h"
31 #include <QGraphicsScene>
31 #include <QGraphicsScene>
32 #include <QGraphicsSceneResizeEvent>
32 #include <QGraphicsSceneResizeEvent>
33
33
34 QTCOMMERCIALCHART_BEGIN_NAMESPACE
34 QTCOMMERCIALCHART_BEGIN_NAMESPACE
35
35
36 /*!
36 /*!
37 \enum QChart::ChartTheme
37 \enum QChart::ChartTheme
38
38
39 This enum describes the theme used by the chart.
39 This enum describes the theme used by the chart.
40
40
41 \value ChartThemeLight The default theme
41 \value ChartThemeLight The default theme
42 \value ChartThemeBlueCerulean
42 \value ChartThemeBlueCerulean
43 \value ChartThemeDark
43 \value ChartThemeDark
44 \value ChartThemeBrownSand
44 \value ChartThemeBrownSand
45 \value ChartThemeBlueNcs
45 \value ChartThemeBlueNcs
46 \value ChartThemeHighContrast
46 \value ChartThemeHighContrast
47 \value ChartThemeBlueIcy
47 \value ChartThemeBlueIcy
48 */
48 */
49
49
50 /*!
50 /*!
51 \enum QChart::AnimationOption
51 \enum QChart::AnimationOption
52
52
53 For enabling/disabling animations. Defaults to NoAnimation.
53 For enabling/disabling animations. Defaults to NoAnimation.
54
54
55 \value NoAnimation
55 \value NoAnimation
56 \value GridAxisAnimations
56 \value GridAxisAnimations
57 \value SeriesAnimations
57 \value SeriesAnimations
58 \value AllAnimations
58 \value AllAnimations
59 */
59 */
60
60
61 /*!
61 /*!
62 \enum QChart::ChartType
62 \enum QChart::ChartType
63
63
64 This enum describes the chart type.
64 This enum describes the chart type.
65
65
66 \value ChartTypeUndefined
66 \value ChartTypeUndefined
67 \value ChartTypeCartesian
67 \value ChartTypeCartesian
68 \value ChartTypePolar
68 \value ChartTypePolar
69 */
69 */
70
70
71 /*!
71 /*!
72 \class QChart
72 \class QChart
73 \brief QtCommercial chart API.
73 \brief QtCommercial chart API.
74
74
75 QChart is a QGraphicsWidget that you can show in a QGraphicsScene. It manages the graphical
75 QChart is a QGraphicsWidget that you can show in a QGraphicsScene. It manages the graphical
76 representation of different types of series and other chart related objects like legend and
76 representation of different types of series and other chart related objects like legend and
77 axes. If you simply want to show a chart in a layout, you can use the
77 axes. If you simply want to show a chart in a layout, you can use the
78 convenience class QChartView instead of QChart.
78 convenience class QChartView instead of QChart.
79 \sa QChartView, QPolarChart
79 \sa QChartView, QPolarChart
80 */
80 */
81
81
82 /*!
82 /*!
83 \property QChart::animationOptions
83 \property QChart::animationOptions
84 The animation \a options for the chart. Animations are enabled/disabled based on this setting.
84 The animation \a options for the chart. Animations are enabled/disabled based on this setting.
85 */
85 */
86
86
87 /*!
87 /*!
88 \property QChart::backgroundVisible
88 \property QChart::backgroundVisible
89 Specifies whether the chart background is visible or not.
89 Specifies whether the chart background is visible or not.
90 \sa setBackgroundBrush(), setBackgroundPen()
90 \sa setBackgroundBrush(), setBackgroundPen(), plotAreaBackgroundVisible
91 */
91 */
92
92
93 /*!
93 /*!
94 \property QChart::dropShadowEnabled
94 \property QChart::dropShadowEnabled
95 If set to true, the background drop shadow effect is enabled. If set to false, it is disabled. Note that the drop
95 If set to true, the background drop shadow effect is enabled. If set to false, it is disabled. Note that the drop
96 shadow effect depends on theme, which means the setting may be changed if you switch to another theme.
96 shadow effect depends on theme, which means the setting may be changed if you switch to another theme.
97 */
97 */
98
98
99 /*!
99 /*!
100 \property QChart::minimumMargins
100 \property QChart::minimumMargins
101 Minimum margins between the plot area (axes) and the edge of the chart widget.
101 Minimum margins between the plot area (axes) and the edge of the chart widget.
102 This property is deprecated; use margins property instead.
102 This property is deprecated; use margins property instead.
103
103
104 \sa margins
104 \sa margins
105 */
105 */
106
106
107 /*!
107 /*!
108 \property QChart::margins
108 \property QChart::margins
109 Margins between the plot area (axes) and the edge of the chart widget.
109 Margins between the plot area (axes) and the edge of the chart widget.
110 */
110 */
111
111
112 /*!
112 /*!
113 \property QChart::theme
113 \property QChart::theme
114 Theme is a built-in collection of UI style related settings applied for all visual elements of a chart, like colors,
114 Theme is a built-in collection of UI style related settings applied for all visual elements of a chart, like colors,
115 pens, brushes, and fonts of series, axes, title, and legend. \l {Chart themes demo} shows an example with a few
115 pens, brushes, and fonts of series, axes, title, and legend. \l {Chart themes demo} shows an example with a few
116 different themes.
116 different themes.
117 \note Changing the theme will overwrite all customizations previously applied to the series.
117 \note Changing the theme will overwrite all customizations previously applied to the series.
118 */
118 */
119
119
120 /*!
120 /*!
121 \property QChart::title
121 \property QChart::title
122 Title is the name (label) of a chart. It is shown as a headline on top of the chart.
122 Title is the name (label) of a chart. It is shown as a headline on top of the chart.
123 */
123 */
124
124
125 /*!
125 /*!
126 \property QChart::chartType
126 \property QChart::chartType
127 Chart type indicates if the chart is a cartesian chart or a polar chart.
127 Chart type indicates if the chart is a cartesian chart or a polar chart.
128 This property is set internally and it is read only.
128 This property is set internally and it is read only.
129 \sa QPolarChart
129 \sa QPolarChart
130 */
130 */
131
131
132 /*!
132 /*!
133 \property QChart::plotAreaBackgroundVisible
134 Specifies whether the chart plot area background is visible or not.
135 \note By default the plot area background is not visible and the plot area uses
136 the general chart background.
137 \sa setPlotAreaBackgroundBrush(), setPlotAreaBackgroundPen(), backgroundVisible
138 */
139
140 /*!
133 \internal
141 \internal
134 Constructs a chart object of \a type which is a child of a \a parent.
142 Constructs a chart object of \a type which is a child of a \a parent.
135 Parameter \a wFlags is passed to the QGraphicsWidget constructor.
143 Parameter \a wFlags is passed to the QGraphicsWidget constructor.
136 This constructor is called only by subclasses.
144 This constructor is called only by subclasses.
137 */
145 */
138 QChart::QChart(QChart::ChartType type, QGraphicsItem *parent, Qt::WindowFlags wFlags)
146 QChart::QChart(QChart::ChartType type, QGraphicsItem *parent, Qt::WindowFlags wFlags)
139 : QGraphicsWidget(parent, wFlags),
147 : QGraphicsWidget(parent, wFlags),
140 d_ptr(new QChartPrivate(this, type))
148 d_ptr(new QChartPrivate(this, type))
141 {
149 {
142 d_ptr->init();
150 d_ptr->init();
143 }
151 }
144
152
145 /*!
153 /*!
146 Constructs a chart object which is a child of a \a parent.
154 Constructs a chart object which is a child of a \a parent.
147 Parameter \a wFlags is passed to the QGraphicsWidget constructor.
155 Parameter \a wFlags is passed to the QGraphicsWidget constructor.
148 */
156 */
149 QChart::QChart(QGraphicsItem *parent, Qt::WindowFlags wFlags)
157 QChart::QChart(QGraphicsItem *parent, Qt::WindowFlags wFlags)
150 : QGraphicsWidget(parent, wFlags),
158 : QGraphicsWidget(parent, wFlags),
151 d_ptr(new QChartPrivate(this, ChartTypeCartesian))
159 d_ptr(new QChartPrivate(this, ChartTypeCartesian))
152 {
160 {
153 d_ptr->init();
161 d_ptr->init();
154 }
162 }
155
163
156 /*!
164 /*!
157 Destroys the chart object and its children, like series and axis objects added to it.
165 Destroys the chart object and its children, like series and axis objects added to it.
158 */
166 */
159 QChart::~QChart()
167 QChart::~QChart()
160 {
168 {
161 //start by deleting dataset, it will remove all series and axes
169 //start by deleting dataset, it will remove all series and axes
162 delete d_ptr->m_dataset;
170 delete d_ptr->m_dataset;
163 d_ptr->m_dataset = 0;
171 d_ptr->m_dataset = 0;
164 }
172 }
165
173
166 /*!
174 /*!
167 Adds the \a series onto the chart and takes the ownership of it.
175 Adds the \a series onto the chart and takes the ownership of it.
168
176
169 \note A newly added series is attached to no axes by default, including any axes that were created for the chart
177 \note A newly added series is attached to no axes by default, including any axes that were created for the chart
170 using createDefaultAxes() before the series was added to the chart. If no axes are attached to
178 using createDefaultAxes() before the series was added to the chart. If no axes are attached to
171 the newly added series before the chart is shown, the series will get drawn as if it had axes with ranges
179 the newly added series before the chart is shown, the series will get drawn as if it had axes with ranges
172 that exactly fit the series to the plot area of the chart. This can be confusing if the same chart also displays other
180 that exactly fit the series to the plot area of the chart. This can be confusing if the same chart also displays other
173 series that have properly attached axes, so always make sure you either call createDefaultAxes() after
181 series that have properly attached axes, so always make sure you either call createDefaultAxes() after
174 a series has been added or explicitly attach axes for the series.
182 a series has been added or explicitly attach axes for the series.
175
183
176 \sa removeSeries(), removeAllSeries(), createDefaultAxes(), QAbstractSeries::attachAxis()
184 \sa removeSeries(), removeAllSeries(), createDefaultAxes(), QAbstractSeries::attachAxis()
177 */
185 */
178 void QChart::addSeries(QAbstractSeries *series)
186 void QChart::addSeries(QAbstractSeries *series)
179 {
187 {
180 Q_ASSERT(series);
188 Q_ASSERT(series);
181 d_ptr->m_dataset->addSeries(series);
189 d_ptr->m_dataset->addSeries(series);
182 }
190 }
183
191
184 /*!
192 /*!
185 Removes the \a series from the chart.
193 Removes the \a series from the chart.
186 The chart releases its ownership of the specified \a series object.
194 The chart releases its ownership of the specified \a series object.
187
195
188 \sa addSeries(), removeAllSeries()
196 \sa addSeries(), removeAllSeries()
189 */
197 */
190 void QChart::removeSeries(QAbstractSeries *series)
198 void QChart::removeSeries(QAbstractSeries *series)
191 {
199 {
192 Q_ASSERT(series);
200 Q_ASSERT(series);
193 d_ptr->m_dataset->removeSeries(series);
201 d_ptr->m_dataset->removeSeries(series);
194 }
202 }
195
203
196 /*!
204 /*!
197 Removes and deletes all series objects that have been added to the chart.
205 Removes and deletes all series objects that have been added to the chart.
198
206
199 \sa addSeries(), removeSeries()
207 \sa addSeries(), removeSeries()
200 */
208 */
201 void QChart::removeAllSeries()
209 void QChart::removeAllSeries()
202 {
210 {
203 foreach (QAbstractSeries *s , d_ptr->m_dataset->series()){
211 foreach (QAbstractSeries *s , d_ptr->m_dataset->series()){
204 removeSeries(s);
212 removeSeries(s);
205 delete s;
213 delete s;
206 }
214 }
207 }
215 }
208
216
209 /*!
217 /*!
210 Sets the \a brush that is used for painting the background of the chart area.
218 Sets the \a brush that is used for painting the background of the chart area.
211 */
219 */
212 void QChart::setBackgroundBrush(const QBrush &brush)
220 void QChart::setBackgroundBrush(const QBrush &brush)
213 {
221 {
214 d_ptr->m_presenter->setBackgroundBrush(brush);
222 d_ptr->m_presenter->setBackgroundBrush(brush);
215 }
223 }
216
224
217 /*!
225 /*!
218 Gets the brush that is used for painting the background of the chart area.
226 Gets the brush that is used for painting the background of the chart area.
219 */
227 */
220 QBrush QChart::backgroundBrush() const
228 QBrush QChart::backgroundBrush() const
221 {
229 {
222 return d_ptr->m_presenter->backgroundBrush();
230 return d_ptr->m_presenter->backgroundBrush();
223 }
231 }
224
232
225 /*!
233 /*!
226 Sets the \a pen that is used for painting the background of the chart area.
234 Sets the \a pen that is used for painting the background of the chart area.
227 */
235 */
228 void QChart::setBackgroundPen(const QPen &pen)
236 void QChart::setBackgroundPen(const QPen &pen)
229 {
237 {
230 d_ptr->m_presenter->setBackgroundPen(pen);
238 d_ptr->m_presenter->setBackgroundPen(pen);
231 }
239 }
232
240
233 /*!
241 /*!
234 Gets the pen that is used for painting the background of the chart area.
242 Gets the pen that is used for painting the background of the chart area.
235 */
243 */
236 QPen QChart::backgroundPen() const
244 QPen QChart::backgroundPen() const
237 {
245 {
238 return d_ptr->m_presenter->backgroundPen();
246 return d_ptr->m_presenter->backgroundPen();
239 }
247 }
240
248
241 void QChart::setTitle(const QString &title)
249 void QChart::setTitle(const QString &title)
242 {
250 {
243 d_ptr->m_presenter->setTitle(title);
251 d_ptr->m_presenter->setTitle(title);
244 }
252 }
245
253
246 QString QChart::title() const
254 QString QChart::title() const
247 {
255 {
248 return d_ptr->m_presenter->title();
256 return d_ptr->m_presenter->title();
249 }
257 }
250
258
251 /*!
259 /*!
252 Sets the \a font that is used for drawing the chart title.
260 Sets the \a font that is used for drawing the chart title.
253 */
261 */
254 void QChart::setTitleFont(const QFont &font)
262 void QChart::setTitleFont(const QFont &font)
255 {
263 {
256 d_ptr->m_presenter->setTitleFont(font);
264 d_ptr->m_presenter->setTitleFont(font);
257 }
265 }
258
266
259 /*!
267 /*!
260 Gets the font that is used for drawing the chart title.
268 Gets the font that is used for drawing the chart title.
261 */
269 */
262 QFont QChart::titleFont() const
270 QFont QChart::titleFont() const
263 {
271 {
264 return d_ptr->m_presenter->titleFont();
272 return d_ptr->m_presenter->titleFont();
265 }
273 }
266
274
267 /*!
275 /*!
268 Sets the \a brush used for drawing the title text.
276 Sets the \a brush used for drawing the title text.
269 */
277 */
270 void QChart::setTitleBrush(const QBrush &brush)
278 void QChart::setTitleBrush(const QBrush &brush)
271 {
279 {
272 d_ptr->m_presenter->setTitleBrush(brush);
280 d_ptr->m_presenter->setTitleBrush(brush);
273 }
281 }
274
282
275 /*!
283 /*!
276 Returns the brush used for drawing the title text.
284 Returns the brush used for drawing the title text.
277 */
285 */
278 QBrush QChart::titleBrush() const
286 QBrush QChart::titleBrush() const
279 {
287 {
280 return d_ptr->m_presenter->titleBrush();
288 return d_ptr->m_presenter->titleBrush();
281 }
289 }
282
290
283 void QChart::setTheme(QChart::ChartTheme theme)
291 void QChart::setTheme(QChart::ChartTheme theme)
284 {
292 {
285 d_ptr->m_themeManager->setTheme(theme);
293 d_ptr->m_themeManager->setTheme(theme);
286 }
294 }
287
295
288 QChart::ChartTheme QChart::theme() const
296 QChart::ChartTheme QChart::theme() const
289 {
297 {
290 return d_ptr->m_themeManager->theme()->id();
298 return d_ptr->m_themeManager->theme()->id();
291 }
299 }
292
300
293 /*!
301 /*!
294 Zooms in the view by a factor of two.
302 Zooms in the view by a factor of two.
295 */
303 */
296 void QChart::zoomIn()
304 void QChart::zoomIn()
297 {
305 {
298 d_ptr->zoomIn(2.0);
306 d_ptr->zoomIn(2.0);
299 }
307 }
300
308
301 /*!
309 /*!
302 Zooms in the view to a maximum level at which \a rect is still fully visible.
310 Zooms in the view to a maximum level at which \a rect is still fully visible.
303 \note This is not supported for polar charts.
311 \note This is not supported for polar charts.
304 */
312 */
305 void QChart::zoomIn(const QRectF &rect)
313 void QChart::zoomIn(const QRectF &rect)
306 {
314 {
307 if (d_ptr->m_type == QChart::ChartTypePolar)
315 if (d_ptr->m_type == QChart::ChartTypePolar)
308 return;
316 return;
309 d_ptr->zoomIn(rect);
317 d_ptr->zoomIn(rect);
310 }
318 }
311
319
312 /*!
320 /*!
313 Zooms out the view by a factor of two.
321 Zooms out the view by a factor of two.
314 */
322 */
315 void QChart::zoomOut()
323 void QChart::zoomOut()
316 {
324 {
317 d_ptr->zoomOut(2.0);
325 d_ptr->zoomOut(2.0);
318 }
326 }
319
327
320 /*!
328 /*!
321 Zooms in the view by a custom \a factor.
329 Zooms in the view by a custom \a factor.
322
330
323 A factor over 1.0 zooms the view in and factor between 0.0 and 1.0 zooms out.
331 A factor over 1.0 zooms the view in and factor between 0.0 and 1.0 zooms out.
324 */
332 */
325 void QChart::zoom(qreal factor)
333 void QChart::zoom(qreal factor)
326 {
334 {
327 if (qFuzzyCompare(factor, 0))
335 if (qFuzzyCompare(factor, 0))
328 return;
336 return;
329
337
330 if (qFuzzyCompare(factor, (qreal)1.0))
338 if (qFuzzyCompare(factor, (qreal)1.0))
331 return;
339 return;
332
340
333 if (factor < 0)
341 if (factor < 0)
334 return;
342 return;
335
343
336 if (factor > 1.0)
344 if (factor > 1.0)
337 d_ptr->zoomIn(factor);
345 d_ptr->zoomIn(factor);
338 else
346 else
339 d_ptr->zoomOut(1.0 / factor);
347 d_ptr->zoomOut(1.0 / factor);
340 }
348 }
341
349
342 /*!
350 /*!
343 Returns a pointer to the horizontal axis attached to the specified \a series.
351 Returns a pointer to the horizontal axis attached to the specified \a series.
344 If no \a series is specified, the first horizontal axis added to the chart is returned.
352 If no \a series is specified, the first horizontal axis added to the chart is returned.
345
353
346 \sa addAxis(), QAbstractSeries::attachAxis()
354 \sa addAxis(), QAbstractSeries::attachAxis()
347 */
355 */
348 QAbstractAxis *QChart::axisX(QAbstractSeries *series) const
356 QAbstractAxis *QChart::axisX(QAbstractSeries *series) const
349 {
357 {
350 QList<QAbstractAxis *> axisList = axes(Qt::Horizontal, series);
358 QList<QAbstractAxis *> axisList = axes(Qt::Horizontal, series);
351 if (axisList.count())
359 if (axisList.count())
352 return axisList[0];
360 return axisList[0];
353 return 0;
361 return 0;
354 }
362 }
355
363
356 /*!
364 /*!
357 Returns a pointer to the vertical axis attached to the specified \a series.
365 Returns a pointer to the vertical axis attached to the specified \a series.
358 If no \a series is specified, the first vertical axis added to the chart is returned.
366 If no \a series is specified, the first vertical axis added to the chart is returned.
359
367
360 \sa addAxis(), QAbstractSeries::attachAxis()
368 \sa addAxis(), QAbstractSeries::attachAxis()
361 */
369 */
362 QAbstractAxis *QChart::axisY(QAbstractSeries *series) const
370 QAbstractAxis *QChart::axisY(QAbstractSeries *series) const
363 {
371 {
364 QList<QAbstractAxis *> axisList = axes(Qt::Vertical, series);
372 QList<QAbstractAxis *> axisList = axes(Qt::Vertical, series);
365 if (axisList.count())
373 if (axisList.count())
366 return axisList[0];
374 return axisList[0];
367 return 0;
375 return 0;
368 }
376 }
369
377
370 /*!
378 /*!
371 Returns the axes attached to the \a series with \a orientation. If no \a series is provided,
379 Returns the axes attached to the \a series with \a orientation. If no \a series is provided,
372 then all axes added to the chart with the specified orientation are returned.
380 then all axes added to the chart with the specified orientation are returned.
373 \sa addAxis(), createDefaultAxes()
381 \sa addAxis(), createDefaultAxes()
374 */
382 */
375 QList<QAbstractAxis *> QChart::axes(Qt::Orientations orientation, QAbstractSeries *series) const
383 QList<QAbstractAxis *> QChart::axes(Qt::Orientations orientation, QAbstractSeries *series) const
376 {
384 {
377 QList<QAbstractAxis *> result ;
385 QList<QAbstractAxis *> result ;
378
386
379 if (series) {
387 if (series) {
380 foreach (QAbstractAxis *axis, series->attachedAxes()){
388 foreach (QAbstractAxis *axis, series->attachedAxes()){
381 if (orientation.testFlag(axis->orientation()))
389 if (orientation.testFlag(axis->orientation()))
382 result << axis;
390 result << axis;
383 }
391 }
384 } else {
392 } else {
385 foreach (QAbstractAxis *axis, d_ptr->m_dataset->axes()){
393 foreach (QAbstractAxis *axis, d_ptr->m_dataset->axes()){
386 if (orientation.testFlag(axis->orientation()) && !result.contains(axis))
394 if (orientation.testFlag(axis->orientation()) && !result.contains(axis))
387 result << axis;
395 result << axis;
388 }
396 }
389 }
397 }
390
398
391 return result;
399 return result;
392 }
400 }
393
401
394 /*!
402 /*!
395 Creates axes for the chart based on the series that have already been added to the chart. Any axes previously added to
403 Creates axes for the chart based on the series that have already been added to the chart. Any axes previously added to
396 the chart will be deleted.
404 the chart will be deleted.
397
405
398 \note This function has to be called after all series have been added to the chart. The axes created by this function
406 \note This function has to be called after all series have been added to the chart. The axes created by this function
399 will NOT get automatically attached to any series added to the chart after this function has been called.
407 will NOT get automatically attached to any series added to the chart after this function has been called.
400 A series with no axes attached will by default scale to utilize the entire plot area of the chart, which can be confusing
408 A series with no axes attached will by default scale to utilize the entire plot area of the chart, which can be confusing
401 if there are other series with properly attached axes also present.
409 if there are other series with properly attached axes also present.
402
410
403 \table
411 \table
404 \header
412 \header
405 \o Series type
413 \o Series type
406 \o X-axis
414 \o X-axis
407 \o Y-axis
415 \o Y-axis
408 \row
416 \row
409 \o QXYSeries
417 \o QXYSeries
410 \o QValueAxis
418 \o QValueAxis
411 \o QValueAxis
419 \o QValueAxis
412 \row
420 \row
413 \o QBarSeries
421 \o QBarSeries
414 \o QBarCategoryAxis
422 \o QBarCategoryAxis
415 \o QValueAxis
423 \o QValueAxis
416 \row
424 \row
417 \o QPieSeries
425 \o QPieSeries
418 \o None
426 \o None
419 \o None
427 \o None
420 \endtable
428 \endtable
421
429
422 If there are several QXYSeries derived series added to the chart and no series of other types have been added, then only one pair of axes is created.
430 If there are several QXYSeries derived series added to the chart and no series of other types have been added, then only one pair of axes is created.
423 If there are several series of different types added to the chart, then each series gets its own axes pair.
431 If there are several series of different types added to the chart, then each series gets its own axes pair.
424
432
425 The axes specific to the series can be later obtained from the chart by providing the series as the parameter for axes() function call.
433 The axes specific to the series can be later obtained from the chart by providing the series as the parameter for axes() function call.
426 QPieSeries does not create any axes.
434 QPieSeries does not create any axes.
427
435
428 \sa axisX(), axisY(), axes(), setAxisX(), setAxisY(), QAbstractSeries::attachAxis()
436 \sa axisX(), axisY(), axes(), setAxisX(), setAxisY(), QAbstractSeries::attachAxis()
429 */
437 */
430 void QChart::createDefaultAxes()
438 void QChart::createDefaultAxes()
431 {
439 {
432 d_ptr->m_dataset->createDefaultAxes();
440 d_ptr->m_dataset->createDefaultAxes();
433 }
441 }
434
442
435 /*!
443 /*!
436 Returns the legend object of the chart. Ownership stays with the chart.
444 Returns the legend object of the chart. Ownership stays with the chart.
437 */
445 */
438 QLegend *QChart::legend() const
446 QLegend *QChart::legend() const
439 {
447 {
440 return d_ptr->m_legend;
448 return d_ptr->m_legend;
441 }
449 }
442
450
443 void QChart::setMinimumMargins(const QMargins &margins)
451 void QChart::setMinimumMargins(const QMargins &margins)
444 {
452 {
445 qWarning() << "QChart::setMinimumMargins is deprecated. Use QChart::setMargins instead.";
453 qWarning() << "QChart::setMinimumMargins is deprecated. Use QChart::setMargins instead.";
446 d_ptr->m_presenter->layout()->setMargins(margins);
454 d_ptr->m_presenter->layout()->setMargins(margins);
447 }
455 }
448
456
449 QMargins QChart::minimumMargins() const
457 QMargins QChart::minimumMargins() const
450 {
458 {
451 qWarning() << "QChart::minimumMargins is deprecated. Use QChart::margins instead.";
459 qWarning() << "QChart::minimumMargins is deprecated. Use QChart::margins instead.";
452 return d_ptr->m_presenter->layout()->margins();
460 return d_ptr->m_presenter->layout()->margins();
453 }
461 }
454
462
455 void QChart::setMargins(const QMargins &margins)
463 void QChart::setMargins(const QMargins &margins)
456 {
464 {
457 d_ptr->m_presenter->layout()->setMargins(margins);
465 d_ptr->m_presenter->layout()->setMargins(margins);
458 }
466 }
459
467
460 QMargins QChart::margins() const
468 QMargins QChart::margins() const
461 {
469 {
462 return d_ptr->m_presenter->layout()->margins();
470 return d_ptr->m_presenter->layout()->margins();
463 }
471 }
464
472
465 QChart::ChartType QChart::chartType() const
473 QChart::ChartType QChart::chartType() const
466 {
474 {
467 return d_ptr->m_type;
475 return d_ptr->m_type;
468 }
476 }
469
477
470 /*!
478 /*!
471 Returns the the rectangle within which the drawing of the chart is done.
479 Returns the the rectangle within which the drawing of the chart is done.
472 It does not include the area defined by margins.
480 It does not include the area defined by margins.
473 */
481 */
474 QRectF QChart::plotArea() const
482 QRectF QChart::plotArea() const
475 {
483 {
476 return d_ptr->m_presenter->geometry();
484 return d_ptr->m_presenter->geometry();
477 }
485 }
478
486
487 /*!
488 Sets the \a brush for the background of the plot area of the chart.
489
490 \sa plotArea(), plotAreaBackgroundVisible, setPlotAreaBackgroundPen(), plotAreaBackgroundBrush()
491 */
492 void QChart::setPlotAreaBackgroundBrush(const QBrush &brush)
493 {
494 d_ptr->m_presenter->setPlotAreaBackgroundBrush(brush);
495 }
496
497 /*!
498 Returns the brush for the background of the plot area of the chart.
499
500 \sa plotArea(), plotAreaBackgroundVisible, plotAreaBackgroundPen(), setPlotAreaBackgroundBrush()
501 */
502 QBrush QChart::plotAreaBackgroundBrush() const
503 {
504 return d_ptr->m_presenter->plotAreaBackgroundBrush();
505 }
506
507 /*!
508 Sets the \a pen for the background of the plot area of the chart.
509
510 \sa plotArea(), plotAreaBackgroundVisible, setPlotAreaBackgroundBrush(), plotAreaBackgroundPen()
511 */
512 void QChart::setPlotAreaBackgroundPen(const QPen &pen)
513 {
514 d_ptr->m_presenter->setPlotAreaBackgroundPen(pen);
515 }
516
517 /*!
518 Returns the \a pen for the background of the plot area of the chart.
519
520 \sa plotArea(), plotAreaBackgroundVisible, plotAreaBackgroundBrush(), setPlotAreaBackgroundPen()
521 */
522 QPen QChart::plotAreaBackgroundPen() const
523 {
524 return d_ptr->m_presenter->plotAreaBackgroundPen();
525 }
526
527 void QChart::setPlotAreaBackgroundVisible(bool visible)
528 {
529 d_ptr->m_presenter->setPlotAreaBackgroundVisible(visible);
530 }
531
532 bool QChart::isPlotAreaBackgroundVisible() const
533 {
534 return d_ptr->m_presenter->isPlotAreaBackgroundVisible();
535 }
536
479 void QChart::setAnimationOptions(AnimationOptions options)
537 void QChart::setAnimationOptions(AnimationOptions options)
480 {
538 {
481 d_ptr->m_presenter->setAnimationOptions(options);
539 d_ptr->m_presenter->setAnimationOptions(options);
482 }
540 }
483
541
484 QChart::AnimationOptions QChart::animationOptions() const
542 QChart::AnimationOptions QChart::animationOptions() const
485 {
543 {
486 return d_ptr->m_presenter->animationOptions();
544 return d_ptr->m_presenter->animationOptions();
487 }
545 }
488
546
489 /*!
547 /*!
490 Scrolls the visible area of the chart by the distance defined in the \a dx and \a dy.
548 Scrolls the visible area of the chart by the distance defined in the \a dx and \a dy.
491
549
492 For polar charts, \a dx indicates the angle along angular axis instead of distance.
550 For polar charts, \a dx indicates the angle along angular axis instead of distance.
493 */
551 */
494 void QChart::scroll(qreal dx, qreal dy)
552 void QChart::scroll(qreal dx, qreal dy)
495 {
553 {
496 d_ptr->scroll(dx,dy);
554 d_ptr->scroll(dx,dy);
497 }
555 }
498
556
499 void QChart::setBackgroundVisible(bool visible)
557 void QChart::setBackgroundVisible(bool visible)
500 {
558 {
501 d_ptr->m_presenter->setBackgroundVisible(visible);
559 d_ptr->m_presenter->setBackgroundVisible(visible);
502 }
560 }
503
561
504 bool QChart::isBackgroundVisible() const
562 bool QChart::isBackgroundVisible() const
505 {
563 {
506 return d_ptr->m_presenter->isBackgroundVisible();
564 return d_ptr->m_presenter->isBackgroundVisible();
507 }
565 }
508
566
509 void QChart::setDropShadowEnabled(bool enabled)
567 void QChart::setDropShadowEnabled(bool enabled)
510 {
568 {
511 d_ptr->m_presenter->setBackgroundDropShadowEnabled(enabled);
569 d_ptr->m_presenter->setBackgroundDropShadowEnabled(enabled);
512 }
570 }
513
571
514 bool QChart::isDropShadowEnabled() const
572 bool QChart::isDropShadowEnabled() const
515 {
573 {
516 return d_ptr->m_presenter->isBackgroundDropShadowEnabled();
574 return d_ptr->m_presenter->isBackgroundDropShadowEnabled();
517 }
575 }
518
576
519 /*!
577 /*!
520 Returns all series that are added to the chart.
578 Returns all series that are added to the chart.
521
579
522 \sa addSeries(), removeSeries(), removeAllSeries()
580 \sa addSeries(), removeSeries(), removeAllSeries()
523 */
581 */
524 QList<QAbstractSeries *> QChart::series() const
582 QList<QAbstractSeries *> QChart::series() const
525 {
583 {
526 return d_ptr->m_dataset->series();
584 return d_ptr->m_dataset->series();
527 }
585 }
528
586
529 /*!
587 /*!
530 Adds the \a axis to the chart and attaches it to the \a series as a bottom-aligned horizontal axis.
588 Adds the \a axis to the chart and attaches it to the \a series as a bottom-aligned horizontal axis.
531 The chart takes ownership of both the \a axis and the \a series.
589 The chart takes ownership of both the \a axis and the \a series.
532 Any horizontal axes previously attached to the \a series are deleted.
590 Any horizontal axes previously attached to the \a series are deleted.
533
591
534 \sa axisX(), axisY(), setAxisY(), createDefaultAxes(), QAbstractSeries::attachAxis()
592 \sa axisX(), axisY(), setAxisY(), createDefaultAxes(), QAbstractSeries::attachAxis()
535 */
593 */
536 void QChart::setAxisX(QAbstractAxis *axis ,QAbstractSeries *series)
594 void QChart::setAxisX(QAbstractAxis *axis ,QAbstractSeries *series)
537 {
595 {
538 QList<QAbstractAxis*> list = axes(Qt::Horizontal, series);
596 QList<QAbstractAxis*> list = axes(Qt::Horizontal, series);
539
597
540 foreach (QAbstractAxis* a, list) {
598 foreach (QAbstractAxis* a, list) {
541 d_ptr->m_dataset->removeAxis(a);
599 d_ptr->m_dataset->removeAxis(a);
542 delete a;
600 delete a;
543 }
601 }
544
602
545 if (!d_ptr->m_dataset->axes().contains(axis))
603 if (!d_ptr->m_dataset->axes().contains(axis))
546 d_ptr->m_dataset->addAxis(axis, Qt::AlignBottom);
604 d_ptr->m_dataset->addAxis(axis, Qt::AlignBottom);
547 d_ptr->m_dataset->attachAxis(series, axis);
605 d_ptr->m_dataset->attachAxis(series, axis);
548 }
606 }
549
607
550 /*!
608 /*!
551 Adds the \a axis to the chart and attaches it to the \a series as a left-aligned vertical axis.
609 Adds the \a axis to the chart and attaches it to the \a series as a left-aligned vertical axis.
552 The chart takes ownership of both the \a axis and the \a series.
610 The chart takes ownership of both the \a axis and the \a series.
553 Any vertical axes previously attached to the \a series are deleted.
611 Any vertical axes previously attached to the \a series are deleted.
554
612
555 \sa axisX(), axisY(), setAxisX(), createDefaultAxes(), QAbstractSeries::attachAxis()
613 \sa axisX(), axisY(), setAxisX(), createDefaultAxes(), QAbstractSeries::attachAxis()
556 */
614 */
557 void QChart::setAxisY(QAbstractAxis *axis ,QAbstractSeries *series)
615 void QChart::setAxisY(QAbstractAxis *axis ,QAbstractSeries *series)
558 {
616 {
559 QList<QAbstractAxis*> list = axes(Qt::Vertical, series);
617 QList<QAbstractAxis*> list = axes(Qt::Vertical, series);
560
618
561 foreach (QAbstractAxis* a, list) {
619 foreach (QAbstractAxis* a, list) {
562 d_ptr->m_dataset->removeAxis(a);
620 d_ptr->m_dataset->removeAxis(a);
563 delete a;
621 delete a;
564 }
622 }
565
623
566 if (!d_ptr->m_dataset->axes().contains(axis))
624 if (!d_ptr->m_dataset->axes().contains(axis))
567 d_ptr->m_dataset->addAxis(axis, Qt::AlignLeft);
625 d_ptr->m_dataset->addAxis(axis, Qt::AlignLeft);
568 d_ptr->m_dataset->attachAxis(series, axis);
626 d_ptr->m_dataset->attachAxis(series, axis);
569 }
627 }
570
628
571 /*!
629 /*!
572 Adds the \a axis to the chart with \a alignment. The chart takes the ownership of the axis.
630 Adds the \a axis to the chart with \a alignment. The chart takes the ownership of the axis.
573
631
574 \sa removeAxis(), createDefaultAxes(), QAbstractSeries::attachAxis()
632 \sa removeAxis(), createDefaultAxes(), QAbstractSeries::attachAxis()
575 */
633 */
576 void QChart::addAxis(QAbstractAxis *axis, Qt::Alignment alignment)
634 void QChart::addAxis(QAbstractAxis *axis, Qt::Alignment alignment)
577 {
635 {
578 d_ptr->m_dataset->addAxis(axis, alignment);
636 d_ptr->m_dataset->addAxis(axis, alignment);
579 }
637 }
580
638
581 /*!
639 /*!
582 Removes the \a axis from the chart.
640 Removes the \a axis from the chart.
583 The chart releases its ownership of the specified \a axis object.
641 The chart releases its ownership of the specified \a axis object.
584
642
585 \sa addAxis(), createDefaultAxes(), QAbstractSeries::detachAxis()
643 \sa addAxis(), createDefaultAxes(), QAbstractSeries::detachAxis()
586 */
644 */
587 void QChart::removeAxis(QAbstractAxis *axis)
645 void QChart::removeAxis(QAbstractAxis *axis)
588 {
646 {
589 d_ptr->m_dataset->removeAxis(axis);
647 d_ptr->m_dataset->removeAxis(axis);
590 }
648 }
591
649
592 /*!
650 /*!
593 Returns the value in the \a series domain that corresponds to the \a position relative to chart widget.
651 Returns the value in the \a series domain that corresponds to the \a position relative to chart widget.
594 */
652 */
595 QPointF QChart::mapToValue(const QPointF &position, QAbstractSeries *series)
653 QPointF QChart::mapToValue(const QPointF &position, QAbstractSeries *series)
596 {
654 {
597 return d_ptr->m_dataset->mapToValue(position, series);
655 return d_ptr->m_dataset->mapToValue(position, series);
598 }
656 }
599
657
600 /*!
658 /*!
601 Returns the position on the chart widget that corresponds to the \a value in the \a series domain.
659 Returns the position on the chart widget that corresponds to the \a value in the \a series domain.
602 */
660 */
603 QPointF QChart::mapToPosition(const QPointF &value, QAbstractSeries *series)
661 QPointF QChart::mapToPosition(const QPointF &value, QAbstractSeries *series)
604 {
662 {
605 return d_ptr->m_dataset->mapToPosition(value, series);
663 return d_ptr->m_dataset->mapToPosition(value, series);
606 }
664 }
607
665
608 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
666 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
609
667
610 QChartPrivate::QChartPrivate(QChart *q, QChart::ChartType type):
668 QChartPrivate::QChartPrivate(QChart *q, QChart::ChartType type):
611 q_ptr(q),
669 q_ptr(q),
612 m_type(type),
670 m_type(type),
613 m_legend(0),
671 m_legend(0),
614 m_dataset(new ChartDataSet(q)),
672 m_dataset(new ChartDataSet(q)),
615 m_presenter(new ChartPresenter(q, type)),
673 m_presenter(new ChartPresenter(q, type)),
616 m_themeManager(new ChartThemeManager(q))
674 m_themeManager(new ChartThemeManager(q))
617 {
675 {
618 QObject::connect(m_dataset, SIGNAL(seriesAdded(QAbstractSeries*)), m_presenter, SLOT(handleSeriesAdded(QAbstractSeries*)));
676 QObject::connect(m_dataset, SIGNAL(seriesAdded(QAbstractSeries*)), m_presenter, SLOT(handleSeriesAdded(QAbstractSeries*)));
619 QObject::connect(m_dataset, SIGNAL(seriesRemoved(QAbstractSeries*)), m_presenter, SLOT(handleSeriesRemoved(QAbstractSeries*)));
677 QObject::connect(m_dataset, SIGNAL(seriesRemoved(QAbstractSeries*)), m_presenter, SLOT(handleSeriesRemoved(QAbstractSeries*)));
620 QObject::connect(m_dataset, SIGNAL(axisAdded(QAbstractAxis*)), m_presenter, SLOT(handleAxisAdded(QAbstractAxis*)));
678 QObject::connect(m_dataset, SIGNAL(axisAdded(QAbstractAxis*)), m_presenter, SLOT(handleAxisAdded(QAbstractAxis*)));
621 QObject::connect(m_dataset, SIGNAL(axisRemoved(QAbstractAxis*)), m_presenter, SLOT(handleAxisRemoved(QAbstractAxis*)));
679 QObject::connect(m_dataset, SIGNAL(axisRemoved(QAbstractAxis*)), m_presenter, SLOT(handleAxisRemoved(QAbstractAxis*)));
622 QObject::connect(m_dataset, SIGNAL(seriesAdded(QAbstractSeries*)), m_themeManager, SLOT(handleSeriesAdded(QAbstractSeries*)));
680 QObject::connect(m_dataset, SIGNAL(seriesAdded(QAbstractSeries*)), m_themeManager, SLOT(handleSeriesAdded(QAbstractSeries*)));
623 QObject::connect(m_dataset, SIGNAL(seriesRemoved(QAbstractSeries*)), m_themeManager, SLOT(handleSeriesRemoved(QAbstractSeries*)));
681 QObject::connect(m_dataset, SIGNAL(seriesRemoved(QAbstractSeries*)), m_themeManager, SLOT(handleSeriesRemoved(QAbstractSeries*)));
624 QObject::connect(m_dataset, SIGNAL(axisAdded(QAbstractAxis*)), m_themeManager, SLOT(handleAxisAdded(QAbstractAxis*)));
682 QObject::connect(m_dataset, SIGNAL(axisAdded(QAbstractAxis*)), m_themeManager, SLOT(handleAxisAdded(QAbstractAxis*)));
625 QObject::connect(m_dataset, SIGNAL(axisRemoved(QAbstractAxis*)), m_themeManager, SLOT(handleAxisRemoved(QAbstractAxis*)));
683 QObject::connect(m_dataset, SIGNAL(axisRemoved(QAbstractAxis*)), m_themeManager, SLOT(handleAxisRemoved(QAbstractAxis*)));
626 }
684 }
627
685
628 QChartPrivate::~QChartPrivate()
686 QChartPrivate::~QChartPrivate()
629 {
687 {
630 }
688 }
631
689
632 void QChartPrivate::init()
690 void QChartPrivate::init()
633 {
691 {
634 m_legend = new LegendScroller(q_ptr);
692 m_legend = new LegendScroller(q_ptr);
635 q_ptr->setTheme(QChart::ChartThemeLight);
693 q_ptr->setTheme(QChart::ChartThemeLight);
636 q_ptr->setLayout(m_presenter->layout());
694 q_ptr->setLayout(m_presenter->layout());
637 }
695 }
638
696
639 void QChartPrivate::zoomIn(qreal factor)
697 void QChartPrivate::zoomIn(qreal factor)
640 {
698 {
641 QRectF rect = m_presenter->geometry();
699 QRectF rect = m_presenter->geometry();
642 rect.setWidth(rect.width() / factor);
700 rect.setWidth(rect.width() / factor);
643 rect.setHeight(rect.height() / factor);
701 rect.setHeight(rect.height() / factor);
644 rect.moveCenter(m_presenter->geometry().center());
702 rect.moveCenter(m_presenter->geometry().center());
645 zoomIn(rect);
703 zoomIn(rect);
646 }
704 }
647
705
648 void QChartPrivate::zoomIn(const QRectF &rect)
706 void QChartPrivate::zoomIn(const QRectF &rect)
649 {
707 {
650 if (!rect.isValid())
708 if (!rect.isValid())
651 return;
709 return;
652
710
653 QRectF r = rect.normalized();
711 QRectF r = rect.normalized();
654 const QRectF geometry = m_presenter->geometry();
712 const QRectF geometry = m_presenter->geometry();
655 r.translate(-geometry.topLeft());
713 r.translate(-geometry.topLeft());
656
714
657 if (!r.isValid())
715 if (!r.isValid())
658 return;
716 return;
659
717
660 QPointF zoomPoint(r.center().x() / geometry.width(), r.center().y() / geometry.height());
718 QPointF zoomPoint(r.center().x() / geometry.width(), r.center().y() / geometry.height());
661 m_presenter->setState(ChartPresenter::ZoomInState,zoomPoint);
719 m_presenter->setState(ChartPresenter::ZoomInState,zoomPoint);
662 m_dataset->zoomInDomain(r);
720 m_dataset->zoomInDomain(r);
663 m_presenter->setState(ChartPresenter::ShowState,QPointF());
721 m_presenter->setState(ChartPresenter::ShowState,QPointF());
664
722
665 }
723 }
666
724
667 void QChartPrivate::zoomOut(qreal factor)
725 void QChartPrivate::zoomOut(qreal factor)
668 {
726 {
669 const QRectF geometry = m_presenter->geometry();
727 const QRectF geometry = m_presenter->geometry();
670
728
671 QRectF r;
729 QRectF r;
672 r.setSize(geometry.size() / factor);
730 r.setSize(geometry.size() / factor);
673 r.moveCenter(QPointF(geometry.size().width()/2 ,geometry.size().height()/2));
731 r.moveCenter(QPointF(geometry.size().width()/2 ,geometry.size().height()/2));
674 if (!r.isValid())
732 if (!r.isValid())
675 return;
733 return;
676
734
677 QPointF zoomPoint(r.center().x() / geometry.width(), r.center().y() / geometry.height());
735 QPointF zoomPoint(r.center().x() / geometry.width(), r.center().y() / geometry.height());
678 m_presenter->setState(ChartPresenter::ZoomOutState,zoomPoint);
736 m_presenter->setState(ChartPresenter::ZoomOutState,zoomPoint);
679 m_dataset->zoomOutDomain(r);
737 m_dataset->zoomOutDomain(r);
680 m_presenter->setState(ChartPresenter::ShowState,QPointF());
738 m_presenter->setState(ChartPresenter::ShowState,QPointF());
681 }
739 }
682
740
683 void QChartPrivate::scroll(qreal dx, qreal dy)
741 void QChartPrivate::scroll(qreal dx, qreal dy)
684 {
742 {
685 if (dx < 0) m_presenter->setState(ChartPresenter::ScrollLeftState,QPointF());
743 if (dx < 0) m_presenter->setState(ChartPresenter::ScrollLeftState,QPointF());
686 if (dx > 0) m_presenter->setState(ChartPresenter::ScrollRightState,QPointF());
744 if (dx > 0) m_presenter->setState(ChartPresenter::ScrollRightState,QPointF());
687 if (dy < 0) m_presenter->setState(ChartPresenter::ScrollUpState,QPointF());
745 if (dy < 0) m_presenter->setState(ChartPresenter::ScrollUpState,QPointF());
688 if (dy > 0) m_presenter->setState(ChartPresenter::ScrollDownState,QPointF());
746 if (dy > 0) m_presenter->setState(ChartPresenter::ScrollDownState,QPointF());
689
747
690 m_dataset->scrollDomain(dx, dy);
748 m_dataset->scrollDomain(dx, dy);
691 m_presenter->setState(ChartPresenter::ShowState,QPointF());
749 m_presenter->setState(ChartPresenter::ShowState,QPointF());
692 }
750 }
693
751
694 #include "moc_qchart.cpp"
752 #include "moc_qchart.cpp"
695
753
696 QTCOMMERCIALCHART_END_NAMESPACE
754 QTCOMMERCIALCHART_END_NAMESPACE
@@ -1,162 +1,169
1 /****************************************************************************
1 /****************************************************************************
2 **
2 **
3 ** Copyright (C) 2013 Digia Plc
3 ** Copyright (C) 2013 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 class QChartPrivate;
36 class 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 minimumMargins READ minimumMargins WRITE setMinimumMargins)
46 Q_PROPERTY(QMargins minimumMargins READ minimumMargins WRITE setMinimumMargins)
47 Q_PROPERTY(QMargins margins READ margins WRITE setMargins)
47 Q_PROPERTY(QMargins margins READ margins WRITE setMargins)
48 Q_PROPERTY(QChart::ChartType chartType READ chartType)
48 Q_PROPERTY(QChart::ChartType chartType READ chartType)
49 Q_PROPERTY(bool plotAreaBackgroundVisible READ isPlotAreaBackgroundVisible WRITE setPlotAreaBackgroundVisible)
49 Q_ENUMS(ChartTheme)
50 Q_ENUMS(ChartTheme)
50 Q_ENUMS(AnimationOption)
51 Q_ENUMS(AnimationOption)
51 Q_ENUMS(ChartType)
52 Q_ENUMS(ChartType)
52
53
53 public:
54 public:
54 enum ChartType {
55 enum ChartType {
55 ChartTypeUndefined = 0,
56 ChartTypeUndefined = 0,
56 ChartTypeCartesian,
57 ChartTypeCartesian,
57 ChartTypePolar
58 ChartTypePolar
58 };
59 };
59
60
60 enum ChartTheme {
61 enum ChartTheme {
61 ChartThemeLight = 0,
62 ChartThemeLight = 0,
62 ChartThemeBlueCerulean,
63 ChartThemeBlueCerulean,
63 ChartThemeDark,
64 ChartThemeDark,
64 ChartThemeBrownSand,
65 ChartThemeBrownSand,
65 ChartThemeBlueNcs,
66 ChartThemeBlueNcs,
66 ChartThemeHighContrast,
67 ChartThemeHighContrast,
67 ChartThemeBlueIcy
68 ChartThemeBlueIcy
68 };
69 };
69
70
70 enum AnimationOption {
71 enum AnimationOption {
71 NoAnimation = 0x0,
72 NoAnimation = 0x0,
72 GridAxisAnimations = 0x1,
73 GridAxisAnimations = 0x1,
73 SeriesAnimations = 0x2,
74 SeriesAnimations = 0x2,
74 AllAnimations = 0x3
75 AllAnimations = 0x3
75 };
76 };
76
77
77 Q_DECLARE_FLAGS(AnimationOptions, AnimationOption)
78 Q_DECLARE_FLAGS(AnimationOptions, AnimationOption)
78
79
79 public:
80 public:
80 explicit QChart(QGraphicsItem *parent = 0, Qt::WindowFlags wFlags = 0);
81 explicit QChart(QGraphicsItem *parent = 0, Qt::WindowFlags wFlags = 0);
81 ~QChart();
82 ~QChart();
82
83
83 void addSeries(QAbstractSeries *series);
84 void addSeries(QAbstractSeries *series);
84 void removeSeries(QAbstractSeries *series);
85 void removeSeries(QAbstractSeries *series);
85 void removeAllSeries();
86 void removeAllSeries();
86 QList<QAbstractSeries *> series() const;
87 QList<QAbstractSeries *> series() const;
87
88
88 // *** deprecated ***
89 // *** deprecated ***
89 void setAxisX(QAbstractAxis *axis, QAbstractSeries *series = 0);
90 void setAxisX(QAbstractAxis *axis, QAbstractSeries *series = 0);
90 void setAxisY(QAbstractAxis *axis, QAbstractSeries *series = 0);
91 void setAxisY(QAbstractAxis *axis, QAbstractSeries *series = 0);
91 QAbstractAxis *axisX(QAbstractSeries *series = 0) const;
92 QAbstractAxis *axisX(QAbstractSeries *series = 0) const;
92 QAbstractAxis *axisY(QAbstractSeries *series = 0) const;
93 QAbstractAxis *axisY(QAbstractSeries *series = 0) const;
93 // ******************
94 // ******************
94
95
95 void addAxis(QAbstractAxis *axis, Qt::Alignment alignment);
96 void addAxis(QAbstractAxis *axis, Qt::Alignment alignment);
96 void removeAxis(QAbstractAxis *axis);
97 void removeAxis(QAbstractAxis *axis);
97 QList<QAbstractAxis*> axes(Qt::Orientations orientation = Qt::Horizontal|Qt::Vertical, QAbstractSeries *series = 0) const;
98 QList<QAbstractAxis*> axes(Qt::Orientations orientation = Qt::Horizontal|Qt::Vertical, QAbstractSeries *series = 0) const;
98
99
99 void createDefaultAxes();
100 void createDefaultAxes();
100
101
101 void setTheme(QChart::ChartTheme theme);
102 void setTheme(QChart::ChartTheme theme);
102 QChart::ChartTheme theme() const;
103 QChart::ChartTheme theme() const;
103
104
104 void setTitle(const QString &title);
105 void setTitle(const QString &title);
105 QString title() const;
106 QString title() const;
106 void setTitleFont(const QFont &font);
107 void setTitleFont(const QFont &font);
107 QFont titleFont() const;
108 QFont titleFont() const;
108 void setTitleBrush(const QBrush &brush);
109 void setTitleBrush(const QBrush &brush);
109 QBrush titleBrush() const;
110 QBrush titleBrush() const;
110
111
111 void setBackgroundBrush(const QBrush &brush);
112 void setBackgroundBrush(const QBrush &brush);
112 QBrush backgroundBrush() const;
113 QBrush backgroundBrush() const;
113 void setBackgroundPen(const QPen &pen);
114 void setBackgroundPen(const QPen &pen);
114 QPen backgroundPen() const;
115 QPen backgroundPen() const;
115 void setBackgroundVisible(bool visible = true);
116 void setBackgroundVisible(bool visible = true);
116 bool isBackgroundVisible() const;
117 bool isBackgroundVisible() const;
117
118
118 void setDropShadowEnabled(bool enabled = true);
119 void setDropShadowEnabled(bool enabled = true);
119 bool isDropShadowEnabled() const;
120 bool isDropShadowEnabled() const;
120 void setAnimationOptions(AnimationOptions options);
121 void setAnimationOptions(AnimationOptions options);
121 AnimationOptions animationOptions() const;
122 AnimationOptions animationOptions() const;
122
123
123 void zoomIn();
124 void zoomIn();
124 void zoomOut();
125 void zoomOut();
125
126
126 void zoomIn(const QRectF &rect);
127 void zoomIn(const QRectF &rect);
127 void zoom(qreal factor);
128 void zoom(qreal factor);
128
129
129 void scroll(qreal dx, qreal dy);
130 void scroll(qreal dx, qreal dy);
130
131
131 QLegend *legend() const;
132 QLegend *legend() const;
132
133
133 void setMinimumMargins(const QMargins& margins);
134 void setMinimumMargins(const QMargins& margins);
134 QMargins minimumMargins() const;
135 QMargins minimumMargins() const;
135
136
136 void setMargins(const QMargins &margins);
137 void setMargins(const QMargins &margins);
137 QMargins margins() const;
138 QMargins margins() const;
138
139
139 QRectF plotArea() const;
140 QRectF plotArea() const;
141 void setPlotAreaBackgroundBrush(const QBrush &brush);
142 QBrush plotAreaBackgroundBrush() const;
143 void setPlotAreaBackgroundPen(const QPen &pen);
144 QPen plotAreaBackgroundPen() const;
145 void setPlotAreaBackgroundVisible(bool visible = true);
146 bool isPlotAreaBackgroundVisible() const;
140
147
141 QPointF mapToValue(const QPointF &position, QAbstractSeries *series = 0);
148 QPointF mapToValue(const QPointF &position, QAbstractSeries *series = 0);
142 QPointF mapToPosition(const QPointF &value, QAbstractSeries *series = 0);
149 QPointF mapToPosition(const QPointF &value, QAbstractSeries *series = 0);
143
150
144 ChartType chartType() const;
151 ChartType chartType() const;
145
152
146 protected:
153 protected:
147 explicit QChart(QChart::ChartType type, QGraphicsItem *parent, Qt::WindowFlags wFlags);
154 explicit QChart(QChart::ChartType type, QGraphicsItem *parent, Qt::WindowFlags wFlags);
148 QScopedPointer<QChartPrivate> d_ptr;
155 QScopedPointer<QChartPrivate> d_ptr;
149 friend class QLegend;
156 friend class QLegend;
150 friend class DeclarativeChart;
157 friend class DeclarativeChart;
151 friend class ChartDataSet;
158 friend class ChartDataSet;
152 friend class ChartPresenter;
159 friend class ChartPresenter;
153 friend class ChartThemeManager;
160 friend class ChartThemeManager;
154 friend class QAbstractSeries;
161 friend class QAbstractSeries;
155 Q_DISABLE_COPY(QChart)
162 Q_DISABLE_COPY(QChart)
156 };
163 };
157
164
158 QTCOMMERCIALCHART_END_NAMESPACE
165 QTCOMMERCIALCHART_END_NAMESPACE
159
166
160 Q_DECLARE_OPERATORS_FOR_FLAGS(QTCOMMERCIALCHART_NAMESPACE::QChart::AnimationOptions)
167 Q_DECLARE_OPERATORS_FOR_FLAGS(QTCOMMERCIALCHART_NAMESPACE::QChart::AnimationOptions)
161
168
162 #endif // QCHART_H
169 #endif // QCHART_H
@@ -1,909 +1,961
1 /****************************************************************************
1 /****************************************************************************
2 **
2 **
3 ** Copyright (C) 2013 Digia Plc
3 ** Copyright (C) 2013 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 <QtTest/QtTest>
21 #include <QtTest/QtTest>
22 #include <qchartview.h>
22 #include <qchartview.h>
23 #include <qlineseries.h>
23 #include <qlineseries.h>
24 #include <qareaseries.h>
24 #include <qareaseries.h>
25 #include <qscatterseries.h>
25 #include <qscatterseries.h>
26 #include <qsplineseries.h>
26 #include <qsplineseries.h>
27 #include <qpieseries.h>
27 #include <qpieseries.h>
28 #include <qabstractbarseries.h>
28 #include <qabstractbarseries.h>
29 #include <qbarseries.h>
29 #include <qbarseries.h>
30 #include <qpercentbarseries.h>
30 #include <qpercentbarseries.h>
31 #include <qstackedbarseries.h>
31 #include <qstackedbarseries.h>
32 #include <qvalueaxis.h>
32 #include <qvalueaxis.h>
33 #include <qbarcategoryaxis.h>
33 #include <qbarcategoryaxis.h>
34 #include "tst_definitions.h"
34 #include "tst_definitions.h"
35
35
36 QTCOMMERCIALCHART_USE_NAMESPACE
36 QTCOMMERCIALCHART_USE_NAMESPACE
37
37
38 Q_DECLARE_METATYPE(QAbstractAxis *)
38 Q_DECLARE_METATYPE(QAbstractAxis *)
39 Q_DECLARE_METATYPE(QValueAxis *)
39 Q_DECLARE_METATYPE(QValueAxis *)
40 Q_DECLARE_METATYPE(QBarCategoryAxis *)
40 Q_DECLARE_METATYPE(QBarCategoryAxis *)
41 Q_DECLARE_METATYPE(QAbstractSeries *)
41 Q_DECLARE_METATYPE(QAbstractSeries *)
42 Q_DECLARE_METATYPE(QChart::AnimationOption)
42 Q_DECLARE_METATYPE(QChart::AnimationOption)
43 Q_DECLARE_METATYPE(QBrush)
43 Q_DECLARE_METATYPE(QBrush)
44 Q_DECLARE_METATYPE(QPen)
44 Q_DECLARE_METATYPE(QPen)
45 Q_DECLARE_METATYPE(QChart::ChartTheme)
45 Q_DECLARE_METATYPE(QChart::ChartTheme)
46
46
47 class tst_QChart : public QObject
47 class tst_QChart : public QObject
48 {
48 {
49 Q_OBJECT
49 Q_OBJECT
50
50
51 public slots:
51 public slots:
52 void initTestCase();
52 void initTestCase();
53 void cleanupTestCase();
53 void cleanupTestCase();
54 void init();
54 void init();
55 void cleanup();
55 void cleanup();
56
56
57 private slots:
57 private slots:
58 void qchart_data();
58 void qchart_data();
59 void qchart();
59 void qchart();
60 void addSeries_data();
60 void addSeries_data();
61 void addSeries();
61 void addSeries();
62 void animationOptions_data();
62 void animationOptions_data();
63 void animationOptions();
63 void animationOptions();
64 void axisX_data();
64 void axisX_data();
65 void axisX();
65 void axisX();
66 void axisY_data();
66 void axisY_data();
67 void axisY();
67 void axisY();
68 void backgroundBrush_data();
68 void backgroundBrush_data();
69 void backgroundBrush();
69 void backgroundBrush();
70 void backgroundPen_data();
70 void backgroundPen_data();
71 void backgroundPen();
71 void backgroundPen();
72 void isBackgroundVisible_data();
72 void isBackgroundVisible_data();
73 void isBackgroundVisible();
73 void isBackgroundVisible();
74 void plotAreaBackgroundBrush_data();
75 void plotAreaBackgroundBrush();
76 void plotAreaBackgroundPen_data();
77 void plotAreaBackgroundPen();
78 void isPlotAreaBackgroundVisible_data();
79 void isPlotAreaBackgroundVisible();
74 void legend_data();
80 void legend_data();
75 void legend();
81 void legend();
76 void plotArea_data();
82 void plotArea_data();
77 void plotArea();
83 void plotArea();
78 void removeAllSeries_data();
84 void removeAllSeries_data();
79 void removeAllSeries();
85 void removeAllSeries();
80 void removeSeries_data();
86 void removeSeries_data();
81 void removeSeries();
87 void removeSeries();
82 void scroll_right_data();
88 void scroll_right_data();
83 void scroll_right();
89 void scroll_right();
84 void scroll_left_data();
90 void scroll_left_data();
85 void scroll_left();
91 void scroll_left();
86 void scroll_up_data();
92 void scroll_up_data();
87 void scroll_up();
93 void scroll_up();
88 void scroll_down_data();
94 void scroll_down_data();
89 void scroll_down();
95 void scroll_down();
90 void theme_data();
96 void theme_data();
91 void theme();
97 void theme();
92 void title_data();
98 void title_data();
93 void title();
99 void title();
94 void titleBrush_data();
100 void titleBrush_data();
95 void titleBrush();
101 void titleBrush();
96 void titleFont_data();
102 void titleFont_data();
97 void titleFont();
103 void titleFont();
98 void zoomIn_data();
104 void zoomIn_data();
99 void zoomIn();
105 void zoomIn();
100 void zoomOut_data();
106 void zoomOut_data();
101 void zoomOut();
107 void zoomOut();
102 void createDefaultAxesForLineSeries_data();
108 void createDefaultAxesForLineSeries_data();
103 void createDefaultAxesForLineSeries();
109 void createDefaultAxesForLineSeries();
104 void axisPolarOrientation();
110 void axisPolarOrientation();
105 private:
111 private:
106 void createTestData();
112 void createTestData();
107
113
108 private:
114 private:
109 QChartView* m_view;
115 QChartView* m_view;
110 QChart* m_chart;
116 QChart* m_chart;
111 };
117 };
112
118
113 void tst_QChart::initTestCase()
119 void tst_QChart::initTestCase()
114 {
120 {
115
121
116 }
122 }
117
123
118 void tst_QChart::cleanupTestCase()
124 void tst_QChart::cleanupTestCase()
119 {
125 {
120
126
121 }
127 }
122
128
123 void tst_QChart::init()
129 void tst_QChart::init()
124 {
130 {
125 m_view = new QChartView(newQChartOrQPolarChart());
131 m_view = new QChartView(newQChartOrQPolarChart());
126 m_chart = m_view->chart();
132 m_chart = m_view->chart();
127 }
133 }
128
134
129 void tst_QChart::cleanup()
135 void tst_QChart::cleanup()
130 {
136 {
131 delete m_view;
137 delete m_view;
132 m_view = 0;
138 m_view = 0;
133 m_chart = 0;
139 m_chart = 0;
134 }
140 }
135
141
136
142
137 void tst_QChart::createTestData()
143 void tst_QChart::createTestData()
138 {
144 {
139 QLineSeries* series0 = new QLineSeries(this);
145 QLineSeries* series0 = new QLineSeries(this);
140 *series0 << QPointF(0, 0) << QPointF(100, 100);
146 *series0 << QPointF(0, 0) << QPointF(100, 100);
141 m_chart->addSeries(series0);
147 m_chart->addSeries(series0);
142 m_view->show();
148 m_view->show();
143 QTest::qWaitForWindowShown(m_view);
149 QTest::qWaitForWindowShown(m_view);
144 }
150 }
145
151
146 void tst_QChart::qchart_data()
152 void tst_QChart::qchart_data()
147 {
153 {
148 }
154 }
149
155
150 void tst_QChart::qchart()
156 void tst_QChart::qchart()
151 {
157 {
152 QVERIFY(m_chart);
158 QVERIFY(m_chart);
153 QVERIFY(m_chart->legend());
159 QVERIFY(m_chart->legend());
154 QVERIFY(m_chart->legend()->isVisible());
160 QVERIFY(m_chart->legend()->isVisible());
155
161
156 QCOMPARE(m_chart->animationOptions(), QChart::NoAnimation);
162 QCOMPARE(m_chart->animationOptions(), QChart::NoAnimation);
157 QVERIFY(!m_chart->axisX());
163 QVERIFY(!m_chart->axisX());
158 QVERIFY(!m_chart->axisY());
164 QVERIFY(!m_chart->axisY());
159 QVERIFY(m_chart->backgroundBrush()!=QBrush());
165 QVERIFY(m_chart->backgroundBrush()!=QBrush());
160 QVERIFY(m_chart->backgroundPen()!=QPen());
166 QVERIFY(m_chart->backgroundPen()!=QPen());
161 QCOMPARE(m_chart->isBackgroundVisible(), true);
167 QCOMPARE(m_chart->isBackgroundVisible(), true);
162 QVERIFY(m_chart->plotArea().top()==0);
168 QVERIFY(m_chart->plotArea().top()==0);
163 QVERIFY(m_chart->plotArea().left()==0);
169 QVERIFY(m_chart->plotArea().left()==0);
164 QVERIFY(m_chart->plotArea().right()==0);
170 QVERIFY(m_chart->plotArea().right()==0);
165 QVERIFY(m_chart->plotArea().bottom()==0);
171 QVERIFY(m_chart->plotArea().bottom()==0);
166 QCOMPARE(m_chart->theme(), QChart::ChartThemeLight);
172 QCOMPARE(m_chart->theme(), QChart::ChartThemeLight);
167 QCOMPARE(m_chart->title(), QString());
173 QCOMPARE(m_chart->title(), QString());
168
174
169 //QCOMPARE(m_chart->titleBrush(),QBrush());
175 //QCOMPARE(m_chart->titleBrush(),QBrush());
170 //QCOMPARE(m_chart->titleFont(),QFont());
176 //QCOMPARE(m_chart->titleFont(),QFont());
171
177
172 m_chart->removeAllSeries();
178 m_chart->removeAllSeries();
173 m_chart->scroll(0,0);
179 m_chart->scroll(0,0);
174
180
175 m_chart->zoomIn();
181 m_chart->zoomIn();
176 m_chart->zoomIn(QRectF());
182 m_chart->zoomIn(QRectF());
177 m_chart->zoomOut();
183 m_chart->zoomOut();
178
184
179 m_view->show();
185 m_view->show();
180
186
181 QVERIFY(m_chart->plotArea().top()>0);
187 QVERIFY(m_chart->plotArea().top()>0);
182 QVERIFY(m_chart->plotArea().left()>0);
188 QVERIFY(m_chart->plotArea().left()>0);
183 QVERIFY(m_chart->plotArea().right()>0);
189 QVERIFY(m_chart->plotArea().right()>0);
184 QVERIFY(m_chart->plotArea().bottom()>0);
190 QVERIFY(m_chart->plotArea().bottom()>0);
185 }
191 }
186
192
187 void tst_QChart::addSeries_data()
193 void tst_QChart::addSeries_data()
188 {
194 {
189 QTest::addColumn<QAbstractSeries *>("series");
195 QTest::addColumn<QAbstractSeries *>("series");
190
196
191 QAbstractSeries* line = new QLineSeries(this);
197 QAbstractSeries* line = new QLineSeries(this);
192 QAbstractSeries* area = new QAreaSeries(static_cast<QLineSeries*>(line));
198 QAbstractSeries* area = new QAreaSeries(static_cast<QLineSeries*>(line));
193 QAbstractSeries* scatter = new QScatterSeries(this);
199 QAbstractSeries* scatter = new QScatterSeries(this);
194 QAbstractSeries* spline = new QSplineSeries(this);
200 QAbstractSeries* spline = new QSplineSeries(this);
195
201
196 QTest::newRow("lineSeries") << line;
202 QTest::newRow("lineSeries") << line;
197 QTest::newRow("areaSeries") << area;
203 QTest::newRow("areaSeries") << area;
198 QTest::newRow("scatterSeries") << scatter;
204 QTest::newRow("scatterSeries") << scatter;
199 QTest::newRow("splineSeries") << spline;
205 QTest::newRow("splineSeries") << spline;
200
206
201 if (!isPolarTest()) {
207 if (!isPolarTest()) {
202 QAbstractSeries* pie = new QPieSeries(this);
208 QAbstractSeries* pie = new QPieSeries(this);
203 QAbstractSeries* bar = new QBarSeries(this);
209 QAbstractSeries* bar = new QBarSeries(this);
204 QAbstractSeries* percent = new QPercentBarSeries(this);
210 QAbstractSeries* percent = new QPercentBarSeries(this);
205 QAbstractSeries* stacked = new QStackedBarSeries(this);
211 QAbstractSeries* stacked = new QStackedBarSeries(this);
206 QTest::newRow("pieSeries") << pie;
212 QTest::newRow("pieSeries") << pie;
207 QTest::newRow("barSeries") << bar;
213 QTest::newRow("barSeries") << bar;
208 QTest::newRow("percentBarSeries") << percent;
214 QTest::newRow("percentBarSeries") << percent;
209 QTest::newRow("stackedBarSeries") << stacked;
215 QTest::newRow("stackedBarSeries") << stacked;
210 }
216 }
211 }
217 }
212
218
213 void tst_QChart::addSeries()
219 void tst_QChart::addSeries()
214 {
220 {
215 QFETCH(QAbstractSeries *, series);
221 QFETCH(QAbstractSeries *, series);
216 m_view->show();
222 m_view->show();
217 QTest::qWaitForWindowShown(m_view);
223 QTest::qWaitForWindowShown(m_view);
218 QVERIFY(!series->chart());
224 QVERIFY(!series->chart());
219 QCOMPARE(m_chart->series().count(), 0);
225 QCOMPARE(m_chart->series().count(), 0);
220 m_chart->addSeries(series);
226 m_chart->addSeries(series);
221 QCOMPARE(m_chart->series().count(), 1);
227 QCOMPARE(m_chart->series().count(), 1);
222 QCOMPARE(m_chart->series().first(), series);
228 QCOMPARE(m_chart->series().first(), series);
223 QVERIFY(series->chart() == m_chart);
229 QVERIFY(series->chart() == m_chart);
224 m_chart->createDefaultAxes();
230 m_chart->createDefaultAxes();
225 if(series->type()!=QAbstractSeries::SeriesTypePie){
231 if(series->type()!=QAbstractSeries::SeriesTypePie){
226 QVERIFY(m_chart->axisY(series));
232 QVERIFY(m_chart->axisY(series));
227 QVERIFY(m_chart->axisX(series));
233 QVERIFY(m_chart->axisX(series));
228 }else{
234 }else{
229 QVERIFY(!m_chart->axisY(series));
235 QVERIFY(!m_chart->axisY(series));
230 QVERIFY(!m_chart->axisX(series));
236 QVERIFY(!m_chart->axisX(series));
231 }
237 }
232 m_chart->removeSeries(series);
238 m_chart->removeSeries(series);
233 QVERIFY(!series->chart());
239 QVERIFY(!series->chart());
234 QCOMPARE(m_chart->series().count(), 0);
240 QCOMPARE(m_chart->series().count(), 0);
235 }
241 }
236
242
237 void tst_QChart::animationOptions_data()
243 void tst_QChart::animationOptions_data()
238 {
244 {
239 QTest::addColumn<QChart::AnimationOption>("animationOptions");
245 QTest::addColumn<QChart::AnimationOption>("animationOptions");
240 QTest::newRow("AllAnimations") << QChart::AllAnimations;
246 QTest::newRow("AllAnimations") << QChart::AllAnimations;
241 QTest::newRow("NoAnimation") << QChart::NoAnimation;
247 QTest::newRow("NoAnimation") << QChart::NoAnimation;
242 QTest::newRow("GridAxisAnimations") << QChart::GridAxisAnimations;
248 QTest::newRow("GridAxisAnimations") << QChart::GridAxisAnimations;
243 QTest::newRow("SeriesAnimations") << QChart::SeriesAnimations;
249 QTest::newRow("SeriesAnimations") << QChart::SeriesAnimations;
244 }
250 }
245
251
246 void tst_QChart::animationOptions()
252 void tst_QChart::animationOptions()
247 {
253 {
248 createTestData();
254 createTestData();
249 QFETCH(QChart::AnimationOption, animationOptions);
255 QFETCH(QChart::AnimationOption, animationOptions);
250 m_chart->setAnimationOptions(animationOptions);
256 m_chart->setAnimationOptions(animationOptions);
251 QCOMPARE(m_chart->animationOptions(), animationOptions);
257 QCOMPARE(m_chart->animationOptions(), animationOptions);
252 }
258 }
253
259
254 void tst_QChart::axisX_data()
260 void tst_QChart::axisX_data()
255 {
261 {
256
262
257 QTest::addColumn<QAbstractAxis*>("axis");
263 QTest::addColumn<QAbstractAxis*>("axis");
258 QTest::addColumn<QAbstractSeries *>("series");
264 QTest::addColumn<QAbstractSeries *>("series");
259
265
260 QTest::newRow("categories,lineSeries") << (QAbstractAxis*) new QBarCategoryAxis() << (QAbstractSeries*) new QLineSeries(this);
266 QTest::newRow("categories,lineSeries") << (QAbstractAxis*) new QBarCategoryAxis() << (QAbstractSeries*) new QLineSeries(this);
261 QTest::newRow("categories,areaSeries") << (QAbstractAxis*) new QBarCategoryAxis() << (QAbstractSeries*) new QAreaSeries(new QLineSeries(this));
267 QTest::newRow("categories,areaSeries") << (QAbstractAxis*) new QBarCategoryAxis() << (QAbstractSeries*) new QAreaSeries(new QLineSeries(this));
262 QTest::newRow("categories,scatterSeries") << (QAbstractAxis*) new QBarCategoryAxis() << (QAbstractSeries*) new QScatterSeries(this);
268 QTest::newRow("categories,scatterSeries") << (QAbstractAxis*) new QBarCategoryAxis() << (QAbstractSeries*) new QScatterSeries(this);
263 QTest::newRow("categories,splineSeries") << (QAbstractAxis*) new QBarCategoryAxis() << (QAbstractSeries*) new QSplineSeries(this);
269 QTest::newRow("categories,splineSeries") << (QAbstractAxis*) new QBarCategoryAxis() << (QAbstractSeries*) new QSplineSeries(this);
264 if (!isPolarTest()) {
270 if (!isPolarTest()) {
265 QTest::newRow("categories,pieSeries") << (QAbstractAxis*) new QBarCategoryAxis() << (QAbstractSeries*) new QPieSeries(this);
271 QTest::newRow("categories,pieSeries") << (QAbstractAxis*) new QBarCategoryAxis() << (QAbstractSeries*) new QPieSeries(this);
266 QTest::newRow("categories,barSeries") << (QAbstractAxis*) new QBarCategoryAxis() << (QAbstractSeries*) new QBarSeries(this);
272 QTest::newRow("categories,barSeries") << (QAbstractAxis*) new QBarCategoryAxis() << (QAbstractSeries*) new QBarSeries(this);
267 QTest::newRow("categories,percentBarSeries") << (QAbstractAxis*) new QBarCategoryAxis() << (QAbstractSeries*) new QPercentBarSeries(this);
273 QTest::newRow("categories,percentBarSeries") << (QAbstractAxis*) new QBarCategoryAxis() << (QAbstractSeries*) new QPercentBarSeries(this);
268 QTest::newRow("categories,stackedBarSeries") << (QAbstractAxis*) new QBarCategoryAxis() << (QAbstractSeries*) new QStackedBarSeries(this);
274 QTest::newRow("categories,stackedBarSeries") << (QAbstractAxis*) new QBarCategoryAxis() << (QAbstractSeries*) new QStackedBarSeries(this);
269 }
275 }
270
276
271 QTest::newRow("value,lineSeries") << (QAbstractAxis*) new QValueAxis() << (QAbstractSeries*) new QLineSeries(this);
277 QTest::newRow("value,lineSeries") << (QAbstractAxis*) new QValueAxis() << (QAbstractSeries*) new QLineSeries(this);
272 QTest::newRow("value,areaSeries") << (QAbstractAxis*) new QValueAxis() << (QAbstractSeries*) new QAreaSeries(new QLineSeries(this));
278 QTest::newRow("value,areaSeries") << (QAbstractAxis*) new QValueAxis() << (QAbstractSeries*) new QAreaSeries(new QLineSeries(this));
273 QTest::newRow("value,scatterSeries") << (QAbstractAxis*) new QValueAxis() << (QAbstractSeries*) new QScatterSeries(this);
279 QTest::newRow("value,scatterSeries") << (QAbstractAxis*) new QValueAxis() << (QAbstractSeries*) new QScatterSeries(this);
274 QTest::newRow("value,splineSeries") << (QAbstractAxis*) new QValueAxis() << (QAbstractSeries*) new QSplineSeries(this);
280 QTest::newRow("value,splineSeries") << (QAbstractAxis*) new QValueAxis() << (QAbstractSeries*) new QSplineSeries(this);
275 if (!isPolarTest()) {
281 if (!isPolarTest()) {
276 QTest::newRow("value,pieSeries") << (QAbstractAxis*) new QValueAxis() << (QAbstractSeries*) new QPieSeries(this);
282 QTest::newRow("value,pieSeries") << (QAbstractAxis*) new QValueAxis() << (QAbstractSeries*) new QPieSeries(this);
277 QTest::newRow("value,barSeries") << (QAbstractAxis*) new QValueAxis() << (QAbstractSeries*) new QBarSeries(this);
283 QTest::newRow("value,barSeries") << (QAbstractAxis*) new QValueAxis() << (QAbstractSeries*) new QBarSeries(this);
278 QTest::newRow("value,percentBarSeries") << (QAbstractAxis*) new QValueAxis() << (QAbstractSeries*) new QPercentBarSeries(this);
284 QTest::newRow("value,percentBarSeries") << (QAbstractAxis*) new QValueAxis() << (QAbstractSeries*) new QPercentBarSeries(this);
279 QTest::newRow("value,stackedBarSeries") << (QAbstractAxis*) new QValueAxis() << (QAbstractSeries*) new QStackedBarSeries(this);
285 QTest::newRow("value,stackedBarSeries") << (QAbstractAxis*) new QValueAxis() << (QAbstractSeries*) new QStackedBarSeries(this);
280 }
286 }
281 }
287 }
282
288
283 void tst_QChart::axisX()
289 void tst_QChart::axisX()
284 {
290 {
285 QFETCH(QAbstractAxis*, axis);
291 QFETCH(QAbstractAxis*, axis);
286 QFETCH(QAbstractSeries*, series);
292 QFETCH(QAbstractSeries*, series);
287 QVERIFY(!m_chart->axisX());
293 QVERIFY(!m_chart->axisX());
288 m_view->show();
294 m_view->show();
289 QTest::qWaitForWindowShown(m_view);
295 QTest::qWaitForWindowShown(m_view);
290 m_chart->addSeries(series);
296 m_chart->addSeries(series);
291 m_chart->setAxisX(axis,series);
297 m_chart->setAxisX(axis,series);
292 QVERIFY(m_chart->axisX(series)==axis);
298 QVERIFY(m_chart->axisX(series)==axis);
293 }
299 }
294
300
295 void tst_QChart::axisY_data()
301 void tst_QChart::axisY_data()
296 {
302 {
297 axisX_data();
303 axisX_data();
298 }
304 }
299
305
300
306
301 void tst_QChart::axisY()
307 void tst_QChart::axisY()
302 {
308 {
303 QFETCH(QAbstractAxis*, axis);
309 QFETCH(QAbstractAxis*, axis);
304 QFETCH(QAbstractSeries*, series);
310 QFETCH(QAbstractSeries*, series);
305 QVERIFY(!m_chart->axisY());
311 QVERIFY(!m_chart->axisY());
306 m_view->show();
312 m_view->show();
307 QTest::qWaitForWindowShown(m_view);
313 QTest::qWaitForWindowShown(m_view);
308 m_chart->addSeries(series);
314 m_chart->addSeries(series);
309 m_chart->setAxisY(axis,series);
315 m_chart->setAxisY(axis,series);
310 QVERIFY(m_chart->axisY(series)==axis);
316 QVERIFY(m_chart->axisY(series)==axis);
311 }
317 }
312
318
313 void tst_QChart::backgroundBrush_data()
319 void tst_QChart::backgroundBrush_data()
314 {
320 {
315 QTest::addColumn<QBrush>("backgroundBrush");
321 QTest::addColumn<QBrush>("backgroundBrush");
316 QTest::newRow("null") << QBrush();
322 QTest::newRow("null") << QBrush();
317 QTest::newRow("blue") << QBrush(Qt::blue);
323 QTest::newRow("blue") << QBrush(Qt::blue);
318 QTest::newRow("white") << QBrush(Qt::white);
324 QTest::newRow("white") << QBrush(Qt::white);
319 QTest::newRow("black") << QBrush(Qt::black);
325 QTest::newRow("black") << QBrush(Qt::black);
320 }
326 }
321
327
322 void tst_QChart::backgroundBrush()
328 void tst_QChart::backgroundBrush()
323 {
329 {
324 QFETCH(QBrush, backgroundBrush);
330 QFETCH(QBrush, backgroundBrush);
325 m_chart->setBackgroundBrush(backgroundBrush);
331 m_chart->setBackgroundBrush(backgroundBrush);
326 QCOMPARE(m_chart->backgroundBrush(), backgroundBrush);
332 QCOMPARE(m_chart->backgroundBrush(), backgroundBrush);
327 }
333 }
328
334
329 void tst_QChart::backgroundPen_data()
335 void tst_QChart::backgroundPen_data()
330 {
336 {
331 QTest::addColumn<QPen>("backgroundPen");
337 QTest::addColumn<QPen>("backgroundPen");
332 QTest::newRow("null") << QPen();
338 QTest::newRow("null") << QPen();
333 QTest::newRow("blue") << QPen(Qt::blue);
339 QTest::newRow("blue") << QPen(Qt::blue);
334 QTest::newRow("white") << QPen(Qt::white);
340 QTest::newRow("white") << QPen(Qt::white);
335 QTest::newRow("black") << QPen(Qt::black);
341 QTest::newRow("black") << QPen(Qt::black);
336 }
342 }
337
343
338
344
339 void tst_QChart::backgroundPen()
345 void tst_QChart::backgroundPen()
340 {
346 {
341 QFETCH(QPen, backgroundPen);
347 QFETCH(QPen, backgroundPen);
342 m_chart->setBackgroundPen(backgroundPen);
348 m_chart->setBackgroundPen(backgroundPen);
343 QCOMPARE(m_chart->backgroundPen(), backgroundPen);
349 QCOMPARE(m_chart->backgroundPen(), backgroundPen);
344 }
350 }
345
351
346 void tst_QChart::isBackgroundVisible_data()
352 void tst_QChart::isBackgroundVisible_data()
347 {
353 {
348 QTest::addColumn<bool>("isBackgroundVisible");
354 QTest::addColumn<bool>("isBackgroundVisible");
349 QTest::newRow("true") << true;
355 QTest::newRow("true") << true;
350 QTest::newRow("false") << false;
356 QTest::newRow("false") << false;
351 }
357 }
352
358
353 void tst_QChart::isBackgroundVisible()
359 void tst_QChart::isBackgroundVisible()
354 {
360 {
355 QFETCH(bool, isBackgroundVisible);
361 QFETCH(bool, isBackgroundVisible);
356 m_chart->setBackgroundVisible(isBackgroundVisible);
362 m_chart->setBackgroundVisible(isBackgroundVisible);
357 QCOMPARE(m_chart->isBackgroundVisible(), isBackgroundVisible);
363 QCOMPARE(m_chart->isBackgroundVisible(), isBackgroundVisible);
358 }
364 }
359
365
366 void tst_QChart::plotAreaBackgroundBrush_data()
367 {
368 QTest::addColumn<QBrush>("plotAreaBackgroundBrush");
369 QTest::newRow("null") << QBrush();
370 QTest::newRow("blue") << QBrush(Qt::blue);
371 QTest::newRow("white") << QBrush(Qt::white);
372 QTest::newRow("black") << QBrush(Qt::black);
373 }
374
375 void tst_QChart::plotAreaBackgroundBrush()
376 {
377 QFETCH(QBrush, plotAreaBackgroundBrush);
378 m_chart->setPlotAreaBackgroundBrush(plotAreaBackgroundBrush);
379 QCOMPARE(m_chart->plotAreaBackgroundBrush(), plotAreaBackgroundBrush);
380 }
381
382 void tst_QChart::plotAreaBackgroundPen_data()
383 {
384 QTest::addColumn<QPen>("plotAreaBackgroundPen");
385 QTest::newRow("null") << QPen();
386 QTest::newRow("blue") << QPen(Qt::blue);
387 QTest::newRow("white") << QPen(Qt::white);
388 QTest::newRow("black") << QPen(Qt::black);
389 }
390
391
392 void tst_QChart::plotAreaBackgroundPen()
393 {
394 QFETCH(QPen, plotAreaBackgroundPen);
395 m_chart->setPlotAreaBackgroundPen(plotAreaBackgroundPen);
396 QCOMPARE(m_chart->plotAreaBackgroundPen(), plotAreaBackgroundPen);
397 }
398
399 void tst_QChart::isPlotAreaBackgroundVisible_data()
400 {
401 QTest::addColumn<bool>("isPlotAreaBackgroundVisible");
402 QTest::newRow("true") << true;
403 QTest::newRow("false") << false;
404 }
405
406 void tst_QChart::isPlotAreaBackgroundVisible()
407 {
408 QFETCH(bool, isPlotAreaBackgroundVisible);
409 m_chart->setPlotAreaBackgroundVisible(isPlotAreaBackgroundVisible);
410 QCOMPARE(m_chart->isPlotAreaBackgroundVisible(), isPlotAreaBackgroundVisible);
411 }
360 void tst_QChart::legend_data()
412 void tst_QChart::legend_data()
361 {
413 {
362
414
363 }
415 }
364
416
365 void tst_QChart::legend()
417 void tst_QChart::legend()
366 {
418 {
367 QLegend *legend = m_chart->legend();
419 QLegend *legend = m_chart->legend();
368 QVERIFY(legend);
420 QVERIFY(legend);
369
421
370 // Colors related signals
422 // Colors related signals
371 QSignalSpy colorSpy(legend, SIGNAL(colorChanged(QColor)));
423 QSignalSpy colorSpy(legend, SIGNAL(colorChanged(QColor)));
372 QSignalSpy borderColorSpy(legend, SIGNAL(borderColorChanged(QColor)));
424 QSignalSpy borderColorSpy(legend, SIGNAL(borderColorChanged(QColor)));
373 QSignalSpy labelColorSpy(legend, SIGNAL(labelColorChanged(QColor)));
425 QSignalSpy labelColorSpy(legend, SIGNAL(labelColorChanged(QColor)));
374
426
375 // colorChanged
427 // colorChanged
376 legend->setColor(QColor("aliceblue"));
428 legend->setColor(QColor("aliceblue"));
377 QCOMPARE(colorSpy.count(), 1);
429 QCOMPARE(colorSpy.count(), 1);
378 QBrush b = legend->brush();
430 QBrush b = legend->brush();
379 b.setColor(QColor("aqua"));
431 b.setColor(QColor("aqua"));
380 legend->setBrush(b);
432 legend->setBrush(b);
381 QCOMPARE(colorSpy.count(), 2);
433 QCOMPARE(colorSpy.count(), 2);
382
434
383 // borderColorChanged
435 // borderColorChanged
384 legend->setBorderColor(QColor("aliceblue"));
436 legend->setBorderColor(QColor("aliceblue"));
385 QCOMPARE(borderColorSpy.count(), 1);
437 QCOMPARE(borderColorSpy.count(), 1);
386 QPen p = legend->pen();
438 QPen p = legend->pen();
387 p.setColor(QColor("aqua"));
439 p.setColor(QColor("aqua"));
388 legend->setPen(p);
440 legend->setPen(p);
389 QCOMPARE(borderColorSpy.count(), 2);
441 QCOMPARE(borderColorSpy.count(), 2);
390
442
391 // labelColorChanged
443 // labelColorChanged
392 legend->setLabelColor(QColor("lightsalmon"));
444 legend->setLabelColor(QColor("lightsalmon"));
393 QCOMPARE(labelColorSpy.count(), 1);
445 QCOMPARE(labelColorSpy.count(), 1);
394 b = legend->labelBrush();
446 b = legend->labelBrush();
395 b.setColor(QColor("lightseagreen"));
447 b.setColor(QColor("lightseagreen"));
396 legend->setLabelBrush(b);
448 legend->setLabelBrush(b);
397 QCOMPARE(labelColorSpy.count(), 2);
449 QCOMPARE(labelColorSpy.count(), 2);
398
450
399 // fontChanged
451 // fontChanged
400 QSignalSpy fontSpy(legend, SIGNAL(fontChanged(QFont)));
452 QSignalSpy fontSpy(legend, SIGNAL(fontChanged(QFont)));
401 QFont f = legend->font();
453 QFont f = legend->font();
402 f.setBold(!f.bold());
454 f.setBold(!f.bold());
403 legend->setFont(f);
455 legend->setFont(f);
404 QCOMPARE(fontSpy.count(), 1);
456 QCOMPARE(fontSpy.count(), 1);
405 }
457 }
406
458
407 void tst_QChart::plotArea_data()
459 void tst_QChart::plotArea_data()
408 {
460 {
409
461
410 }
462 }
411
463
412 void tst_QChart::plotArea()
464 void tst_QChart::plotArea()
413 {
465 {
414 createTestData();
466 createTestData();
415 QRectF rect = m_chart->geometry();
467 QRectF rect = m_chart->geometry();
416 QVERIFY(m_chart->plotArea().isValid());
468 QVERIFY(m_chart->plotArea().isValid());
417 QVERIFY(m_chart->plotArea().height() < rect.height());
469 QVERIFY(m_chart->plotArea().height() < rect.height());
418 QVERIFY(m_chart->plotArea().width() < rect.width());
470 QVERIFY(m_chart->plotArea().width() < rect.width());
419 }
471 }
420
472
421 void tst_QChart::removeAllSeries_data()
473 void tst_QChart::removeAllSeries_data()
422 {
474 {
423
475
424 }
476 }
425
477
426 void tst_QChart::removeAllSeries()
478 void tst_QChart::removeAllSeries()
427 {
479 {
428 QLineSeries* series0 = new QLineSeries(this);
480 QLineSeries* series0 = new QLineSeries(this);
429 QLineSeries* series1 = new QLineSeries(this);
481 QLineSeries* series1 = new QLineSeries(this);
430 QLineSeries* series2 = new QLineSeries(this);
482 QLineSeries* series2 = new QLineSeries(this);
431 QSignalSpy deleteSpy1(series0, SIGNAL(destroyed()));
483 QSignalSpy deleteSpy1(series0, SIGNAL(destroyed()));
432 QSignalSpy deleteSpy2(series1, SIGNAL(destroyed()));
484 QSignalSpy deleteSpy2(series1, SIGNAL(destroyed()));
433 QSignalSpy deleteSpy3(series2, SIGNAL(destroyed()));
485 QSignalSpy deleteSpy3(series2, SIGNAL(destroyed()));
434
486
435 m_chart->addSeries(series0);
487 m_chart->addSeries(series0);
436 m_chart->addSeries(series1);
488 m_chart->addSeries(series1);
437 m_chart->addSeries(series2);
489 m_chart->addSeries(series2);
438 m_view->show();
490 m_view->show();
439 QTest::qWaitForWindowShown(m_view);
491 QTest::qWaitForWindowShown(m_view);
440 m_chart->createDefaultAxes();
492 m_chart->createDefaultAxes();
441 QCOMPARE(m_chart->axes().count(), 2);
493 QCOMPARE(m_chart->axes().count(), 2);
442 QVERIFY(m_chart->axisY(series0)!=0);
494 QVERIFY(m_chart->axisY(series0)!=0);
443 QVERIFY(m_chart->axisY(series1)!=0);
495 QVERIFY(m_chart->axisY(series1)!=0);
444 QVERIFY(m_chart->axisY(series2)!=0);
496 QVERIFY(m_chart->axisY(series2)!=0);
445
497
446 m_chart->removeAllSeries();
498 m_chart->removeAllSeries();
447 QCOMPARE(m_chart->axes().count(), 2);
499 QCOMPARE(m_chart->axes().count(), 2);
448 QVERIFY(m_chart->axisX() != 0);
500 QVERIFY(m_chart->axisX() != 0);
449 QVERIFY(m_chart->axisY() != 0);
501 QVERIFY(m_chart->axisY() != 0);
450 QCOMPARE(deleteSpy1.count(), 1);
502 QCOMPARE(deleteSpy1.count(), 1);
451 QCOMPARE(deleteSpy2.count(), 1);
503 QCOMPARE(deleteSpy2.count(), 1);
452 QCOMPARE(deleteSpy3.count(), 1);
504 QCOMPARE(deleteSpy3.count(), 1);
453 }
505 }
454
506
455 void tst_QChart::removeSeries_data()
507 void tst_QChart::removeSeries_data()
456 {
508 {
457 axisX_data();
509 axisX_data();
458 }
510 }
459
511
460 void tst_QChart::removeSeries()
512 void tst_QChart::removeSeries()
461 {
513 {
462 QFETCH(QAbstractAxis *, axis);
514 QFETCH(QAbstractAxis *, axis);
463 QFETCH(QAbstractSeries *, series);
515 QFETCH(QAbstractSeries *, series);
464 QSignalSpy deleteSpy(series, SIGNAL(destroyed()));
516 QSignalSpy deleteSpy(series, SIGNAL(destroyed()));
465 m_view->show();
517 m_view->show();
466 QTest::qWaitForWindowShown(m_view);
518 QTest::qWaitForWindowShown(m_view);
467 if(!axis) axis = m_chart->axisY();
519 if(!axis) axis = m_chart->axisY();
468 m_chart->addSeries(series);
520 m_chart->addSeries(series);
469 m_chart->setAxisY(axis,series);
521 m_chart->setAxisY(axis,series);
470 QCOMPARE(m_chart->axisY(series),axis);
522 QCOMPARE(m_chart->axisY(series),axis);
471 m_chart->removeSeries(series);
523 m_chart->removeSeries(series);
472 QCOMPARE(m_chart->axes().count(), 1);
524 QCOMPARE(m_chart->axes().count(), 1);
473 QVERIFY(m_chart->axisY() != 0);
525 QVERIFY(m_chart->axisY() != 0);
474 QVERIFY(m_chart->axisY(series)==0);
526 QVERIFY(m_chart->axisY(series)==0);
475 QCOMPARE(deleteSpy.count(), 0);
527 QCOMPARE(deleteSpy.count(), 0);
476 }
528 }
477
529
478 void tst_QChart::scroll_right_data()
530 void tst_QChart::scroll_right_data()
479 {
531 {
480 QTest::addColumn<QAbstractSeries *>("series");
532 QTest::addColumn<QAbstractSeries *>("series");
481
533
482 QLineSeries* series0 = new QLineSeries(this);
534 QLineSeries* series0 = new QLineSeries(this);
483 *series0 << QPointF(0, 0) << QPointF(100, 100);
535 *series0 << QPointF(0, 0) << QPointF(100, 100);
484
536
485 QTest::newRow("lineSeries") << (QAbstractSeries*) series0;
537 QTest::newRow("lineSeries") << (QAbstractSeries*) series0;
486
538
487
539
488 }
540 }
489
541
490 void tst_QChart::scroll_right()
542 void tst_QChart::scroll_right()
491 {
543 {
492 QFETCH(QAbstractSeries *, series);
544 QFETCH(QAbstractSeries *, series);
493 m_chart->addSeries(series);
545 m_chart->addSeries(series);
494 m_chart->createDefaultAxes();
546 m_chart->createDefaultAxes();
495 m_view->show();
547 m_view->show();
496 QTest::qWaitForWindowShown(m_view);
548 QTest::qWaitForWindowShown(m_view);
497 QAbstractAxis * axis = m_chart->axisX();
549 QAbstractAxis * axis = m_chart->axisX();
498 QVERIFY(axis!=0);
550 QVERIFY(axis!=0);
499
551
500 switch(axis->type())
552 switch(axis->type())
501 {
553 {
502 case QAbstractAxis::AxisTypeValue:{
554 case QAbstractAxis::AxisTypeValue:{
503 QValueAxis* vaxis = qobject_cast<QValueAxis*>(axis);
555 QValueAxis* vaxis = qobject_cast<QValueAxis*>(axis);
504 QVERIFY(vaxis!=0);
556 QVERIFY(vaxis!=0);
505 qreal min = vaxis->min();
557 qreal min = vaxis->min();
506 qreal max = vaxis->max();
558 qreal max = vaxis->max();
507 QVERIFY(max>min);
559 QVERIFY(max>min);
508 m_chart->scroll(50, 0);
560 m_chart->scroll(50, 0);
509 QVERIFY(min<vaxis->min());
561 QVERIFY(min<vaxis->min());
510 QVERIFY(max<vaxis->max());
562 QVERIFY(max<vaxis->max());
511 break;
563 break;
512 }
564 }
513 case QAbstractAxis::AxisTypeBarCategory:{
565 case QAbstractAxis::AxisTypeBarCategory:{
514 QBarCategoryAxis* caxis = qobject_cast<QBarCategoryAxis*>(axis);
566 QBarCategoryAxis* caxis = qobject_cast<QBarCategoryAxis*>(axis);
515 QVERIFY(caxis!=0);
567 QVERIFY(caxis!=0);
516 qreal min = caxis->min().toDouble();
568 qreal min = caxis->min().toDouble();
517 qreal max = caxis->max().toDouble();
569 qreal max = caxis->max().toDouble();
518 m_chart->scroll(50, 0);
570 m_chart->scroll(50, 0);
519 QVERIFY(min<caxis->min().toDouble());
571 QVERIFY(min<caxis->min().toDouble());
520 QVERIFY(max<caxis->max().toDouble());
572 QVERIFY(max<caxis->max().toDouble());
521 break;
573 break;
522 }
574 }
523 default:
575 default:
524 qFatal("Unsupported type");
576 qFatal("Unsupported type");
525 break;
577 break;
526 }
578 }
527 }
579 }
528
580
529 void tst_QChart::scroll_left_data()
581 void tst_QChart::scroll_left_data()
530 {
582 {
531 scroll_right_data();
583 scroll_right_data();
532 }
584 }
533
585
534 void tst_QChart::scroll_left()
586 void tst_QChart::scroll_left()
535 {
587 {
536 QFETCH(QAbstractSeries *, series);
588 QFETCH(QAbstractSeries *, series);
537 m_chart->addSeries(series);
589 m_chart->addSeries(series);
538 m_chart->createDefaultAxes();
590 m_chart->createDefaultAxes();
539 m_view->show();
591 m_view->show();
540 QTest::qWaitForWindowShown(m_view);
592 QTest::qWaitForWindowShown(m_view);
541 QAbstractAxis * axis = m_chart->axisX();
593 QAbstractAxis * axis = m_chart->axisX();
542 QVERIFY(axis!=0);
594 QVERIFY(axis!=0);
543
595
544 switch(axis->type())
596 switch(axis->type())
545 {
597 {
546 case QAbstractAxis::AxisTypeValue:{
598 case QAbstractAxis::AxisTypeValue:{
547 QValueAxis* vaxis = qobject_cast<QValueAxis*>(axis);
599 QValueAxis* vaxis = qobject_cast<QValueAxis*>(axis);
548 QVERIFY(vaxis!=0);
600 QVERIFY(vaxis!=0);
549 qreal min = vaxis->min();
601 qreal min = vaxis->min();
550 qreal max = vaxis->max();
602 qreal max = vaxis->max();
551 m_chart->scroll(-50, 0);
603 m_chart->scroll(-50, 0);
552 QVERIFY(min>vaxis->min());
604 QVERIFY(min>vaxis->min());
553 QVERIFY(max>vaxis->max());
605 QVERIFY(max>vaxis->max());
554 break;
606 break;
555 }
607 }
556 case QAbstractAxis::AxisTypeBarCategory:{
608 case QAbstractAxis::AxisTypeBarCategory:{
557 QBarCategoryAxis* caxis = qobject_cast<QBarCategoryAxis*>(axis);
609 QBarCategoryAxis* caxis = qobject_cast<QBarCategoryAxis*>(axis);
558 QVERIFY(caxis!=0);
610 QVERIFY(caxis!=0);
559 qreal min = caxis->min().toDouble();
611 qreal min = caxis->min().toDouble();
560 qreal max = caxis->max().toDouble();
612 qreal max = caxis->max().toDouble();
561 m_chart->scroll(-50, 0);
613 m_chart->scroll(-50, 0);
562 QVERIFY(min>caxis->min().toDouble());
614 QVERIFY(min>caxis->min().toDouble());
563 QVERIFY(max>caxis->max().toDouble());
615 QVERIFY(max>caxis->max().toDouble());
564 break;
616 break;
565 }
617 }
566 default:
618 default:
567 qFatal("Unsupported type");
619 qFatal("Unsupported type");
568 break;
620 break;
569 }
621 }
570 }
622 }
571
623
572 void tst_QChart::scroll_up_data()
624 void tst_QChart::scroll_up_data()
573 {
625 {
574 scroll_right_data();
626 scroll_right_data();
575 }
627 }
576
628
577 void tst_QChart::scroll_up()
629 void tst_QChart::scroll_up()
578 {
630 {
579 QFETCH(QAbstractSeries *, series);
631 QFETCH(QAbstractSeries *, series);
580 m_chart->addSeries(series);
632 m_chart->addSeries(series);
581 m_chart->createDefaultAxes();
633 m_chart->createDefaultAxes();
582 m_view->show();
634 m_view->show();
583 QTest::qWaitForWindowShown(m_view);
635 QTest::qWaitForWindowShown(m_view);
584 QAbstractAxis * axis = m_chart->axisY();
636 QAbstractAxis * axis = m_chart->axisY();
585 QVERIFY(axis!=0);
637 QVERIFY(axis!=0);
586
638
587 switch(axis->type())
639 switch(axis->type())
588 {
640 {
589 case QAbstractAxis::AxisTypeValue:{
641 case QAbstractAxis::AxisTypeValue:{
590 QValueAxis* vaxis = qobject_cast<QValueAxis*>(axis);
642 QValueAxis* vaxis = qobject_cast<QValueAxis*>(axis);
591 QVERIFY(vaxis!=0);
643 QVERIFY(vaxis!=0);
592 qreal min = vaxis->min();
644 qreal min = vaxis->min();
593 qreal max = vaxis->max();
645 qreal max = vaxis->max();
594 m_chart->scroll(0, 50);
646 m_chart->scroll(0, 50);
595 QVERIFY(min<vaxis->min());
647 QVERIFY(min<vaxis->min());
596 QVERIFY(max<vaxis->max());
648 QVERIFY(max<vaxis->max());
597 break;
649 break;
598 }
650 }
599 case QAbstractAxis::AxisTypeBarCategory:{
651 case QAbstractAxis::AxisTypeBarCategory:{
600 QBarCategoryAxis* caxis = qobject_cast<QBarCategoryAxis*>(axis);
652 QBarCategoryAxis* caxis = qobject_cast<QBarCategoryAxis*>(axis);
601 QVERIFY(caxis!=0);
653 QVERIFY(caxis!=0);
602 qreal min = caxis->min().toDouble();
654 qreal min = caxis->min().toDouble();
603 qreal max = caxis->max().toDouble();
655 qreal max = caxis->max().toDouble();
604 m_chart->scroll(0, 50);
656 m_chart->scroll(0, 50);
605 QVERIFY(min<caxis->min().toDouble());
657 QVERIFY(min<caxis->min().toDouble());
606 QVERIFY(max<caxis->max().toDouble());
658 QVERIFY(max<caxis->max().toDouble());
607 break;
659 break;
608 }
660 }
609 default:
661 default:
610 qFatal("Unsupported type");
662 qFatal("Unsupported type");
611 break;
663 break;
612 }
664 }
613 }
665 }
614
666
615 void tst_QChart::scroll_down_data()
667 void tst_QChart::scroll_down_data()
616 {
668 {
617 scroll_right_data();
669 scroll_right_data();
618 }
670 }
619
671
620 void tst_QChart::scroll_down()
672 void tst_QChart::scroll_down()
621 {
673 {
622 QFETCH(QAbstractSeries *, series);
674 QFETCH(QAbstractSeries *, series);
623 m_chart->addSeries(series);
675 m_chart->addSeries(series);
624 m_chart->createDefaultAxes();
676 m_chart->createDefaultAxes();
625 m_view->show();
677 m_view->show();
626 QTest::qWaitForWindowShown(m_view);
678 QTest::qWaitForWindowShown(m_view);
627 QAbstractAxis * axis = m_chart->axisY();
679 QAbstractAxis * axis = m_chart->axisY();
628 QVERIFY(axis!=0);
680 QVERIFY(axis!=0);
629
681
630 switch(axis->type())
682 switch(axis->type())
631 {
683 {
632 case QAbstractAxis::AxisTypeValue:{
684 case QAbstractAxis::AxisTypeValue:{
633 QValueAxis* vaxis = qobject_cast<QValueAxis*>(axis);
685 QValueAxis* vaxis = qobject_cast<QValueAxis*>(axis);
634 QVERIFY(vaxis!=0);
686 QVERIFY(vaxis!=0);
635 qreal min = vaxis->min();
687 qreal min = vaxis->min();
636 qreal max = vaxis->max();
688 qreal max = vaxis->max();
637 m_chart->scroll(0, -50);
689 m_chart->scroll(0, -50);
638 QVERIFY(min>vaxis->min());
690 QVERIFY(min>vaxis->min());
639 QVERIFY(max>vaxis->max());
691 QVERIFY(max>vaxis->max());
640 break;
692 break;
641 }
693 }
642 case QAbstractAxis::AxisTypeBarCategory:{
694 case QAbstractAxis::AxisTypeBarCategory:{
643 QBarCategoryAxis* caxis = qobject_cast<QBarCategoryAxis*>(axis);
695 QBarCategoryAxis* caxis = qobject_cast<QBarCategoryAxis*>(axis);
644 QVERIFY(caxis!=0);
696 QVERIFY(caxis!=0);
645 qreal min = caxis->min().toDouble();
697 qreal min = caxis->min().toDouble();
646 qreal max = caxis->max().toDouble();
698 qreal max = caxis->max().toDouble();
647 m_chart->scroll(0, -50);
699 m_chart->scroll(0, -50);
648 QVERIFY(min>caxis->min().toDouble());
700 QVERIFY(min>caxis->min().toDouble());
649 QVERIFY(max>caxis->max().toDouble());
701 QVERIFY(max>caxis->max().toDouble());
650 break;
702 break;
651 }
703 }
652 default:
704 default:
653 qFatal("Unsupported type");
705 qFatal("Unsupported type");
654 break;
706 break;
655 }
707 }
656 }
708 }
657
709
658 void tst_QChart::theme_data()
710 void tst_QChart::theme_data()
659 {
711 {
660 QTest::addColumn<QChart::ChartTheme>("theme");
712 QTest::addColumn<QChart::ChartTheme>("theme");
661 QTest::newRow("ChartThemeBlueCerulean") << QChart::ChartThemeBlueCerulean;
713 QTest::newRow("ChartThemeBlueCerulean") << QChart::ChartThemeBlueCerulean;
662 QTest::newRow("ChartThemeBlueIcy") << QChart::ChartThemeBlueIcy;
714 QTest::newRow("ChartThemeBlueIcy") << QChart::ChartThemeBlueIcy;
663 QTest::newRow("ChartThemeBlueNcs") << QChart::ChartThemeBlueNcs;
715 QTest::newRow("ChartThemeBlueNcs") << QChart::ChartThemeBlueNcs;
664 QTest::newRow("ChartThemeBrownSand") << QChart::ChartThemeBrownSand;
716 QTest::newRow("ChartThemeBrownSand") << QChart::ChartThemeBrownSand;
665 QTest::newRow("ChartThemeDark") << QChart::ChartThemeDark;
717 QTest::newRow("ChartThemeDark") << QChart::ChartThemeDark;
666 QTest::newRow("hartThemeHighContrast") << QChart::ChartThemeHighContrast;
718 QTest::newRow("hartThemeHighContrast") << QChart::ChartThemeHighContrast;
667 QTest::newRow("ChartThemeLight") << QChart::ChartThemeLight;
719 QTest::newRow("ChartThemeLight") << QChart::ChartThemeLight;
668 }
720 }
669
721
670 void tst_QChart::theme()
722 void tst_QChart::theme()
671 {
723 {
672 QFETCH(QChart::ChartTheme, theme);
724 QFETCH(QChart::ChartTheme, theme);
673 createTestData();
725 createTestData();
674 m_chart->setTheme(theme);
726 m_chart->setTheme(theme);
675 QVERIFY(m_chart->theme()==theme);
727 QVERIFY(m_chart->theme()==theme);
676 }
728 }
677
729
678 void tst_QChart::title_data()
730 void tst_QChart::title_data()
679 {
731 {
680 QTest::addColumn<QString>("title");
732 QTest::addColumn<QString>("title");
681 QTest::newRow("null") << QString();
733 QTest::newRow("null") << QString();
682 QTest::newRow("foo") << QString("foo");
734 QTest::newRow("foo") << QString("foo");
683 }
735 }
684
736
685 void tst_QChart::title()
737 void tst_QChart::title()
686 {
738 {
687 QFETCH(QString, title);
739 QFETCH(QString, title);
688 m_chart->setTitle(title);
740 m_chart->setTitle(title);
689 QCOMPARE(m_chart->title(), title);
741 QCOMPARE(m_chart->title(), title);
690 }
742 }
691
743
692 void tst_QChart::titleBrush_data()
744 void tst_QChart::titleBrush_data()
693 {
745 {
694 QTest::addColumn<QBrush>("titleBrush");
746 QTest::addColumn<QBrush>("titleBrush");
695 QTest::newRow("null") << QBrush();
747 QTest::newRow("null") << QBrush();
696 QTest::newRow("blue") << QBrush(Qt::blue);
748 QTest::newRow("blue") << QBrush(Qt::blue);
697 QTest::newRow("white") << QBrush(Qt::white);
749 QTest::newRow("white") << QBrush(Qt::white);
698 QTest::newRow("black") << QBrush(Qt::black);
750 QTest::newRow("black") << QBrush(Qt::black);
699 }
751 }
700
752
701 void tst_QChart::titleBrush()
753 void tst_QChart::titleBrush()
702 {
754 {
703 QFETCH(QBrush, titleBrush);
755 QFETCH(QBrush, titleBrush);
704 m_chart->setTitleBrush(titleBrush);
756 m_chart->setTitleBrush(titleBrush);
705 QCOMPARE(m_chart->titleBrush(), titleBrush);
757 QCOMPARE(m_chart->titleBrush(), titleBrush);
706 }
758 }
707
759
708 void tst_QChart::titleFont_data()
760 void tst_QChart::titleFont_data()
709 {
761 {
710 QTest::addColumn<QFont>("titleFont");
762 QTest::addColumn<QFont>("titleFont");
711 QTest::newRow("null") << QFont();
763 QTest::newRow("null") << QFont();
712 QTest::newRow("courier") << QFont("Courier", 8, QFont::Bold, true);
764 QTest::newRow("courier") << QFont("Courier", 8, QFont::Bold, true);
713 }
765 }
714
766
715 void tst_QChart::titleFont()
767 void tst_QChart::titleFont()
716 {
768 {
717 QFETCH(QFont, titleFont);
769 QFETCH(QFont, titleFont);
718 m_chart->setTitleFont(titleFont);
770 m_chart->setTitleFont(titleFont);
719 QCOMPARE(m_chart->titleFont(), titleFont);
771 QCOMPARE(m_chart->titleFont(), titleFont);
720 }
772 }
721
773
722 void tst_QChart::zoomIn_data()
774 void tst_QChart::zoomIn_data()
723 {
775 {
724 QTest::addColumn<QRectF>("rect");
776 QTest::addColumn<QRectF>("rect");
725 QTest::newRow("null") << QRectF();
777 QTest::newRow("null") << QRectF();
726 QTest::newRow("100x100") << QRectF(10,10,100,100);
778 QTest::newRow("100x100") << QRectF(10,10,100,100);
727 QTest::newRow("200x200") << QRectF(10,10,200,200);
779 QTest::newRow("200x200") << QRectF(10,10,200,200);
728 }
780 }
729
781
730
782
731 void tst_QChart::zoomIn()
783 void tst_QChart::zoomIn()
732 {
784 {
733
785
734 QFETCH(QRectF, rect);
786 QFETCH(QRectF, rect);
735 createTestData();
787 createTestData();
736 m_chart->createDefaultAxes();
788 m_chart->createDefaultAxes();
737 QRectF marigns = m_chart->plotArea();
789 QRectF marigns = m_chart->plotArea();
738 rect.adjust(marigns.left(),marigns.top(),-marigns.right(),-marigns.bottom());
790 rect.adjust(marigns.left(),marigns.top(),-marigns.right(),-marigns.bottom());
739 QValueAxis* axisX = qobject_cast<QValueAxis*>(m_chart->axisX());
791 QValueAxis* axisX = qobject_cast<QValueAxis*>(m_chart->axisX());
740 QVERIFY(axisX!=0);
792 QVERIFY(axisX!=0);
741 QValueAxis* axisY = qobject_cast<QValueAxis*>(m_chart->axisY());
793 QValueAxis* axisY = qobject_cast<QValueAxis*>(m_chart->axisY());
742 QVERIFY(axisY!=0);
794 QVERIFY(axisY!=0);
743 qreal minX = axisX->min();
795 qreal minX = axisX->min();
744 qreal minY = axisY->min();
796 qreal minY = axisY->min();
745 qreal maxX = axisX->max();
797 qreal maxX = axisX->max();
746 qreal maxY = axisY->max();
798 qreal maxY = axisY->max();
747 m_chart->zoomIn(rect);
799 m_chart->zoomIn(rect);
748 if(rect.isValid()){
800 if(rect.isValid()){
749 QVERIFY(minX<axisX->min());
801 QVERIFY(minX<axisX->min());
750 QVERIFY(maxX>axisX->max());
802 QVERIFY(maxX>axisX->max());
751 QVERIFY(minY<axisY->min());
803 QVERIFY(minY<axisY->min());
752 QVERIFY(maxY>axisY->max());
804 QVERIFY(maxY>axisY->max());
753 }
805 }
754
806
755 }
807 }
756
808
757 void tst_QChart::zoomOut_data()
809 void tst_QChart::zoomOut_data()
758 {
810 {
759
811
760 }
812 }
761
813
762 void tst_QChart::zoomOut()
814 void tst_QChart::zoomOut()
763 {
815 {
764 createTestData();
816 createTestData();
765 m_chart->createDefaultAxes();
817 m_chart->createDefaultAxes();
766
818
767 QValueAxis* axisX = qobject_cast<QValueAxis*>(m_chart->axisX());
819 QValueAxis* axisX = qobject_cast<QValueAxis*>(m_chart->axisX());
768 QVERIFY(axisX!=0);
820 QVERIFY(axisX!=0);
769 QValueAxis* axisY = qobject_cast<QValueAxis*>(m_chart->axisY());
821 QValueAxis* axisY = qobject_cast<QValueAxis*>(m_chart->axisY());
770 QVERIFY(axisY!=0);
822 QVERIFY(axisY!=0);
771
823
772 qreal minX = axisX->min();
824 qreal minX = axisX->min();
773 qreal minY = axisY->min();
825 qreal minY = axisY->min();
774 qreal maxX = axisX->max();
826 qreal maxX = axisX->max();
775 qreal maxY = axisY->max();
827 qreal maxY = axisY->max();
776
828
777 m_chart->zoomIn();
829 m_chart->zoomIn();
778
830
779 QVERIFY(minX < axisX->min());
831 QVERIFY(minX < axisX->min());
780 QVERIFY(maxX > axisX->max());
832 QVERIFY(maxX > axisX->max());
781 QVERIFY(minY < axisY->min());
833 QVERIFY(minY < axisY->min());
782 QVERIFY(maxY > axisY->max());
834 QVERIFY(maxY > axisY->max());
783
835
784 m_chart->zoomOut();
836 m_chart->zoomOut();
785
837
786 // min x may be a zero value
838 // min x may be a zero value
787 if (qFuzzyIsNull(minX))
839 if (qFuzzyIsNull(minX))
788 QVERIFY(qFuzzyIsNull(axisX->min()));
840 QVERIFY(qFuzzyIsNull(axisX->min()));
789 else
841 else
790 QCOMPARE(minX, axisX->min());
842 QCOMPARE(minX, axisX->min());
791
843
792 // min y may be a zero value
844 // min y may be a zero value
793 if (qFuzzyIsNull(minY))
845 if (qFuzzyIsNull(minY))
794 QVERIFY(qFuzzyIsNull(axisY->min()));
846 QVERIFY(qFuzzyIsNull(axisY->min()));
795 else
847 else
796 QCOMPARE(minY, axisY->min());
848 QCOMPARE(minY, axisY->min());
797
849
798 QVERIFY(maxX == axisX->max());
850 QVERIFY(maxX == axisX->max());
799 QVERIFY(maxY == axisY->max());
851 QVERIFY(maxY == axisY->max());
800
852
801 }
853 }
802
854
803 void tst_QChart::createDefaultAxesForLineSeries_data()
855 void tst_QChart::createDefaultAxesForLineSeries_data()
804 {
856 {
805 QTest::addColumn<qreal>("series1minX");
857 QTest::addColumn<qreal>("series1minX");
806 QTest::addColumn<qreal>("series1midX");
858 QTest::addColumn<qreal>("series1midX");
807 QTest::addColumn<qreal>("series1maxX");
859 QTest::addColumn<qreal>("series1maxX");
808 QTest::addColumn<qreal>("series2minX");
860 QTest::addColumn<qreal>("series2minX");
809 QTest::addColumn<qreal>("series2midX");
861 QTest::addColumn<qreal>("series2midX");
810 QTest::addColumn<qreal>("series2maxX");
862 QTest::addColumn<qreal>("series2maxX");
811 QTest::addColumn<qreal>("overallminX");
863 QTest::addColumn<qreal>("overallminX");
812 QTest::addColumn<qreal>("overallmaxX");
864 QTest::addColumn<qreal>("overallmaxX");
813 QTest::addColumn<qreal>("series1minY");
865 QTest::addColumn<qreal>("series1minY");
814 QTest::addColumn<qreal>("series1midY");
866 QTest::addColumn<qreal>("series1midY");
815 QTest::addColumn<qreal>("series1maxY");
867 QTest::addColumn<qreal>("series1maxY");
816 QTest::addColumn<qreal>("series2minY");
868 QTest::addColumn<qreal>("series2minY");
817 QTest::addColumn<qreal>("series2midY");
869 QTest::addColumn<qreal>("series2midY");
818 QTest::addColumn<qreal>("series2maxY");
870 QTest::addColumn<qreal>("series2maxY");
819 QTest::addColumn<qreal>("overallminY");
871 QTest::addColumn<qreal>("overallminY");
820 QTest::addColumn<qreal>("overallmaxY");
872 QTest::addColumn<qreal>("overallmaxY");
821 QTest::newRow("series1hasMinAndMax") << (qreal)1.0 << (qreal)2.0 << (qreal)3.0 << (qreal)1.1 << (qreal)1.7 << (qreal)2.9 << (qreal)1.0 << (qreal)3.0
873 QTest::newRow("series1hasMinAndMax") << (qreal)1.0 << (qreal)2.0 << (qreal)3.0 << (qreal)1.1 << (qreal)1.7 << (qreal)2.9 << (qreal)1.0 << (qreal)3.0
822 << (qreal)1.0 << (qreal)2.0 << (qreal)3.0 << (qreal)1.1 << (qreal)1.7 << (qreal)2.9 << (qreal)1.0 << (qreal)3.0;
874 << (qreal)1.0 << (qreal)2.0 << (qreal)3.0 << (qreal)1.1 << (qreal)1.7 << (qreal)2.9 << (qreal)1.0 << (qreal)3.0;
823 QTest::newRow("series2hasMinAndMax") << (qreal)1.1 << (qreal)2.0 << (qreal)2.9 << (qreal)1.0 << (qreal)1.7 << (qreal)3.0 << (qreal)1.0 << (qreal)3.0
875 QTest::newRow("series2hasMinAndMax") << (qreal)1.1 << (qreal)2.0 << (qreal)2.9 << (qreal)1.0 << (qreal)1.7 << (qreal)3.0 << (qreal)1.0 << (qreal)3.0
824 << (qreal)1.1 << (qreal)2.0 << (qreal)2.9 << (qreal)1.0 << (qreal)1.7 << (qreal)3.0 << (qreal)1.0 << (qreal)3.0;
876 << (qreal)1.1 << (qreal)2.0 << (qreal)2.9 << (qreal)1.0 << (qreal)1.7 << (qreal)3.0 << (qreal)1.0 << (qreal)3.0;
825 QTest::newRow("series1hasMinAndMaxX_series2hasMinAndMaxY") << (qreal)1.0 << (qreal)2.0 << (qreal)3.0 << (qreal)1.1 << (qreal)1.7 << (qreal)2.9 << (qreal)1.0 << (qreal)3.0
877 QTest::newRow("series1hasMinAndMaxX_series2hasMinAndMaxY") << (qreal)1.0 << (qreal)2.0 << (qreal)3.0 << (qreal)1.1 << (qreal)1.7 << (qreal)2.9 << (qreal)1.0 << (qreal)3.0
826 << (qreal)1.1 << (qreal)2.0 << (qreal)2.9 << (qreal)1.0 << (qreal)2.0 << (qreal)3.0 << (qreal)1.0 << (qreal)3.0;
878 << (qreal)1.1 << (qreal)2.0 << (qreal)2.9 << (qreal)1.0 << (qreal)2.0 << (qreal)3.0 << (qreal)1.0 << (qreal)3.0;
827 QTest::newRow("series1hasMin_series2hasMax") << (qreal)1.0 << (qreal)2.0 << (qreal)2.9 << (qreal)1.1 << (qreal)1.7 << (qreal)3.0 << (qreal)1.0 << (qreal)3.0
879 QTest::newRow("series1hasMin_series2hasMax") << (qreal)1.0 << (qreal)2.0 << (qreal)2.9 << (qreal)1.1 << (qreal)1.7 << (qreal)3.0 << (qreal)1.0 << (qreal)3.0
828 << (qreal)1.0 << (qreal)2.0 << (qreal)2.9 << (qreal)1.1 << (qreal)1.7 << (qreal)3.0 << (qreal)1.0 << (qreal)3.0;
880 << (qreal)1.0 << (qreal)2.0 << (qreal)2.9 << (qreal)1.1 << (qreal)1.7 << (qreal)3.0 << (qreal)1.0 << (qreal)3.0;
829 QTest::newRow("bothSeriesHaveSameMinAndMax") << (qreal)1.0 << (qreal)2.0 << (qreal)2.9 << (qreal)1.1 << (qreal)1.7 << (qreal)3.0 << (qreal)1.0 << (qreal)3.0
881 QTest::newRow("bothSeriesHaveSameMinAndMax") << (qreal)1.0 << (qreal)2.0 << (qreal)2.9 << (qreal)1.1 << (qreal)1.7 << (qreal)3.0 << (qreal)1.0 << (qreal)3.0
830 << (qreal)1.1 << (qreal)1.1 << (qreal)1.1 << (qreal)1.1 << (qreal)1.1 << (qreal)1.1 << (qreal)0.6 << (qreal)1.6;
882 << (qreal)1.1 << (qreal)1.1 << (qreal)1.1 << (qreal)1.1 << (qreal)1.1 << (qreal)1.1 << (qreal)0.6 << (qreal)1.6;
831 }
883 }
832
884
833 void tst_QChart::createDefaultAxesForLineSeries()
885 void tst_QChart::createDefaultAxesForLineSeries()
834 {
886 {
835 QFETCH(qreal, series1minX);
887 QFETCH(qreal, series1minX);
836 QFETCH(qreal, series1midX);
888 QFETCH(qreal, series1midX);
837 QFETCH(qreal, series1maxX);
889 QFETCH(qreal, series1maxX);
838 QFETCH(qreal, series2minX);
890 QFETCH(qreal, series2minX);
839 QFETCH(qreal, series2midX);
891 QFETCH(qreal, series2midX);
840 QFETCH(qreal, series2maxX);
892 QFETCH(qreal, series2maxX);
841 QFETCH(qreal, series1minY);
893 QFETCH(qreal, series1minY);
842 QFETCH(qreal, series1midY);
894 QFETCH(qreal, series1midY);
843 QFETCH(qreal, series1maxY);
895 QFETCH(qreal, series1maxY);
844 QFETCH(qreal, series2minY);
896 QFETCH(qreal, series2minY);
845 QFETCH(qreal, series2midY);
897 QFETCH(qreal, series2midY);
846 QFETCH(qreal, series2maxY);
898 QFETCH(qreal, series2maxY);
847 QFETCH(qreal, overallminX);
899 QFETCH(qreal, overallminX);
848 QFETCH(qreal, overallmaxX);
900 QFETCH(qreal, overallmaxX);
849 QFETCH(qreal, overallminY);
901 QFETCH(qreal, overallminY);
850 QFETCH(qreal, overallmaxY);
902 QFETCH(qreal, overallmaxY);
851 QLineSeries* series1 = new QLineSeries(this);
903 QLineSeries* series1 = new QLineSeries(this);
852 series1->append(series1minX, series1minY);
904 series1->append(series1minX, series1minY);
853 series1->append(series1midX, series1midY);
905 series1->append(series1midX, series1midY);
854 series1->append(series1maxX, series1maxY);
906 series1->append(series1maxX, series1maxY);
855 QLineSeries* series2 = new QLineSeries(this);
907 QLineSeries* series2 = new QLineSeries(this);
856 series2->append(series2minX, series2minY);
908 series2->append(series2minX, series2minY);
857 series2->append(series2midX, series2midY);
909 series2->append(series2midX, series2midY);
858 series2->append(series2maxX, series2maxY);
910 series2->append(series2maxX, series2maxY);
859 QChart *chart = newQChartOrQPolarChart();
911 QChart *chart = newQChartOrQPolarChart();
860 chart->addSeries(series1);
912 chart->addSeries(series1);
861 chart->addSeries(series2);
913 chart->addSeries(series2);
862 chart->createDefaultAxes();
914 chart->createDefaultAxes();
863 QValueAxis *xAxis = (QValueAxis *)chart->axisX();
915 QValueAxis *xAxis = (QValueAxis *)chart->axisX();
864 QCOMPARE(xAxis->min(), overallminX);
916 QCOMPARE(xAxis->min(), overallminX);
865 QCOMPARE(xAxis->max(), overallmaxX);
917 QCOMPARE(xAxis->max(), overallmaxX);
866 QValueAxis *yAxis = (QValueAxis *)chart->axisY();
918 QValueAxis *yAxis = (QValueAxis *)chart->axisY();
867 QCOMPARE(yAxis->min(), overallminY);
919 QCOMPARE(yAxis->min(), overallminY);
868 QCOMPARE(yAxis->max(), overallmaxY);
920 QCOMPARE(yAxis->max(), overallmaxY);
869 QLineSeries *series3 = new QLineSeries(this);
921 QLineSeries *series3 = new QLineSeries(this);
870 // Numbers clearly out of existing range
922 // Numbers clearly out of existing range
871 series3->append(0, 0);
923 series3->append(0, 0);
872 series3->append(100, 100);
924 series3->append(100, 100);
873 // Adding a new series should not change the axes as they have not been told to update
925 // Adding a new series should not change the axes as they have not been told to update
874 chart->addSeries(series3);
926 chart->addSeries(series3);
875 QCOMPARE(xAxis->min(), overallminX);
927 QCOMPARE(xAxis->min(), overallminX);
876 QCOMPARE(xAxis->max(), overallmaxX);
928 QCOMPARE(xAxis->max(), overallmaxX);
877 QCOMPARE(yAxis->min(), overallminY);
929 QCOMPARE(yAxis->min(), overallminY);
878 QCOMPARE(yAxis->max(), overallmaxY);
930 QCOMPARE(yAxis->max(), overallmaxY);
879 }
931 }
880
932
881 void tst_QChart::axisPolarOrientation()
933 void tst_QChart::axisPolarOrientation()
882 {
934 {
883 QLineSeries* series1 = new QLineSeries(this);
935 QLineSeries* series1 = new QLineSeries(this);
884 series1->append(1, 2);
936 series1->append(1, 2);
885 series1->append(2, 4);
937 series1->append(2, 4);
886 series1->append(3, 8);
938 series1->append(3, 8);
887 QPolarChart chart;
939 QPolarChart chart;
888 chart.addSeries(series1);
940 chart.addSeries(series1);
889
941
890 QValueAxis *xAxis = new QValueAxis();
942 QValueAxis *xAxis = new QValueAxis();
891 QValueAxis *yAxis = new QValueAxis();
943 QValueAxis *yAxis = new QValueAxis();
892 chart.addAxis(xAxis, QPolarChart::PolarOrientationAngular);
944 chart.addAxis(xAxis, QPolarChart::PolarOrientationAngular);
893 chart.addAxis(yAxis, QPolarChart::PolarOrientationRadial);
945 chart.addAxis(yAxis, QPolarChart::PolarOrientationRadial);
894
946
895 QList<QAbstractAxis *> xAxes = chart.axes(QPolarChart::PolarOrientationAngular);
947 QList<QAbstractAxis *> xAxes = chart.axes(QPolarChart::PolarOrientationAngular);
896 QList<QAbstractAxis *> yAxes = chart.axes(QPolarChart::PolarOrientationRadial);
948 QList<QAbstractAxis *> yAxes = chart.axes(QPolarChart::PolarOrientationRadial);
897
949
898 QCOMPARE(xAxes.size(), 1);
950 QCOMPARE(xAxes.size(), 1);
899 QCOMPARE(yAxes.size(), 1);
951 QCOMPARE(yAxes.size(), 1);
900 QCOMPARE(xAxes[0], xAxis);
952 QCOMPARE(xAxes[0], xAxis);
901 QCOMPARE(yAxes[0], yAxis);
953 QCOMPARE(yAxes[0], yAxis);
902
954
903 QCOMPARE(chart.axisPolarOrientation(xAxes[0]), QPolarChart::PolarOrientationAngular);
955 QCOMPARE(chart.axisPolarOrientation(xAxes[0]), QPolarChart::PolarOrientationAngular);
904 QCOMPARE(chart.axisPolarOrientation(yAxes[0]), QPolarChart::PolarOrientationRadial);
956 QCOMPARE(chart.axisPolarOrientation(yAxes[0]), QPolarChart::PolarOrientationRadial);
905 }
957 }
906
958
907 QTEST_MAIN(tst_QChart)
959 QTEST_MAIN(tst_QChart)
908 #include "tst_qchart.moc"
960 #include "tst_qchart.moc"
909
961
@@ -1,1136 +1,1199
1 /****************************************************************************
1 /****************************************************************************
2 **
2 **
3 ** Copyright (C) 2013 Digia Plc
3 ** Copyright (C) 2013 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 "mainwindow.h"
21 #include "mainwindow.h"
22 #include "chartview.h"
22 #include "chartview.h"
23 #include <QScatterSeries>
23 #include <QScatterSeries>
24 #include <QLineSeries>
24 #include <QLineSeries>
25 #include <QSplineSeries>
25 #include <QSplineSeries>
26 #include <QAreaSeries>
26 #include <QAreaSeries>
27 #include <QBarSeries>
27 #include <QBarSeries>
28 #include <QBarSet>
28 #include <QBarSet>
29 #include <QValueAxis>
29 #include <QValueAxis>
30 #include <QLogValueAxis>
30 #include <QLogValueAxis>
31 #include <QDateTimeAxis>
31 #include <QDateTimeAxis>
32 #include <QCategoryAxis>
32 #include <QCategoryAxis>
33 #include <QPolarChart>
33 #include <QPolarChart>
34 #include <QDebug>
34 #include <QDebug>
35 #include <qmath.h>
35 #include <qmath.h>
36 #include <QDateTime>
36 #include <QDateTime>
37
37
38 QTCOMMERCIALCHART_USE_NAMESPACE
38 QTCOMMERCIALCHART_USE_NAMESPACE
39 #include "ui_mainwindow.h"
39 #include "ui_mainwindow.h"
40
40
41 MainWindow::MainWindow(QWidget *parent) :
41 MainWindow::MainWindow(QWidget *parent) :
42 QMainWindow(parent),
42 QMainWindow(parent),
43 ui(new Ui::MainWindow),
43 ui(new Ui::MainWindow),
44 m_angularTickCount(9),
44 m_angularTickCount(9),
45 m_radialTickCount(11),
45 m_radialTickCount(11),
46 m_labelsAngle(0),
46 m_labelsAngle(0),
47 m_angularMin(0.0),
47 m_angularMin(0.0),
48 m_angularMax(40000.0),
48 m_angularMax(40000.0),
49 m_radialMin(0.0),
49 m_radialMin(0.0),
50 m_radialMax(30000.0),
50 m_radialMax(30000.0),
51 m_angularShadesVisible(false),
51 m_angularShadesVisible(false),
52 m_radialShadesVisible(false),
52 m_radialShadesVisible(false),
53 m_labelsVisible(true),
53 m_labelsVisible(true),
54 m_titleVisible(true),
54 m_titleVisible(true),
55 m_gridVisible(true),
55 m_gridVisible(true),
56 m_arrowVisible(true),
56 m_arrowVisible(true),
57 m_angularShadesBrush(new QBrush(Qt::NoBrush)),
57 m_angularShadesBrush(new QBrush(Qt::NoBrush)),
58 m_radialShadesBrush(new QBrush(Qt::NoBrush)),
58 m_radialShadesBrush(new QBrush(Qt::NoBrush)),
59 m_labelBrush(new QBrush(Qt::black)),
59 m_labelBrush(new QBrush(Qt::black)),
60 m_titleBrush(new QBrush(Qt::black)),
60 m_titleBrush(new QBrush(Qt::black)),
61 m_backgroundBrush(new QBrush(Qt::white)),
62 m_plotAreaBackgroundBrush(new QBrush(Qt::NoBrush)),
61 m_angularShadesPen(new QPen(Qt::NoPen)),
63 m_angularShadesPen(new QPen(Qt::NoPen)),
62 m_radialShadesPen(new QPen(Qt::NoPen)),
64 m_radialShadesPen(new QPen(Qt::NoPen)),
63 m_labelPen(new QPen(Qt::NoPen)),
65 m_labelPen(new QPen(Qt::NoPen)),
64 m_titlePen(new QPen(Qt::NoPen)),
66 m_titlePen(new QPen(Qt::NoPen)),
65 m_gridPen(new QPen(QRgb(0x010101))), // Note: Pure black is default color, so it gets overridden by
67 m_gridPen(new QPen(QRgb(0x010101))), // Note: Pure black is default color, so it gets overridden by
66 m_arrowPen(new QPen(QRgb(0x010101))), // default theme if set to that initially. This is an example of workaround.
68 m_arrowPen(new QPen(QRgb(0x010101))), // default theme if set to that initially. This is an example of workaround.
69 m_backgroundPen(new QPen(Qt::NoPen)),
70 m_plotAreaBackgroundPen(new QPen(Qt::NoPen)),
67 m_labelFormat(QString("%.2f")),
71 m_labelFormat(QString("%.2f")),
68 m_animationOptions(QChart::NoAnimation),
72 m_animationOptions(QChart::NoAnimation),
69 m_angularTitle(QString("Angular Title")),
73 m_angularTitle(QString("Angular Title")),
70 m_radialTitle(QString("Radial Title")),
74 m_radialTitle(QString("Radial Title")),
71 m_base(2.0),
75 m_base(2.0),
72 m_chart(0),
76 m_chart(0),
73 m_angularAxis(0),
77 m_angularAxis(0),
74 m_radialAxis(0),
78 m_radialAxis(0),
75 m_angularAxisMode(AxisModeNone),
79 m_angularAxisMode(AxisModeNone),
76 m_radialAxisMode(AxisModeNone),
80 m_radialAxisMode(AxisModeNone),
77 m_series1(0),
81 m_series1(0),
78 m_series2(0),
82 m_series2(0),
79 m_series3(0),
83 m_series3(0),
80 m_series4(0),
84 m_series4(0),
81 m_series5(0),
85 m_series5(0),
82 m_series6(0),
86 m_series6(0),
83 m_series7(0),
87 m_series7(0),
84 m_dateFormat(QString("mm-ss-zzz")),
88 m_dateFormat(QString("mm-ss-zzz")),
85 m_moreCategories(false)
89 m_moreCategories(false)
86 {
90 {
87 ui->setupUi(this);
91 ui->setupUi(this);
88
92
89 ui->angularTicksSpin->setValue(m_angularTickCount);
93 ui->angularTicksSpin->setValue(m_angularTickCount);
90 ui->radialTicksSpin->setValue(m_radialTickCount);
94 ui->radialTicksSpin->setValue(m_radialTickCount);
91 ui->anglesSpin->setValue(m_labelsAngle);
95 ui->anglesSpin->setValue(m_labelsAngle);
92 ui->radialMinSpin->setValue(m_radialMin);
96 ui->radialMinSpin->setValue(m_radialMin);
93 ui->radialMaxSpin->setValue(m_radialMax);
97 ui->radialMaxSpin->setValue(m_radialMax);
94 ui->angularMinSpin->setValue(m_angularMin);
98 ui->angularMinSpin->setValue(m_angularMin);
95 ui->angularMaxSpin->setValue(m_angularMax);
99 ui->angularMaxSpin->setValue(m_angularMax);
96 ui->angularShadesComboBox->setCurrentIndex(0);
100 ui->angularShadesComboBox->setCurrentIndex(0);
97 ui->radialShadesComboBox->setCurrentIndex(0);
101 ui->radialShadesComboBox->setCurrentIndex(0);
98 ui->labelFormatEdit->setText(m_labelFormat);
102 ui->labelFormatEdit->setText(m_labelFormat);
99 ui->dateFormatEdit->setText(m_dateFormat);
103 ui->dateFormatEdit->setText(m_dateFormat);
100 ui->moreCategoriesCheckBox->setChecked(m_moreCategories);
104 ui->moreCategoriesCheckBox->setChecked(m_moreCategories);
101
105
102 ui->series1checkBox->setChecked(true);
106 ui->series1checkBox->setChecked(true);
103 ui->series2checkBox->setChecked(true);
107 ui->series2checkBox->setChecked(true);
104 ui->series3checkBox->setChecked(true);
108 ui->series3checkBox->setChecked(true);
105 ui->series4checkBox->setChecked(true);
109 ui->series4checkBox->setChecked(true);
106 ui->series5checkBox->setChecked(true);
110 ui->series5checkBox->setChecked(true);
107 ui->series6checkBox->setChecked(true);
111 ui->series6checkBox->setChecked(true);
108 ui->series7checkBox->setChecked(true);
112 ui->series7checkBox->setChecked(true);
109
113
110 m_currentLabelFont.setFamily(ui->labelFontComboBox->currentFont().family());
114 m_currentLabelFont.setFamily(ui->labelFontComboBox->currentFont().family());
111 m_currentLabelFont.setPixelSize(15);
115 m_currentLabelFont.setPixelSize(15);
112 m_currentTitleFont.setFamily(ui->titleFontComboBox->currentFont().family());
116 m_currentTitleFont.setFamily(ui->titleFontComboBox->currentFont().family());
113 m_currentTitleFont.setPixelSize(30);
117 m_currentTitleFont.setPixelSize(30);
114
118
115 ui->labelFontSizeSpin->setValue(m_currentLabelFont.pixelSize());
119 ui->labelFontSizeSpin->setValue(m_currentLabelFont.pixelSize());
116 ui->titleFontSizeSpin->setValue(m_currentTitleFont.pixelSize());
120 ui->titleFontSizeSpin->setValue(m_currentTitleFont.pixelSize());
117
121
118 ui->logBaseSpin->setValue(m_base);
122 ui->logBaseSpin->setValue(m_base);
119
123
120 initXYValueChart();
124 initXYValueChart();
121 setAngularAxis(AxisModeValue);
125 setAngularAxis(AxisModeValue);
122 setRadialAxis(AxisModeValue);
126 setRadialAxis(AxisModeValue);
123
127
124 ui->angularAxisComboBox->setCurrentIndex(int(m_angularAxisMode));
128 ui->angularAxisComboBox->setCurrentIndex(int(m_angularAxisMode));
125 ui->radialAxisComboBox->setCurrentIndex(int(m_radialAxisMode));
129 ui->radialAxisComboBox->setCurrentIndex(int(m_radialAxisMode));
126
130
127 connect(ui->angularTicksSpin, SIGNAL(valueChanged(int)), this, SLOT(angularTicksChanged(int)));
131 connect(ui->angularTicksSpin, SIGNAL(valueChanged(int)), this, SLOT(angularTicksChanged(int)));
128 connect(ui->radialTicksSpin, SIGNAL(valueChanged(int)), this, SLOT(radialTicksChanged(int)));
132 connect(ui->radialTicksSpin, SIGNAL(valueChanged(int)), this, SLOT(radialTicksChanged(int)));
129 connect(ui->anglesSpin, SIGNAL(valueChanged(int)), this, SLOT(anglesChanged(int)));
133 connect(ui->anglesSpin, SIGNAL(valueChanged(int)), this, SLOT(anglesChanged(int)));
130 connect(ui->radialMinSpin, SIGNAL(valueChanged(double)), this, SLOT(radialMinChanged(double)));
134 connect(ui->radialMinSpin, SIGNAL(valueChanged(double)), this, SLOT(radialMinChanged(double)));
131 connect(ui->radialMaxSpin, SIGNAL(valueChanged(double)), this, SLOT(radialMaxChanged(double)));
135 connect(ui->radialMaxSpin, SIGNAL(valueChanged(double)), this, SLOT(radialMaxChanged(double)));
132 connect(ui->angularMinSpin, SIGNAL(valueChanged(double)), this, SLOT(angularMinChanged(double)));
136 connect(ui->angularMinSpin, SIGNAL(valueChanged(double)), this, SLOT(angularMinChanged(double)));
133 connect(ui->angularMaxSpin, SIGNAL(valueChanged(double)), this, SLOT(angularMaxChanged(double)));
137 connect(ui->angularMaxSpin, SIGNAL(valueChanged(double)), this, SLOT(angularMaxChanged(double)));
134 connect(ui->angularShadesComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(angularShadesIndexChanged(int)));
138 connect(ui->angularShadesComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(angularShadesIndexChanged(int)));
135 connect(ui->radialShadesComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(radialShadesIndexChanged(int)));
139 connect(ui->radialShadesComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(radialShadesIndexChanged(int)));
136 connect(ui->animationsComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(animationIndexChanged(int)));
140 connect(ui->animationsComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(animationIndexChanged(int)));
137 connect(ui->labelFormatEdit, SIGNAL(textEdited(QString)), this, SLOT(labelFormatEdited(QString)));
141 connect(ui->labelFormatEdit, SIGNAL(textEdited(QString)), this, SLOT(labelFormatEdited(QString)));
138 connect(ui->labelFontComboBox, SIGNAL(currentFontChanged(QFont)), this, SLOT(labelFontChanged(QFont)));
142 connect(ui->labelFontComboBox, SIGNAL(currentFontChanged(QFont)), this, SLOT(labelFontChanged(QFont)));
139 connect(ui->labelFontSizeSpin, SIGNAL(valueChanged(int)), this, SLOT(labelFontSizeChanged(int)));
143 connect(ui->labelFontSizeSpin, SIGNAL(valueChanged(int)), this, SLOT(labelFontSizeChanged(int)));
140 connect(ui->labelComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(labelsIndexChanged(int)));
144 connect(ui->labelComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(labelsIndexChanged(int)));
141 connect(ui->titleFontComboBox, SIGNAL(currentFontChanged(QFont)), this, SLOT(titleFontChanged(QFont)));
145 connect(ui->titleFontComboBox, SIGNAL(currentFontChanged(QFont)), this, SLOT(titleFontChanged(QFont)));
142 connect(ui->titleFontSizeSpin, SIGNAL(valueChanged(int)), this, SLOT(titleFontSizeChanged(int)));
146 connect(ui->titleFontSizeSpin, SIGNAL(valueChanged(int)), this, SLOT(titleFontSizeChanged(int)));
143 connect(ui->titleComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(titleIndexChanged(int)));
147 connect(ui->titleComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(titleIndexChanged(int)));
144 connect(ui->gridComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(gridIndexChanged(int)));
148 connect(ui->gridComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(gridIndexChanged(int)));
145 connect(ui->arrowComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(arrowIndexChanged(int)));
149 connect(ui->arrowComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(arrowIndexChanged(int)));
146 connect(ui->logBaseSpin, SIGNAL(valueChanged(double)), this, SLOT(logBaseChanged(double)));
150 connect(ui->logBaseSpin, SIGNAL(valueChanged(double)), this, SLOT(logBaseChanged(double)));
147 connect(ui->angularAxisComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(angularAxisIndexChanged(int)));
151 connect(ui->angularAxisComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(angularAxisIndexChanged(int)));
148 connect(ui->radialAxisComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(radialAxisIndexChanged(int)));
152 connect(ui->radialAxisComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(radialAxisIndexChanged(int)));
149 connect(ui->niceNumbersCheckBox, SIGNAL(clicked()), this, SLOT(niceNumbersChecked()));
153 connect(ui->niceNumbersCheckBox, SIGNAL(clicked()), this, SLOT(niceNumbersChecked()));
150 connect(ui->dateFormatEdit, SIGNAL(textEdited(QString)), this, SLOT(dateFormatEdited(QString)));
154 connect(ui->dateFormatEdit, SIGNAL(textEdited(QString)), this, SLOT(dateFormatEdited(QString)));
151 connect(ui->moreCategoriesCheckBox, SIGNAL(clicked()), this, SLOT(moreCategoriesChecked()));
155 connect(ui->moreCategoriesCheckBox, SIGNAL(clicked()), this, SLOT(moreCategoriesChecked()));
152 connect(ui->series1checkBox, SIGNAL(clicked()), this, SLOT(series1CheckBoxChecked()));
156 connect(ui->series1checkBox, SIGNAL(clicked()), this, SLOT(series1CheckBoxChecked()));
153 connect(ui->series2checkBox, SIGNAL(clicked()), this, SLOT(series2CheckBoxChecked()));
157 connect(ui->series2checkBox, SIGNAL(clicked()), this, SLOT(series2CheckBoxChecked()));
154 connect(ui->series3checkBox, SIGNAL(clicked()), this, SLOT(series3CheckBoxChecked()));
158 connect(ui->series3checkBox, SIGNAL(clicked()), this, SLOT(series3CheckBoxChecked()));
155 connect(ui->series4checkBox, SIGNAL(clicked()), this, SLOT(series4CheckBoxChecked()));
159 connect(ui->series4checkBox, SIGNAL(clicked()), this, SLOT(series4CheckBoxChecked()));
156 connect(ui->series5checkBox, SIGNAL(clicked()), this, SLOT(series5CheckBoxChecked()));
160 connect(ui->series5checkBox, SIGNAL(clicked()), this, SLOT(series5CheckBoxChecked()));
157 connect(ui->series6checkBox, SIGNAL(clicked()), this, SLOT(series6CheckBoxChecked()));
161 connect(ui->series6checkBox, SIGNAL(clicked()), this, SLOT(series6CheckBoxChecked()));
158 connect(ui->series7checkBox, SIGNAL(clicked()), this, SLOT(series7CheckBoxChecked()));
162 connect(ui->series7checkBox, SIGNAL(clicked()), this, SLOT(series7CheckBoxChecked()));
159 connect(ui->themeComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(themeIndexChanged(int)));
163 connect(ui->themeComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(themeIndexChanged(int)));
164 connect(ui->backgroundComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(backgroundIndexChanged(int)));
165 connect(ui->plotAreaComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(plotAreaIndexChanged(int)));
160
166
161 ui->chartView->setChart(m_chart);
167 ui->chartView->setChart(m_chart);
162 ui->chartView->setRenderHint(QPainter::Antialiasing);
168 ui->chartView->setRenderHint(QPainter::Antialiasing);
163 }
169 }
164
170
165 MainWindow::~MainWindow()
171 MainWindow::~MainWindow()
166 {
172 {
167 delete ui;
173 delete ui;
168 delete m_angularShadesBrush;
174 delete m_angularShadesBrush;
169 delete m_radialShadesBrush;
175 delete m_radialShadesBrush;
170 delete m_angularShadesPen;
176 delete m_angularShadesPen;
171 delete m_radialShadesPen;
177 delete m_radialShadesPen;
172 }
178 }
173
179
174 void MainWindow::initXYValueChart()
180 void MainWindow::initXYValueChart()
175 {
181 {
176 qreal seriesAngularMin = 1;
182 qreal seriesAngularMin = 1;
177 qreal seriesAngularMax = 46000;
183 qreal seriesAngularMax = 46000;
178 qreal seriesRadialMin = 1;
184 qreal seriesRadialMin = 1;
179 qreal seriesRadialMax = 23500;
185 qreal seriesRadialMax = 23500;
180 qreal radialDimension = seriesRadialMax - seriesRadialMin;
186 qreal radialDimension = seriesRadialMax - seriesRadialMin;
181 qreal angularDimension = seriesAngularMax - seriesAngularMin;
187 qreal angularDimension = seriesAngularMax - seriesAngularMin;
182
188
183 // Scatter series, points outside min-max ranges should not be drawn
189 // Scatter series, points outside min-max ranges should not be drawn
184 m_series1 = new QScatterSeries();
190 m_series1 = new QScatterSeries();
185 m_series1->setName("scatter");
191 m_series1->setName("scatter");
186 qreal scatterCount = 10;
192 qreal scatterCount = 10;
187 qreal scatterAngularStep = angularDimension / scatterCount;
193 qreal scatterAngularStep = angularDimension / scatterCount;
188 qreal scatterRadialStep = radialDimension / scatterCount;
194 qreal scatterRadialStep = radialDimension / scatterCount;
189 for (qreal i = 0.0; i < scatterCount; i++) {
195 for (qreal i = 0.0; i < scatterCount; i++) {
190 m_series1->append((i * scatterAngularStep) + seriesAngularMin, (i * scatterRadialStep) + seriesRadialMin);
196 m_series1->append((i * scatterAngularStep) + seriesAngularMin, (i * scatterRadialStep) + seriesRadialMin);
191 //qDebug() << m_series1->points().last();
197 //qDebug() << m_series1->points().last();
192 }
198 }
193 m_series1->setMarkerSize(10);
199 m_series1->setMarkerSize(10);
194 *m_series1 << QPointF(50, 50) << QPointF(150, 150) << QPointF(250, 250) << QPointF(350, 350) << QPointF(450, 450);
200 *m_series1 << QPointF(50, 50) << QPointF(150, 150) << QPointF(250, 250) << QPointF(350, 350) << QPointF(450, 450);
195 *m_series1 << QPointF(1050, 0.50) << QPointF(1150, 0.25) << QPointF(1250, 0.12) << QPointF(1350, 0.075) << QPointF(1450, 0.036);
201 *m_series1 << QPointF(1050, 0.50) << QPointF(1150, 0.25) << QPointF(1250, 0.12) << QPointF(1350, 0.075) << QPointF(1450, 0.036);
196 *m_series1 << QPointF(0.50, 2000) << QPointF(0.25, 3500) << QPointF(0.12, 5000) << QPointF(0.075, 6500) << QPointF(0.036, 8000);
202 *m_series1 << QPointF(0.50, 2000) << QPointF(0.25, 3500) << QPointF(0.12, 5000) << QPointF(0.075, 6500) << QPointF(0.036, 8000);
197
203
198 // Line series, points outside min-max ranges should not be drawn,
204 // Line series, points outside min-max ranges should not be drawn,
199 // but lines should be properly interpolated at chart edges
205 // but lines should be properly interpolated at chart edges
200 m_series2 = new QLineSeries();
206 m_series2 = new QLineSeries();
201 m_series2->setName("line 1");
207 m_series2->setName("line 1");
202 qreal lineCount = 100;
208 qreal lineCount = 100;
203 qreal lineAngularStep = angularDimension / lineCount;
209 qreal lineAngularStep = angularDimension / lineCount;
204 qreal lineRadialStep = radialDimension / lineCount;
210 qreal lineRadialStep = radialDimension / lineCount;
205 for (qreal i = 0.0; i < lineCount; i++) {
211 for (qreal i = 0.0; i < lineCount; i++) {
206 m_series2->append((i * lineAngularStep) + seriesAngularMin, (i * lineRadialStep) + seriesRadialMin);
212 m_series2->append((i * lineAngularStep) + seriesAngularMin, (i * lineRadialStep) + seriesRadialMin);
207 //qDebug() << m_series2->points().last();
213 //qDebug() << m_series2->points().last();
208 }
214 }
209 QPen series2Pen = QPen(Qt::blue, 10);
215 QPen series2Pen = QPen(Qt::blue, 10);
210 //series2Pen.setStyle(Qt::DashDotDotLine);
216 //series2Pen.setStyle(Qt::DashDotDotLine);
211 m_series2->setPen(series2Pen);
217 m_series2->setPen(series2Pen);
212
218
213 m_series3 = new QLineSeries();
219 m_series3 = new QLineSeries();
214 m_series3->setName("Area upper");
220 m_series3->setName("Area upper");
215 lineCount = 87;
221 lineCount = 87;
216 lineAngularStep = angularDimension / lineCount;
222 lineAngularStep = angularDimension / lineCount;
217 lineRadialStep = radialDimension / lineCount;
223 lineRadialStep = radialDimension / lineCount;
218 for (qreal i = 1.0; i <= lineCount; i++) {
224 for (qreal i = 1.0; i <= lineCount; i++) {
219 m_series3->append((i * lineAngularStep) + seriesAngularMin, (i * lineRadialStep) + seriesRadialMin + 200.0);
225 m_series3->append((i * lineAngularStep) + seriesAngularMin, (i * lineRadialStep) + seriesRadialMin + 200.0);
220 //qDebug() << m_series3->points().last();
226 //qDebug() << m_series3->points().last();
221 }
227 }
222
228
223 m_series4 = new QLineSeries();
229 m_series4 = new QLineSeries();
224 m_series4->setName("Area lower");
230 m_series4->setName("Area lower");
225 lineCount = 89;
231 lineCount = 89;
226 lineAngularStep = angularDimension / lineCount;
232 lineAngularStep = angularDimension / lineCount;
227 lineRadialStep = radialDimension / lineCount;
233 lineRadialStep = radialDimension / lineCount;
228 for (qreal i = 1.0; i <= lineCount; i++) {
234 for (qreal i = 1.0; i <= lineCount; i++) {
229 m_series4->append((i * lineAngularStep) + seriesAngularMin + 100.0, (i * lineRadialStep) + seriesRadialMin + i * 300.0);
235 m_series4->append((i * lineAngularStep) + seriesAngularMin + 100.0, (i * lineRadialStep) + seriesRadialMin + i * 300.0);
230 //qDebug() << m_series4->points().last();
236 //qDebug() << m_series4->points().last();
231 }
237 }
232
238
233 m_series5 = new QAreaSeries();
239 m_series5 = new QAreaSeries();
234 m_series5->setName("area");
240 m_series5->setName("area");
235 m_series5->setUpperSeries(m_series3);
241 m_series5->setUpperSeries(m_series3);
236 m_series5->setLowerSeries(m_series4);
242 m_series5->setLowerSeries(m_series4);
237 m_series5->setOpacity(0.5);
243 m_series5->setOpacity(0.5);
238
244
239 m_series6 = new QSplineSeries();
245 m_series6 = new QSplineSeries();
240 m_series6->setName("spline");
246 m_series6->setName("spline");
241 qreal ad = angularDimension / 20;
247 qreal ad = angularDimension / 20;
242 qreal rd = radialDimension / 10;
248 qreal rd = radialDimension / 10;
243 m_series6->append(seriesAngularMin, seriesRadialMin + rd * 2);
249 m_series6->append(seriesAngularMin, seriesRadialMin + rd * 2);
244 m_series6->append(seriesAngularMin + ad, seriesRadialMin + rd * 5);
250 m_series6->append(seriesAngularMin + ad, seriesRadialMin + rd * 5);
245 m_series6->append(seriesAngularMin + ad * 2, seriesRadialMin + rd * 4);
251 m_series6->append(seriesAngularMin + ad * 2, seriesRadialMin + rd * 4);
246 m_series6->append(seriesAngularMin + ad * 3, seriesRadialMin + rd * 9);
252 m_series6->append(seriesAngularMin + ad * 3, seriesRadialMin + rd * 9);
247 m_series6->append(seriesAngularMin + ad * 4, seriesRadialMin + rd * 11);
253 m_series6->append(seriesAngularMin + ad * 4, seriesRadialMin + rd * 11);
248 m_series6->append(seriesAngularMin + ad * 5, seriesRadialMin + rd * 12);
254 m_series6->append(seriesAngularMin + ad * 5, seriesRadialMin + rd * 12);
249 m_series6->append(seriesAngularMin + ad * 6, seriesRadialMin + rd * 9);
255 m_series6->append(seriesAngularMin + ad * 6, seriesRadialMin + rd * 9);
250 m_series6->append(seriesAngularMin + ad * 7, seriesRadialMin + rd * 11);
256 m_series6->append(seriesAngularMin + ad * 7, seriesRadialMin + rd * 11);
251 m_series6->append(seriesAngularMin + ad * 8, seriesRadialMin + rd * 12);
257 m_series6->append(seriesAngularMin + ad * 8, seriesRadialMin + rd * 12);
252 m_series6->append(seriesAngularMin + ad * 9, seriesRadialMin + rd * 6);
258 m_series6->append(seriesAngularMin + ad * 9, seriesRadialMin + rd * 6);
253 m_series6->append(seriesAngularMin + ad * 10, seriesRadialMin + rd * 4);
259 m_series6->append(seriesAngularMin + ad * 10, seriesRadialMin + rd * 4);
254 m_series6->append(seriesAngularMin + ad * 10, seriesRadialMin + rd * 8);
260 m_series6->append(seriesAngularMin + ad * 10, seriesRadialMin + rd * 8);
255 m_series6->append(seriesAngularMin + ad * 11, seriesRadialMin + rd * 9);
261 m_series6->append(seriesAngularMin + ad * 11, seriesRadialMin + rd * 9);
256 m_series6->append(seriesAngularMin + ad * 12, seriesRadialMin + rd * 11);
262 m_series6->append(seriesAngularMin + ad * 12, seriesRadialMin + rd * 11);
257 m_series6->append(seriesAngularMin + ad * 13, seriesRadialMin + rd * 12);
263 m_series6->append(seriesAngularMin + ad * 13, seriesRadialMin + rd * 12);
258 m_series6->append(seriesAngularMin + ad * 14, seriesRadialMin + rd * 6);
264 m_series6->append(seriesAngularMin + ad * 14, seriesRadialMin + rd * 6);
259 m_series6->append(seriesAngularMin + ad * 15, seriesRadialMin + rd * 3);
265 m_series6->append(seriesAngularMin + ad * 15, seriesRadialMin + rd * 3);
260 m_series6->append(seriesAngularMin + ad * 16, seriesRadialMin + rd * 2);
266 m_series6->append(seriesAngularMin + ad * 16, seriesRadialMin + rd * 2);
261 m_series6->append(seriesAngularMin + ad * 17, seriesRadialMin + rd * 6);
267 m_series6->append(seriesAngularMin + ad * 17, seriesRadialMin + rd * 6);
262 m_series6->append(seriesAngularMin + ad * 18, seriesRadialMin + rd * 6);
268 m_series6->append(seriesAngularMin + ad * 18, seriesRadialMin + rd * 6);
263 m_series6->append(seriesAngularMin + ad * 19, seriesRadialMin + rd * 6);
269 m_series6->append(seriesAngularMin + ad * 19, seriesRadialMin + rd * 6);
264 m_series6->append(seriesAngularMin + ad * 20, seriesRadialMin + rd * 6);
270 m_series6->append(seriesAngularMin + ad * 20, seriesRadialMin + rd * 6);
265 m_series6->append(seriesAngularMin + ad * 19, seriesRadialMin + rd * 2);
271 m_series6->append(seriesAngularMin + ad * 19, seriesRadialMin + rd * 2);
266 m_series6->append(seriesAngularMin + ad * 18, seriesRadialMin + rd * 9);
272 m_series6->append(seriesAngularMin + ad * 18, seriesRadialMin + rd * 9);
267 m_series6->append(seriesAngularMin + ad * 17, seriesRadialMin + rd * 7);
273 m_series6->append(seriesAngularMin + ad * 17, seriesRadialMin + rd * 7);
268 m_series6->append(seriesAngularMin + ad * 16, seriesRadialMin + rd * 3);
274 m_series6->append(seriesAngularMin + ad * 16, seriesRadialMin + rd * 3);
269 m_series6->append(seriesAngularMin + ad * 15, seriesRadialMin + rd * 1);
275 m_series6->append(seriesAngularMin + ad * 15, seriesRadialMin + rd * 1);
270 m_series6->append(seriesAngularMin + ad * 14, seriesRadialMin + rd * 7);
276 m_series6->append(seriesAngularMin + ad * 14, seriesRadialMin + rd * 7);
271 m_series6->append(seriesAngularMin + ad * 13, seriesRadialMin + rd * 5);
277 m_series6->append(seriesAngularMin + ad * 13, seriesRadialMin + rd * 5);
272 m_series6->append(seriesAngularMin + ad * 12, seriesRadialMin + rd * 9);
278 m_series6->append(seriesAngularMin + ad * 12, seriesRadialMin + rd * 9);
273 m_series6->append(seriesAngularMin + ad * 11, seriesRadialMin + rd * 1);
279 m_series6->append(seriesAngularMin + ad * 11, seriesRadialMin + rd * 1);
274 m_series6->append(seriesAngularMin + ad * 10, seriesRadialMin + rd * 4);
280 m_series6->append(seriesAngularMin + ad * 10, seriesRadialMin + rd * 4);
275 m_series6->append(seriesAngularMin + ad * 9, seriesRadialMin + rd * 1);
281 m_series6->append(seriesAngularMin + ad * 9, seriesRadialMin + rd * 1);
276 m_series6->append(seriesAngularMin + ad * 8, seriesRadialMin + rd * 2);
282 m_series6->append(seriesAngularMin + ad * 8, seriesRadialMin + rd * 2);
277 m_series6->append(seriesAngularMin + ad * 7, seriesRadialMin + rd * 4);
283 m_series6->append(seriesAngularMin + ad * 7, seriesRadialMin + rd * 4);
278 m_series6->append(seriesAngularMin + ad * 6, seriesRadialMin + rd * 8);
284 m_series6->append(seriesAngularMin + ad * 6, seriesRadialMin + rd * 8);
279 m_series6->append(seriesAngularMin + ad * 5, seriesRadialMin + rd * 12);
285 m_series6->append(seriesAngularMin + ad * 5, seriesRadialMin + rd * 12);
280 m_series6->append(seriesAngularMin + ad * 4, seriesRadialMin + rd * 9);
286 m_series6->append(seriesAngularMin + ad * 4, seriesRadialMin + rd * 9);
281 m_series6->append(seriesAngularMin + ad * 3, seriesRadialMin + rd * 8);
287 m_series6->append(seriesAngularMin + ad * 3, seriesRadialMin + rd * 8);
282 m_series6->append(seriesAngularMin + ad * 2, seriesRadialMin + rd * 7);
288 m_series6->append(seriesAngularMin + ad * 2, seriesRadialMin + rd * 7);
283 m_series6->append(seriesAngularMin + ad, seriesRadialMin + rd * 4);
289 m_series6->append(seriesAngularMin + ad, seriesRadialMin + rd * 4);
284 m_series6->append(seriesAngularMin, seriesRadialMin + rd * 10);
290 m_series6->append(seriesAngularMin, seriesRadialMin + rd * 10);
285
291
286 m_series6->setPointsVisible(true);
292 m_series6->setPointsVisible(true);
287 QPen series6Pen = QPen(Qt::red, 10);
293 QPen series6Pen = QPen(Qt::red, 10);
288 //series6Pen.setStyle(Qt::DashDotDotLine);
294 //series6Pen.setStyle(Qt::DashDotDotLine);
289 m_series6->setPen(series6Pen);
295 m_series6->setPen(series6Pen);
290
296
291 // m_series7 shows points at category intersections
297 // m_series7 shows points at category intersections
292 m_series7 = new QScatterSeries();
298 m_series7 = new QScatterSeries();
293 m_series7->setName("Category check");
299 m_series7->setName("Category check");
294 m_series7->setMarkerSize(7);
300 m_series7->setMarkerSize(7);
295 m_series7->setBrush(QColor(Qt::red));
301 m_series7->setBrush(QColor(Qt::red));
296 m_series7->setMarkerShape(QScatterSeries::MarkerShapeRectangle);
302 m_series7->setMarkerShape(QScatterSeries::MarkerShapeRectangle);
297 *m_series7 << QPointF(1000, 1000)
303 *m_series7 << QPointF(1000, 1000)
298 << QPointF(1000, 2000)
304 << QPointF(1000, 2000)
299 << QPointF(1000, 4000)
305 << QPointF(1000, 4000)
300 << QPointF(1000, 9000)
306 << QPointF(1000, 9000)
301 << QPointF(1000, 14000)
307 << QPointF(1000, 14000)
302 << QPointF(1000, 16500)
308 << QPointF(1000, 16500)
303 << QPointF(1000, 19000)
309 << QPointF(1000, 19000)
304
310
305 << QPointF(4000, 1000)
311 << QPointF(4000, 1000)
306 << QPointF(4000, 2000)
312 << QPointF(4000, 2000)
307 << QPointF(4000, 4000)
313 << QPointF(4000, 4000)
308 << QPointF(4000, 9000)
314 << QPointF(4000, 9000)
309 << QPointF(4000, 14000)
315 << QPointF(4000, 14000)
310 << QPointF(4000, 16500)
316 << QPointF(4000, 16500)
311 << QPointF(4000, 19000)
317 << QPointF(4000, 19000)
312
318
313 << QPointF(7000, 1000)
319 << QPointF(7000, 1000)
314 << QPointF(7000, 2000)
320 << QPointF(7000, 2000)
315 << QPointF(7000, 4000)
321 << QPointF(7000, 4000)
316 << QPointF(7000, 9000)
322 << QPointF(7000, 9000)
317 << QPointF(7000, 14000)
323 << QPointF(7000, 14000)
318 << QPointF(7000, 16500)
324 << QPointF(7000, 16500)
319 << QPointF(7000, 19000)
325 << QPointF(7000, 19000)
320
326
321 << QPointF(12000, 1000)
327 << QPointF(12000, 1000)
322 << QPointF(12000, 2000)
328 << QPointF(12000, 2000)
323 << QPointF(12000, 4000)
329 << QPointF(12000, 4000)
324 << QPointF(12000, 9000)
330 << QPointF(12000, 9000)
325 << QPointF(12000, 14000)
331 << QPointF(12000, 14000)
326 << QPointF(12000, 16500)
332 << QPointF(12000, 16500)
327 << QPointF(12000, 19000)
333 << QPointF(12000, 19000)
328
334
329 << QPointF(17000, 1000)
335 << QPointF(17000, 1000)
330 << QPointF(17000, 2000)
336 << QPointF(17000, 2000)
331 << QPointF(17000, 4000)
337 << QPointF(17000, 4000)
332 << QPointF(17000, 9000)
338 << QPointF(17000, 9000)
333 << QPointF(17000, 14000)
339 << QPointF(17000, 14000)
334 << QPointF(17000, 16500)
340 << QPointF(17000, 16500)
335 << QPointF(17000, 19000)
341 << QPointF(17000, 19000)
336
342
337 << QPointF(22000, 1000)
343 << QPointF(22000, 1000)
338 << QPointF(22000, 2000)
344 << QPointF(22000, 2000)
339 << QPointF(22000, 4000)
345 << QPointF(22000, 4000)
340 << QPointF(22000, 9000)
346 << QPointF(22000, 9000)
341 << QPointF(22000, 14000)
347 << QPointF(22000, 14000)
342 << QPointF(22000, 16500)
348 << QPointF(22000, 16500)
343 << QPointF(22000, 19000)
349 << QPointF(22000, 19000)
344
350
345 << QPointF(28000, 1000)
351 << QPointF(28000, 1000)
346 << QPointF(28000, 2000)
352 << QPointF(28000, 2000)
347 << QPointF(28000, 4000)
353 << QPointF(28000, 4000)
348 << QPointF(28000, 9000)
354 << QPointF(28000, 9000)
349 << QPointF(28000, 14000)
355 << QPointF(28000, 14000)
350 << QPointF(28000, 16500)
356 << QPointF(28000, 16500)
351 << QPointF(28000, 19000);
357 << QPointF(28000, 19000);
352
358
353 m_chart = new QPolarChart();
359 m_chart = new QPolarChart();
354
360
355 m_chart->addSeries(m_series1);
361 m_chart->addSeries(m_series1);
356 m_chart->addSeries(m_series2);
362 m_chart->addSeries(m_series2);
357 m_chart->addSeries(m_series3);
363 m_chart->addSeries(m_series3);
358 m_chart->addSeries(m_series4);
364 m_chart->addSeries(m_series4);
359 m_chart->addSeries(m_series5);
365 m_chart->addSeries(m_series5);
360 m_chart->addSeries(m_series6);
366 m_chart->addSeries(m_series6);
361 m_chart->addSeries(m_series7);
367 m_chart->addSeries(m_series7);
362
368
363 connect(m_series1, SIGNAL(clicked(QPointF)), this, SLOT(seriesClicked(QPointF)));
369 connect(m_series1, SIGNAL(clicked(QPointF)), this, SLOT(seriesClicked(QPointF)));
364 connect(m_series2, SIGNAL(clicked(QPointF)), this, SLOT(seriesClicked(QPointF)));
370 connect(m_series2, SIGNAL(clicked(QPointF)), this, SLOT(seriesClicked(QPointF)));
365 connect(m_series3, SIGNAL(clicked(QPointF)), this, SLOT(seriesClicked(QPointF)));
371 connect(m_series3, SIGNAL(clicked(QPointF)), this, SLOT(seriesClicked(QPointF)));
366 connect(m_series4, SIGNAL(clicked(QPointF)), this, SLOT(seriesClicked(QPointF)));
372 connect(m_series4, SIGNAL(clicked(QPointF)), this, SLOT(seriesClicked(QPointF)));
367 connect(m_series5, SIGNAL(clicked(QPointF)), this, SLOT(seriesClicked(QPointF)));
373 connect(m_series5, SIGNAL(clicked(QPointF)), this, SLOT(seriesClicked(QPointF)));
368 connect(m_series6, SIGNAL(clicked(QPointF)), this, SLOT(seriesClicked(QPointF)));
374 connect(m_series6, SIGNAL(clicked(QPointF)), this, SLOT(seriesClicked(QPointF)));
369 connect(m_series7, SIGNAL(clicked(QPointF)), this, SLOT(seriesClicked(QPointF)));
375 connect(m_series7, SIGNAL(clicked(QPointF)), this, SLOT(seriesClicked(QPointF)));
370 connect(m_series1, SIGNAL(hovered(QPointF, bool)), this, SLOT(seriesHovered(QPointF, bool)));
376 connect(m_series1, SIGNAL(hovered(QPointF, bool)), this, SLOT(seriesHovered(QPointF, bool)));
371 connect(m_series2, SIGNAL(hovered(QPointF, bool)), this, SLOT(seriesHovered(QPointF, bool)));
377 connect(m_series2, SIGNAL(hovered(QPointF, bool)), this, SLOT(seriesHovered(QPointF, bool)));
372 connect(m_series3, SIGNAL(hovered(QPointF, bool)), this, SLOT(seriesHovered(QPointF, bool)));
378 connect(m_series3, SIGNAL(hovered(QPointF, bool)), this, SLOT(seriesHovered(QPointF, bool)));
373 connect(m_series4, SIGNAL(hovered(QPointF, bool)), this, SLOT(seriesHovered(QPointF, bool)));
379 connect(m_series4, SIGNAL(hovered(QPointF, bool)), this, SLOT(seriesHovered(QPointF, bool)));
374 connect(m_series5, SIGNAL(hovered(QPointF, bool)), this, SLOT(seriesHovered(QPointF, bool)));
380 connect(m_series5, SIGNAL(hovered(QPointF, bool)), this, SLOT(seriesHovered(QPointF, bool)));
375 connect(m_series6, SIGNAL(hovered(QPointF, bool)), this, SLOT(seriesHovered(QPointF, bool)));
381 connect(m_series6, SIGNAL(hovered(QPointF, bool)), this, SLOT(seriesHovered(QPointF, bool)));
376 connect(m_series7, SIGNAL(hovered(QPointF, bool)), this, SLOT(seriesHovered(QPointF, bool)));
382 connect(m_series7, SIGNAL(hovered(QPointF, bool)), this, SLOT(seriesHovered(QPointF, bool)));
377
383
378 m_chart->setTitle("Use arrow keys to scroll and +/- to zoom");
384 m_chart->setTitle("Use arrow keys to scroll and +/- to zoom");
379 m_chart->setAnimationOptions(m_animationOptions);
385 m_chart->setAnimationOptions(m_animationOptions);
380 //m_chart->legend()->setVisible(false);
386 //m_chart->legend()->setVisible(false);
381 m_chart->setAcceptHoverEvents(true);
387 m_chart->setAcceptHoverEvents(true);
388 m_chart->setBackgroundBrush(*m_backgroundBrush);
389 m_chart->setBackgroundPen(*m_backgroundPen);
390 m_chart->setPlotAreaBackgroundBrush(*m_plotAreaBackgroundBrush);
391 m_chart->setPlotAreaBackgroundPen(*m_plotAreaBackgroundPen);
382 }
392 }
383
393
384 void MainWindow::setAngularAxis(MainWindow::AxisMode mode)
394 void MainWindow::setAngularAxis(MainWindow::AxisMode mode)
385 {
395 {
386 if (m_angularAxis) {
396 if (m_angularAxis) {
387 m_chart->removeAxis(m_angularAxis);
397 m_chart->removeAxis(m_angularAxis);
388 delete m_angularAxis;
398 delete m_angularAxis;
389 m_angularAxis = 0;
399 m_angularAxis = 0;
390 }
400 }
391
401
392 m_angularAxisMode = mode;
402 m_angularAxisMode = mode;
393
403
394 switch (m_angularAxisMode) {
404 switch (m_angularAxisMode) {
395 case AxisModeNone:
405 case AxisModeNone:
396 return;
406 return;
397 case AxisModeValue:
407 case AxisModeValue:
398 m_angularAxis = new QValueAxis();
408 m_angularAxis = new QValueAxis();
399 static_cast<QValueAxis *>(m_angularAxis)->setTickCount(m_angularTickCount);
409 static_cast<QValueAxis *>(m_angularAxis)->setTickCount(m_angularTickCount);
400 static_cast<QValueAxis *>(m_angularAxis)->setLabelFormat(m_labelFormat);
410 static_cast<QValueAxis *>(m_angularAxis)->setLabelFormat(m_labelFormat);
401 break;
411 break;
402 case AxisModeLogValue:
412 case AxisModeLogValue:
403 m_angularAxis = new QLogValueAxis();
413 m_angularAxis = new QLogValueAxis();
404 static_cast<QLogValueAxis *>(m_angularAxis)->setBase(m_base);
414 static_cast<QLogValueAxis *>(m_angularAxis)->setBase(m_base);
405 static_cast<QLogValueAxis *>(m_angularAxis)->setLabelFormat(m_labelFormat);
415 static_cast<QLogValueAxis *>(m_angularAxis)->setLabelFormat(m_labelFormat);
406 break;
416 break;
407 case AxisModeDateTime:
417 case AxisModeDateTime:
408 m_angularAxis = new QDateTimeAxis();
418 m_angularAxis = new QDateTimeAxis();
409 static_cast<QDateTimeAxis *>(m_angularAxis)->setTickCount(m_angularTickCount);
419 static_cast<QDateTimeAxis *>(m_angularAxis)->setTickCount(m_angularTickCount);
410 static_cast<QDateTimeAxis *>(m_angularAxis)->setFormat(m_dateFormat);
420 static_cast<QDateTimeAxis *>(m_angularAxis)->setFormat(m_dateFormat);
411 break;
421 break;
412 case AxisModeCategory:
422 case AxisModeCategory:
413 m_angularAxis = new QCategoryAxis();
423 m_angularAxis = new QCategoryAxis();
414 applyCategories();
424 applyCategories();
415 break;
425 break;
416 default:
426 default:
417 qWarning() << "Unsupported AxisMode";
427 qWarning() << "Unsupported AxisMode";
418 break;
428 break;
419 }
429 }
420
430
421 m_angularAxis->setLabelsAngle(m_labelsAngle);
431 m_angularAxis->setLabelsAngle(m_labelsAngle);
422 m_angularAxis->setLabelsFont(m_currentLabelFont);
432 m_angularAxis->setLabelsFont(m_currentLabelFont);
423 m_angularAxis->setLabelsBrush(*m_labelBrush);
433 m_angularAxis->setLabelsBrush(*m_labelBrush);
424 m_angularAxis->setLabelsPen(*m_labelPen);
434 m_angularAxis->setLabelsPen(*m_labelPen);
425 m_angularAxis->setLabelsVisible(m_labelsVisible);
435 m_angularAxis->setLabelsVisible(m_labelsVisible);
426 m_angularAxis->setShadesBrush(*m_angularShadesBrush);
436 m_angularAxis->setShadesBrush(*m_angularShadesBrush);
427 m_angularAxis->setShadesPen(*m_angularShadesPen);
437 m_angularAxis->setShadesPen(*m_angularShadesPen);
428 m_angularAxis->setShadesVisible(m_angularShadesVisible);
438 m_angularAxis->setShadesVisible(m_angularShadesVisible);
429 m_angularAxis->setTitleFont(m_currentTitleFont);
439 m_angularAxis->setTitleFont(m_currentTitleFont);
430 m_angularAxis->setTitleBrush(*m_titleBrush);
440 m_angularAxis->setTitleBrush(*m_titleBrush);
431 m_angularAxis->setTitlePen(*m_titlePen);
441 m_angularAxis->setTitlePen(*m_titlePen);
432 m_angularAxis->setTitleVisible(m_titleVisible);
442 m_angularAxis->setTitleVisible(m_titleVisible);
433 m_angularAxis->setTitleText(m_angularTitle);
443 m_angularAxis->setTitleText(m_angularTitle);
434 m_angularAxis->setGridLinePen(*m_gridPen);
444 m_angularAxis->setGridLinePen(*m_gridPen);
435 m_angularAxis->setGridLineVisible(m_gridVisible);
445 m_angularAxis->setGridLineVisible(m_gridVisible);
436 m_angularAxis->setLinePen(*m_arrowPen);
446 m_angularAxis->setLinePen(*m_arrowPen);
437 m_angularAxis->setLineVisible(m_arrowVisible);
447 m_angularAxis->setLineVisible(m_arrowVisible);
438
448
439 m_chart->addAxis(m_angularAxis, QPolarChart::PolarOrientationAngular);
449 m_chart->addAxis(m_angularAxis, QPolarChart::PolarOrientationAngular);
440
450
441 m_series1->attachAxis(m_angularAxis);
451 m_series1->attachAxis(m_angularAxis);
442 m_series2->attachAxis(m_angularAxis);
452 m_series2->attachAxis(m_angularAxis);
443 m_series3->attachAxis(m_angularAxis);
453 m_series3->attachAxis(m_angularAxis);
444 m_series4->attachAxis(m_angularAxis);
454 m_series4->attachAxis(m_angularAxis);
445 m_series5->attachAxis(m_angularAxis);
455 m_series5->attachAxis(m_angularAxis);
446 m_series6->attachAxis(m_angularAxis);
456 m_series6->attachAxis(m_angularAxis);
447 m_series7->attachAxis(m_angularAxis);
457 m_series7->attachAxis(m_angularAxis);
448
458
449 applyRanges();
459 applyRanges();
450
460
451 //connect(m_angularAxis, SIGNAL(rangeChanged(qreal, qreal)), this, SLOT(angularRangeChanged(qreal, qreal)));
461 //connect(m_angularAxis, SIGNAL(rangeChanged(qreal, qreal)), this, SLOT(angularRangeChanged(qreal, qreal)));
452 }
462 }
453
463
454 void MainWindow::setRadialAxis(MainWindow::AxisMode mode)
464 void MainWindow::setRadialAxis(MainWindow::AxisMode mode)
455 {
465 {
456 if (m_radialAxis) {
466 if (m_radialAxis) {
457 m_chart->removeAxis(m_radialAxis);
467 m_chart->removeAxis(m_radialAxis);
458 delete m_radialAxis;
468 delete m_radialAxis;
459 m_radialAxis = 0;
469 m_radialAxis = 0;
460 }
470 }
461
471
462 m_radialAxisMode = mode;
472 m_radialAxisMode = mode;
463
473
464 switch (m_radialAxisMode) {
474 switch (m_radialAxisMode) {
465 case AxisModeNone:
475 case AxisModeNone:
466 return;
476 return;
467 case AxisModeValue:
477 case AxisModeValue:
468 m_radialAxis = new QValueAxis();
478 m_radialAxis = new QValueAxis();
469 static_cast<QValueAxis *>(m_radialAxis)->setTickCount(m_radialTickCount);
479 static_cast<QValueAxis *>(m_radialAxis)->setTickCount(m_radialTickCount);
470 static_cast<QValueAxis *>(m_radialAxis)->setLabelFormat(m_labelFormat);
480 static_cast<QValueAxis *>(m_radialAxis)->setLabelFormat(m_labelFormat);
471 break;
481 break;
472 case AxisModeLogValue:
482 case AxisModeLogValue:
473 m_radialAxis = new QLogValueAxis();
483 m_radialAxis = new QLogValueAxis();
474 static_cast<QLogValueAxis *>(m_radialAxis)->setBase(m_base);
484 static_cast<QLogValueAxis *>(m_radialAxis)->setBase(m_base);
475 static_cast<QLogValueAxis *>(m_radialAxis)->setLabelFormat(m_labelFormat);
485 static_cast<QLogValueAxis *>(m_radialAxis)->setLabelFormat(m_labelFormat);
476 break;
486 break;
477 case AxisModeDateTime:
487 case AxisModeDateTime:
478 m_radialAxis = new QDateTimeAxis();
488 m_radialAxis = new QDateTimeAxis();
479 static_cast<QDateTimeAxis *>(m_radialAxis)->setTickCount(m_radialTickCount);
489 static_cast<QDateTimeAxis *>(m_radialAxis)->setTickCount(m_radialTickCount);
480 static_cast<QDateTimeAxis *>(m_radialAxis)->setFormat(m_dateFormat);
490 static_cast<QDateTimeAxis *>(m_radialAxis)->setFormat(m_dateFormat);
481 break;
491 break;
482 case AxisModeCategory:
492 case AxisModeCategory:
483 m_radialAxis = new QCategoryAxis();
493 m_radialAxis = new QCategoryAxis();
484 applyCategories();
494 applyCategories();
485 break;
495 break;
486 default:
496 default:
487 qWarning() << "Unsupported AxisMode";
497 qWarning() << "Unsupported AxisMode";
488 break;
498 break;
489 }
499 }
490
500
491 m_radialAxis->setLabelsAngle(m_labelsAngle);
501 m_radialAxis->setLabelsAngle(m_labelsAngle);
492 m_radialAxis->setLabelsFont(m_currentLabelFont);
502 m_radialAxis->setLabelsFont(m_currentLabelFont);
493 m_radialAxis->setLabelsBrush(*m_labelBrush);
503 m_radialAxis->setLabelsBrush(*m_labelBrush);
494 m_radialAxis->setLabelsPen(*m_labelPen);
504 m_radialAxis->setLabelsPen(*m_labelPen);
495 m_radialAxis->setLabelsVisible(m_labelsVisible);
505 m_radialAxis->setLabelsVisible(m_labelsVisible);
496 m_radialAxis->setShadesBrush(*m_radialShadesBrush);
506 m_radialAxis->setShadesBrush(*m_radialShadesBrush);
497 m_radialAxis->setShadesPen(*m_radialShadesPen);
507 m_radialAxis->setShadesPen(*m_radialShadesPen);
498 m_radialAxis->setShadesVisible(m_radialShadesVisible);
508 m_radialAxis->setShadesVisible(m_radialShadesVisible);
499 m_radialAxis->setTitleFont(m_currentTitleFont);
509 m_radialAxis->setTitleFont(m_currentTitleFont);
500 m_radialAxis->setTitleBrush(*m_titleBrush);
510 m_radialAxis->setTitleBrush(*m_titleBrush);
501 m_radialAxis->setTitlePen(*m_titlePen);
511 m_radialAxis->setTitlePen(*m_titlePen);
502 m_radialAxis->setTitleVisible(m_titleVisible);
512 m_radialAxis->setTitleVisible(m_titleVisible);
503 m_radialAxis->setTitleText(m_radialTitle);
513 m_radialAxis->setTitleText(m_radialTitle);
504 m_radialAxis->setGridLinePen(*m_gridPen);
514 m_radialAxis->setGridLinePen(*m_gridPen);
505 m_radialAxis->setGridLineVisible(m_gridVisible);
515 m_radialAxis->setGridLineVisible(m_gridVisible);
506 m_radialAxis->setLinePen(*m_arrowPen);
516 m_radialAxis->setLinePen(*m_arrowPen);
507 m_radialAxis->setLineVisible(m_arrowVisible);
517 m_radialAxis->setLineVisible(m_arrowVisible);
508
518
509 m_chart->addAxis(m_radialAxis, QPolarChart::PolarOrientationRadial);
519 m_chart->addAxis(m_radialAxis, QPolarChart::PolarOrientationRadial);
510
520
511 m_series1->attachAxis(m_radialAxis);
521 m_series1->attachAxis(m_radialAxis);
512 m_series2->attachAxis(m_radialAxis);
522 m_series2->attachAxis(m_radialAxis);
513 m_series3->attachAxis(m_radialAxis);
523 m_series3->attachAxis(m_radialAxis);
514 m_series4->attachAxis(m_radialAxis);
524 m_series4->attachAxis(m_radialAxis);
515 m_series5->attachAxis(m_radialAxis);
525 m_series5->attachAxis(m_radialAxis);
516 m_series6->attachAxis(m_radialAxis);
526 m_series6->attachAxis(m_radialAxis);
517 m_series7->attachAxis(m_radialAxis);
527 m_series7->attachAxis(m_radialAxis);
518
528
519 applyRanges();
529 applyRanges();
520
530
521 series1CheckBoxChecked();
531 series1CheckBoxChecked();
522 series2CheckBoxChecked();
532 series2CheckBoxChecked();
523 series3CheckBoxChecked();
533 series3CheckBoxChecked();
524 series4CheckBoxChecked();
534 series4CheckBoxChecked();
525 series5CheckBoxChecked();
535 series5CheckBoxChecked();
526 series6CheckBoxChecked();
536 series6CheckBoxChecked();
527 series7CheckBoxChecked();
537 series7CheckBoxChecked();
528
538
529 //connect(m_radialAxis, SIGNAL(rangeChanged(qreal, qreal)), this, SLOT(radialRangeChanged(qreal, qreal)));
539 //connect(m_radialAxis, SIGNAL(rangeChanged(qreal, qreal)), this, SLOT(radialRangeChanged(qreal, qreal)));
530 }
540 }
531
541
532 void MainWindow::applyRanges()
542 void MainWindow::applyRanges()
533 {
543 {
534 if (ui->niceNumbersCheckBox->isChecked()) {
544 if (ui->niceNumbersCheckBox->isChecked()) {
535 if (m_angularAxisMode == AxisModeValue) {
545 if (m_angularAxisMode == AxisModeValue) {
536 static_cast<QValueAxis *>(m_angularAxis)->applyNiceNumbers();
546 static_cast<QValueAxis *>(m_angularAxis)->applyNiceNumbers();
537 m_angularMin = static_cast<QValueAxis *>(m_angularAxis)->min();
547 m_angularMin = static_cast<QValueAxis *>(m_angularAxis)->min();
538 m_angularMax = static_cast<QValueAxis *>(m_angularAxis)->max();
548 m_angularMax = static_cast<QValueAxis *>(m_angularAxis)->max();
539 m_angularTickCount = static_cast<QValueAxis *>(m_angularAxis)->tickCount();
549 m_angularTickCount = static_cast<QValueAxis *>(m_angularAxis)->tickCount();
540 }
550 }
541 if (m_radialAxisMode == AxisModeValue) {
551 if (m_radialAxisMode == AxisModeValue) {
542 static_cast<QValueAxis *>(m_radialAxis)->applyNiceNumbers();
552 static_cast<QValueAxis *>(m_radialAxis)->applyNiceNumbers();
543 m_radialMin = static_cast<QValueAxis *>(m_radialAxis)->min();
553 m_radialMin = static_cast<QValueAxis *>(m_radialAxis)->min();
544 m_radialMax = static_cast<QValueAxis *>(m_radialAxis)->max();
554 m_radialMax = static_cast<QValueAxis *>(m_radialAxis)->max();
545 m_radialTickCount = static_cast<QValueAxis *>(m_radialAxis)->tickCount();
555 m_radialTickCount = static_cast<QValueAxis *>(m_radialAxis)->tickCount();
546 }
556 }
547 }
557 }
548
558
549 if (m_angularAxis)
559 if (m_angularAxis)
550 m_angularAxis->setRange(m_angularMin, m_angularMax);
560 m_angularAxis->setRange(m_angularMin, m_angularMax);
551 if (m_radialAxis)
561 if (m_radialAxis)
552 m_radialAxis->setRange(m_radialMin, m_radialMax);
562 m_radialAxis->setRange(m_radialMin, m_radialMax);
553 }
563 }
554
564
555 void MainWindow::angularTicksChanged(int value)
565 void MainWindow::angularTicksChanged(int value)
556 {
566 {
557 m_angularTickCount = value;
567 m_angularTickCount = value;
558 if (m_angularAxisMode == AxisModeValue)
568 if (m_angularAxisMode == AxisModeValue)
559 static_cast<QValueAxis *>(m_angularAxis)->setTickCount(m_angularTickCount);
569 static_cast<QValueAxis *>(m_angularAxis)->setTickCount(m_angularTickCount);
560 else if (m_angularAxisMode == AxisModeDateTime)
570 else if (m_angularAxisMode == AxisModeDateTime)
561 static_cast<QDateTimeAxis *>(m_angularAxis)->setTickCount(m_angularTickCount);
571 static_cast<QDateTimeAxis *>(m_angularAxis)->setTickCount(m_angularTickCount);
562 }
572 }
563
573
564 void MainWindow::radialTicksChanged(int value)
574 void MainWindow::radialTicksChanged(int value)
565 {
575 {
566 m_radialTickCount = value;
576 m_radialTickCount = value;
567 if (m_radialAxisMode == AxisModeValue)
577 if (m_radialAxisMode == AxisModeValue)
568 static_cast<QValueAxis *>(m_radialAxis)->setTickCount(m_radialTickCount);
578 static_cast<QValueAxis *>(m_radialAxis)->setTickCount(m_radialTickCount);
569 else if (m_radialAxisMode == AxisModeDateTime)
579 else if (m_radialAxisMode == AxisModeDateTime)
570 static_cast<QDateTimeAxis *>(m_radialAxis)->setTickCount(m_radialTickCount);
580 static_cast<QDateTimeAxis *>(m_radialAxis)->setTickCount(m_radialTickCount);
571 }
581 }
572
582
573 void MainWindow::anglesChanged(int value)
583 void MainWindow::anglesChanged(int value)
574 {
584 {
575 m_labelsAngle = value;
585 m_labelsAngle = value;
576 m_radialAxis->setLabelsAngle(m_labelsAngle);
586 m_radialAxis->setLabelsAngle(m_labelsAngle);
577 m_angularAxis->setLabelsAngle(m_labelsAngle);
587 m_angularAxis->setLabelsAngle(m_labelsAngle);
578 }
588 }
579
589
580 void MainWindow::angularMinChanged(double value)
590 void MainWindow::angularMinChanged(double value)
581 {
591 {
582 m_angularMin = value;
592 m_angularMin = value;
583 if (m_angularAxisMode != AxisModeDateTime) {
593 if (m_angularAxisMode != AxisModeDateTime) {
584 m_angularAxis->setMin(m_angularMin);
594 m_angularAxis->setMin(m_angularMin);
585 } else {
595 } else {
586 QDateTime dateTime;
596 QDateTime dateTime;
587 dateTime.setMSecsSinceEpoch(qint64(m_angularMin));
597 dateTime.setMSecsSinceEpoch(qint64(m_angularMin));
588 m_angularAxis->setMin(dateTime);
598 m_angularAxis->setMin(dateTime);
589 }
599 }
590 }
600 }
591
601
592 void MainWindow::angularMaxChanged(double value)
602 void MainWindow::angularMaxChanged(double value)
593 {
603 {
594 m_angularMax = value;
604 m_angularMax = value;
595 if (m_angularAxisMode != AxisModeDateTime) {
605 if (m_angularAxisMode != AxisModeDateTime) {
596 m_angularAxis->setMax(m_angularMax);
606 m_angularAxis->setMax(m_angularMax);
597 } else {
607 } else {
598 QDateTime dateTime;
608 QDateTime dateTime;
599 dateTime.setMSecsSinceEpoch(qint64(m_angularMax));
609 dateTime.setMSecsSinceEpoch(qint64(m_angularMax));
600 m_angularAxis->setMax(dateTime);
610 m_angularAxis->setMax(dateTime);
601 }
611 }
602 }
612 }
603
613
604 void MainWindow::radialMinChanged(double value)
614 void MainWindow::radialMinChanged(double value)
605 {
615 {
606 m_radialMin = value;
616 m_radialMin = value;
607 if (m_radialAxisMode != AxisModeDateTime) {
617 if (m_radialAxisMode != AxisModeDateTime) {
608 m_radialAxis->setMin(m_radialMin);
618 m_radialAxis->setMin(m_radialMin);
609 } else {
619 } else {
610 QDateTime dateTime;
620 QDateTime dateTime;
611 dateTime.setMSecsSinceEpoch(qint64(m_radialMin));
621 dateTime.setMSecsSinceEpoch(qint64(m_radialMin));
612 m_radialAxis->setMin(dateTime);
622 m_radialAxis->setMin(dateTime);
613 }
623 }
614 }
624 }
615
625
616 void MainWindow::radialMaxChanged(double value)
626 void MainWindow::radialMaxChanged(double value)
617 {
627 {
618 m_radialMax = value;
628 m_radialMax = value;
619 if (m_radialAxisMode != AxisModeDateTime) {
629 if (m_radialAxisMode != AxisModeDateTime) {
620 m_radialAxis->setMax(m_radialMax);
630 m_radialAxis->setMax(m_radialMax);
621 } else {
631 } else {
622 QDateTime dateTime;
632 QDateTime dateTime;
623 dateTime.setMSecsSinceEpoch(qint64(m_radialMax));
633 dateTime.setMSecsSinceEpoch(qint64(m_radialMax));
624 m_radialAxis->setMax(dateTime);
634 m_radialAxis->setMax(dateTime);
625 }
635 }
626 }
636 }
627
637
628 void MainWindow::angularShadesIndexChanged(int index)
638 void MainWindow::angularShadesIndexChanged(int index)
629 {
639 {
630 delete m_angularShadesBrush;
640 delete m_angularShadesBrush;
631 delete m_angularShadesPen;
641 delete m_angularShadesPen;
632
642
633 switch (index) {
643 switch (index) {
634 case 0:
644 case 0:
635 m_angularShadesBrush = new QBrush(Qt::NoBrush);
645 m_angularShadesBrush = new QBrush(Qt::NoBrush);
636 m_angularShadesPen = new QPen(Qt::NoPen);
646 m_angularShadesPen = new QPen(Qt::NoPen);
637 m_angularShadesVisible = false;
647 m_angularShadesVisible = false;
638 break;
648 break;
639 case 1:
649 case 1:
640 m_angularShadesBrush = new QBrush(Qt::lightGray);
650 m_angularShadesBrush = new QBrush(Qt::lightGray);
641 m_angularShadesPen = new QPen(Qt::NoPen);
651 m_angularShadesPen = new QPen(Qt::NoPen);
642 m_angularShadesVisible = true;
652 m_angularShadesVisible = true;
643 break;
653 break;
644 case 2:
654 case 2:
645 m_angularShadesBrush = new QBrush(Qt::yellow);
655 m_angularShadesBrush = new QBrush(Qt::yellow);
646 m_angularShadesPen = new QPen(Qt::DotLine);
656 m_angularShadesPen = new QPen(Qt::DotLine);
647 m_angularShadesPen->setWidth(2);
657 m_angularShadesPen->setWidth(2);
648 m_angularShadesVisible = true;
658 m_angularShadesVisible = true;
649 break;
659 break;
650 default:
660 default:
651 break;
661 break;
652 }
662 }
653
663
654 m_angularAxis->setShadesBrush(*m_angularShadesBrush);
664 m_angularAxis->setShadesBrush(*m_angularShadesBrush);
655 m_angularAxis->setShadesPen(*m_angularShadesPen);
665 m_angularAxis->setShadesPen(*m_angularShadesPen);
656 m_angularAxis->setShadesVisible(m_angularShadesVisible);
666 m_angularAxis->setShadesVisible(m_angularShadesVisible);
657 }
667 }
658
668
659 void MainWindow::radialShadesIndexChanged(int index)
669 void MainWindow::radialShadesIndexChanged(int index)
660 {
670 {
661 delete m_radialShadesBrush;
671 delete m_radialShadesBrush;
662 delete m_radialShadesPen;
672 delete m_radialShadesPen;
663
673
664 switch (index) {
674 switch (index) {
665 case 0:
675 case 0:
666 m_radialShadesBrush = new QBrush(Qt::NoBrush);
676 m_radialShadesBrush = new QBrush(Qt::NoBrush);
667 m_radialShadesPen = new QPen(Qt::NoPen);
677 m_radialShadesPen = new QPen(Qt::NoPen);
668 m_radialShadesVisible = false;
678 m_radialShadesVisible = false;
669 break;
679 break;
670 case 1:
680 case 1:
671 m_radialShadesBrush = new QBrush(Qt::green);
681 m_radialShadesBrush = new QBrush(Qt::green);
672 m_radialShadesPen = new QPen(Qt::NoPen);
682 m_radialShadesPen = new QPen(Qt::NoPen);
673 m_radialShadesVisible = true;
683 m_radialShadesVisible = true;
674 break;
684 break;
675 case 2:
685 case 2:
676 m_radialShadesBrush = new QBrush(Qt::blue);
686 m_radialShadesBrush = new QBrush(Qt::blue);
677 m_radialShadesPen = new QPen(Qt::DotLine);
687 m_radialShadesPen = new QPen(Qt::DotLine);
678 m_radialShadesPen->setWidth(2);
688 m_radialShadesPen->setWidth(2);
679 m_radialShadesVisible = true;
689 m_radialShadesVisible = true;
680 break;
690 break;
681 default:
691 default:
682 break;
692 break;
683 }
693 }
684
694
685 m_radialAxis->setShadesBrush(*m_radialShadesBrush);
695 m_radialAxis->setShadesBrush(*m_radialShadesBrush);
686 m_radialAxis->setShadesPen(*m_radialShadesPen);
696 m_radialAxis->setShadesPen(*m_radialShadesPen);
687 m_radialAxis->setShadesVisible(m_radialShadesVisible);
697 m_radialAxis->setShadesVisible(m_radialShadesVisible);
688 }
698 }
689
699
690 void MainWindow::labelFormatEdited(const QString &text)
700 void MainWindow::labelFormatEdited(const QString &text)
691 {
701 {
692 m_labelFormat = text;
702 m_labelFormat = text;
693 if (m_angularAxisMode == AxisModeValue)
703 if (m_angularAxisMode == AxisModeValue)
694 static_cast<QValueAxis *>(m_angularAxis)->setLabelFormat(m_labelFormat);
704 static_cast<QValueAxis *>(m_angularAxis)->setLabelFormat(m_labelFormat);
695 else if (m_angularAxisMode == AxisModeLogValue)
705 else if (m_angularAxisMode == AxisModeLogValue)
696 static_cast<QLogValueAxis *>(m_angularAxis)->setLabelFormat(m_labelFormat);
706 static_cast<QLogValueAxis *>(m_angularAxis)->setLabelFormat(m_labelFormat);
697
707
698 if (m_radialAxisMode == AxisModeValue)
708 if (m_radialAxisMode == AxisModeValue)
699 static_cast<QValueAxis *>(m_radialAxis)->setLabelFormat(m_labelFormat);
709 static_cast<QValueAxis *>(m_radialAxis)->setLabelFormat(m_labelFormat);
700 else if (m_radialAxisMode == AxisModeLogValue)
710 else if (m_radialAxisMode == AxisModeLogValue)
701 static_cast<QLogValueAxis *>(m_radialAxis)->setLabelFormat(m_labelFormat);
711 static_cast<QLogValueAxis *>(m_radialAxis)->setLabelFormat(m_labelFormat);
702 }
712 }
703
713
704 void MainWindow::labelFontChanged(const QFont &font)
714 void MainWindow::labelFontChanged(const QFont &font)
705 {
715 {
706 m_currentLabelFont = font;
716 m_currentLabelFont = font;
707 m_currentLabelFont.setPixelSize(ui->labelFontSizeSpin->value());
717 m_currentLabelFont.setPixelSize(ui->labelFontSizeSpin->value());
708 m_angularAxis->setLabelsFont(m_currentLabelFont);
718 m_angularAxis->setLabelsFont(m_currentLabelFont);
709 m_radialAxis->setLabelsFont(m_currentLabelFont);
719 m_radialAxis->setLabelsFont(m_currentLabelFont);
710 }
720 }
711
721
712 void MainWindow::labelFontSizeChanged(int value)
722 void MainWindow::labelFontSizeChanged(int value)
713 {
723 {
714 m_currentLabelFont = ui->labelFontComboBox->currentFont();
724 m_currentLabelFont = ui->labelFontComboBox->currentFont();
715 m_currentLabelFont.setPixelSize(value);
725 m_currentLabelFont.setPixelSize(value);
716 m_angularAxis->setLabelsFont(m_currentLabelFont);
726 m_angularAxis->setLabelsFont(m_currentLabelFont);
717 m_radialAxis->setLabelsFont(m_currentLabelFont);
727 m_radialAxis->setLabelsFont(m_currentLabelFont);
718 }
728 }
719
729
720 void MainWindow::animationIndexChanged(int index)
730 void MainWindow::animationIndexChanged(int index)
721 {
731 {
722 switch (index) {
732 switch (index) {
723 case 0:
733 case 0:
724 m_animationOptions = QChart::NoAnimation;
734 m_animationOptions = QChart::NoAnimation;
725 break;
735 break;
726 case 1:
736 case 1:
727 m_animationOptions = QChart::SeriesAnimations;
737 m_animationOptions = QChart::SeriesAnimations;
728 break;
738 break;
729 case 2:
739 case 2:
730 m_animationOptions = QChart::GridAxisAnimations;
740 m_animationOptions = QChart::GridAxisAnimations;
731 break;
741 break;
732 case 3:
742 case 3:
733 m_animationOptions = QChart::AllAnimations;
743 m_animationOptions = QChart::AllAnimations;
734 break;
744 break;
735 default:
745 default:
736 break;
746 break;
737 }
747 }
738
748
739 m_chart->setAnimationOptions(m_animationOptions);
749 m_chart->setAnimationOptions(m_animationOptions);
740 }
750 }
741
751
742 void MainWindow::labelsIndexChanged(int index)
752 void MainWindow::labelsIndexChanged(int index)
743 {
753 {
744 delete m_labelBrush;
754 delete m_labelBrush;
745 delete m_labelPen;
755 delete m_labelPen;
746
756
747 switch (index) {
757 switch (index) {
748 case 0:
758 case 0:
749 m_labelBrush = new QBrush(Qt::NoBrush);
759 m_labelBrush = new QBrush(Qt::NoBrush);
750 m_labelPen = new QPen(Qt::NoPen);
760 m_labelPen = new QPen(Qt::NoPen);
751 m_labelsVisible = false;
761 m_labelsVisible = false;
752 break;
762 break;
753 case 1:
763 case 1:
754 m_labelBrush = new QBrush(Qt::black);
764 m_labelBrush = new QBrush(Qt::black);
755 m_labelPen = new QPen(Qt::NoPen);
765 m_labelPen = new QPen(Qt::NoPen);
756 m_labelsVisible = true;
766 m_labelsVisible = true;
757 break;
767 break;
758 case 2:
768 case 2:
759 m_labelBrush = new QBrush(Qt::white);
769 m_labelBrush = new QBrush(Qt::white);
760 m_labelPen = new QPen(Qt::blue);
770 m_labelPen = new QPen(Qt::blue);
761 m_labelsVisible = true;
771 m_labelsVisible = true;
762 break;
772 break;
763 default:
773 default:
764 break;
774 break;
765 }
775 }
766
776
767 m_radialAxis->setLabelsBrush(*m_labelBrush);
777 m_radialAxis->setLabelsBrush(*m_labelBrush);
768 m_radialAxis->setLabelsPen(*m_labelPen);
778 m_radialAxis->setLabelsPen(*m_labelPen);
769 m_radialAxis->setLabelsVisible(m_labelsVisible);
779 m_radialAxis->setLabelsVisible(m_labelsVisible);
770 m_angularAxis->setLabelsBrush(*m_labelBrush);
780 m_angularAxis->setLabelsBrush(*m_labelBrush);
771 m_angularAxis->setLabelsPen(*m_labelPen);
781 m_angularAxis->setLabelsPen(*m_labelPen);
772 m_angularAxis->setLabelsVisible(m_labelsVisible);
782 m_angularAxis->setLabelsVisible(m_labelsVisible);
773 }
783 }
774
784
775 void MainWindow::titleIndexChanged(int index)
785 void MainWindow::titleIndexChanged(int index)
776 {
786 {
777 delete m_titleBrush;
787 delete m_titleBrush;
778 delete m_titlePen;
788 delete m_titlePen;
779
789
780 switch (index) {
790 switch (index) {
781 case 0:
791 case 0:
782 m_titleBrush = new QBrush(Qt::NoBrush);
792 m_titleBrush = new QBrush(Qt::NoBrush);
783 m_titlePen = new QPen(Qt::NoPen);
793 m_titlePen = new QPen(Qt::NoPen);
784 m_titleVisible = false;
794 m_titleVisible = false;
785 m_angularTitle = QString();
795 m_angularTitle = QString();
786 m_radialTitle = QString();
796 m_radialTitle = QString();
787 break;
797 break;
788 case 1:
798 case 1:
789 m_titleBrush = new QBrush(Qt::NoBrush);
799 m_titleBrush = new QBrush(Qt::NoBrush);
790 m_titlePen = new QPen(Qt::NoPen);
800 m_titlePen = new QPen(Qt::NoPen);
791 m_titleVisible = true;
801 m_titleVisible = true;
792 m_angularTitle = QString();
802 m_angularTitle = QString();
793 m_radialTitle = QString();
803 m_radialTitle = QString();
794 break;
804 break;
795 case 2:
805 case 2:
796 m_titleBrush = new QBrush(Qt::NoBrush);
806 m_titleBrush = new QBrush(Qt::NoBrush);
797 m_titlePen = new QPen(Qt::NoPen);
807 m_titlePen = new QPen(Qt::NoPen);
798 m_titleVisible = false;
808 m_titleVisible = false;
799 m_angularTitle = QString("Invisible Ang. Title!");
809 m_angularTitle = QString("Invisible Ang. Title!");
800 m_radialTitle = QString("Invisible Rad. Title!");
810 m_radialTitle = QString("Invisible Rad. Title!");
801 break;
811 break;
802 case 3:
812 case 3:
803 m_titleBrush = new QBrush(Qt::black);
813 m_titleBrush = new QBrush(Qt::black);
804 m_titlePen = new QPen(Qt::NoPen);
814 m_titlePen = new QPen(Qt::NoPen);
805 m_titleVisible = true;
815 m_titleVisible = true;
806 m_angularTitle = QString("Angular Title");
816 m_angularTitle = QString("Angular Title");
807 m_radialTitle = QString("Radial Title");
817 m_radialTitle = QString("Radial Title");
808 break;
818 break;
809 case 4:
819 case 4:
810 m_titleBrush = new QBrush(Qt::white);
820 m_titleBrush = new QBrush(Qt::white);
811 m_titlePen = new QPen(Qt::blue);
821 m_titlePen = new QPen(Qt::blue);
812 m_titleVisible = true;
822 m_titleVisible = true;
813 m_angularTitle = QString("Angular Blue Title");
823 m_angularTitle = QString("Angular Blue Title");
814 m_radialTitle = QString("Radial Blue Title");
824 m_radialTitle = QString("Radial Blue Title");
815 break;
825 break;
816 default:
826 default:
817 break;
827 break;
818 }
828 }
819
829
820 m_radialAxis->setTitleBrush(*m_titleBrush);
830 m_radialAxis->setTitleBrush(*m_titleBrush);
821 m_radialAxis->setTitlePen(*m_titlePen);
831 m_radialAxis->setTitlePen(*m_titlePen);
822 m_radialAxis->setTitleVisible(m_titleVisible);
832 m_radialAxis->setTitleVisible(m_titleVisible);
823 m_radialAxis->setTitleText(m_radialTitle);
833 m_radialAxis->setTitleText(m_radialTitle);
824 m_angularAxis->setTitleBrush(*m_titleBrush);
834 m_angularAxis->setTitleBrush(*m_titleBrush);
825 m_angularAxis->setTitlePen(*m_titlePen);
835 m_angularAxis->setTitlePen(*m_titlePen);
826 m_angularAxis->setTitleVisible(m_titleVisible);
836 m_angularAxis->setTitleVisible(m_titleVisible);
827 m_angularAxis->setTitleText(m_angularTitle);
837 m_angularAxis->setTitleText(m_angularTitle);
828 }
838 }
829
839
830 void MainWindow::titleFontChanged(const QFont &font)
840 void MainWindow::titleFontChanged(const QFont &font)
831 {
841 {
832 m_currentTitleFont = font;
842 m_currentTitleFont = font;
833 m_currentTitleFont.setPixelSize(ui->titleFontSizeSpin->value());
843 m_currentTitleFont.setPixelSize(ui->titleFontSizeSpin->value());
834 m_angularAxis->setTitleFont(m_currentTitleFont);
844 m_angularAxis->setTitleFont(m_currentTitleFont);
835 m_radialAxis->setTitleFont(m_currentTitleFont);
845 m_radialAxis->setTitleFont(m_currentTitleFont);
836 }
846 }
837
847
838 void MainWindow::titleFontSizeChanged(int value)
848 void MainWindow::titleFontSizeChanged(int value)
839 {
849 {
840 m_currentTitleFont = ui->titleFontComboBox->currentFont();
850 m_currentTitleFont = ui->titleFontComboBox->currentFont();
841 m_currentTitleFont.setPixelSize(value);
851 m_currentTitleFont.setPixelSize(value);
842 m_angularAxis->setTitleFont(m_currentTitleFont);
852 m_angularAxis->setTitleFont(m_currentTitleFont);
843 m_radialAxis->setTitleFont(m_currentTitleFont);
853 m_radialAxis->setTitleFont(m_currentTitleFont);
844 }
854 }
845
855
846 void MainWindow::gridIndexChanged(int index)
856 void MainWindow::gridIndexChanged(int index)
847 {
857 {
848 delete m_gridPen;
858 delete m_gridPen;
849
859
850 switch (index) {
860 switch (index) {
851 case 0:
861 case 0:
852 m_gridPen = new QPen(Qt::NoPen);
862 m_gridPen = new QPen(Qt::NoPen);
853 m_gridVisible = false;
863 m_gridVisible = false;
854 break;
864 break;
855 case 1:
865 case 1:
856 m_gridPen = new QPen(Qt::black);
866 m_gridPen = new QPen(Qt::black);
857 m_gridVisible = true;
867 m_gridVisible = true;
858 break;
868 break;
859 case 2:
869 case 2:
860 m_gridPen = new QPen(Qt::red);
870 m_gridPen = new QPen(Qt::red);
861 m_gridPen->setStyle(Qt::DashDotLine);
871 m_gridPen->setStyle(Qt::DashDotLine);
862 m_gridPen->setWidth(3);
872 m_gridPen->setWidth(3);
863 m_gridVisible = true;
873 m_gridVisible = true;
864 break;
874 break;
865 default:
875 default:
866 break;
876 break;
867 }
877 }
868
878
869 m_angularAxis->setGridLinePen(*m_gridPen);
879 m_angularAxis->setGridLinePen(*m_gridPen);
870 m_angularAxis->setGridLineVisible(m_gridVisible);
880 m_angularAxis->setGridLineVisible(m_gridVisible);
871 m_radialAxis->setGridLinePen(*m_gridPen);
881 m_radialAxis->setGridLinePen(*m_gridPen);
872 m_radialAxis->setGridLineVisible(m_gridVisible);
882 m_radialAxis->setGridLineVisible(m_gridVisible);
873 }
883 }
874
884
875 void MainWindow::arrowIndexChanged(int index)
885 void MainWindow::arrowIndexChanged(int index)
876 {
886 {
877 delete m_arrowPen;
887 delete m_arrowPen;
878
888
879 switch (index) {
889 switch (index) {
880 case 0:
890 case 0:
881 m_arrowPen = new QPen(Qt::NoPen);
891 m_arrowPen = new QPen(Qt::NoPen);
882 m_arrowVisible = false;
892 m_arrowVisible = false;
883 break;
893 break;
884 case 1:
894 case 1:
885 m_arrowPen = new QPen(Qt::black);
895 m_arrowPen = new QPen(Qt::black);
886 m_arrowVisible = true;
896 m_arrowVisible = true;
887 break;
897 break;
888 case 2:
898 case 2:
889 m_arrowPen = new QPen(Qt::red);
899 m_arrowPen = new QPen(Qt::red);
890 m_arrowPen->setStyle(Qt::DashDotLine);
900 m_arrowPen->setStyle(Qt::DashDotLine);
891 m_arrowPen->setWidth(3);
901 m_arrowPen->setWidth(3);
892 m_arrowVisible = true;
902 m_arrowVisible = true;
893 break;
903 break;
894 default:
904 default:
895 break;
905 break;
896 }
906 }
897
907
898 m_angularAxis->setLinePen(*m_arrowPen);
908 m_angularAxis->setLinePen(*m_arrowPen);
899 m_angularAxis->setLineVisible(m_arrowVisible);
909 m_angularAxis->setLineVisible(m_arrowVisible);
900 m_radialAxis->setLinePen(*m_arrowPen);
910 m_radialAxis->setLinePen(*m_arrowPen);
901 m_radialAxis->setLineVisible(m_arrowVisible);
911 m_radialAxis->setLineVisible(m_arrowVisible);
902 }
912 }
903
913
904 void MainWindow::angularRangeChanged(qreal min, qreal max)
914 void MainWindow::angularRangeChanged(qreal min, qreal max)
905 {
915 {
906 if (!qFuzzyCompare(ui->angularMinSpin->value(), min))
916 if (!qFuzzyCompare(ui->angularMinSpin->value(), min))
907 ui->angularMinSpin->setValue(min);
917 ui->angularMinSpin->setValue(min);
908 if (!qFuzzyCompare(ui->angularMaxSpin->value(), max))
918 if (!qFuzzyCompare(ui->angularMaxSpin->value(), max))
909 ui->angularMaxSpin->setValue(max);
919 ui->angularMaxSpin->setValue(max);
910 }
920 }
911
921
912 void MainWindow::radialRangeChanged(qreal min, qreal max)
922 void MainWindow::radialRangeChanged(qreal min, qreal max)
913 {
923 {
914 if (!qFuzzyCompare(ui->radialMinSpin->value(), min))
924 if (!qFuzzyCompare(ui->radialMinSpin->value(), min))
915 ui->radialMinSpin->setValue(min);
925 ui->radialMinSpin->setValue(min);
916 if (!qFuzzyCompare(ui->radialMaxSpin->value(), max))
926 if (!qFuzzyCompare(ui->radialMaxSpin->value(), max))
917 ui->radialMaxSpin->setValue(max);
927 ui->radialMaxSpin->setValue(max);
918 }
928 }
919
929
920 void MainWindow::angularAxisIndexChanged(int index)
930 void MainWindow::angularAxisIndexChanged(int index)
921 {
931 {
922 switch (index) {
932 switch (index) {
923 case 0:
933 case 0:
924 setAngularAxis(AxisModeNone);
934 setAngularAxis(AxisModeNone);
925 break;
935 break;
926 case 1:
936 case 1:
927 setAngularAxis(AxisModeValue);
937 setAngularAxis(AxisModeValue);
928 break;
938 break;
929 case 2:
939 case 2:
930 setAngularAxis(AxisModeLogValue);
940 setAngularAxis(AxisModeLogValue);
931 break;
941 break;
932 case 3:
942 case 3:
933 setAngularAxis(AxisModeDateTime);
943 setAngularAxis(AxisModeDateTime);
934 break;
944 break;
935 case 4:
945 case 4:
936 setAngularAxis(AxisModeCategory);
946 setAngularAxis(AxisModeCategory);
937 break;
947 break;
938 default:
948 default:
939 qWarning("Invalid Index!");
949 qWarning("Invalid Index!");
940 }
950 }
941 }
951 }
942
952
943 void MainWindow::radialAxisIndexChanged(int index)
953 void MainWindow::radialAxisIndexChanged(int index)
944 {
954 {
945 switch (index) {
955 switch (index) {
946 case 0:
956 case 0:
947 setRadialAxis(AxisModeNone);
957 setRadialAxis(AxisModeNone);
948 break;
958 break;
949 case 1:
959 case 1:
950 setRadialAxis(AxisModeValue);
960 setRadialAxis(AxisModeValue);
951 break;
961 break;
952 case 2:
962 case 2:
953 setRadialAxis(AxisModeLogValue);
963 setRadialAxis(AxisModeLogValue);
954 break;
964 break;
955 case 3:
965 case 3:
956 setRadialAxis(AxisModeDateTime);
966 setRadialAxis(AxisModeDateTime);
957 break;
967 break;
958 case 4:
968 case 4:
959 setRadialAxis(AxisModeCategory);
969 setRadialAxis(AxisModeCategory);
960 break;
970 break;
961 default:
971 default:
962 qWarning("Invalid Index!");
972 qWarning("Invalid Index!");
963 }
973 }
964 }
974 }
965
975
966 void MainWindow::logBaseChanged(double value)
976 void MainWindow::logBaseChanged(double value)
967 {
977 {
968 m_base = value;
978 m_base = value;
969 if (m_angularAxisMode == AxisModeLogValue)
979 if (m_angularAxisMode == AxisModeLogValue)
970 static_cast<QLogValueAxis *>(m_angularAxis)->setBase(m_base);
980 static_cast<QLogValueAxis *>(m_angularAxis)->setBase(m_base);
971 if (m_radialAxisMode == AxisModeLogValue)
981 if (m_radialAxisMode == AxisModeLogValue)
972 static_cast<QLogValueAxis *>(m_radialAxis)->setBase(m_base);
982 static_cast<QLogValueAxis *>(m_radialAxis)->setBase(m_base);
973 }
983 }
974
984
975 void MainWindow::niceNumbersChecked()
985 void MainWindow::niceNumbersChecked()
976 {
986 {
977 if (ui->niceNumbersCheckBox->isChecked())
987 if (ui->niceNumbersCheckBox->isChecked())
978 applyRanges();
988 applyRanges();
979 }
989 }
980
990
981 void MainWindow::dateFormatEdited(const QString &text)
991 void MainWindow::dateFormatEdited(const QString &text)
982 {
992 {
983 m_dateFormat = text;
993 m_dateFormat = text;
984 if (m_angularAxisMode == AxisModeDateTime)
994 if (m_angularAxisMode == AxisModeDateTime)
985 static_cast<QDateTimeAxis *>(m_angularAxis)->setFormat(m_dateFormat);
995 static_cast<QDateTimeAxis *>(m_angularAxis)->setFormat(m_dateFormat);
986 if (m_radialAxisMode == AxisModeDateTime)
996 if (m_radialAxisMode == AxisModeDateTime)
987 static_cast<QDateTimeAxis *>(m_radialAxis)->setFormat(m_dateFormat);
997 static_cast<QDateTimeAxis *>(m_radialAxis)->setFormat(m_dateFormat);
988 }
998 }
989
999
990 void MainWindow::moreCategoriesChecked()
1000 void MainWindow::moreCategoriesChecked()
991 {
1001 {
992 applyCategories();
1002 applyCategories();
993 m_moreCategories = ui->moreCategoriesCheckBox->isChecked();
1003 m_moreCategories = ui->moreCategoriesCheckBox->isChecked();
994 }
1004 }
995
1005
996 void MainWindow::series1CheckBoxChecked()
1006 void MainWindow::series1CheckBoxChecked()
997 {
1007 {
998 if (ui->series1checkBox->isChecked())
1008 if (ui->series1checkBox->isChecked())
999 m_series1->setVisible(true);
1009 m_series1->setVisible(true);
1000 else
1010 else
1001 m_series1->setVisible(false);
1011 m_series1->setVisible(false);
1002 }
1012 }
1003
1013
1004 void MainWindow::series2CheckBoxChecked()
1014 void MainWindow::series2CheckBoxChecked()
1005 {
1015 {
1006 if (ui->series2checkBox->isChecked())
1016 if (ui->series2checkBox->isChecked())
1007 m_series2->setVisible(true);
1017 m_series2->setVisible(true);
1008 else
1018 else
1009 m_series2->setVisible(false);
1019 m_series2->setVisible(false);
1010 }
1020 }
1011
1021
1012 void MainWindow::series3CheckBoxChecked()
1022 void MainWindow::series3CheckBoxChecked()
1013 {
1023 {
1014 if (ui->series3checkBox->isChecked())
1024 if (ui->series3checkBox->isChecked())
1015 m_series3->setVisible(true);
1025 m_series3->setVisible(true);
1016 else
1026 else
1017 m_series3->setVisible(false);
1027 m_series3->setVisible(false);
1018 }
1028 }
1019
1029
1020 void MainWindow::series4CheckBoxChecked()
1030 void MainWindow::series4CheckBoxChecked()
1021 {
1031 {
1022 if (ui->series4checkBox->isChecked())
1032 if (ui->series4checkBox->isChecked())
1023 m_series4->setVisible(true);
1033 m_series4->setVisible(true);
1024 else
1034 else
1025 m_series4->setVisible(false);
1035 m_series4->setVisible(false);
1026 }
1036 }
1027
1037
1028 void MainWindow::series5CheckBoxChecked()
1038 void MainWindow::series5CheckBoxChecked()
1029 {
1039 {
1030 if (ui->series5checkBox->isChecked())
1040 if (ui->series5checkBox->isChecked())
1031 m_series5->setVisible(true);
1041 m_series5->setVisible(true);
1032 else
1042 else
1033 m_series5->setVisible(false);
1043 m_series5->setVisible(false);
1034 }
1044 }
1035
1045
1036 void MainWindow::series6CheckBoxChecked()
1046 void MainWindow::series6CheckBoxChecked()
1037 {
1047 {
1038 if (ui->series6checkBox->isChecked())
1048 if (ui->series6checkBox->isChecked())
1039 m_series6->setVisible(true);
1049 m_series6->setVisible(true);
1040 else
1050 else
1041 m_series6->setVisible(false);
1051 m_series6->setVisible(false);
1042 }
1052 }
1043
1053
1044 void MainWindow::series7CheckBoxChecked()
1054 void MainWindow::series7CheckBoxChecked()
1045 {
1055 {
1046 if (ui->series7checkBox->isChecked())
1056 if (ui->series7checkBox->isChecked())
1047 m_series7->setVisible(true);
1057 m_series7->setVisible(true);
1048 else
1058 else
1049 m_series7->setVisible(false);
1059 m_series7->setVisible(false);
1050 }
1060 }
1051
1061
1052 void MainWindow::themeIndexChanged(int index)
1062 void MainWindow::themeIndexChanged(int index)
1053 {
1063 {
1054 m_chart->setTheme(QChart::ChartTheme(index));
1064 m_chart->setTheme(QChart::ChartTheme(index));
1055 }
1065 }
1056
1066
1057 void MainWindow::seriesHovered(QPointF point, bool state)
1067 void MainWindow::seriesHovered(QPointF point, bool state)
1058 {
1068 {
1059 QAbstractSeries *series = qobject_cast<QAbstractSeries *>(sender());
1069 QAbstractSeries *series = qobject_cast<QAbstractSeries *>(sender());
1060 if (series) {
1070 if (series) {
1061 if (state) {
1071 if (state) {
1062 QString str("'%3' - %1 x %2");
1072 QString str("'%3' - %1 x %2");
1063 ui->hoverLabel->setText(str.arg(point.x()).arg(point.y()).arg(series->name()));
1073 ui->hoverLabel->setText(str.arg(point.x()).arg(point.y()).arg(series->name()));
1064 } else {
1074 } else {
1065 ui->hoverLabel->setText("No hover");
1075 ui->hoverLabel->setText("No hover");
1066 }
1076 }
1067 } else {
1077 } else {
1068 qDebug() << "seriesHovered - invalid sender!";
1078 qDebug() << "seriesHovered - invalid sender!";
1069 }
1079 }
1070 }
1080 }
1071
1081
1072 void MainWindow::seriesClicked(const QPointF &point)
1082 void MainWindow::seriesClicked(const QPointF &point)
1073 {
1083 {
1074 QAbstractSeries *series = qobject_cast<QAbstractSeries *>(sender());
1084 QAbstractSeries *series = qobject_cast<QAbstractSeries *>(sender());
1075 if (series) {
1085 if (series) {
1076 QString str("'%3' clicked at: %1 x %2");
1086 QString str("'%3' clicked at: %1 x %2");
1077 m_angularTitle = str.arg(point.x()).arg(point.y()).arg(series->name());
1087 m_angularTitle = str.arg(point.x()).arg(point.y()).arg(series->name());
1078 m_angularAxis->setTitleText(m_angularTitle);
1088 m_angularAxis->setTitleText(m_angularTitle);
1079 } else {
1089 } else {
1080 qDebug() << "seriesClicked - invalid sender!";
1090 qDebug() << "seriesClicked - invalid sender!";
1081 }
1091 }
1082 }
1092 }
1083
1093
1094 void MainWindow::backgroundIndexChanged(int index)
1095 {
1096 delete m_backgroundBrush;
1097 delete m_backgroundPen;
1098
1099 switch (index) {
1100 case 0:
1101 m_backgroundBrush = new QBrush(Qt::white);
1102 m_backgroundPen = new QPen(Qt::NoPen);
1103 break;
1104 case 1:
1105 m_backgroundBrush = new QBrush(Qt::blue);
1106 m_backgroundPen = new QPen(Qt::NoPen);
1107 break;
1108 case 2:
1109 m_backgroundBrush = new QBrush(Qt::yellow);
1110 m_backgroundPen = new QPen(Qt::black, 2);
1111 break;
1112 default:
1113 break;
1114 }
1115 m_chart->setBackgroundBrush(*m_backgroundBrush);
1116 m_chart->setBackgroundPen(*m_backgroundPen);
1117 }
1118
1119 void MainWindow::plotAreaIndexChanged(int index)
1120 {
1121 delete m_plotAreaBackgroundBrush;
1122 delete m_plotAreaBackgroundPen;
1123
1124 switch (index) {
1125 case 0:
1126 m_plotAreaBackgroundBrush = new QBrush(Qt::green);
1127 m_plotAreaBackgroundPen = new QPen(Qt::green);
1128 m_chart->setPlotAreaBackgroundVisible(false);
1129 break;
1130 case 1:
1131 m_plotAreaBackgroundBrush = new QBrush(Qt::magenta);
1132 m_plotAreaBackgroundPen = new QPen(Qt::NoPen);
1133 m_chart->setPlotAreaBackgroundVisible(true);
1134 break;
1135 case 2:
1136 m_plotAreaBackgroundBrush = new QBrush(Qt::lightGray);
1137 m_plotAreaBackgroundPen = new QPen(Qt::red, 6);
1138 m_chart->setPlotAreaBackgroundVisible(true);
1139 break;
1140 default:
1141 break;
1142 }
1143 m_chart->setPlotAreaBackgroundBrush(*m_plotAreaBackgroundBrush);
1144 m_chart->setPlotAreaBackgroundPen(*m_plotAreaBackgroundPen);
1145 }
1146
1084 void MainWindow::applyCategories()
1147 void MainWindow::applyCategories()
1085 {
1148 {
1086 // Basic layout is three categories, extended has five
1149 // Basic layout is three categories, extended has five
1087 if (m_angularAxisMode == AxisModeCategory) {
1150 if (m_angularAxisMode == AxisModeCategory) {
1088 QCategoryAxis *angCatAxis = static_cast<QCategoryAxis *>(m_angularAxis);
1151 QCategoryAxis *angCatAxis = static_cast<QCategoryAxis *>(m_angularAxis);
1089 if (angCatAxis->count() == 0) {
1152 if (angCatAxis->count() == 0) {
1090 angCatAxis->setStartValue(4000);
1153 angCatAxis->setStartValue(4000);
1091 angCatAxis->append("Category A", 7000);
1154 angCatAxis->append("Category A", 7000);
1092 angCatAxis->append("Category B", 12000);
1155 angCatAxis->append("Category B", 12000);
1093 angCatAxis->append("Category C", 17000);
1156 angCatAxis->append("Category C", 17000);
1094 }
1157 }
1095 if (angCatAxis->count() == 3 && ui->moreCategoriesCheckBox->isChecked()) {
1158 if (angCatAxis->count() == 3 && ui->moreCategoriesCheckBox->isChecked()) {
1096 angCatAxis->setStartValue(1000);
1159 angCatAxis->setStartValue(1000);
1097 angCatAxis->replaceLabel("Category A", "Cat A");
1160 angCatAxis->replaceLabel("Category A", "Cat A");
1098 angCatAxis->replaceLabel("Category B", "Cat B");
1161 angCatAxis->replaceLabel("Category B", "Cat B");
1099 angCatAxis->replaceLabel("Category C", "Cat C");
1162 angCatAxis->replaceLabel("Category C", "Cat C");
1100 angCatAxis->append("Cat D", 22000);
1163 angCatAxis->append("Cat D", 22000);
1101 angCatAxis->append("Cat E", 28000);
1164 angCatAxis->append("Cat E", 28000);
1102 } else if (angCatAxis->count() == 5 && !ui->moreCategoriesCheckBox->isChecked()) {
1165 } else if (angCatAxis->count() == 5 && !ui->moreCategoriesCheckBox->isChecked()) {
1103 angCatAxis->setStartValue(4000);
1166 angCatAxis->setStartValue(4000);
1104 angCatAxis->replaceLabel("Cat A", "Category A");
1167 angCatAxis->replaceLabel("Cat A", "Category A");
1105 angCatAxis->replaceLabel("Cat B", "Category B");
1168 angCatAxis->replaceLabel("Cat B", "Category B");
1106 angCatAxis->replaceLabel("Cat C", "Category C");
1169 angCatAxis->replaceLabel("Cat C", "Category C");
1107 angCatAxis->remove("Cat D");
1170 angCatAxis->remove("Cat D");
1108 angCatAxis->remove("Cat E");
1171 angCatAxis->remove("Cat E");
1109 }
1172 }
1110 }
1173 }
1111
1174
1112 if (m_radialAxisMode == AxisModeCategory) {
1175 if (m_radialAxisMode == AxisModeCategory) {
1113 QCategoryAxis *radCatAxis = static_cast<QCategoryAxis *>(m_radialAxis);
1176 QCategoryAxis *radCatAxis = static_cast<QCategoryAxis *>(m_radialAxis);
1114 if (radCatAxis->count() == 0) {
1177 if (radCatAxis->count() == 0) {
1115 radCatAxis->setStartValue(2000);
1178 radCatAxis->setStartValue(2000);
1116 radCatAxis->append("Category 1", 4000);
1179 radCatAxis->append("Category 1", 4000);
1117 radCatAxis->append("Category 2", 9000);
1180 radCatAxis->append("Category 2", 9000);
1118 radCatAxis->append("Category 3", 14000);
1181 radCatAxis->append("Category 3", 14000);
1119 }
1182 }
1120 if (radCatAxis->count() == 3 && ui->moreCategoriesCheckBox->isChecked()) {
1183 if (radCatAxis->count() == 3 && ui->moreCategoriesCheckBox->isChecked()) {
1121 radCatAxis->setStartValue(1000);
1184 radCatAxis->setStartValue(1000);
1122 radCatAxis->replaceLabel("Category 1", "Cat 1");
1185 radCatAxis->replaceLabel("Category 1", "Cat 1");
1123 radCatAxis->replaceLabel("Category 2", "Cat 2");
1186 radCatAxis->replaceLabel("Category 2", "Cat 2");
1124 radCatAxis->replaceLabel("Category 3", "Cat 3");
1187 radCatAxis->replaceLabel("Category 3", "Cat 3");
1125 radCatAxis->append("Cat 4", 16500);
1188 radCatAxis->append("Cat 4", 16500);
1126 radCatAxis->append("Cat 5", 19000);
1189 radCatAxis->append("Cat 5", 19000);
1127 } else if (radCatAxis->count() == 5 && !ui->moreCategoriesCheckBox->isChecked()) {
1190 } else if (radCatAxis->count() == 5 && !ui->moreCategoriesCheckBox->isChecked()) {
1128 radCatAxis->setStartValue(2000);
1191 radCatAxis->setStartValue(2000);
1129 radCatAxis->replaceLabel("Cat 1", "Category 1");
1192 radCatAxis->replaceLabel("Cat 1", "Category 1");
1130 radCatAxis->replaceLabel("Cat 2", "Category 2");
1193 radCatAxis->replaceLabel("Cat 2", "Category 2");
1131 radCatAxis->replaceLabel("Cat 3", "Category 3");
1194 radCatAxis->replaceLabel("Cat 3", "Category 3");
1132 radCatAxis->remove("Cat 4");
1195 radCatAxis->remove("Cat 4");
1133 radCatAxis->remove("Cat 5");
1196 radCatAxis->remove("Cat 5");
1134 }
1197 }
1135 }
1198 }
1136 }
1199 }
@@ -1,155 +1,161
1 /****************************************************************************
1 /****************************************************************************
2 **
2 **
3 ** Copyright (C) 2013 Digia Plc
3 ** Copyright (C) 2013 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 MAINWINDOW_H
21 #ifndef MAINWINDOW_H
22 #define MAINWINDOW_H
22 #define MAINWINDOW_H
23
23
24 #include <QPolarChart>
24 #include <QPolarChart>
25 #include <QMainWindow>
25 #include <QMainWindow>
26 #include <QFont>
26 #include <QFont>
27 #include <QChart>
27 #include <QChart>
28 #include <QScatterSeries>
28 #include <QScatterSeries>
29 #include <QLineSeries>
29 #include <QLineSeries>
30 #include <QSplineSeries>
30 #include <QSplineSeries>
31 #include <QAreaSeries>
31 #include <QAreaSeries>
32
32
33 namespace Ui {
33 namespace Ui {
34 class MainWindow;
34 class MainWindow;
35 }
35 }
36
36
37 QTCOMMERCIALCHART_USE_NAMESPACE
37 QTCOMMERCIALCHART_USE_NAMESPACE
38
38
39 class QBrush;
39 class QBrush;
40 class QPen;
40 class QPen;
41
41
42 class MainWindow : public QMainWindow
42 class MainWindow : public QMainWindow
43 {
43 {
44 Q_OBJECT
44 Q_OBJECT
45
45
46 public:
46 public:
47 explicit MainWindow(QWidget *parent = 0);
47 explicit MainWindow(QWidget *parent = 0);
48 ~MainWindow();
48 ~MainWindow();
49
49
50 public slots:
50 public slots:
51 void angularTicksChanged(int value);
51 void angularTicksChanged(int value);
52 void radialTicksChanged(int value);
52 void radialTicksChanged(int value);
53 void anglesChanged(int value);
53 void anglesChanged(int value);
54 void angularMinChanged(double value);
54 void angularMinChanged(double value);
55 void angularMaxChanged(double value);
55 void angularMaxChanged(double value);
56 void radialMinChanged(double value);
56 void radialMinChanged(double value);
57 void radialMaxChanged(double value);
57 void radialMaxChanged(double value);
58 void angularShadesIndexChanged(int index);
58 void angularShadesIndexChanged(int index);
59 void radialShadesIndexChanged(int index);
59 void radialShadesIndexChanged(int index);
60 void labelFormatEdited(const QString &text);
60 void labelFormatEdited(const QString &text);
61 void labelFontChanged(const QFont &font);
61 void labelFontChanged(const QFont &font);
62 void labelFontSizeChanged(int value);
62 void labelFontSizeChanged(int value);
63 void animationIndexChanged(int index);
63 void animationIndexChanged(int index);
64 void labelsIndexChanged(int index);
64 void labelsIndexChanged(int index);
65 void titleIndexChanged(int index);
65 void titleIndexChanged(int index);
66 void titleFontChanged(const QFont &font);
66 void titleFontChanged(const QFont &font);
67 void titleFontSizeChanged(int value);
67 void titleFontSizeChanged(int value);
68 void gridIndexChanged(int index);
68 void gridIndexChanged(int index);
69 void arrowIndexChanged(int index);
69 void arrowIndexChanged(int index);
70 void angularRangeChanged(qreal min, qreal max);
70 void angularRangeChanged(qreal min, qreal max);
71 void radialRangeChanged(qreal min, qreal max);
71 void radialRangeChanged(qreal min, qreal max);
72 void angularAxisIndexChanged(int index);
72 void angularAxisIndexChanged(int index);
73 void radialAxisIndexChanged(int index);
73 void radialAxisIndexChanged(int index);
74 void logBaseChanged(double value);
74 void logBaseChanged(double value);
75 void niceNumbersChecked();
75 void niceNumbersChecked();
76 void dateFormatEdited(const QString &text);
76 void dateFormatEdited(const QString &text);
77 void moreCategoriesChecked();
77 void moreCategoriesChecked();
78 void series1CheckBoxChecked();
78 void series1CheckBoxChecked();
79 void series2CheckBoxChecked();
79 void series2CheckBoxChecked();
80 void series3CheckBoxChecked();
80 void series3CheckBoxChecked();
81 void series4CheckBoxChecked();
81 void series4CheckBoxChecked();
82 void series5CheckBoxChecked();
82 void series5CheckBoxChecked();
83 void series6CheckBoxChecked();
83 void series6CheckBoxChecked();
84 void series7CheckBoxChecked();
84 void series7CheckBoxChecked();
85 void themeIndexChanged(int index);
85 void themeIndexChanged(int index);
86 void seriesHovered(QPointF point, bool state);
86 void seriesHovered(QPointF point, bool state);
87 void seriesClicked(const QPointF &point);
87 void seriesClicked(const QPointF &point);
88 void backgroundIndexChanged(int index);
89 void plotAreaIndexChanged(int index);
88
90
89 private:
91 private:
90 enum AxisMode {
92 enum AxisMode {
91 AxisModeNone,
93 AxisModeNone,
92 AxisModeValue,
94 AxisModeValue,
93 AxisModeLogValue,
95 AxisModeLogValue,
94 AxisModeDateTime,
96 AxisModeDateTime,
95 AxisModeCategory
97 AxisModeCategory
96 };
98 };
97
99
98 void initXYValueChart();
100 void initXYValueChart();
99 void setAngularAxis(AxisMode mode);
101 void setAngularAxis(AxisMode mode);
100 void setRadialAxis(AxisMode mode);
102 void setRadialAxis(AxisMode mode);
101
103
102 void applyRanges();
104 void applyRanges();
103 void applyCategories();
105 void applyCategories();
104
106
105 Ui::MainWindow *ui;
107 Ui::MainWindow *ui;
106
108
107 int m_angularTickCount;
109 int m_angularTickCount;
108 int m_radialTickCount;
110 int m_radialTickCount;
109 qreal m_labelsAngle;
111 qreal m_labelsAngle;
110 qreal m_angularMin;
112 qreal m_angularMin;
111 qreal m_angularMax;
113 qreal m_angularMax;
112 qreal m_radialMin;
114 qreal m_radialMin;
113 qreal m_radialMax;
115 qreal m_radialMax;
114 bool m_angularShadesVisible;
116 bool m_angularShadesVisible;
115 bool m_radialShadesVisible;
117 bool m_radialShadesVisible;
116 bool m_labelsVisible;
118 bool m_labelsVisible;
117 bool m_titleVisible;
119 bool m_titleVisible;
118 bool m_gridVisible;
120 bool m_gridVisible;
119 bool m_arrowVisible;
121 bool m_arrowVisible;
120 QBrush *m_angularShadesBrush;
122 QBrush *m_angularShadesBrush;
121 QBrush *m_radialShadesBrush;
123 QBrush *m_radialShadesBrush;
122 QBrush *m_labelBrush;
124 QBrush *m_labelBrush;
123 QBrush *m_titleBrush;
125 QBrush *m_titleBrush;
126 QBrush *m_backgroundBrush;
127 QBrush *m_plotAreaBackgroundBrush;
124 QPen *m_angularShadesPen;
128 QPen *m_angularShadesPen;
125 QPen *m_radialShadesPen;
129 QPen *m_radialShadesPen;
126 QPen *m_labelPen;
130 QPen *m_labelPen;
127 QPen *m_titlePen;
131 QPen *m_titlePen;
128 QPen *m_gridPen;
132 QPen *m_gridPen;
129 QPen *m_arrowPen;
133 QPen *m_arrowPen;
134 QPen *m_backgroundPen;
135 QPen *m_plotAreaBackgroundPen;
130 QString m_labelFormat;
136 QString m_labelFormat;
131 QFont m_currentLabelFont;
137 QFont m_currentLabelFont;
132 QFont m_currentTitleFont;
138 QFont m_currentTitleFont;
133 QChart::AnimationOptions m_animationOptions;
139 QChart::AnimationOptions m_animationOptions;
134 QString m_angularTitle;
140 QString m_angularTitle;
135 QString m_radialTitle;
141 QString m_radialTitle;
136 qreal m_base;
142 qreal m_base;
137 QString m_dateFormat;
143 QString m_dateFormat;
138
144
139 QPolarChart *m_chart;
145 QPolarChart *m_chart;
140 QAbstractAxis *m_angularAxis;
146 QAbstractAxis *m_angularAxis;
141 QAbstractAxis *m_radialAxis;
147 QAbstractAxis *m_radialAxis;
142 AxisMode m_angularAxisMode;
148 AxisMode m_angularAxisMode;
143 AxisMode m_radialAxisMode;
149 AxisMode m_radialAxisMode;
144 bool m_moreCategories;
150 bool m_moreCategories;
145
151
146 QScatterSeries *m_series1;
152 QScatterSeries *m_series1;
147 QLineSeries *m_series2;
153 QLineSeries *m_series2;
148 QLineSeries *m_series3;
154 QLineSeries *m_series3;
149 QLineSeries *m_series4;
155 QLineSeries *m_series4;
150 QAreaSeries *m_series5;
156 QAreaSeries *m_series5;
151 QSplineSeries *m_series6;
157 QSplineSeries *m_series6;
152 QScatterSeries *m_series7;
158 QScatterSeries *m_series7;
153 };
159 };
154
160
155 #endif // MAINWINDOW_H
161 #endif // MAINWINDOW_H
@@ -1,929 +1,997
1 <?xml version="1.0" encoding="UTF-8"?>
1 <?xml version="1.0" encoding="UTF-8"?>
2 <ui version="4.0">
2 <ui version="4.0">
3 <class>MainWindow</class>
3 <class>MainWindow</class>
4 <widget class="QMainWindow" name="MainWindow">
4 <widget class="QMainWindow" name="MainWindow">
5 <property name="geometry">
5 <property name="geometry">
6 <rect>
6 <rect>
7 <x>0</x>
7 <x>0</x>
8 <y>0</y>
8 <y>0</y>
9 <width>1207</width>
9 <width>1193</width>
10 <height>905</height>
10 <height>956</height>
11 </rect>
11 </rect>
12 </property>
12 </property>
13 <property name="windowTitle">
13 <property name="windowTitle">
14 <string>MainWindow</string>
14 <string>MainWindow</string>
15 </property>
15 </property>
16 <widget class="QWidget" name="centralWidget">
16 <widget class="QWidget" name="centralWidget">
17 <layout class="QHBoxLayout" name="horizontalLayout">
17 <layout class="QHBoxLayout" name="horizontalLayout">
18 <item>
18 <item>
19 <widget class="ChartView" name="chartView"/>
19 <widget class="ChartView" name="chartView"/>
20 </item>
20 </item>
21 <item>
21 <item>
22 <widget class="QGroupBox" name="settingsBox">
22 <widget class="QGroupBox" name="settingsBox">
23 <property name="sizePolicy">
23 <property name="sizePolicy">
24 <sizepolicy hsizetype="Minimum" vsizetype="Minimum">
24 <sizepolicy hsizetype="Minimum" vsizetype="Minimum">
25 <horstretch>0</horstretch>
25 <horstretch>0</horstretch>
26 <verstretch>0</verstretch>
26 <verstretch>0</verstretch>
27 </sizepolicy>
27 </sizepolicy>
28 </property>
28 </property>
29 <property name="minimumSize">
29 <property name="minimumSize">
30 <size>
30 <size>
31 <width>200</width>
31 <width>200</width>
32 <height>0</height>
32 <height>0</height>
33 </size>
33 </size>
34 </property>
34 </property>
35 <property name="title">
35 <property name="title">
36 <string>Settings</string>
36 <string>Settings</string>
37 </property>
37 </property>
38 <widget class="QSpinBox" name="radialTicksSpin">
38 <widget class="QSpinBox" name="radialTicksSpin">
39 <property name="geometry">
39 <property name="geometry">
40 <rect>
40 <rect>
41 <x>110</x>
41 <x>110</x>
42 <y>90</y>
42 <y>90</y>
43 <width>71</width>
43 <width>71</width>
44 <height>22</height>
44 <height>22</height>
45 </rect>
45 </rect>
46 </property>
46 </property>
47 </widget>
47 </widget>
48 <widget class="QLabel" name="label">
48 <widget class="QLabel" name="label">
49 <property name="geometry">
49 <property name="geometry">
50 <rect>
50 <rect>
51 <x>10</x>
51 <x>10</x>
52 <y>90</y>
52 <y>90</y>
53 <width>101</width>
53 <width>101</width>
54 <height>16</height>
54 <height>16</height>
55 </rect>
55 </rect>
56 </property>
56 </property>
57 <property name="text">
57 <property name="text">
58 <string>Radial Tick count</string>
58 <string>Radial Tick count</string>
59 </property>
59 </property>
60 </widget>
60 </widget>
61 <widget class="QLabel" name="label_2">
61 <widget class="QLabel" name="label_2">
62 <property name="geometry">
62 <property name="geometry">
63 <rect>
63 <rect>
64 <x>10</x>
64 <x>10</x>
65 <y>120</y>
65 <y>120</y>
66 <width>101</width>
66 <width>101</width>
67 <height>16</height>
67 <height>16</height>
68 </rect>
68 </rect>
69 </property>
69 </property>
70 <property name="text">
70 <property name="text">
71 <string>Angular Tick count</string>
71 <string>Angular Tick count</string>
72 </property>
72 </property>
73 </widget>
73 </widget>
74 <widget class="QSpinBox" name="angularTicksSpin">
74 <widget class="QSpinBox" name="angularTicksSpin">
75 <property name="geometry">
75 <property name="geometry">
76 <rect>
76 <rect>
77 <x>110</x>
77 <x>110</x>
78 <y>120</y>
78 <y>120</y>
79 <width>71</width>
79 <width>71</width>
80 <height>22</height>
80 <height>22</height>
81 </rect>
81 </rect>
82 </property>
82 </property>
83 </widget>
83 </widget>
84 <widget class="QSpinBox" name="anglesSpin">
84 <widget class="QSpinBox" name="anglesSpin">
85 <property name="geometry">
85 <property name="geometry">
86 <rect>
86 <rect>
87 <x>110</x>
87 <x>110</x>
88 <y>150</y>
88 <y>150</y>
89 <width>71</width>
89 <width>71</width>
90 <height>22</height>
90 <height>22</height>
91 </rect>
91 </rect>
92 </property>
92 </property>
93 <property name="minimum">
93 <property name="minimum">
94 <number>-9999</number>
94 <number>-9999</number>
95 </property>
95 </property>
96 <property name="maximum">
96 <property name="maximum">
97 <number>9999</number>
97 <number>9999</number>
98 </property>
98 </property>
99 <property name="singleStep">
99 <property name="singleStep">
100 <number>5</number>
100 <number>5</number>
101 </property>
101 </property>
102 </widget>
102 </widget>
103 <widget class="QLabel" name="label_3">
103 <widget class="QLabel" name="label_3">
104 <property name="geometry">
104 <property name="geometry">
105 <rect>
105 <rect>
106 <x>10</x>
106 <x>10</x>
107 <y>150</y>
107 <y>150</y>
108 <width>101</width>
108 <width>101</width>
109 <height>16</height>
109 <height>16</height>
110 </rect>
110 </rect>
111 </property>
111 </property>
112 <property name="text">
112 <property name="text">
113 <string>Label angles</string>
113 <string>Label angles</string>
114 </property>
114 </property>
115 </widget>
115 </widget>
116 <widget class="QLabel" name="label_4">
116 <widget class="QLabel" name="label_4">
117 <property name="geometry">
117 <property name="geometry">
118 <rect>
118 <rect>
119 <x>10</x>
119 <x>10</x>
120 <y>180</y>
120 <y>180</y>
121 <width>101</width>
121 <width>101</width>
122 <height>16</height>
122 <height>16</height>
123 </rect>
123 </rect>
124 </property>
124 </property>
125 <property name="text">
125 <property name="text">
126 <string>Angular min</string>
126 <string>Angular min</string>
127 </property>
127 </property>
128 </widget>
128 </widget>
129 <widget class="QLabel" name="label_5">
129 <widget class="QLabel" name="label_5">
130 <property name="geometry">
130 <property name="geometry">
131 <rect>
131 <rect>
132 <x>10</x>
132 <x>10</x>
133 <y>210</y>
133 <y>210</y>
134 <width>101</width>
134 <width>101</width>
135 <height>16</height>
135 <height>16</height>
136 </rect>
136 </rect>
137 </property>
137 </property>
138 <property name="text">
138 <property name="text">
139 <string>Angular max</string>
139 <string>Angular max</string>
140 </property>
140 </property>
141 </widget>
141 </widget>
142 <widget class="QDoubleSpinBox" name="angularMinSpin">
142 <widget class="QDoubleSpinBox" name="angularMinSpin">
143 <property name="geometry">
143 <property name="geometry">
144 <rect>
144 <rect>
145 <x>90</x>
145 <x>90</x>
146 <y>180</y>
146 <y>180</y>
147 <width>91</width>
147 <width>91</width>
148 <height>22</height>
148 <height>22</height>
149 </rect>
149 </rect>
150 </property>
150 </property>
151 <property name="decimals">
151 <property name="decimals">
152 <number>5</number>
152 <number>5</number>
153 </property>
153 </property>
154 <property name="minimum">
154 <property name="minimum">
155 <double>-999999999.000000000000000</double>
155 <double>-999999999.000000000000000</double>
156 </property>
156 </property>
157 <property name="maximum">
157 <property name="maximum">
158 <double>999999999.000000000000000</double>
158 <double>999999999.000000000000000</double>
159 </property>
159 </property>
160 <property name="singleStep">
160 <property name="singleStep">
161 <double>10.000000000000000</double>
161 <double>10.000000000000000</double>
162 </property>
162 </property>
163 </widget>
163 </widget>
164 <widget class="QDoubleSpinBox" name="angularMaxSpin">
164 <widget class="QDoubleSpinBox" name="angularMaxSpin">
165 <property name="geometry">
165 <property name="geometry">
166 <rect>
166 <rect>
167 <x>90</x>
167 <x>90</x>
168 <y>210</y>
168 <y>210</y>
169 <width>91</width>
169 <width>91</width>
170 <height>22</height>
170 <height>22</height>
171 </rect>
171 </rect>
172 </property>
172 </property>
173 <property name="decimals">
173 <property name="decimals">
174 <number>5</number>
174 <number>5</number>
175 </property>
175 </property>
176 <property name="minimum">
176 <property name="minimum">
177 <double>-999999999.000000000000000</double>
177 <double>-999999999.000000000000000</double>
178 </property>
178 </property>
179 <property name="maximum">
179 <property name="maximum">
180 <double>999999999.000000000000000</double>
180 <double>999999999.000000000000000</double>
181 </property>
181 </property>
182 <property name="singleStep">
182 <property name="singleStep">
183 <double>10.000000000000000</double>
183 <double>10.000000000000000</double>
184 </property>
184 </property>
185 </widget>
185 </widget>
186 <widget class="QDoubleSpinBox" name="radialMaxSpin">
186 <widget class="QDoubleSpinBox" name="radialMaxSpin">
187 <property name="geometry">
187 <property name="geometry">
188 <rect>
188 <rect>
189 <x>90</x>
189 <x>90</x>
190 <y>270</y>
190 <y>270</y>
191 <width>91</width>
191 <width>91</width>
192 <height>22</height>
192 <height>22</height>
193 </rect>
193 </rect>
194 </property>
194 </property>
195 <property name="decimals">
195 <property name="decimals">
196 <number>5</number>
196 <number>5</number>
197 </property>
197 </property>
198 <property name="minimum">
198 <property name="minimum">
199 <double>-999999999.000000000000000</double>
199 <double>-999999999.000000000000000</double>
200 </property>
200 </property>
201 <property name="maximum">
201 <property name="maximum">
202 <double>999999999.000000000000000</double>
202 <double>999999999.000000000000000</double>
203 </property>
203 </property>
204 <property name="singleStep">
204 <property name="singleStep">
205 <double>10.000000000000000</double>
205 <double>10.000000000000000</double>
206 </property>
206 </property>
207 </widget>
207 </widget>
208 <widget class="QDoubleSpinBox" name="radialMinSpin">
208 <widget class="QDoubleSpinBox" name="radialMinSpin">
209 <property name="geometry">
209 <property name="geometry">
210 <rect>
210 <rect>
211 <x>90</x>
211 <x>90</x>
212 <y>240</y>
212 <y>240</y>
213 <width>91</width>
213 <width>91</width>
214 <height>22</height>
214 <height>22</height>
215 </rect>
215 </rect>
216 </property>
216 </property>
217 <property name="decimals">
217 <property name="decimals">
218 <number>5</number>
218 <number>5</number>
219 </property>
219 </property>
220 <property name="minimum">
220 <property name="minimum">
221 <double>-999999999.000000000000000</double>
221 <double>-999999999.000000000000000</double>
222 </property>
222 </property>
223 <property name="maximum">
223 <property name="maximum">
224 <double>999999999.000000000000000</double>
224 <double>999999999.000000000000000</double>
225 </property>
225 </property>
226 <property name="singleStep">
226 <property name="singleStep">
227 <double>10.000000000000000</double>
227 <double>10.000000000000000</double>
228 </property>
228 </property>
229 </widget>
229 </widget>
230 <widget class="QLabel" name="label_11">
230 <widget class="QLabel" name="label_11">
231 <property name="geometry">
231 <property name="geometry">
232 <rect>
232 <rect>
233 <x>10</x>
233 <x>10</x>
234 <y>270</y>
234 <y>270</y>
235 <width>101</width>
235 <width>101</width>
236 <height>16</height>
236 <height>16</height>
237 </rect>
237 </rect>
238 </property>
238 </property>
239 <property name="text">
239 <property name="text">
240 <string>Radial max</string>
240 <string>Radial max</string>
241 </property>
241 </property>
242 </widget>
242 </widget>
243 <widget class="QLabel" name="label_12">
243 <widget class="QLabel" name="label_12">
244 <property name="geometry">
244 <property name="geometry">
245 <rect>
245 <rect>
246 <x>10</x>
246 <x>10</x>
247 <y>240</y>
247 <y>240</y>
248 <width>101</width>
248 <width>101</width>
249 <height>16</height>
249 <height>16</height>
250 </rect>
250 </rect>
251 </property>
251 </property>
252 <property name="text">
252 <property name="text">
253 <string>Radial min</string>
253 <string>Radial min</string>
254 </property>
254 </property>
255 </widget>
255 </widget>
256 <widget class="QComboBox" name="angularShadesComboBox">
256 <widget class="QComboBox" name="angularShadesComboBox">
257 <property name="geometry">
257 <property name="geometry">
258 <rect>
258 <rect>
259 <x>10</x>
259 <x>10</x>
260 <y>300</y>
260 <y>300</y>
261 <width>171</width>
261 <width>171</width>
262 <height>22</height>
262 <height>22</height>
263 </rect>
263 </rect>
264 </property>
264 </property>
265 <item>
265 <item>
266 <property name="text">
266 <property name="text">
267 <string>No angular shades</string>
267 <string>No angular shades</string>
268 </property>
268 </property>
269 </item>
269 </item>
270 <item>
270 <item>
271 <property name="text">
271 <property name="text">
272 <string>Gray angular shades</string>
272 <string>Gray angular shades</string>
273 </property>
273 </property>
274 </item>
274 </item>
275 <item>
275 <item>
276 <property name="text">
276 <property name="text">
277 <string>Yellow ang. shades + custom pen</string>
277 <string>Yellow ang. shades + custom pen</string>
278 </property>
278 </property>
279 </item>
279 </item>
280 </widget>
280 </widget>
281 <widget class="QComboBox" name="radialShadesComboBox">
281 <widget class="QComboBox" name="radialShadesComboBox">
282 <property name="geometry">
282 <property name="geometry">
283 <rect>
283 <rect>
284 <x>10</x>
284 <x>10</x>
285 <y>330</y>
285 <y>330</y>
286 <width>171</width>
286 <width>171</width>
287 <height>22</height>
287 <height>22</height>
288 </rect>
288 </rect>
289 </property>
289 </property>
290 <item>
290 <item>
291 <property name="text">
291 <property name="text">
292 <string>No radial shades</string>
292 <string>No radial shades</string>
293 </property>
293 </property>
294 </item>
294 </item>
295 <item>
295 <item>
296 <property name="text">
296 <property name="text">
297 <string>Green radial shades</string>
297 <string>Green radial shades</string>
298 </property>
298 </property>
299 </item>
299 </item>
300 <item>
300 <item>
301 <property name="text">
301 <property name="text">
302 <string>Blue rad. shades + custom pen</string>
302 <string>Blue rad. shades + custom pen</string>
303 </property>
303 </property>
304 </item>
304 </item>
305 </widget>
305 </widget>
306 <widget class="QLabel" name="label_13">
306 <widget class="QLabel" name="label_13">
307 <property name="geometry">
307 <property name="geometry">
308 <rect>
308 <rect>
309 <x>10</x>
309 <x>10</x>
310 <y>360</y>
310 <y>360</y>
311 <width>101</width>
311 <width>101</width>
312 <height>16</height>
312 <height>16</height>
313 </rect>
313 </rect>
314 </property>
314 </property>
315 <property name="text">
315 <property name="text">
316 <string>Label format</string>
316 <string>Label format</string>
317 </property>
317 </property>
318 </widget>
318 </widget>
319 <widget class="QLineEdit" name="labelFormatEdit">
319 <widget class="QLineEdit" name="labelFormatEdit">
320 <property name="geometry">
320 <property name="geometry">
321 <rect>
321 <rect>
322 <x>100</x>
322 <x>100</x>
323 <y>360</y>
323 <y>360</y>
324 <width>81</width>
324 <width>81</width>
325 <height>20</height>
325 <height>20</height>
326 </rect>
326 </rect>
327 </property>
327 </property>
328 </widget>
328 </widget>
329 <widget class="QLabel" name="label_14">
329 <widget class="QLabel" name="label_14">
330 <property name="geometry">
330 <property name="geometry">
331 <rect>
331 <rect>
332 <x>10</x>
332 <x>10</x>
333 <y>390</y>
333 <y>390</y>
334 <width>101</width>
334 <width>101</width>
335 <height>16</height>
335 <height>16</height>
336 </rect>
336 </rect>
337 </property>
337 </property>
338 <property name="text">
338 <property name="text">
339 <string>Label font size</string>
339 <string>Label font size</string>
340 </property>
340 </property>
341 </widget>
341 </widget>
342 <widget class="QFontComboBox" name="labelFontComboBox">
342 <widget class="QFontComboBox" name="labelFontComboBox">
343 <property name="geometry">
343 <property name="geometry">
344 <rect>
344 <rect>
345 <x>10</x>
345 <x>10</x>
346 <y>420</y>
346 <y>420</y>
347 <width>171</width>
347 <width>171</width>
348 <height>22</height>
348 <height>22</height>
349 </rect>
349 </rect>
350 </property>
350 </property>
351 </widget>
351 </widget>
352 <widget class="QSpinBox" name="labelFontSizeSpin">
352 <widget class="QSpinBox" name="labelFontSizeSpin">
353 <property name="geometry">
353 <property name="geometry">
354 <rect>
354 <rect>
355 <x>100</x>
355 <x>100</x>
356 <y>390</y>
356 <y>390</y>
357 <width>81</width>
357 <width>81</width>
358 <height>22</height>
358 <height>22</height>
359 </rect>
359 </rect>
360 </property>
360 </property>
361 <property name="minimum">
361 <property name="minimum">
362 <number>-100000</number>
362 <number>-100000</number>
363 </property>
363 </property>
364 <property name="maximum">
364 <property name="maximum">
365 <number>100000</number>
365 <number>100000</number>
366 </property>
366 </property>
367 </widget>
367 </widget>
368 <widget class="QComboBox" name="animationsComboBox">
368 <widget class="QComboBox" name="animationsComboBox">
369 <property name="geometry">
369 <property name="geometry">
370 <rect>
370 <rect>
371 <x>10</x>
371 <x>10</x>
372 <y>480</y>
372 <y>480</y>
373 <width>171</width>
373 <width>171</width>
374 <height>22</height>
374 <height>22</height>
375 </rect>
375 </rect>
376 </property>
376 </property>
377 <item>
377 <item>
378 <property name="text">
378 <property name="text">
379 <string>No animations</string>
379 <string>No animations</string>
380 </property>
380 </property>
381 </item>
381 </item>
382 <item>
382 <item>
383 <property name="text">
383 <property name="text">
384 <string>Series animation</string>
384 <string>Series animation</string>
385 </property>
385 </property>
386 </item>
386 </item>
387 <item>
387 <item>
388 <property name="text">
388 <property name="text">
389 <string>Grid animation</string>
389 <string>Grid animation</string>
390 </property>
390 </property>
391 </item>
391 </item>
392 <item>
392 <item>
393 <property name="text">
393 <property name="text">
394 <string>All animations</string>
394 <string>All animations</string>
395 </property>
395 </property>
396 </item>
396 </item>
397 </widget>
397 </widget>
398 <widget class="QComboBox" name="labelComboBox">
398 <widget class="QComboBox" name="labelComboBox">
399 <property name="geometry">
399 <property name="geometry">
400 <rect>
400 <rect>
401 <x>10</x>
401 <x>10</x>
402 <y>450</y>
402 <y>450</y>
403 <width>171</width>
403 <width>171</width>
404 <height>22</height>
404 <height>22</height>
405 </rect>
405 </rect>
406 </property>
406 </property>
407 <property name="currentIndex">
407 <property name="currentIndex">
408 <number>1</number>
408 <number>1</number>
409 </property>
409 </property>
410 <item>
410 <item>
411 <property name="text">
411 <property name="text">
412 <string>No labels</string>
412 <string>No labels</string>
413 </property>
413 </property>
414 </item>
414 </item>
415 <item>
415 <item>
416 <property name="text">
416 <property name="text">
417 <string>Black label</string>
417 <string>Black label</string>
418 </property>
418 </property>
419 </item>
419 </item>
420 <item>
420 <item>
421 <property name="text">
421 <property name="text">
422 <string>White label + blue pen</string>
422 <string>White label + blue pen</string>
423 </property>
423 </property>
424 </item>
424 </item>
425 </widget>
425 </widget>
426 <widget class="QSpinBox" name="titleFontSizeSpin">
426 <widget class="QSpinBox" name="titleFontSizeSpin">
427 <property name="geometry">
427 <property name="geometry">
428 <rect>
428 <rect>
429 <x>100</x>
429 <x>100</x>
430 <y>510</y>
430 <y>510</y>
431 <width>81</width>
431 <width>81</width>
432 <height>22</height>
432 <height>22</height>
433 </rect>
433 </rect>
434 </property>
434 </property>
435 <property name="minimum">
435 <property name="minimum">
436 <number>-100000</number>
436 <number>-100000</number>
437 </property>
437 </property>
438 <property name="maximum">
438 <property name="maximum">
439 <number>100000</number>
439 <number>100000</number>
440 </property>
440 </property>
441 </widget>
441 </widget>
442 <widget class="QComboBox" name="titleComboBox">
442 <widget class="QComboBox" name="titleComboBox">
443 <property name="geometry">
443 <property name="geometry">
444 <rect>
444 <rect>
445 <x>10</x>
445 <x>10</x>
446 <y>570</y>
446 <y>570</y>
447 <width>171</width>
447 <width>171</width>
448 <height>22</height>
448 <height>22</height>
449 </rect>
449 </rect>
450 </property>
450 </property>
451 <property name="sizePolicy">
451 <property name="sizePolicy">
452 <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
452 <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
453 <horstretch>0</horstretch>
453 <horstretch>0</horstretch>
454 <verstretch>0</verstretch>
454 <verstretch>0</verstretch>
455 </sizepolicy>
455 </sizepolicy>
456 </property>
456 </property>
457 <property name="currentIndex">
457 <property name="currentIndex">
458 <number>3</number>
458 <number>3</number>
459 </property>
459 </property>
460 <item>
460 <item>
461 <property name="text">
461 <property name="text">
462 <string>Invisible empty title</string>
462 <string>Invisible empty title</string>
463 </property>
463 </property>
464 </item>
464 </item>
465 <item>
465 <item>
466 <property name="text">
466 <property name="text">
467 <string>Visible empty title</string>
467 <string>Visible empty title</string>
468 </property>
468 </property>
469 </item>
469 </item>
470 <item>
470 <item>
471 <property name="text">
471 <property name="text">
472 <string>Invisible title</string>
472 <string>Invisible title</string>
473 </property>
473 </property>
474 </item>
474 </item>
475 <item>
475 <item>
476 <property name="text">
476 <property name="text">
477 <string>Black title</string>
477 <string>Black title</string>
478 </property>
478 </property>
479 </item>
479 </item>
480 <item>
480 <item>
481 <property name="text">
481 <property name="text">
482 <string>White title + blue pen</string>
482 <string>White title + blue pen</string>
483 </property>
483 </property>
484 </item>
484 </item>
485 </widget>
485 </widget>
486 <widget class="QFontComboBox" name="titleFontComboBox">
486 <widget class="QFontComboBox" name="titleFontComboBox">
487 <property name="geometry">
487 <property name="geometry">
488 <rect>
488 <rect>
489 <x>10</x>
489 <x>10</x>
490 <y>540</y>
490 <y>540</y>
491 <width>171</width>
491 <width>171</width>
492 <height>22</height>
492 <height>22</height>
493 </rect>
493 </rect>
494 </property>
494 </property>
495 </widget>
495 </widget>
496 <widget class="QLabel" name="label_15">
496 <widget class="QLabel" name="label_15">
497 <property name="geometry">
497 <property name="geometry">
498 <rect>
498 <rect>
499 <x>10</x>
499 <x>10</x>
500 <y>510</y>
500 <y>510</y>
501 <width>101</width>
501 <width>101</width>
502 <height>16</height>
502 <height>16</height>
503 </rect>
503 </rect>
504 </property>
504 </property>
505 <property name="text">
505 <property name="text">
506 <string>Title font size</string>
506 <string>Title font size</string>
507 </property>
507 </property>
508 </widget>
508 </widget>
509 <widget class="QComboBox" name="gridComboBox">
509 <widget class="QComboBox" name="gridComboBox">
510 <property name="geometry">
510 <property name="geometry">
511 <rect>
511 <rect>
512 <x>10</x>
512 <x>10</x>
513 <y>600</y>
513 <y>600</y>
514 <width>171</width>
514 <width>171</width>
515 <height>22</height>
515 <height>22</height>
516 </rect>
516 </rect>
517 </property>
517 </property>
518 <property name="sizePolicy">
518 <property name="sizePolicy">
519 <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
519 <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
520 <horstretch>0</horstretch>
520 <horstretch>0</horstretch>
521 <verstretch>0</verstretch>
521 <verstretch>0</verstretch>
522 </sizepolicy>
522 </sizepolicy>
523 </property>
523 </property>
524 <property name="currentIndex">
524 <property name="currentIndex">
525 <number>1</number>
525 <number>1</number>
526 </property>
526 </property>
527 <item>
527 <item>
528 <property name="text">
528 <property name="text">
529 <string>Invisible grid</string>
529 <string>Invisible grid</string>
530 </property>
530 </property>
531 </item>
531 </item>
532 <item>
532 <item>
533 <property name="text">
533 <property name="text">
534 <string>Black grid</string>
534 <string>Black grid</string>
535 </property>
535 </property>
536 </item>
536 </item>
537 <item>
537 <item>
538 <property name="text">
538 <property name="text">
539 <string>Custom grid pen</string>
539 <string>Custom grid pen</string>
540 </property>
540 </property>
541 </item>
541 </item>
542 </widget>
542 </widget>
543 <widget class="QComboBox" name="arrowComboBox">
543 <widget class="QComboBox" name="arrowComboBox">
544 <property name="geometry">
544 <property name="geometry">
545 <rect>
545 <rect>
546 <x>10</x>
546 <x>10</x>
547 <y>630</y>
547 <y>630</y>
548 <width>171</width>
548 <width>171</width>
549 <height>22</height>
549 <height>22</height>
550 </rect>
550 </rect>
551 </property>
551 </property>
552 <property name="sizePolicy">
552 <property name="sizePolicy">
553 <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
553 <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
554 <horstretch>0</horstretch>
554 <horstretch>0</horstretch>
555 <verstretch>0</verstretch>
555 <verstretch>0</verstretch>
556 </sizepolicy>
556 </sizepolicy>
557 </property>
557 </property>
558 <property name="currentIndex">
558 <property name="currentIndex">
559 <number>1</number>
559 <number>1</number>
560 </property>
560 </property>
561 <item>
561 <item>
562 <property name="text">
562 <property name="text">
563 <string>Invisible arrow</string>
563 <string>Invisible arrow</string>
564 </property>
564 </property>
565 </item>
565 </item>
566 <item>
566 <item>
567 <property name="text">
567 <property name="text">
568 <string>Black arrow</string>
568 <string>Black arrow</string>
569 </property>
569 </property>
570 </item>
570 </item>
571 <item>
571 <item>
572 <property name="text">
572 <property name="text">
573 <string>Custom arrow pen</string>
573 <string>Custom arrow pen</string>
574 </property>
574 </property>
575 </item>
575 </item>
576 </widget>
576 </widget>
577 <widget class="QComboBox" name="angularAxisComboBox">
577 <widget class="QComboBox" name="angularAxisComboBox">
578 <property name="geometry">
578 <property name="geometry">
579 <rect>
579 <rect>
580 <x>10</x>
580 <x>10</x>
581 <y>20</y>
581 <y>20</y>
582 <width>171</width>
582 <width>171</width>
583 <height>22</height>
583 <height>22</height>
584 </rect>
584 </rect>
585 </property>
585 </property>
586 <property name="currentIndex">
586 <property name="currentIndex">
587 <number>1</number>
587 <number>1</number>
588 </property>
588 </property>
589 <item>
589 <item>
590 <property name="text">
590 <property name="text">
591 <string>No Angular Axis</string>
591 <string>No Angular Axis</string>
592 </property>
592 </property>
593 </item>
593 </item>
594 <item>
594 <item>
595 <property name="text">
595 <property name="text">
596 <string>Angular Value Axis</string>
596 <string>Angular Value Axis</string>
597 </property>
597 </property>
598 </item>
598 </item>
599 <item>
599 <item>
600 <property name="text">
600 <property name="text">
601 <string>Angular Log Axis</string>
601 <string>Angular Log Axis</string>
602 </property>
602 </property>
603 </item>
603 </item>
604 <item>
604 <item>
605 <property name="text">
605 <property name="text">
606 <string>Angular DateTime Axis</string>
606 <string>Angular DateTime Axis</string>
607 </property>
607 </property>
608 </item>
608 </item>
609 <item>
609 <item>
610 <property name="text">
610 <property name="text">
611 <string>Angular Category Axis</string>
611 <string>Angular Category Axis</string>
612 </property>
612 </property>
613 </item>
613 </item>
614 </widget>
614 </widget>
615 <widget class="QComboBox" name="radialAxisComboBox">
615 <widget class="QComboBox" name="radialAxisComboBox">
616 <property name="geometry">
616 <property name="geometry">
617 <rect>
617 <rect>
618 <x>10</x>
618 <x>10</x>
619 <y>50</y>
619 <y>50</y>
620 <width>171</width>
620 <width>171</width>
621 <height>22</height>
621 <height>22</height>
622 </rect>
622 </rect>
623 </property>
623 </property>
624 <property name="currentIndex">
624 <property name="currentIndex">
625 <number>1</number>
625 <number>1</number>
626 </property>
626 </property>
627 <item>
627 <item>
628 <property name="text">
628 <property name="text">
629 <string>No Radial Axis</string>
629 <string>No Radial Axis</string>
630 </property>
630 </property>
631 </item>
631 </item>
632 <item>
632 <item>
633 <property name="text">
633 <property name="text">
634 <string>Radial Value Axis</string>
634 <string>Radial Value Axis</string>
635 </property>
635 </property>
636 </item>
636 </item>
637 <item>
637 <item>
638 <property name="text">
638 <property name="text">
639 <string>Radial Log Axis</string>
639 <string>Radial Log Axis</string>
640 </property>
640 </property>
641 </item>
641 </item>
642 <item>
642 <item>
643 <property name="text">
643 <property name="text">
644 <string>Radial DateTime Axis</string>
644 <string>Radial DateTime Axis</string>
645 </property>
645 </property>
646 </item>
646 </item>
647 <item>
647 <item>
648 <property name="text">
648 <property name="text">
649 <string>Radial Category Axis</string>
649 <string>Radial Category Axis</string>
650 </property>
650 </property>
651 </item>
651 </item>
652 </widget>
652 </widget>
653 <widget class="QLabel" name="label_16">
653 <widget class="QLabel" name="label_16">
654 <property name="geometry">
654 <property name="geometry">
655 <rect>
655 <rect>
656 <x>10</x>
656 <x>10</x>
657 <y>660</y>
657 <y>660</y>
658 <width>101</width>
658 <width>101</width>
659 <height>16</height>
659 <height>16</height>
660 </rect>
660 </rect>
661 </property>
661 </property>
662 <property name="text">
662 <property name="text">
663 <string>Log Base</string>
663 <string>Log Base</string>
664 </property>
664 </property>
665 </widget>
665 </widget>
666 <widget class="QDoubleSpinBox" name="logBaseSpin">
666 <widget class="QDoubleSpinBox" name="logBaseSpin">
667 <property name="geometry">
667 <property name="geometry">
668 <rect>
668 <rect>
669 <x>90</x>
669 <x>90</x>
670 <y>660</y>
670 <y>660</y>
671 <width>91</width>
671 <width>91</width>
672 <height>22</height>
672 <height>22</height>
673 </rect>
673 </rect>
674 </property>
674 </property>
675 <property name="decimals">
675 <property name="decimals">
676 <number>5</number>
676 <number>5</number>
677 </property>
677 </property>
678 <property name="minimum">
678 <property name="minimum">
679 <double>-999999999.000000000000000</double>
679 <double>-999999999.000000000000000</double>
680 </property>
680 </property>
681 <property name="maximum">
681 <property name="maximum">
682 <double>999999999.000000000000000</double>
682 <double>999999999.000000000000000</double>
683 </property>
683 </property>
684 <property name="value">
684 <property name="value">
685 <double>8.000000000000000</double>
685 <double>8.000000000000000</double>
686 </property>
686 </property>
687 </widget>
687 </widget>
688 <widget class="QCheckBox" name="niceNumbersCheckBox">
688 <widget class="QCheckBox" name="niceNumbersCheckBox">
689 <property name="geometry">
689 <property name="geometry">
690 <rect>
690 <rect>
691 <x>10</x>
691 <x>10</x>
692 <y>690</y>
692 <y>690</y>
693 <width>91</width>
693 <width>91</width>
694 <height>16</height>
694 <height>16</height>
695 </rect>
695 </rect>
696 </property>
696 </property>
697 <property name="text">
697 <property name="text">
698 <string>Nice Numbers</string>
698 <string>Nice Numbers</string>
699 </property>
699 </property>
700 </widget>
700 </widget>
701 <widget class="QLineEdit" name="dateFormatEdit">
701 <widget class="QLineEdit" name="dateFormatEdit">
702 <property name="geometry">
702 <property name="geometry">
703 <rect>
703 <rect>
704 <x>100</x>
704 <x>100</x>
705 <y>710</y>
705 <y>710</y>
706 <width>81</width>
706 <width>81</width>
707 <height>20</height>
707 <height>20</height>
708 </rect>
708 </rect>
709 </property>
709 </property>
710 </widget>
710 </widget>
711 <widget class="QLabel" name="label_17">
711 <widget class="QLabel" name="label_17">
712 <property name="geometry">
712 <property name="geometry">
713 <rect>
713 <rect>
714 <x>10</x>
714 <x>10</x>
715 <y>710</y>
715 <y>710</y>
716 <width>101</width>
716 <width>101</width>
717 <height>16</height>
717 <height>16</height>
718 </rect>
718 </rect>
719 </property>
719 </property>
720 <property name="text">
720 <property name="text">
721 <string>DateTime format</string>
721 <string>DateTime format</string>
722 </property>
722 </property>
723 </widget>
723 </widget>
724 <widget class="QCheckBox" name="moreCategoriesCheckBox">
724 <widget class="QCheckBox" name="moreCategoriesCheckBox">
725 <property name="geometry">
725 <property name="geometry">
726 <rect>
726 <rect>
727 <x>100</x>
727 <x>100</x>
728 <y>690</y>
728 <y>690</y>
729 <width>141</width>
729 <width>141</width>
730 <height>16</height>
730 <height>16</height>
731 </rect>
731 </rect>
732 </property>
732 </property>
733 <property name="text">
733 <property name="text">
734 <string>More Categories</string>
734 <string>More Categories</string>
735 </property>
735 </property>
736 </widget>
736 </widget>
737 <widget class="QCheckBox" name="series1checkBox">
737 <widget class="QCheckBox" name="series1checkBox">
738 <property name="geometry">
738 <property name="geometry">
739 <rect>
739 <rect>
740 <x>10</x>
740 <x>10</x>
741 <y>730</y>
741 <y>730</y>
742 <width>31</width>
742 <width>31</width>
743 <height>16</height>
743 <height>16</height>
744 </rect>
744 </rect>
745 </property>
745 </property>
746 <property name="text">
746 <property name="text">
747 <string>1</string>
747 <string>1</string>
748 </property>
748 </property>
749 </widget>
749 </widget>
750 <widget class="QCheckBox" name="series2checkBox">
750 <widget class="QCheckBox" name="series2checkBox">
751 <property name="geometry">
751 <property name="geometry">
752 <rect>
752 <rect>
753 <x>40</x>
753 <x>40</x>
754 <y>730</y>
754 <y>730</y>
755 <width>31</width>
755 <width>31</width>
756 <height>16</height>
756 <height>16</height>
757 </rect>
757 </rect>
758 </property>
758 </property>
759 <property name="text">
759 <property name="text">
760 <string>2</string>
760 <string>2</string>
761 </property>
761 </property>
762 </widget>
762 </widget>
763 <widget class="QCheckBox" name="series3checkBox">
763 <widget class="QCheckBox" name="series3checkBox">
764 <property name="geometry">
764 <property name="geometry">
765 <rect>
765 <rect>
766 <x>70</x>
766 <x>70</x>
767 <y>730</y>
767 <y>730</y>
768 <width>31</width>
768 <width>31</width>
769 <height>16</height>
769 <height>16</height>
770 </rect>
770 </rect>
771 </property>
771 </property>
772 <property name="text">
772 <property name="text">
773 <string>3</string>
773 <string>3</string>
774 </property>
774 </property>
775 </widget>
775 </widget>
776 <widget class="QCheckBox" name="series4checkBox">
776 <widget class="QCheckBox" name="series4checkBox">
777 <property name="geometry">
777 <property name="geometry">
778 <rect>
778 <rect>
779 <x>10</x>
779 <x>10</x>
780 <y>750</y>
780 <y>750</y>
781 <width>31</width>
781 <width>31</width>
782 <height>16</height>
782 <height>16</height>
783 </rect>
783 </rect>
784 </property>
784 </property>
785 <property name="text">
785 <property name="text">
786 <string>4</string>
786 <string>4</string>
787 </property>
787 </property>
788 </widget>
788 </widget>
789 <widget class="QCheckBox" name="series5checkBox">
789 <widget class="QCheckBox" name="series5checkBox">
790 <property name="geometry">
790 <property name="geometry">
791 <rect>
791 <rect>
792 <x>40</x>
792 <x>40</x>
793 <y>750</y>
793 <y>750</y>
794 <width>31</width>
794 <width>31</width>
795 <height>16</height>
795 <height>16</height>
796 </rect>
796 </rect>
797 </property>
797 </property>
798 <property name="text">
798 <property name="text">
799 <string>5</string>
799 <string>5</string>
800 </property>
800 </property>
801 </widget>
801 </widget>
802 <widget class="QCheckBox" name="series6checkBox">
802 <widget class="QCheckBox" name="series6checkBox">
803 <property name="geometry">
803 <property name="geometry">
804 <rect>
804 <rect>
805 <x>70</x>
805 <x>70</x>
806 <y>750</y>
806 <y>750</y>
807 <width>31</width>
807 <width>31</width>
808 <height>16</height>
808 <height>16</height>
809 </rect>
809 </rect>
810 </property>
810 </property>
811 <property name="text">
811 <property name="text">
812 <string>6</string>
812 <string>6</string>
813 </property>
813 </property>
814 </widget>
814 </widget>
815 <widget class="QCheckBox" name="series7checkBox">
815 <widget class="QCheckBox" name="series7checkBox">
816 <property name="geometry">
816 <property name="geometry">
817 <rect>
817 <rect>
818 <x>100</x>
818 <x>100</x>
819 <y>740</y>
819 <y>740</y>
820 <width>31</width>
820 <width>31</width>
821 <height>16</height>
821 <height>16</height>
822 </rect>
822 </rect>
823 </property>
823 </property>
824 <property name="text">
824 <property name="text">
825 <string>7</string>
825 <string>7</string>
826 </property>
826 </property>
827 </widget>
827 </widget>
828 <widget class="QComboBox" name="themeComboBox">
828 <widget class="QComboBox" name="themeComboBox">
829 <property name="geometry">
829 <property name="geometry">
830 <rect>
830 <rect>
831 <x>10</x>
831 <x>10</x>
832 <y>770</y>
832 <y>770</y>
833 <width>171</width>
833 <width>171</width>
834 <height>22</height>
834 <height>22</height>
835 </rect>
835 </rect>
836 </property>
836 </property>
837 <property name="sizePolicy">
837 <property name="sizePolicy">
838 <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
838 <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
839 <horstretch>0</horstretch>
839 <horstretch>0</horstretch>
840 <verstretch>0</verstretch>
840 <verstretch>0</verstretch>
841 </sizepolicy>
841 </sizepolicy>
842 </property>
842 </property>
843 <property name="currentIndex">
843 <property name="currentIndex">
844 <number>0</number>
844 <number>0</number>
845 </property>
845 </property>
846 <item>
846 <item>
847 <property name="text">
847 <property name="text">
848 <string>Theme: Light</string>
848 <string>Theme: Light</string>
849 </property>
849 </property>
850 </item>
850 </item>
851 <item>
851 <item>
852 <property name="text">
852 <property name="text">
853 <string>Theme: Blue Cerulean</string>
853 <string>Theme: Blue Cerulean</string>
854 </property>
854 </property>
855 </item>
855 </item>
856 <item>
856 <item>
857 <property name="text">
857 <property name="text">
858 <string>Theme: Dark</string>
858 <string>Theme: Dark</string>
859 </property>
859 </property>
860 </item>
860 </item>
861 <item>
861 <item>
862 <property name="text">
862 <property name="text">
863 <string>Theme: Brown Sand</string>
863 <string>Theme: Brown Sand</string>
864 </property>
864 </property>
865 </item>
865 </item>
866 <item>
866 <item>
867 <property name="text">
867 <property name="text">
868 <string>Theme: Blue Ncs</string>
868 <string>Theme: Blue Ncs</string>
869 </property>
869 </property>
870 </item>
870 </item>
871 <item>
871 <item>
872 <property name="text">
872 <property name="text">
873 <string>Theme: High Contrast</string>
873 <string>Theme: High Contrast</string>
874 </property>
874 </property>
875 </item>
875 </item>
876 <item>
876 <item>
877 <property name="text">
877 <property name="text">
878 <string>Theme: Blue Icy</string>
878 <string>Theme: Blue Icy</string>
879 </property>
879 </property>
880 </item>
880 </item>
881 </widget>
881 </widget>
882 <widget class="QLabel" name="hoverLabel">
882 <widget class="QLabel" name="hoverLabel">
883 <property name="geometry">
883 <property name="geometry">
884 <rect>
884 <rect>
885 <x>10</x>
885 <x>10</x>
886 <y>800</y>
886 <y>800</y>
887 <width>171</width>
887 <width>171</width>
888 <height>16</height>
888 <height>16</height>
889 </rect>
889 </rect>
890 </property>
890 </property>
891 <property name="text">
891 <property name="text">
892 <string>Hover coordinates here!</string>
892 <string>Hover coordinates here!</string>
893 </property>
893 </property>
894 </widget>
894 </widget>
895 <widget class="QComboBox" name="backgroundComboBox">
896 <property name="geometry">
897 <rect>
898 <x>10</x>
899 <y>820</y>
900 <width>171</width>
901 <height>22</height>
902 </rect>
903 </property>
904 <property name="sizePolicy">
905 <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
906 <horstretch>0</horstretch>
907 <verstretch>0</verstretch>
908 </sizepolicy>
909 </property>
910 <property name="currentIndex">
911 <number>0</number>
912 </property>
913 <item>
914 <property name="text">
915 <string>Background: White</string>
916 </property>
917 </item>
918 <item>
919 <property name="text">
920 <string>Background: Blue</string>
921 </property>
922 </item>
923 <item>
924 <property name="text">
925 <string>Background: Yellow + Black Border</string>
926 </property>
927 </item>
928 </widget>
929 <widget class="QComboBox" name="plotAreaComboBox">
930 <property name="geometry">
931 <rect>
932 <x>10</x>
933 <y>850</y>
934 <width>171</width>
935 <height>22</height>
936 </rect>
937 </property>
938 <property name="sizePolicy">
939 <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
940 <horstretch>0</horstretch>
941 <verstretch>0</verstretch>
942 </sizepolicy>
943 </property>
944 <property name="currentIndex">
945 <number>0</number>
946 </property>
947 <item>
948 <property name="text">
949 <string>PlotArea: Transparent</string>
950 </property>
951 </item>
952 <item>
953 <property name="text">
954 <string>PlotArea: Magenta</string>
955 </property>
956 </item>
957 <item>
958 <property name="text">
959 <string>PlotArea: Gray + Red Border</string>
960 </property>
961 </item>
962 </widget>
895 </widget>
963 </widget>
896 </item>
964 </item>
897 </layout>
965 </layout>
898 </widget>
966 </widget>
899 <widget class="QMenuBar" name="menuBar">
967 <widget class="QMenuBar" name="menuBar">
900 <property name="geometry">
968 <property name="geometry">
901 <rect>
969 <rect>
902 <x>0</x>
970 <x>0</x>
903 <y>0</y>
971 <y>0</y>
904 <width>1207</width>
972 <width>1193</width>
905 <height>21</height>
973 <height>21</height>
906 </rect>
974 </rect>
907 </property>
975 </property>
908 </widget>
976 </widget>
909 <widget class="QToolBar" name="mainToolBar">
977 <widget class="QToolBar" name="mainToolBar">
910 <attribute name="toolBarArea">
978 <attribute name="toolBarArea">
911 <enum>TopToolBarArea</enum>
979 <enum>TopToolBarArea</enum>
912 </attribute>
980 </attribute>
913 <attribute name="toolBarBreak">
981 <attribute name="toolBarBreak">
914 <bool>false</bool>
982 <bool>false</bool>
915 </attribute>
983 </attribute>
916 </widget>
984 </widget>
917 <widget class="QStatusBar" name="statusBar"/>
985 <widget class="QStatusBar" name="statusBar"/>
918 </widget>
986 </widget>
919 <layoutdefault spacing="6" margin="11"/>
987 <layoutdefault spacing="6" margin="11"/>
920 <customwidgets>
988 <customwidgets>
921 <customwidget>
989 <customwidget>
922 <class>ChartView</class>
990 <class>ChartView</class>
923 <extends>QGraphicsView</extends>
991 <extends>QGraphicsView</extends>
924 <header>chartview.h</header>
992 <header>chartview.h</header>
925 </customwidget>
993 </customwidget>
926 </customwidgets>
994 </customwidgets>
927 <resources/>
995 <resources/>
928 <connections/>
996 <connections/>
929 </ui>
997 </ui>
@@ -1,106 +1,107
1 /****************************************************************************
1 /****************************************************************************
2 **
2 **
3 ** Copyright (C) 2013 Digia Plc
3 ** Copyright (C) 2013 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 import QtQuick 1.0
21 import QtQuick 1.0
22 import QtCommercial.Chart 1.2
22 import QtCommercial.Chart 1.3
23
23
24 ChartView {
24 ChartView {
25 id: chartView
25 id: chartView
26 title: "Chart Title"
26 title: "Chart Title"
27 anchors.fill: parent
27 anchors.fill: parent
28 property variant chart: chartView
28 property variant chart: chartView
29
29
30 LineSeries {
30 LineSeries {
31 name: "line"
31 name: "line"
32 XYPoint { x: 0; y: 0 }
32 XYPoint { x: 0; y: 0 }
33 XYPoint { x: 1.1; y: 2.1 }
33 XYPoint { x: 1.1; y: 2.1 }
34 XYPoint { x: 1.9; y: 3.3 }
34 XYPoint { x: 1.9; y: 3.3 }
35 XYPoint { x: 2.1; y: 2.1 }
35 XYPoint { x: 2.1; y: 2.1 }
36 XYPoint { x: 2.9; y: 4.9 }
36 XYPoint { x: 2.9; y: 4.9 }
37 XYPoint { x: 3.4; y: 3.0 }
37 XYPoint { x: 3.4; y: 3.0 }
38 XYPoint { x: 4.1; y: 3.3 }
38 XYPoint { x: 4.1; y: 3.3 }
39 }
39 }
40
40
41 onVisibleChanged: console.log("chart.onVisibleChanged: " + visible);
41 onVisibleChanged: console.log("chart.onVisibleChanged: " + visible);
42 onTitleColorChanged: console.log("chart.onTitleColorChanged: " + color);
42 onTitleColorChanged: console.log("chart.onTitleColorChanged: " + color);
43 onBackgroundColorChanged: console.log("chart.onBackgroundColorChanged: " + chart.backgroundColor);
43 onBackgroundColorChanged: console.log("chart.onBackgroundColorChanged: " + chart.backgroundColor);
44 onDropShadowEnabledChanged: console.log("chart.onDropShadowEnabledChanged: " + enabled);
44 onDropShadowEnabledChanged: console.log("chart.onDropShadowEnabledChanged: " + enabled);
45 onSeriesAdded: console.log("chart.onSeriesAdded: " + series.name);
45 onSeriesAdded: console.log("chart.onSeriesAdded: " + series.name);
46 onSeriesRemoved: console.log("chart.onSeriesRemoved: " + series.name);
46 onSeriesRemoved: console.log("chart.onSeriesRemoved: " + series.name);
47 onPlotAreaColorChanged: console.log("chart.plotAreaColorChanged: " + chart.plotAreaColor);
47
48
48 legend.onVisibleChanged: console.log("legend.onVisibleChanged: " + chart.legend.visible);
49 legend.onVisibleChanged: console.log("legend.onVisibleChanged: " + chart.legend.visible);
49 legend.onBackgroundVisibleChanged: console.log("legend.onBackgroundVisibleChanged: " + visible);
50 legend.onBackgroundVisibleChanged: console.log("legend.onBackgroundVisibleChanged: " + visible);
50 legend.onColorChanged: console.log("legend.onColorChanged: " + color);
51 legend.onColorChanged: console.log("legend.onColorChanged: " + color);
51 legend.onBorderColorChanged: console.log("legend.onBorderColorChanged: " + color);
52 legend.onBorderColorChanged: console.log("legend.onBorderColorChanged: " + color);
52 legend.onLabelColorChanged: console.log("legend.onLabelColorChanged: " + color);
53 legend.onLabelColorChanged: console.log("legend.onLabelColorChanged: " + color);
53 margins.onTopChanged: console.log("chart.margins.onTopChanged: " + top );
54 margins.onTopChanged: console.log("chart.margins.onTopChanged: " + top );
54 margins.onBottomChanged: console.log("chart.margins.onBottomChanged: " + bottom);
55 margins.onBottomChanged: console.log("chart.margins.onBottomChanged: " + bottom);
55 margins.onLeftChanged: console.log("chart.margins.onLeftChanged: " + left);
56 margins.onLeftChanged: console.log("chart.margins.onLeftChanged: " + left);
56 margins.onRightChanged: console.log("chart.margins.onRightChanged: " + right);
57 margins.onRightChanged: console.log("chart.margins.onRightChanged: " + right);
57 onPlotAreaChanged: {
58 onPlotAreaChanged: {
58 console.log("chart.onPlotAreaChanged, width: " + chartView.plotArea.width
59 console.log("chart.onPlotAreaChanged, width: " + chartView.plotArea.width
59 + " height: " + chartView.plotArea.height
60 + " height: " + chartView.plotArea.height
60 + " y: " + chartView.plotArea.y
61 + " y: " + chartView.plotArea.y
61 + " x: " + chartView.plotArea.x);
62 + " x: " + chartView.plotArea.x);
62 marginVisualizer.opacity = 1.0;
63 marginVisualizer.opacity = 1.0;
63 }
64 }
64
65
65 ValueAxis{
66 ValueAxis{
66 onColorChanged: console.log("axisX.onColorChanged: " + color);
67 onColorChanged: console.log("axisX.onColorChanged: " + color);
67 onLabelsVisibleChanged: console.log("axisX.onLabelsVisibleChanged: " + visible);
68 onLabelsVisibleChanged: console.log("axisX.onLabelsVisibleChanged: " + visible);
68 onLabelsColorChanged: console.log("axisX.onLabelsColorChanged: " + color);
69 onLabelsColorChanged: console.log("axisX.onLabelsColorChanged: " + color);
69 onVisibleChanged: console.log("axisX.onVisibleChanged: " + visible);
70 onVisibleChanged: console.log("axisX.onVisibleChanged: " + visible);
70 onGridVisibleChanged: console.log("axisX.onGridVisibleChanged: " + visible);
71 onGridVisibleChanged: console.log("axisX.onGridVisibleChanged: " + visible);
71 onShadesVisibleChanged: console.log("axisX.onShadesVisibleChanged: " + visible);
72 onShadesVisibleChanged: console.log("axisX.onShadesVisibleChanged: " + visible);
72 onShadesColorChanged: console.log("axisX.onShadesColorChanged: " + color);
73 onShadesColorChanged: console.log("axisX.onShadesColorChanged: " + color);
73 onShadesBorderColorChanged: console.log("axisX.onShadesBorderColorChanged: " + color);
74 onShadesBorderColorChanged: console.log("axisX.onShadesBorderColorChanged: " + color);
74 onMinChanged: console.log("axisX.onMinChanged: " + min);
75 onMinChanged: console.log("axisX.onMinChanged: " + min);
75 onMaxChanged: console.log("axisX.onMaxChanged: " + max);
76 onMaxChanged: console.log("axisX.onMaxChanged: " + max);
76 }
77 }
77
78
78 ValueAxis{
79 ValueAxis{
79 onColorChanged: console.log("axisY.onColorChanged: " + color);
80 onColorChanged: console.log("axisY.onColorChanged: " + color);
80 onLabelsVisibleChanged: console.log("axisY.onLabelsVisibleChanged: " + visible);
81 onLabelsVisibleChanged: console.log("axisY.onLabelsVisibleChanged: " + visible);
81 onLabelsColorChanged: console.log("axisY.onLabelsColorChanged: " + color);
82 onLabelsColorChanged: console.log("axisY.onLabelsColorChanged: " + color);
82 onVisibleChanged: console.log("axisY.onVisibleChanged: " + visible);
83 onVisibleChanged: console.log("axisY.onVisibleChanged: " + visible);
83 onGridVisibleChanged: console.log("axisY.onGridVisibleChanged: " + visible);
84 onGridVisibleChanged: console.log("axisY.onGridVisibleChanged: " + visible);
84 onShadesVisibleChanged: console.log("axisY.onShadesVisibleChanged: " + visible);
85 onShadesVisibleChanged: console.log("axisY.onShadesVisibleChanged: " + visible);
85 onShadesColorChanged: console.log("axisY.onShadesColorChanged: " + color);
86 onShadesColorChanged: console.log("axisY.onShadesColorChanged: " + color);
86 onShadesBorderColorChanged: console.log("axisY.onShadesBorderColorChanged: " + color);
87 onShadesBorderColorChanged: console.log("axisY.onShadesBorderColorChanged: " + color);
87 onMinChanged: console.log("axisY.onMinChanged: " + min);
88 onMinChanged: console.log("axisY.onMinChanged: " + min);
88 onMaxChanged: console.log("axisY.onMaxChanged: " + max);
89 onMaxChanged: console.log("axisY.onMaxChanged: " + max);
89 }
90 }
90
91
91 Rectangle {
92 Rectangle {
92 id: marginVisualizer
93 id: marginVisualizer
93 color: "transparent"
94 color: "transparent"
94 border.color: "red"
95 border.color: "red"
95 anchors.fill: parent
96 anchors.fill: parent
96 anchors.topMargin: chartView.minimumMargins.top
97 anchors.topMargin: chartView.minimumMargins.top
97 anchors.bottomMargin: chartView.minimumMargins.bottom
98 anchors.bottomMargin: chartView.minimumMargins.bottom
98 anchors.leftMargin: chartView.minimumMargins.left
99 anchors.leftMargin: chartView.minimumMargins.left
99 anchors.rightMargin: chartView.minimumMargins.right
100 anchors.rightMargin: chartView.minimumMargins.right
100 opacity: 0.0
101 opacity: 0.0
101 onOpacityChanged: if (opacity > 0.9) opacity = 0.0;
102 onOpacityChanged: if (opacity > 0.9) opacity = 0.0;
102 Behavior on opacity {
103 Behavior on opacity {
103 NumberAnimation { duration: 800 }
104 NumberAnimation { duration: 800 }
104 }
105 }
105 }
106 }
106 }
107 }
@@ -1,116 +1,120
1 /****************************************************************************
1 /****************************************************************************
2 **
2 **
3 ** Copyright (C) 2013 Digia Plc
3 ** Copyright (C) 2013 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 import QtQuick 1.0
21 import QtQuick 1.0
22
22
23 Flow {
23 Flow {
24 anchors.fill: parent
24 anchors.fill: parent
25 property variant chart
25 property variant chart
26 flow: Flow.TopToBottom
26 flow: Flow.TopToBottom
27 spacing: 5
27 spacing: 5
28 Button {
28 Button {
29 text: "visible"
29 text: "visible"
30 onClicked: chart.visible = !chart.visible;
30 onClicked: chart.visible = !chart.visible;
31 }
31 }
32 Button {
32 Button {
33 text: "theme +"
33 text: "theme +"
34 onClicked: chart.theme++;
34 onClicked: chart.theme++;
35 }
35 }
36 Button {
36 Button {
37 text: "theme -"
37 text: "theme -"
38 onClicked: chart.theme--;
38 onClicked: chart.theme--;
39 }
39 }
40 Button {
40 Button {
41 text: "animation opt +"
41 text: "animation opt +"
42 onClicked: chart.animationOptions++;
42 onClicked: chart.animationOptions++;
43 }
43 }
44 Button {
44 Button {
45 text: "animation opt -"
45 text: "animation opt -"
46 onClicked: chart.animationOptions--;
46 onClicked: chart.animationOptions--;
47 }
47 }
48 Button {
48 Button {
49 text: "background color"
49 text: "background color"
50 onClicked: chart.backgroundColor = main.nextColor();
50 onClicked: chart.backgroundColor = main.nextColor();
51 }
51 }
52 Button {
52 Button {
53 text: "plot area color"
54 onClicked: chart.plotAreaColor = main.nextColor();
55 }
56 Button {
53 text: "drop shadow enabled"
57 text: "drop shadow enabled"
54 onClicked: chart.dropShadowEnabled = !chart.dropShadowEnabled;
58 onClicked: chart.dropShadowEnabled = !chart.dropShadowEnabled;
55 }
59 }
56 Button {
60 Button {
57 text: "zoom +"
61 text: "zoom +"
58 onClicked: chart.zoom(2);
62 onClicked: chart.zoom(2);
59 }
63 }
60 Button {
64 Button {
61 text: "zoom -"
65 text: "zoom -"
62 onClicked: chart.zoom(0.5);
66 onClicked: chart.zoom(0.5);
63 }
67 }
64 Button {
68 Button {
65 text: "scroll left"
69 text: "scroll left"
66 onClicked: chart.scrollLeft(10);
70 onClicked: chart.scrollLeft(10);
67 }
71 }
68 Button {
72 Button {
69 text: "scroll right"
73 text: "scroll right"
70 onClicked: chart.scrollRight(10);
74 onClicked: chart.scrollRight(10);
71 }
75 }
72 Button {
76 Button {
73 text: "scroll up"
77 text: "scroll up"
74 onClicked: chart.scrollUp(10);
78 onClicked: chart.scrollUp(10);
75 }
79 }
76 Button {
80 Button {
77 text: "scroll down"
81 text: "scroll down"
78 onClicked: chart.scrollDown(10);
82 onClicked: chart.scrollDown(10);
79 }
83 }
80 Button {
84 Button {
81 text: "title color"
85 text: "title color"
82 onClicked: chart.titleColor = main.nextColor();
86 onClicked: chart.titleColor = main.nextColor();
83 }
87 }
84 Button {
88 Button {
85 text: "top margin +"
89 text: "top margin +"
86 onClicked: chart.margins.top += 5;
90 onClicked: chart.margins.top += 5;
87 }
91 }
88 Button {
92 Button {
89 text: "top margin -"
93 text: "top margin -"
90 onClicked: chart.margins.top -= 5;
94 onClicked: chart.margins.top -= 5;
91 }
95 }
92 Button {
96 Button {
93 text: "bottom margin +"
97 text: "bottom margin +"
94 onClicked: chart.margins.bottom += 5;
98 onClicked: chart.margins.bottom += 5;
95 }
99 }
96 Button {
100 Button {
97 text: "bottom margin -"
101 text: "bottom margin -"
98 onClicked: chart.margins.bottom -= 5;
102 onClicked: chart.margins.bottom -= 5;
99 }
103 }
100 Button {
104 Button {
101 text: "left margin +"
105 text: "left margin +"
102 onClicked: chart.margins.left += 5;
106 onClicked: chart.margins.left += 5;
103 }
107 }
104 Button {
108 Button {
105 text: "left margin -"
109 text: "left margin -"
106 onClicked: chart.margins.left -= 5;
110 onClicked: chart.margins.left -= 5;
107 }
111 }
108 Button {
112 Button {
109 text: "right margin +"
113 text: "right margin +"
110 onClicked: chart.margins.right += 5;
114 onClicked: chart.margins.right += 5;
111 }
115 }
112 Button {
116 Button {
113 text: "right margin -"
117 text: "right margin -"
114 onClicked: chart.margins.right -= 5;
118 onClicked: chart.margins.right -= 5;
115 }
119 }
116 }
120 }
@@ -1,106 +1,107
1 /****************************************************************************
1 /****************************************************************************
2 **
2 **
3 ** Copyright (C) 2013 Digia Plc
3 ** Copyright (C) 2013 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 import QtQuick 2.0
21 import QtQuick 2.0
22 import QtCommercial.Chart 1.2
22 import QtCommercial.Chart 1.3
23
23
24 ChartView {
24 ChartView {
25 id: chartView
25 id: chartView
26 title: "Chart Title"
26 title: "Chart Title"
27 anchors.fill: parent
27 anchors.fill: parent
28 property variant chart: chartView
28 property variant chart: chartView
29
29
30 LineSeries {
30 LineSeries {
31 name: "line"
31 name: "line"
32 XYPoint { x: 0; y: 0 }
32 XYPoint { x: 0; y: 0 }
33 XYPoint { x: 1.1; y: 2.1 }
33 XYPoint { x: 1.1; y: 2.1 }
34 XYPoint { x: 1.9; y: 3.3 }
34 XYPoint { x: 1.9; y: 3.3 }
35 XYPoint { x: 2.1; y: 2.1 }
35 XYPoint { x: 2.1; y: 2.1 }
36 XYPoint { x: 2.9; y: 4.9 }
36 XYPoint { x: 2.9; y: 4.9 }
37 XYPoint { x: 3.4; y: 3.0 }
37 XYPoint { x: 3.4; y: 3.0 }
38 XYPoint { x: 4.1; y: 3.3 }
38 XYPoint { x: 4.1; y: 3.3 }
39 }
39 }
40
40
41 onVisibleChanged: console.log("chart.onVisibleChanged: " + visible);
41 onVisibleChanged: console.log("chart.onVisibleChanged: " + visible);
42 onTitleColorChanged: console.log("chart.onTitleColorChanged: " + color);
42 onTitleColorChanged: console.log("chart.onTitleColorChanged: " + color);
43 onBackgroundColorChanged: console.log("chart.onBackgroundColorChanged: " + chart.backgroundColor);
43 onBackgroundColorChanged: console.log("chart.onBackgroundColorChanged: " + chart.backgroundColor);
44 onDropShadowEnabledChanged: console.log("chart.onDropShadowEnabledChanged: " + enabled);
44 onDropShadowEnabledChanged: console.log("chart.onDropShadowEnabledChanged: " + enabled);
45 onSeriesAdded: console.log("chart.onSeriesAdded: " + series.name);
45 onSeriesAdded: console.log("chart.onSeriesAdded: " + series.name);
46 onSeriesRemoved: console.log("chart.onSeriesRemoved: " + series.name);
46 onSeriesRemoved: console.log("chart.onSeriesRemoved: " + series.name);
47 onPlotAreaColorChanged: console.log("chart.plotAreaColorChanged: " + chart.plotAreaColor);
47
48
48 legend.onVisibleChanged: console.log("legend.onVisibleChanged: " + chart.legend.visible);
49 legend.onVisibleChanged: console.log("legend.onVisibleChanged: " + chart.legend.visible);
49 legend.onBackgroundVisibleChanged: console.log("legend.onBackgroundVisibleChanged: " + visible);
50 legend.onBackgroundVisibleChanged: console.log("legend.onBackgroundVisibleChanged: " + visible);
50 legend.onColorChanged: console.log("legend.onColorChanged: " + color);
51 legend.onColorChanged: console.log("legend.onColorChanged: " + color);
51 legend.onBorderColorChanged: console.log("legend.onBorderColorChanged: " + color);
52 legend.onBorderColorChanged: console.log("legend.onBorderColorChanged: " + color);
52 legend.onLabelColorChanged: console.log("legend.onLabelColorChanged: " + color);
53 legend.onLabelColorChanged: console.log("legend.onLabelColorChanged: " + color);
53 margins.onTopChanged: console.log("chart.margins.onTopChanged: " + top );
54 margins.onTopChanged: console.log("chart.margins.onTopChanged: " + top );
54 margins.onBottomChanged: console.log("chart.margins.onBottomChanged: " + bottom);
55 margins.onBottomChanged: console.log("chart.margins.onBottomChanged: " + bottom);
55 margins.onLeftChanged: console.log("chart.margins.onLeftChanged: " + left);
56 margins.onLeftChanged: console.log("chart.margins.onLeftChanged: " + left);
56 margins.onRightChanged: console.log("chart.margins.onRightChanged: " + right);
57 margins.onRightChanged: console.log("chart.margins.onRightChanged: " + right);
57 onPlotAreaChanged: {
58 onPlotAreaChanged: {
58 console.log("chart.onPlotAreaChanged, width: " + chartView.plotArea.width
59 console.log("chart.onPlotAreaChanged, width: " + chartView.plotArea.width
59 + " height: " + chartView.plotArea.height
60 + " height: " + chartView.plotArea.height
60 + " y: " + chartView.plotArea.y
61 + " y: " + chartView.plotArea.y
61 + " x: " + chartView.plotArea.x);
62 + " x: " + chartView.plotArea.x);
62 marginVisualizer.opacity = 1.0;
63 marginVisualizer.opacity = 1.0;
63 }
64 }
64
65
65 ValueAxis{
66 ValueAxis{
66 onColorChanged: console.log("axisX.onColorChanged: " + color);
67 onColorChanged: console.log("axisX.onColorChanged: " + color);
67 onLabelsVisibleChanged: console.log("axisX.onLabelsVisibleChanged: " + visible);
68 onLabelsVisibleChanged: console.log("axisX.onLabelsVisibleChanged: " + visible);
68 onLabelsColorChanged: console.log("axisX.onLabelsColorChanged: " + color);
69 onLabelsColorChanged: console.log("axisX.onLabelsColorChanged: " + color);
69 onVisibleChanged: console.log("axisX.onVisibleChanged: " + visible);
70 onVisibleChanged: console.log("axisX.onVisibleChanged: " + visible);
70 onGridVisibleChanged: console.log("axisX.onGridVisibleChanged: " + visible);
71 onGridVisibleChanged: console.log("axisX.onGridVisibleChanged: " + visible);
71 onShadesVisibleChanged: console.log("axisX.onShadesVisibleChanged: " + visible);
72 onShadesVisibleChanged: console.log("axisX.onShadesVisibleChanged: " + visible);
72 onShadesColorChanged: console.log("axisX.onShadesColorChanged: " + color);
73 onShadesColorChanged: console.log("axisX.onShadesColorChanged: " + color);
73 onShadesBorderColorChanged: console.log("axisX.onShadesBorderColorChanged: " + color);
74 onShadesBorderColorChanged: console.log("axisX.onShadesBorderColorChanged: " + color);
74 onMinChanged: console.log("axisX.onMinChanged: " + min);
75 onMinChanged: console.log("axisX.onMinChanged: " + min);
75 onMaxChanged: console.log("axisX.onMaxChanged: " + max);
76 onMaxChanged: console.log("axisX.onMaxChanged: " + max);
76 }
77 }
77
78
78 ValueAxis{
79 ValueAxis{
79 onColorChanged: console.log("axisY.onColorChanged: " + color);
80 onColorChanged: console.log("axisY.onColorChanged: " + color);
80 onLabelsVisibleChanged: console.log("axisY.onLabelsVisibleChanged: " + visible);
81 onLabelsVisibleChanged: console.log("axisY.onLabelsVisibleChanged: " + visible);
81 onLabelsColorChanged: console.log("axisY.onLabelsColorChanged: " + color);
82 onLabelsColorChanged: console.log("axisY.onLabelsColorChanged: " + color);
82 onVisibleChanged: console.log("axisY.onVisibleChanged: " + visible);
83 onVisibleChanged: console.log("axisY.onVisibleChanged: " + visible);
83 onGridVisibleChanged: console.log("axisY.onGridVisibleChanged: " + visible);
84 onGridVisibleChanged: console.log("axisY.onGridVisibleChanged: " + visible);
84 onShadesVisibleChanged: console.log("axisY.onShadesVisibleChanged: " + visible);
85 onShadesVisibleChanged: console.log("axisY.onShadesVisibleChanged: " + visible);
85 onShadesColorChanged: console.log("axisY.onShadesColorChanged: " + color);
86 onShadesColorChanged: console.log("axisY.onShadesColorChanged: " + color);
86 onShadesBorderColorChanged: console.log("axisY.onShadesBorderColorChanged: " + color);
87 onShadesBorderColorChanged: console.log("axisY.onShadesBorderColorChanged: " + color);
87 onMinChanged: console.log("axisY.onMinChanged: " + min);
88 onMinChanged: console.log("axisY.onMinChanged: " + min);
88 onMaxChanged: console.log("axisY.onMaxChanged: " + max);
89 onMaxChanged: console.log("axisY.onMaxChanged: " + max);
89 }
90 }
90
91
91 Rectangle {
92 Rectangle {
92 id: marginVisualizer
93 id: marginVisualizer
93 color: "transparent"
94 color: "transparent"
94 border.color: "red"
95 border.color: "red"
95 anchors.fill: parent
96 anchors.fill: parent
96 anchors.topMargin: chartView.minimumMargins.top
97 anchors.topMargin: chartView.minimumMargins.top
97 anchors.bottomMargin: chartView.minimumMargins.bottom
98 anchors.bottomMargin: chartView.minimumMargins.bottom
98 anchors.leftMargin: chartView.minimumMargins.left
99 anchors.leftMargin: chartView.minimumMargins.left
99 anchors.rightMargin: chartView.minimumMargins.right
100 anchors.rightMargin: chartView.minimumMargins.right
100 opacity: 0.0
101 opacity: 0.0
101 onOpacityChanged: if (opacity > 0.9) opacity = 0.0;
102 onOpacityChanged: if (opacity > 0.9) opacity = 0.0;
102 Behavior on opacity {
103 Behavior on opacity {
103 NumberAnimation { duration: 800 }
104 NumberAnimation { duration: 800 }
104 }
105 }
105 }
106 }
106 }
107 }
@@ -1,116 +1,120
1 /****************************************************************************
1 /****************************************************************************
2 **
2 **
3 ** Copyright (C) 2013 Digia Plc
3 ** Copyright (C) 2013 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 import QtQuick 2.0
21 import QtQuick 2.0
22
22
23 Flow {
23 Flow {
24 anchors.fill: parent
24 anchors.fill: parent
25 property variant chart
25 property variant chart
26 flow: Flow.TopToBottom
26 flow: Flow.TopToBottom
27 spacing: 5
27 spacing: 5
28 Button {
28 Button {
29 text: "visible"
29 text: "visible"
30 onClicked: chart.visible = !chart.visible;
30 onClicked: chart.visible = !chart.visible;
31 }
31 }
32 Button {
32 Button {
33 text: "theme +"
33 text: "theme +"
34 onClicked: chart.theme++;
34 onClicked: chart.theme++;
35 }
35 }
36 Button {
36 Button {
37 text: "theme -"
37 text: "theme -"
38 onClicked: chart.theme--;
38 onClicked: chart.theme--;
39 }
39 }
40 Button {
40 Button {
41 text: "animation opt +"
41 text: "animation opt +"
42 onClicked: chart.animationOptions++;
42 onClicked: chart.animationOptions++;
43 }
43 }
44 Button {
44 Button {
45 text: "animation opt -"
45 text: "animation opt -"
46 onClicked: chart.animationOptions--;
46 onClicked: chart.animationOptions--;
47 }
47 }
48 Button {
48 Button {
49 text: "background color"
49 text: "background color"
50 onClicked: chart.backgroundColor = main.nextColor();
50 onClicked: chart.backgroundColor = main.nextColor();
51 }
51 }
52 Button {
52 Button {
53 text: "plot area color"
54 onClicked: chart.plotAreaColor = main.nextColor();
55 }
56 Button {
53 text: "drop shadow enabled"
57 text: "drop shadow enabled"
54 onClicked: chart.dropShadowEnabled = !chart.dropShadowEnabled;
58 onClicked: chart.dropShadowEnabled = !chart.dropShadowEnabled;
55 }
59 }
56 Button {
60 Button {
57 text: "zoom +"
61 text: "zoom +"
58 onClicked: chart.zoom(2);
62 onClicked: chart.zoom(2);
59 }
63 }
60 Button {
64 Button {
61 text: "zoom -"
65 text: "zoom -"
62 onClicked: chart.zoom(0.5);
66 onClicked: chart.zoom(0.5);
63 }
67 }
64 Button {
68 Button {
65 text: "scroll left"
69 text: "scroll left"
66 onClicked: chart.scrollLeft(10);
70 onClicked: chart.scrollLeft(10);
67 }
71 }
68 Button {
72 Button {
69 text: "scroll right"
73 text: "scroll right"
70 onClicked: chart.scrollRight(10);
74 onClicked: chart.scrollRight(10);
71 }
75 }
72 Button {
76 Button {
73 text: "scroll up"
77 text: "scroll up"
74 onClicked: chart.scrollUp(10);
78 onClicked: chart.scrollUp(10);
75 }
79 }
76 Button {
80 Button {
77 text: "scroll down"
81 text: "scroll down"
78 onClicked: chart.scrollDown(10);
82 onClicked: chart.scrollDown(10);
79 }
83 }
80 Button {
84 Button {
81 text: "title color"
85 text: "title color"
82 onClicked: chart.titleColor = main.nextColor();
86 onClicked: chart.titleColor = main.nextColor();
83 }
87 }
84 Button {
88 Button {
85 text: "top margin +"
89 text: "top margin +"
86 onClicked: chart.margins.top += 5;
90 onClicked: chart.margins.top += 5;
87 }
91 }
88 Button {
92 Button {
89 text: "top margin -"
93 text: "top margin -"
90 onClicked: chart.margins.top -= 5;
94 onClicked: chart.margins.top -= 5;
91 }
95 }
92 Button {
96 Button {
93 text: "bottom margin +"
97 text: "bottom margin +"
94 onClicked: chart.margins.bottom += 5;
98 onClicked: chart.margins.bottom += 5;
95 }
99 }
96 Button {
100 Button {
97 text: "bottom margin -"
101 text: "bottom margin -"
98 onClicked: chart.margins.bottom -= 5;
102 onClicked: chart.margins.bottom -= 5;
99 }
103 }
100 Button {
104 Button {
101 text: "left margin +"
105 text: "left margin +"
102 onClicked: chart.margins.left += 5;
106 onClicked: chart.margins.left += 5;
103 }
107 }
104 Button {
108 Button {
105 text: "left margin -"
109 text: "left margin -"
106 onClicked: chart.margins.left -= 5;
110 onClicked: chart.margins.left -= 5;
107 }
111 }
108 Button {
112 Button {
109 text: "right margin +"
113 text: "right margin +"
110 onClicked: chart.margins.right += 5;
114 onClicked: chart.margins.right += 5;
111 }
115 }
112 Button {
116 Button {
113 text: "right margin -"
117 text: "right margin -"
114 onClicked: chart.margins.right -= 5;
118 onClicked: chart.margins.right -= 5;
115 }
119 }
116 }
120 }
General Comments 0
You need to be logged in to leave comments. Login now