##// END OF EJS Templates
Fixed a bug in setting axes dynamically via QML API
Tero Ahola -
r1947:a62b3bfbefaa
parent child
Show More
@@ -0,0 +1,75
1 /****************************************************************************
2 **
3 ** Copyright (C) 2012 Digia Plc
4 ** All rights reserved.
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 **
7 ** This file is part of the Qt Commercial Charts Add-on.
8 **
9 ** $QT_BEGIN_LICENSE$
10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 ** accordance with the Qt Commercial License Agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia.
14 **
15 ** If you have questions regarding the use of this file, please use
16 ** contact form at http://qt.digia.com
17 ** $QT_END_LICENSE$
18 **
19 ****************************************************************************/
20
21 import QtQuick 1.0
22 import QtCommercial.Chart 1.1
23
24 ChartView {
25 id: chartView
26 title: "chart axes"
27
28 // TODO: Do we need a property for orientation or properties "axisX" and "axisY" on ChartView
29 // to make an axis the default axis for all series with no other axes defined...?
30 // ValueAxis {
31 // orientation: ValueAxis.AxisX
32 // min: 0
33 // max: 10
34 // }
35 // axisX: ValueAxis {
36 // min: 0
37 // max: 10
38 // }
39 // ...Now that we don't have this implementation, the following axes won't have any affect:
40 ValueAxis {
41 min: 0
42 max: 10
43 }
44 ValueAxis {
45 min: 0
46 max: 5
47 }
48
49 LineSeries {
50 name: "line series"
51 XYPoint { x: 0; y: 0 }
52 XYPoint { x: 1; y: 1 }
53 XYPoint { x: 2; y: 2 }
54 XYPoint { x: 3; y: 3 }
55 XYPoint { x: 4; y: 4 }
56 }
57
58 ScatterSeries {
59 name: "scatter series"
60 XYPoint { x: 0; y: 0 }
61 XYPoint { x: 0.5; y: 1 }
62 XYPoint { x: 1; y: 2 }
63 XYPoint { x: 1.5; y: 3 }
64 XYPoint { x: 2; y: 4 }
65 XYPoint { x: 1; y: 1 }
66 XYPoint { x: 2; y: 2 }
67 XYPoint { x: 3; y: 3 }
68 XYPoint { x: 4; y: 4 }
69 }
70
71 // Component.onCompleted: {
72 // // You can also set the axes dynamically
73 // chartView.setAxisX(axisX, scatter);
74 // }
75 }
@@ -0,0 +1,71
1 /****************************************************************************
2 **
3 ** Copyright (C) 2012 Digia Plc
4 ** All rights reserved.
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 **
7 ** This file is part of the Qt Commercial Charts Add-on.
8 **
9 ** $QT_BEGIN_LICENSE$
10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 ** accordance with the Qt Commercial License Agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia.
14 **
15 ** If you have questions regarding the use of this file, please use
16 ** contact form at http://qt.digia.com
17 ** $QT_END_LICENSE$
18 **
19 ****************************************************************************/
20
21 import QtQuick 1.0
22 import QtCommercial.Chart 1.1
23
24 ChartView {
25 title: "default + user defined"
26
27 ValueAxis {
28 id: axisX
29 min: 0
30 max: 6
31 }
32
33 ValueAxis {
34 id: axisY
35 min: 0
36 max: 6
37 }
38
39 LineSeries {
40 name: "line series 1"
41 XYPoint { x: 0; y: 0 }
42 XYPoint { x: 1; y: 1 }
43 XYPoint { x: 2; y: 2 }
44 XYPoint { x: 3; y: 3 }
45 XYPoint { x: 4; y: 4 }
46 }
47
48 ScatterSeries {
49 name: "scatter series"
50 axisX: axisX
51 axisY: axisY
52 XYPoint { x: 0; y: 0 }
53 XYPoint { x: 0.5; y: 1 }
54 XYPoint { x: 1; y: 2 }
55 XYPoint { x: 1.5; y: 3 }
56 XYPoint { x: 2; y: 4 }
57 XYPoint { x: 1; y: 1 }
58 XYPoint { x: 2; y: 2 }
59 XYPoint { x: 3; y: 3 }
60 XYPoint { x: 4; y: 4 }
61 }
62
63 LineSeries {
64 name: "line series 2"
65 XYPoint { x: 0; y: 0 }
66 XYPoint { x: 0.5; y: 1 }
67 XYPoint { x: 1; y: 2 }
68 XYPoint { x: 1.5; y: 3 }
69 XYPoint { x: 2; y: 4 }
70 }
71 }
@@ -0,0 +1,64
1 /****************************************************************************
2 **
3 ** Copyright (C) 2012 Digia Plc
4 ** All rights reserved.
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 **
7 ** This file is part of the Qt Commercial Charts Add-on.
8 **
9 ** $QT_BEGIN_LICENSE$
10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 ** accordance with the Qt Commercial License Agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia.
14 **
15 ** If you have questions regarding the use of this file, please use
16 ** contact form at http://qt.digia.com
17 ** $QT_END_LICENSE$
18 **
19 ****************************************************************************/
20
21 import QtQuick 1.0
22 import QtCommercial.Chart 1.1
23
24 ChartView {
25 title: "user defined reverted"
26
27 ValueAxis {
28 id: axisX
29 min: 0
30 max: 6
31 }
32
33 ValueAxis {
34 id: axisY
35 min: 0
36 max: 6
37 }
38
39 ScatterSeries {
40 name: "scatter series"
41 axisX: axisX
42 axisY: axisY
43 XYPoint { x: 0; y: 0 }
44 XYPoint { x: 0.5; y: 1 }
45 XYPoint { x: 1; y: 2 }
46 XYPoint { x: 1.5; y: 3 }
47 XYPoint { x: 2; y: 4 }
48 XYPoint { x: 1; y: 1 }
49 XYPoint { x: 2; y: 2 }
50 XYPoint { x: 3; y: 3 }
51 XYPoint { x: 4; y: 4 }
52 }
53
54 LineSeries {
55 name: "line series"
56 axisX: axisX
57 axisY: axisY
58 XYPoint { x: 0; y: 0 }
59 XYPoint { x: 1; y: 1 }
60 XYPoint { x: 2; y: 2 }
61 XYPoint { x: 3; y: 3 }
62 XYPoint { x: 4; y: 4 }
63 }
64 }
@@ -1,677 +1,678
1 /****************************************************************************
1 /****************************************************************************
2 **
2 **
3 ** Copyright (C) 2012 Digia Plc
3 ** Copyright (C) 2012 Digia Plc
4 ** All rights reserved.
4 ** All rights reserved.
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 **
6 **
7 ** This file is part of the Qt Commercial Charts Add-on.
7 ** This file is part of the Qt Commercial Charts Add-on.
8 **
8 **
9 ** $QT_BEGIN_LICENSE$
9 ** $QT_BEGIN_LICENSE$
10 ** Licensees holding valid Qt Commercial licenses may use this file in
10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 ** accordance with the Qt Commercial License Agreement provided with the
11 ** accordance with the Qt Commercial License Agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia.
13 ** a written agreement between you and Digia.
14 **
14 **
15 ** If you have questions regarding the use of this file, please use
15 ** If you have questions regarding the use of this file, please use
16 ** contact form at http://qt.digia.com
16 ** contact form at http://qt.digia.com
17 ** $QT_END_LICENSE$
17 ** $QT_END_LICENSE$
18 **
18 **
19 ****************************************************************************/
19 ****************************************************************************/
20
20
21 #include "declarativechart.h"
21 #include "declarativechart.h"
22 #include <QPainter>
22 #include <QPainter>
23 #include <QDeclarativeEngine>
23 #include <QDeclarativeEngine>
24 #include "declarativelineseries.h"
24 #include "declarativelineseries.h"
25 #include "declarativeareaseries.h"
25 #include "declarativeareaseries.h"
26 #include "declarativebarseries.h"
26 #include "declarativebarseries.h"
27 #include "declarativepieseries.h"
27 #include "declarativepieseries.h"
28 #include "declarativesplineseries.h"
28 #include "declarativesplineseries.h"
29 #include "declarativescatterseries.h"
29 #include "declarativescatterseries.h"
30 #include "qbarcategoryaxis.h"
30 #include "qbarcategoryaxis.h"
31 #include "qvalueaxis.h"
31 #include "qvalueaxis.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
35
36 #ifndef QT_ON_ARM
36 #ifndef QT_ON_ARM
37 #include "qdatetimeaxis.h"
37 #include "qdatetimeaxis.h"
38 #endif
38 #endif
39
39
40 QTCOMMERCIALCHART_BEGIN_NAMESPACE
40 QTCOMMERCIALCHART_BEGIN_NAMESPACE
41
41
42 /*!
42 /*!
43 \qmlclass ChartView DeclarativeChart
43 \qmlclass ChartView DeclarativeChart
44
44
45 ChartView element is the parent that is responsible for showing different chart series types.
45 ChartView element is the parent that is responsible for showing different chart series types.
46
46
47 The following QML shows how to create a simple chart with one pie series:
47 The following QML shows how to create a simple chart with one pie series:
48 \snippet ../examples/qmlpiechart/qml/qmlpiechart/main.qml 1
48 \snippet ../examples/qmlpiechart/qml/qmlpiechart/main.qml 1
49 \snippet ../examples/qmlpiechart/qml/qmlpiechart/main.qml 2
49 \snippet ../examples/qmlpiechart/qml/qmlpiechart/main.qml 2
50 \snippet ../examples/qmlpiechart/qml/qmlpiechart/main.qml 3
50 \snippet ../examples/qmlpiechart/qml/qmlpiechart/main.qml 3
51
51
52 \beginfloatleft
52 \beginfloatleft
53 \image examples_qmlpiechart.png
53 \image examples_qmlpiechart.png
54 \endfloat
54 \endfloat
55 \clearfloat
55 \clearfloat
56 */
56 */
57
57
58 /*!
58 /*!
59 \qmlproperty Theme ChartView::theme
59 \qmlproperty Theme ChartView::theme
60 Theme defines the visual appearance of the chart, including for example colors, fonts, line
60 Theme defines the visual appearance of the chart, including for example colors, fonts, line
61 widths and chart background.
61 widths and chart background.
62 */
62 */
63
63
64 /*!
64 /*!
65 \qmlproperty Animation ChartView::animation
65 \qmlproperty Animation ChartView::animation
66 Animation configuration of the chart. One of ChartView.NoAnimation, ChartView.GridAxisAnimations,
66 Animation configuration of the chart. One of ChartView.NoAnimation, ChartView.GridAxisAnimations,
67 ChartView.SeriesAnimations or ChartView.AllAnimations.
67 ChartView.SeriesAnimations or ChartView.AllAnimations.
68 */
68 */
69
69
70 /*!
70 /*!
71 \qmlproperty Font ChartView::titleFont
71 \qmlproperty Font ChartView::titleFont
72 The title font of the chart
72 The title font of the chart
73
73
74 See the \l {Font} {QML Font Element} for detailed documentation.
74 See the \l {Font} {QML Font Element} for detailed documentation.
75 */
75 */
76
76
77 /*!
77 /*!
78 \qmlproperty string ChartView::title
78 \qmlproperty string ChartView::title
79 The title of the chart, shown on top of the chart.
79 The title of the chart, shown on top of the chart.
80 \sa ChartView::titleColor
80 \sa ChartView::titleColor
81 */
81 */
82
82
83 /*!
83 /*!
84 \qmlproperty string ChartView::titleColor
84 \qmlproperty string ChartView::titleColor
85 The color of the title text.
85 The color of the title text.
86 */
86 */
87
87
88 /*!
88 /*!
89 \qmlproperty Axis ChartView::axisX
89 \qmlproperty Axis ChartView::axisX
90 The x-axis of the chart.
90 The x-axis of the chart.
91 */
91 */
92
92
93 /*!
93 /*!
94 \qmlproperty Axis ChartView::axisY
94 \qmlproperty Axis ChartView::axisY
95 The default y-axis of the chart.
95 The default y-axis of the chart.
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 bool ChartView::dropShadowEnabled
115 \qmlproperty bool ChartView::dropShadowEnabled
116 The chart's border drop shadow. Set to true to enable drop shadow.
116 The chart's border drop shadow. Set to true to enable drop shadow.
117 */
117 */
118
118
119 /*!
119 /*!
120 \qmlproperty real ChartView::topMargin
120 \qmlproperty real ChartView::topMargin
121 Deprecated. Use minimumMargins and plotArea instead.
121 Deprecated. Use minimumMargins and plotArea instead.
122 */
122 */
123
123
124 /*!
124 /*!
125 \qmlproperty real ChartView::bottomMargin
125 \qmlproperty real ChartView::bottomMargin
126 Deprecated. Use minimumMargins and plotArea instead.
126 Deprecated. Use minimumMargins and plotArea instead.
127 */
127 */
128
128
129 /*!
129 /*!
130 \qmlproperty real ChartView::leftMargin
130 \qmlproperty real ChartView::leftMargin
131 Deprecated. Use minimumMargins and plotArea instead.
131 Deprecated. Use minimumMargins and plotArea instead.
132 */
132 */
133
133
134 /*!
134 /*!
135 \qmlproperty real ChartView::rightMargin
135 \qmlproperty real ChartView::rightMargin
136 Deprecated. Use minimumMargins and plotArea instead.
136 Deprecated. Use minimumMargins and plotArea instead.
137 */
137 */
138
138
139 /*!
139 /*!
140 \qmlproperty Margins ChartView::minimumMargins
140 \qmlproperty Margins ChartView::minimumMargins
141 The minimum margins allowed between the outer bounds and the plotArea of the ChartView. Margins
141 The minimum margins allowed between the outer bounds and the plotArea of the ChartView. Margins
142 area of ChartView is used for drawing title, axes and legend. Please note that setting the
142 area of ChartView is used for drawing title, axes and legend. Please note that setting the
143 properties of minimumMargins may be bigger than the defined value, depending on other ChartView
143 properties of minimumMargins may be bigger than the defined value, depending on other ChartView
144 properties that affect it's layout. If you need to know the actual plotting area used at any
144 properties that affect it's layout. If you need to know the actual plotting area used at any
145 given time, you can check ChartView::plotArea instead.
145 given time, you can check ChartView::plotArea instead.
146 */
146 */
147
147
148 /*!
148 /*!
149 \qmlproperty rect ChartView::plotArea
149 \qmlproperty rect ChartView::plotArea
150 The area on the ChartView that is used for drawing series. This is the ChartView rect without the
150 The area on the ChartView that is used for drawing series. This is the ChartView rect without the
151 margins.
151 margins.
152 \sa ChartView::minimumMargins
152 \sa ChartView::minimumMargins
153 */
153 */
154
154
155 /*!
155 /*!
156 \qmlmethod AbstractSeries ChartView::series(int index)
156 \qmlmethod AbstractSeries ChartView::series(int index)
157 Returns the series with \a index on the chart. This allows you to loop through the series of a chart together with
157 Returns the series with \a index on the chart. This allows you to loop through the series of a chart together with
158 the count property of the chart.
158 the count property of the chart.
159 */
159 */
160
160
161 /*!
161 /*!
162 \qmlmethod AbstractSeries ChartView::series(string name)
162 \qmlmethod AbstractSeries ChartView::series(string name)
163 Returns the first series on the chart with \a name. If there is no series with that name, returns null.
163 Returns the first series on the chart with \a name. If there is no series with that name, returns null.
164 */
164 */
165
165
166 /*!
166 /*!
167 \qmlmethod AbstractSeries ChartView::createSeries(SeriesType type, string name)
167 \qmlmethod AbstractSeries ChartView::createSeries(SeriesType type, string name)
168 Creates a series object of \a type to the chart. For example:
168 Creates a series object of \a type to the chart. For example:
169 \code
169 \code
170 var scatter = chartView.createSeries(ChartView.SeriesTypeScatter, "scatter series");
170 var scatter = chartView.createSeries(ChartView.SeriesTypeScatter, "scatter series");
171 scatter.markerSize = 22;
171 scatter.markerSize = 22;
172 scatter.append(1.1, 2.0);
172 scatter.append(1.1, 2.0);
173 \endcode
173 \endcode
174 */
174 */
175
175
176 /*!
176 /*!
177 \qmlmethod Axis ChartView::axisY(QAbstractSeries *series)
177 \qmlmethod Axis ChartView::axisY(QAbstractSeries *series)
178 The y-axis of the series. This is the same as the default y-axis of the chart as multiple y-axes are not yet supported.
178 The y-axis of the series. This is the same as the default y-axis of the chart as multiple y-axes are not yet supported.
179 */
179 */
180
180
181 /*!
181 /*!
182 \qmlmethod ChartView::zoomY(real factor)
182 \qmlmethod ChartView::zoomY(real factor)
183 Zooms in by \a factor on the center of the chart.
183 Zooms in by \a factor on the center of the chart.
184 */
184 */
185
185
186 /*!
186 /*!
187 \qmlmethod ChartView::scrollLeft(real pixels)
187 \qmlmethod ChartView::scrollLeft(real pixels)
188 Scrolls to left by \a pixels. This is a convenience function that suits for example for key navigation.
188 Scrolls to left by \a pixels. This is a convenience function that suits for example for key navigation.
189 \sa ValueAxis::min, ValueAxis::max, BarCategoryAxis::min, BarCategoryAxis::max
189 \sa ValueAxis::min, ValueAxis::max, BarCategoryAxis::min, BarCategoryAxis::max
190 */
190 */
191
191
192 /*!
192 /*!
193 \qmlmethod ChartView::scrollRight(real pixels)
193 \qmlmethod ChartView::scrollRight(real pixels)
194 Scrolls to right by \a pixels. This is a convenience function that suits for example for key navigation.
194 Scrolls to right by \a pixels. This is a convenience function that suits for example for key navigation.
195 \sa ValueAxis::min, ValueAxis::max, BarCategoryAxis::min, BarCategoryAxis::max
195 \sa ValueAxis::min, ValueAxis::max, BarCategoryAxis::min, BarCategoryAxis::max
196 */
196 */
197
197
198 /*!
198 /*!
199 \qmlmethod ChartView::scrollUp(real pixels)
199 \qmlmethod ChartView::scrollUp(real pixels)
200 Scrolls up by \a pixels. This is a convenience function that suits for example for key navigation.
200 Scrolls up by \a pixels. This is a convenience function that suits for example for key navigation.
201 \sa ValueAxis::min, ValueAxis::max, BarCategoryAxis::min, BarCategoryAxis::max
201 \sa ValueAxis::min, ValueAxis::max, BarCategoryAxis::min, BarCategoryAxis::max
202 */
202 */
203
203
204 /*!
204 /*!
205 \qmlmethod ChartView::scrollDown(real pixels)
205 \qmlmethod ChartView::scrollDown(real pixels)
206 Scrolls down by \a pixels. This is a convenience function that suits for example for key navigation.
206 Scrolls down by \a pixels. This is a convenience function that suits for example for key navigation.
207 \sa ValueAxis::min, ValueAxis::max, BarCategoryAxis::min, BarCategoryAxis::max
207 \sa ValueAxis::min, ValueAxis::max, BarCategoryAxis::min, BarCategoryAxis::max
208 */
208 */
209
209
210 /*!
210 /*!
211 \qmlsignal ChartView::onPlotAreaChanged(rect plotArea)
211 \qmlsignal ChartView::onPlotAreaChanged(rect plotArea)
212 The plot area of the chart has changed. This may happen for example, if you modify minimumMargins
212 The plot area of the chart has changed. This may happen for example, if you modify minimumMargins
213 or if you resize the chart, or if you modify font size related properties of the legend or chart
213 or if you resize the chart, or if you modify font size related properties of the legend or chart
214 title.
214 title.
215 */
215 */
216
216
217 DeclarativeChart::DeclarativeChart(QDeclarativeItem *parent)
217 DeclarativeChart::DeclarativeChart(QDeclarativeItem *parent)
218 : QDeclarativeItem(parent),
218 : QDeclarativeItem(parent),
219 m_chart(new QChart(this))
219 m_chart(new QChart(this))
220 {
220 {
221 setFlag(QGraphicsItem::ItemHasNoContents, false);
221 setFlag(QGraphicsItem::ItemHasNoContents, false);
222 m_minMargins = new DeclarativeMargins(this);
222 m_minMargins = new DeclarativeMargins(this);
223 connect(m_minMargins, SIGNAL(topChanged(int, int, int, int)), this, SLOT(changeMinimumMargins(int, int, int, int)));
223 connect(m_minMargins, SIGNAL(topChanged(int, int, int, int)), this, SLOT(changeMinimumMargins(int, int, int, int)));
224 connect(m_minMargins, SIGNAL(bottomChanged(int, int, int, int)), this, SLOT(changeMinimumMargins(int, int, int, int)));
224 connect(m_minMargins, SIGNAL(bottomChanged(int, int, int, int)), this, SLOT(changeMinimumMargins(int, int, int, int)));
225 connect(m_minMargins, SIGNAL(leftChanged(int, int, int, int)), this, SLOT(changeMinimumMargins(int, int, int, int)));
225 connect(m_minMargins, SIGNAL(leftChanged(int, int, int, int)), this, SLOT(changeMinimumMargins(int, int, int, int)));
226 connect(m_minMargins, SIGNAL(rightChanged(int, int, int, int)), this, SLOT(changeMinimumMargins(int, int, int, int)));
226 connect(m_minMargins, SIGNAL(rightChanged(int, int, int, int)), this, SLOT(changeMinimumMargins(int, int, int, int)));
227 }
227 }
228
228
229 void DeclarativeChart::changeMinimumMargins(int top, int bottom, int left, int right)
229 void DeclarativeChart::changeMinimumMargins(int top, int bottom, int left, int right)
230 {
230 {
231 m_chart->setMinimumMargins(QMargins(left, top, right, bottom));
231 m_chart->setMinimumMargins(QMargins(left, top, right, bottom));
232 emit minimumMarginsChanged();
232 emit minimumMarginsChanged();
233 emit plotAreaChanged(m_chart->plotArea());
233 emit plotAreaChanged(m_chart->plotArea());
234 }
234 }
235
235
236 DeclarativeChart::~DeclarativeChart()
236 DeclarativeChart::~DeclarativeChart()
237 {
237 {
238 delete m_chart;
238 delete m_chart;
239 }
239 }
240
240
241 void DeclarativeChart::childEvent(QChildEvent *event)
241 void DeclarativeChart::childEvent(QChildEvent *event)
242 {
242 {
243 if (event->type() == QEvent::ChildAdded) {
243 if (event->type() == QEvent::ChildAdded) {
244 if (qobject_cast<QAbstractSeries *>(event->child())) {
244 if (qobject_cast<QAbstractSeries *>(event->child())) {
245 m_chart->addSeries(qobject_cast<QAbstractSeries *>(event->child()));
245 m_chart->addSeries(qobject_cast<QAbstractSeries *>(event->child()));
246 }
246 }
247 }
247 }
248 }
248 }
249
249
250 void DeclarativeChart::componentComplete()
250 void DeclarativeChart::componentComplete()
251 {
251 {
252 foreach(QObject *child, children()) {
252 foreach(QObject *child, children()) {
253 if (qobject_cast<QAbstractSeries *>(child)) {
253 if (qobject_cast<QAbstractSeries *>(child)) {
254 // Add series to the chart
254 // Add series to the chart
255 QAbstractSeries *series = qobject_cast<QAbstractSeries *>(child);
255 QAbstractSeries *series = qobject_cast<QAbstractSeries *>(child);
256 m_chart->addSeries(series);
256 m_chart->addSeries(series);
257
257
258 // Set optional user defined axes and connect axis related signals
258 // Set optional user defined axes for the series and connect axis related signals
259 if (qobject_cast<DeclarativeLineSeries *>(child)) {
259 if (qobject_cast<DeclarativeLineSeries *>(child)) {
260 DeclarativeLineSeries *s = qobject_cast<DeclarativeLineSeries *>(child);
260 DeclarativeLineSeries *s = qobject_cast<DeclarativeLineSeries *>(child);
261 connect(s, SIGNAL(axisXChanged(QAbstractAxis*)), this, SLOT(handleAxisXSet(QAbstractAxis*)));
261 connect(s, SIGNAL(axisXChanged(QAbstractAxis*)), this, SLOT(handleAxisXSet(QAbstractAxis*)));
262 connect(s, SIGNAL(axisYChanged(QAbstractAxis*)), this, SLOT(handleAxisYSet(QAbstractAxis*)));
262 connect(s, SIGNAL(axisYChanged(QAbstractAxis*)), this, SLOT(handleAxisYSet(QAbstractAxis*)));
263 setAxisX(s->axisX(), s);
263 setAxisX(s->axisX(), s);
264 setAxisY(s->axisY(), s);
264 setAxisY(s->axisY(), s);
265 } else if (qobject_cast<DeclarativeSplineSeries *>(child)) {
265 } else if (qobject_cast<DeclarativeSplineSeries *>(child)) {
266 DeclarativeSplineSeries *s = qobject_cast<DeclarativeSplineSeries *>(child);
266 DeclarativeSplineSeries *s = qobject_cast<DeclarativeSplineSeries *>(child);
267 connect(s, SIGNAL(axisXChanged(QAbstractAxis*)), this, SLOT(handleAxisXSet(QAbstractAxis*)));
267 connect(s, SIGNAL(axisXChanged(QAbstractAxis*)), this, SLOT(handleAxisXSet(QAbstractAxis*)));
268 connect(s, SIGNAL(axisYChanged(QAbstractAxis*)), this, SLOT(handleAxisYSet(QAbstractAxis*)));
268 connect(s, SIGNAL(axisYChanged(QAbstractAxis*)), this, SLOT(handleAxisYSet(QAbstractAxis*)));
269 setAxisX(s->axisX(), s);
269 setAxisX(s->axisX(), s);
270 setAxisY(s->axisY(), s);
270 setAxisY(s->axisY(), s);
271 } else if (qobject_cast<DeclarativeScatterSeries *>(child)) {
271 } else if (qobject_cast<DeclarativeScatterSeries *>(child)) {
272 DeclarativeScatterSeries *s = qobject_cast<DeclarativeScatterSeries *>(child);
272 DeclarativeScatterSeries *s = qobject_cast<DeclarativeScatterSeries *>(child);
273 connect(s, SIGNAL(axisXChanged(QAbstractAxis*)), this, SLOT(handleAxisXSet(QAbstractAxis*)));
273 connect(s, SIGNAL(axisXChanged(QAbstractAxis*)), this, SLOT(handleAxisXSet(QAbstractAxis*)));
274 connect(s, SIGNAL(axisYChanged(QAbstractAxis*)), this, SLOT(handleAxisYSet(QAbstractAxis*)));
274 connect(s, SIGNAL(axisYChanged(QAbstractAxis*)), this, SLOT(handleAxisYSet(QAbstractAxis*)));
275 setAxisX(s->axisX(), s);
275 setAxisX(s->axisX(), s);
276 setAxisY(s->axisY(), s);
276 setAxisY(s->axisY(), s);
277 } else if (qobject_cast<DeclarativeAreaSeries *>(child)) {
277 } else if (qobject_cast<DeclarativeAreaSeries *>(child)) {
278 DeclarativeAreaSeries *s = qobject_cast<DeclarativeAreaSeries *>(child);
278 DeclarativeAreaSeries *s = qobject_cast<DeclarativeAreaSeries *>(child);
279 connect(s, SIGNAL(axisXChanged(QAbstractAxis*)), this, SLOT(handleAxisXSet(QAbstractAxis*)));
279 connect(s, SIGNAL(axisXChanged(QAbstractAxis*)), this, SLOT(handleAxisXSet(QAbstractAxis*)));
280 connect(s, SIGNAL(axisYChanged(QAbstractAxis*)), this, SLOT(handleAxisYSet(QAbstractAxis*)));
280 connect(s, SIGNAL(axisYChanged(QAbstractAxis*)), this, SLOT(handleAxisYSet(QAbstractAxis*)));
281 setAxisX(s->axisX(), s);
281 setAxisX(s->axisX(), s);
282 setAxisY(s->axisY(), s);
282 setAxisY(s->axisY(), s);
283 } else if (qobject_cast<DeclarativeBarSeries *>(child)) {
283 } else if (qobject_cast<DeclarativeBarSeries *>(child)) {
284 DeclarativeBarSeries *s = qobject_cast<DeclarativeBarSeries *>(child);
284 DeclarativeBarSeries *s = qobject_cast<DeclarativeBarSeries *>(child);
285 connect(s, SIGNAL(axisXChanged(QAbstractAxis*)), this, SLOT(handleAxisXSet(QAbstractAxis*)));
285 connect(s, SIGNAL(axisXChanged(QAbstractAxis*)), this, SLOT(handleAxisXSet(QAbstractAxis*)));
286 connect(s, SIGNAL(axisYChanged(QAbstractAxis*)), this, SLOT(handleAxisYSet(QAbstractAxis*)));
286 connect(s, SIGNAL(axisYChanged(QAbstractAxis*)), this, SLOT(handleAxisYSet(QAbstractAxis*)));
287 setAxisX(s->axisX(), s);
287 setAxisX(s->axisX(), s);
288 setAxisY(s->axisY(), s);
288 setAxisY(s->axisY(), s);
289 } else if (qobject_cast<DeclarativeStackedBarSeries *>(child)) {
289 } else if (qobject_cast<DeclarativeStackedBarSeries *>(child)) {
290 DeclarativeStackedBarSeries *s = qobject_cast<DeclarativeStackedBarSeries *>(child);
290 DeclarativeStackedBarSeries *s = qobject_cast<DeclarativeStackedBarSeries *>(child);
291 connect(s, SIGNAL(axisXChanged(QAbstractAxis*)), this, SLOT(handleAxisXSet(QAbstractAxis*)));
291 connect(s, SIGNAL(axisXChanged(QAbstractAxis*)), this, SLOT(handleAxisXSet(QAbstractAxis*)));
292 connect(s, SIGNAL(axisYChanged(QAbstractAxis*)), this, SLOT(handleAxisYSet(QAbstractAxis*)));
292 connect(s, SIGNAL(axisYChanged(QAbstractAxis*)), this, SLOT(handleAxisYSet(QAbstractAxis*)));
293 setAxisX(s->axisX(), s);
293 setAxisX(s->axisX(), s);
294 setAxisY(s->axisY(), s);
294 setAxisY(s->axisY(), s);
295 } else if (qobject_cast<DeclarativePercentBarSeries *>(child)) {
295 } else if (qobject_cast<DeclarativePercentBarSeries *>(child)) {
296 DeclarativePercentBarSeries *s = qobject_cast<DeclarativePercentBarSeries *>(child);
296 DeclarativePercentBarSeries *s = qobject_cast<DeclarativePercentBarSeries *>(child);
297 connect(s, SIGNAL(axisXChanged(QAbstractAxis*)), this, SLOT(handleAxisXSet(QAbstractAxis*)));
297 connect(s, SIGNAL(axisXChanged(QAbstractAxis*)), this, SLOT(handleAxisXSet(QAbstractAxis*)));
298 connect(s, SIGNAL(axisYChanged(QAbstractAxis*)), this, SLOT(handleAxisYSet(QAbstractAxis*)));
298 connect(s, SIGNAL(axisYChanged(QAbstractAxis*)), this, SLOT(handleAxisYSet(QAbstractAxis*)));
299 setAxisX(s->axisX(), s);
299 setAxisX(s->axisX(), s);
300 setAxisY(s->axisY(), s);
300 setAxisY(s->axisY(), s);
301 } else if (qobject_cast<DeclarativeHorizontalBarSeries *>(child)) {
301 } else if (qobject_cast<DeclarativeHorizontalBarSeries *>(child)) {
302 DeclarativeHorizontalBarSeries *s = qobject_cast<DeclarativeHorizontalBarSeries *>(child);
302 DeclarativeHorizontalBarSeries *s = qobject_cast<DeclarativeHorizontalBarSeries *>(child);
303 connect(s, SIGNAL(axisXChanged(QAbstractAxis*)), this, SLOT(handleAxisXSet(QAbstractAxis*)));
303 connect(s, SIGNAL(axisXChanged(QAbstractAxis*)), this, SLOT(handleAxisXSet(QAbstractAxis*)));
304 connect(s, SIGNAL(axisYChanged(QAbstractAxis*)), this, SLOT(handleAxisYSet(QAbstractAxis*)));
304 connect(s, SIGNAL(axisYChanged(QAbstractAxis*)), this, SLOT(handleAxisYSet(QAbstractAxis*)));
305 setAxisX(s->axisX(), s);
305 setAxisX(s->axisX(), s);
306 setAxisY(s->axisY(), s);
306 setAxisY(s->axisY(), s);
307 } else if (qobject_cast<DeclarativeHorizontalStackedBarSeries *>(child)) {
307 } else if (qobject_cast<DeclarativeHorizontalStackedBarSeries *>(child)) {
308 DeclarativeHorizontalStackedBarSeries *s = qobject_cast<DeclarativeHorizontalStackedBarSeries *>(child);
308 DeclarativeHorizontalStackedBarSeries *s = qobject_cast<DeclarativeHorizontalStackedBarSeries *>(child);
309 connect(s, SIGNAL(axisXChanged(QAbstractAxis*)), this, SLOT(handleAxisXSet(QAbstractAxis*)));
309 connect(s, SIGNAL(axisXChanged(QAbstractAxis*)), this, SLOT(handleAxisXSet(QAbstractAxis*)));
310 connect(s, SIGNAL(axisYChanged(QAbstractAxis*)), this, SLOT(handleAxisYSet(QAbstractAxis*)));
310 connect(s, SIGNAL(axisYChanged(QAbstractAxis*)), this, SLOT(handleAxisYSet(QAbstractAxis*)));
311 setAxisX(s->axisX(), s);
311 setAxisX(s->axisX(), s);
312 setAxisY(s->axisY(), s);
312 setAxisY(s->axisY(), s);
313 } else if (qobject_cast<DeclarativeHorizontalPercentBarSeries *>(child)) {
313 } else if (qobject_cast<DeclarativeHorizontalPercentBarSeries *>(child)) {
314 DeclarativeHorizontalPercentBarSeries *s = qobject_cast<DeclarativeHorizontalPercentBarSeries *>(child);
314 DeclarativeHorizontalPercentBarSeries *s = qobject_cast<DeclarativeHorizontalPercentBarSeries *>(child);
315 connect(s, SIGNAL(axisXChanged(QAbstractAxis*)), this, SLOT(handleAxisXSet(QAbstractAxis*)));
315 connect(s, SIGNAL(axisXChanged(QAbstractAxis*)), this, SLOT(handleAxisXSet(QAbstractAxis*)));
316 connect(s, SIGNAL(axisYChanged(QAbstractAxis*)), this, SLOT(handleAxisYSet(QAbstractAxis*)));
316 connect(s, SIGNAL(axisYChanged(QAbstractAxis*)), this, SLOT(handleAxisYSet(QAbstractAxis*)));
317 setAxisX(s->axisX(), s);
317 setAxisX(s->axisX(), s);
318 setAxisY(s->axisY(), s);
318 setAxisY(s->axisY(), s);
319 }
319 }
320
321 // Create the missing axes for the series that cannot be painted without axes
322 createDefaultAxes(series);
323 } else if(qobject_cast<QAbstractAxis *>(child)) {
324 // Do nothing, axes are set for the chart in the context of series
325 }
320 }
326 }
321 }
327
322
323 // Create the missing axes for the series that cannot be painted without axes
324 foreach (QAbstractSeries *chartSeries, m_chart->series())
325 createDefaultAxes(chartSeries);
326
328 QDeclarativeItem::componentComplete();
327 QDeclarativeItem::componentComplete();
329 }
328 }
330
329
331 void DeclarativeChart::handleAxisXSet(QAbstractAxis* axis)
330 void DeclarativeChart::handleAxisXSet(QAbstractAxis* axis)
332 {
331 {
333 // qDebug() << "DeclarativeChart::handleAxisXSet" << sender() << axis;
332 // qDebug() << "DeclarativeChart::handleAxisXSet" << sender() << axis;
334 if (axis && qobject_cast<DeclarativeLineSeries *>(sender())) {
333 if (axis && qobject_cast<QAbstractSeries *>(sender()))
335 m_chart->setAxisX(axis, qobject_cast<DeclarativeLineSeries *>(sender()));
334 m_chart->setAxisX(axis, qobject_cast<QAbstractSeries *>(sender()));
336 }
335 else
336 qWarning() << "Trying to set axisX to null.";
337 }
337 }
338
338
339 void DeclarativeChart::handleAxisYSet(QAbstractAxis* axis)
339 void DeclarativeChart::handleAxisYSet(QAbstractAxis* axis)
340 {
340 {
341 // qDebug() << "DeclarativeChart::handleAxisYSet" << sender() << axis;
341 // qDebug() << "DeclarativeChart::handleAxisYSet" << sender() << axis;
342 if (axis && qobject_cast<DeclarativeLineSeries *>(sender())) {
342 if (axis && qobject_cast<QAbstractSeries *>(sender()))
343 m_chart->setAxisY(axis, qobject_cast<DeclarativeLineSeries *>(sender()));
343 m_chart->setAxisY(axis, qobject_cast<QAbstractSeries *>(sender()));
344 }
344 else
345 qWarning() << "Trying to set axisY to null.";
345 }
346 }
346
347
347 void DeclarativeChart::geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry)
348 void DeclarativeChart::geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry)
348 {
349 {
349 // qDebug() << "DeclarativeChart::geometryChanged" << newGeometry.width() << newGeometry.height();
350 // qDebug() << "DeclarativeChart::geometryChanged" << newGeometry.width() << newGeometry.height();
350 if (newGeometry.isValid()) {
351 if (newGeometry.isValid()) {
351 if (newGeometry.width() > 0 && newGeometry.height() > 0) {
352 if (newGeometry.width() > 0 && newGeometry.height() > 0) {
352 m_chart->resize(newGeometry.width(), newGeometry.height());
353 m_chart->resize(newGeometry.width(), newGeometry.height());
353 }
354 }
354 }
355 }
355 QDeclarativeItem::geometryChanged(newGeometry, oldGeometry);
356 QDeclarativeItem::geometryChanged(newGeometry, oldGeometry);
356
357
357 // It would be better to trigger the plotAreaChanged signal from QChart::plotAreaChanged or
358 // It would be better to trigger the plotAreaChanged signal from QChart::plotAreaChanged or
358 // similar. Since that kind of a signal is not clearly needed in the C++ API the work-around is
359 // similar. Since that kind of a signal is not clearly needed in the C++ API the work-around is
359 // to implement it here for the QML API purposes.
360 // to implement it here for the QML API purposes.
360 emit plotAreaChanged(m_chart->plotArea());
361 emit plotAreaChanged(m_chart->plotArea());
361 }
362 }
362
363
363 void DeclarativeChart::setTheme(DeclarativeChart::Theme theme)
364 void DeclarativeChart::setTheme(DeclarativeChart::Theme theme)
364 {
365 {
365 QChart::ChartTheme chartTheme = (QChart::ChartTheme) theme;
366 QChart::ChartTheme chartTheme = (QChart::ChartTheme) theme;
366 if (chartTheme != m_chart->theme())
367 if (chartTheme != m_chart->theme())
367 m_chart->setTheme(chartTheme);
368 m_chart->setTheme(chartTheme);
368 }
369 }
369
370
370 DeclarativeChart::Theme DeclarativeChart::theme()
371 DeclarativeChart::Theme DeclarativeChart::theme()
371 {
372 {
372 return (DeclarativeChart::Theme) m_chart->theme();
373 return (DeclarativeChart::Theme) m_chart->theme();
373 }
374 }
374
375
375 void DeclarativeChart::setAnimationOptions(DeclarativeChart::Animation animations)
376 void DeclarativeChart::setAnimationOptions(DeclarativeChart::Animation animations)
376 {
377 {
377 QChart::AnimationOption animationOptions = (QChart::AnimationOption) animations;
378 QChart::AnimationOption animationOptions = (QChart::AnimationOption) animations;
378 if (animationOptions != m_chart->animationOptions())
379 if (animationOptions != m_chart->animationOptions())
379 m_chart->setAnimationOptions(animationOptions);
380 m_chart->setAnimationOptions(animationOptions);
380 }
381 }
381
382
382 DeclarativeChart::Animation DeclarativeChart::animationOptions()
383 DeclarativeChart::Animation DeclarativeChart::animationOptions()
383 {
384 {
384 if (m_chart->animationOptions().testFlag(QChart::AllAnimations))
385 if (m_chart->animationOptions().testFlag(QChart::AllAnimations))
385 return DeclarativeChart::AllAnimations;
386 return DeclarativeChart::AllAnimations;
386 else if (m_chart->animationOptions().testFlag(QChart::GridAxisAnimations))
387 else if (m_chart->animationOptions().testFlag(QChart::GridAxisAnimations))
387 return DeclarativeChart::GridAxisAnimations;
388 return DeclarativeChart::GridAxisAnimations;
388 else if (m_chart->animationOptions().testFlag(QChart::SeriesAnimations))
389 else if (m_chart->animationOptions().testFlag(QChart::SeriesAnimations))
389 return DeclarativeChart::SeriesAnimations;
390 return DeclarativeChart::SeriesAnimations;
390 else
391 else
391 return DeclarativeChart::NoAnimation;
392 return DeclarativeChart::NoAnimation;
392 }
393 }
393
394
394 void DeclarativeChart::setTitle(QString title)
395 void DeclarativeChart::setTitle(QString title)
395 {
396 {
396 if (title != m_chart->title())
397 if (title != m_chart->title())
397 m_chart->setTitle(title);
398 m_chart->setTitle(title);
398 }
399 }
399 QString DeclarativeChart::title()
400 QString DeclarativeChart::title()
400 {
401 {
401 return m_chart->title();
402 return m_chart->title();
402 }
403 }
403
404
404 QAbstractAxis *DeclarativeChart::axisX(QAbstractSeries *series)
405 QAbstractAxis *DeclarativeChart::axisX(QAbstractSeries *series)
405 {
406 {
406 return m_chart->axisX(series);
407 return m_chart->axisX(series);
407 }
408 }
408
409
409 QAbstractAxis *DeclarativeChart::axisY(QAbstractSeries *series)
410 QAbstractAxis *DeclarativeChart::axisY(QAbstractSeries *series)
410 {
411 {
411 return m_chart->axisY(series);
412 return m_chart->axisY(series);
412 }
413 }
413
414
414 QLegend *DeclarativeChart::legend()
415 QLegend *DeclarativeChart::legend()
415 {
416 {
416 return m_chart->legend();
417 return m_chart->legend();
417 }
418 }
418
419
419 void DeclarativeChart::setTitleColor(QColor color)
420 void DeclarativeChart::setTitleColor(QColor color)
420 {
421 {
421 QBrush b = m_chart->titleBrush();
422 QBrush b = m_chart->titleBrush();
422 if (color != b.color()) {
423 if (color != b.color()) {
423 b.setColor(color);
424 b.setColor(color);
424 m_chart->setTitleBrush(b);
425 m_chart->setTitleBrush(b);
425 emit titleColorChanged(color);
426 emit titleColorChanged(color);
426 }
427 }
427 }
428 }
428
429
429 QFont DeclarativeChart::titleFont() const
430 QFont DeclarativeChart::titleFont() const
430 {
431 {
431 return m_chart->titleFont();
432 return m_chart->titleFont();
432 }
433 }
433
434
434 void DeclarativeChart::setTitleFont(const QFont& font)
435 void DeclarativeChart::setTitleFont(const QFont& font)
435 {
436 {
436 m_chart->setTitleFont(font);
437 m_chart->setTitleFont(font);
437 }
438 }
438
439
439 QColor DeclarativeChart::titleColor()
440 QColor DeclarativeChart::titleColor()
440 {
441 {
441 return m_chart->titleBrush().color();
442 return m_chart->titleBrush().color();
442 }
443 }
443
444
444 void DeclarativeChart::setBackgroundColor(QColor color)
445 void DeclarativeChart::setBackgroundColor(QColor color)
445 {
446 {
446 QBrush b = m_chart->backgroundBrush();
447 QBrush b = m_chart->backgroundBrush();
447 if (b.style() != Qt::SolidPattern || color != b.color()) {
448 if (b.style() != Qt::SolidPattern || color != b.color()) {
448 b.setStyle(Qt::SolidPattern);
449 b.setStyle(Qt::SolidPattern);
449 b.setColor(color);
450 b.setColor(color);
450 m_chart->setBackgroundBrush(b);
451 m_chart->setBackgroundBrush(b);
451 emit backgroundColorChanged();
452 emit backgroundColorChanged();
452 }
453 }
453 }
454 }
454
455
455 QColor DeclarativeChart::backgroundColor()
456 QColor DeclarativeChart::backgroundColor()
456 {
457 {
457 return m_chart->backgroundBrush().color();
458 return m_chart->backgroundBrush().color();
458 }
459 }
459
460
460 int DeclarativeChart::count()
461 int DeclarativeChart::count()
461 {
462 {
462 return m_chart->series().count();
463 return m_chart->series().count();
463 }
464 }
464
465
465 void DeclarativeChart::setDropShadowEnabled(bool enabled)
466 void DeclarativeChart::setDropShadowEnabled(bool enabled)
466 {
467 {
467 if (enabled != m_chart->isDropShadowEnabled()) {
468 if (enabled != m_chart->isDropShadowEnabled()) {
468 m_chart->setDropShadowEnabled(enabled);
469 m_chart->setDropShadowEnabled(enabled);
469 dropShadowEnabledChanged(enabled);
470 dropShadowEnabledChanged(enabled);
470 }
471 }
471 }
472 }
472
473
473 bool DeclarativeChart::dropShadowEnabled()
474 bool DeclarativeChart::dropShadowEnabled()
474 {
475 {
475 return m_chart->isDropShadowEnabled();
476 return m_chart->isDropShadowEnabled();
476 }
477 }
477
478
478 qreal DeclarativeChart::topMargin()
479 qreal DeclarativeChart::topMargin()
479 {
480 {
480 qWarning() << "ChartView.topMargin is deprecated. Use minimumMargins and plotArea instead.";
481 qWarning() << "ChartView.topMargin is deprecated. Use minimumMargins and plotArea instead.";
481 return m_chart->plotArea().top();
482 return m_chart->plotArea().top();
482 }
483 }
483
484
484 qreal DeclarativeChart::bottomMargin()
485 qreal DeclarativeChart::bottomMargin()
485 {
486 {
486 qWarning() << "ChartView.bottomMargin is deprecated. Use minimumMargins and plotArea instead.";
487 qWarning() << "ChartView.bottomMargin is deprecated. Use minimumMargins and plotArea instead.";
487 return m_chart->plotArea().bottom();
488 return m_chart->plotArea().bottom();
488 }
489 }
489
490
490 qreal DeclarativeChart::leftMargin()
491 qreal DeclarativeChart::leftMargin()
491 {
492 {
492 qWarning() << "ChartView.leftMargin is deprecated. Use minimumMargins and plotArea instead.";
493 qWarning() << "ChartView.leftMargin is deprecated. Use minimumMargins and plotArea instead.";
493 return m_chart->plotArea().left();
494 return m_chart->plotArea().left();
494 }
495 }
495
496
496 qreal DeclarativeChart::rightMargin()
497 qreal DeclarativeChart::rightMargin()
497 {
498 {
498 qWarning() << "ChartView.rightMargin is deprecated. Use minimumMargins and plotArea instead.";
499 qWarning() << "ChartView.rightMargin is deprecated. Use minimumMargins and plotArea instead.";
499 return m_chart->plotArea().right();
500 return m_chart->plotArea().right();
500 }
501 }
501
502
502 void DeclarativeChart::zoom(qreal factor)
503 void DeclarativeChart::zoom(qreal factor)
503 {
504 {
504 m_chart->zoom(factor);
505 m_chart->zoom(factor);
505 }
506 }
506
507
507 void DeclarativeChart::scrollLeft(qreal pixels)
508 void DeclarativeChart::scrollLeft(qreal pixels)
508 {
509 {
509 m_chart->scroll(pixels, 0);
510 m_chart->scroll(pixels, 0);
510 }
511 }
511
512
512 void DeclarativeChart::scrollRight(qreal pixels)
513 void DeclarativeChart::scrollRight(qreal pixels)
513 {
514 {
514 m_chart->scroll(-pixels, 0);
515 m_chart->scroll(-pixels, 0);
515 }
516 }
516
517
517 void DeclarativeChart::scrollUp(qreal pixels)
518 void DeclarativeChart::scrollUp(qreal pixels)
518 {
519 {
519 m_chart->scroll(0, pixels);
520 m_chart->scroll(0, pixels);
520 }
521 }
521
522
522 void DeclarativeChart::scrollDown(qreal pixels)
523 void DeclarativeChart::scrollDown(qreal pixels)
523 {
524 {
524 m_chart->scroll(0, -pixels);
525 m_chart->scroll(0, -pixels);
525 }
526 }
526
527
527 QAbstractSeries *DeclarativeChart::series(int index)
528 QAbstractSeries *DeclarativeChart::series(int index)
528 {
529 {
529 if (index < m_chart->series().count()) {
530 if (index < m_chart->series().count()) {
530 return m_chart->series().at(index);
531 return m_chart->series().at(index);
531 }
532 }
532 return 0;
533 return 0;
533 }
534 }
534
535
535 QAbstractSeries *DeclarativeChart::series(QString seriesName)
536 QAbstractSeries *DeclarativeChart::series(QString seriesName)
536 {
537 {
537 foreach(QAbstractSeries *series, m_chart->series()) {
538 foreach(QAbstractSeries *series, m_chart->series()) {
538 if (series->name() == seriesName)
539 if (series->name() == seriesName)
539 return series;
540 return series;
540 }
541 }
541 return 0;
542 return 0;
542 }
543 }
543
544
544 QAbstractSeries *DeclarativeChart::createSeries(DeclarativeChart::SeriesType type, QString name)
545 QAbstractSeries *DeclarativeChart::createSeries(DeclarativeChart::SeriesType type, QString name)
545 {
546 {
546 QAbstractSeries *series = 0;
547 QAbstractSeries *series = 0;
547
548
548 switch (type) {
549 switch (type) {
549 case DeclarativeChart::SeriesTypeLine:
550 case DeclarativeChart::SeriesTypeLine:
550 series = new DeclarativeLineSeries();
551 series = new DeclarativeLineSeries();
551 break;
552 break;
552 case DeclarativeChart::SeriesTypeArea:
553 case DeclarativeChart::SeriesTypeArea:
553 series = new DeclarativeAreaSeries();
554 series = new DeclarativeAreaSeries();
554 break;
555 break;
555 case DeclarativeChart::SeriesTypeStackedBar:
556 case DeclarativeChart::SeriesTypeStackedBar:
556 series = new DeclarativeStackedBarSeries();
557 series = new DeclarativeStackedBarSeries();
557 break;
558 break;
558 case DeclarativeChart::SeriesTypePercentBar:
559 case DeclarativeChart::SeriesTypePercentBar:
559 series = new DeclarativePercentBarSeries();
560 series = new DeclarativePercentBarSeries();
560 break;
561 break;
561 case DeclarativeChart::SeriesTypeBar:
562 case DeclarativeChart::SeriesTypeBar:
562 series = new DeclarativeBarSeries();
563 series = new DeclarativeBarSeries();
563 break;
564 break;
564 case DeclarativeChart::SeriesTypeHorizontalBar:
565 case DeclarativeChart::SeriesTypeHorizontalBar:
565 series = new DeclarativeHorizontalBarSeries();
566 series = new DeclarativeHorizontalBarSeries();
566 break;
567 break;
567 case DeclarativeChart::SeriesTypeHorizontalPercentBar:
568 case DeclarativeChart::SeriesTypeHorizontalPercentBar:
568 series = new DeclarativeHorizontalPercentBarSeries();
569 series = new DeclarativeHorizontalPercentBarSeries();
569 break;
570 break;
570 case DeclarativeChart::SeriesTypeHorizontalStackedBar:
571 case DeclarativeChart::SeriesTypeHorizontalStackedBar:
571 series = new DeclarativeHorizontalStackedBarSeries();
572 series = new DeclarativeHorizontalStackedBarSeries();
572 break;
573 break;
573 case DeclarativeChart::SeriesTypePie:
574 case DeclarativeChart::SeriesTypePie:
574 series = new DeclarativePieSeries();
575 series = new DeclarativePieSeries();
575 break;
576 break;
576 case DeclarativeChart::SeriesTypeScatter:
577 case DeclarativeChart::SeriesTypeScatter:
577 series = new DeclarativeScatterSeries();
578 series = new DeclarativeScatterSeries();
578 break;
579 break;
579 case DeclarativeChart::SeriesTypeSpline:
580 case DeclarativeChart::SeriesTypeSpline:
580 series = new DeclarativeSplineSeries();
581 series = new DeclarativeSplineSeries();
581 break;
582 break;
582 default:
583 default:
583 qWarning() << "Illegal series type";
584 qWarning() << "Illegal series type";
584 }
585 }
585
586
586 if (series) {
587 if (series) {
587 series->setName(name);
588 series->setName(name);
588 m_chart->addSeries(series);
589 m_chart->addSeries(series);
589 createDefaultAxes(series);
590 createDefaultAxes(series);
590 }
591 }
591
592
592 return series;
593 return series;
593 }
594 }
594
595
595 void DeclarativeChart::setAxisX(QAbstractAxis *axis, QAbstractSeries *series)
596 void DeclarativeChart::setAxisX(QAbstractAxis *axis, QAbstractSeries *series)
596 {
597 {
597 if (axis)
598 if (axis)
598 m_chart->setAxisX(axis, series);
599 m_chart->setAxisX(axis, series);
599 }
600 }
600
601
601 void DeclarativeChart::setAxisY(QAbstractAxis *axis, QAbstractSeries *series)
602 void DeclarativeChart::setAxisY(QAbstractAxis *axis, QAbstractSeries *series)
602 {
603 {
603 if (axis)
604 if (axis)
604 m_chart->setAxisY(axis, series);
605 m_chart->setAxisY(axis, series);
605 }
606 }
606
607
607 void DeclarativeChart::createDefaultAxes()
608 void DeclarativeChart::createDefaultAxes()
608 {
609 {
609 qWarning() << "ChartView.createDefaultAxes() is deprecated. Axes are created automatically.";
610 qWarning() << "ChartView.createDefaultAxes() is deprecated. Axes are created automatically.";
610 }
611 }
611
612
612 void DeclarativeChart::createDefaultAxes(QAbstractSeries* series)
613 void DeclarativeChart::createDefaultAxes(QAbstractSeries* series)
613 {
614 {
614 foreach (QAbstractSeries *s, m_chart->series()) {
615 foreach (QAbstractSeries *s, m_chart->series()) {
615 // If there is already an x axis of the correct type, re-use it
616 // If there is already an x axis of the correct type, re-use it
616 if (!m_chart->axisX(series) && s != series && m_chart->axisX(s)
617 if (!m_chart->axisX(series) && s != series && m_chart->axisX(s)
617 && m_chart->axisX(s)->type() == series->d_ptr->defaultAxisType(Qt::Horizontal))
618 && m_chart->axisX(s)->type() == series->d_ptr->defaultAxisType(Qt::Horizontal))
618 m_chart->setAxisX(m_chart->axisX(s), series);
619 m_chart->setAxisX(m_chart->axisX(s), series);
619
620
620 // If there is already a y axis of the correct type, re-use it
621 // If there is already a y axis of the correct type, re-use it
621 if (!m_chart->axisY(series) && s != series && m_chart->axisY(s)
622 if (!m_chart->axisY(series) && s != series && m_chart->axisY(s)
622 && m_chart->axisY(s)->type() == series->d_ptr->defaultAxisType(Qt::Vertical))
623 && m_chart->axisY(s)->type() == series->d_ptr->defaultAxisType(Qt::Vertical))
623 m_chart->setAxisY(m_chart->axisY(s), series);
624 m_chart->setAxisY(m_chart->axisY(s), series);
624 }
625 }
625
626
626 // If no x axis of correct type was found, create a new x axis based of default axis type
627 // If no x axis of correct type was found, create a new x axis based of default axis type
627 if (!m_chart->axisX(series)) {
628 if (!m_chart->axisX(series)) {
628 switch (series->d_ptr->defaultAxisType(Qt::Horizontal)) {
629 switch (series->d_ptr->defaultAxisType(Qt::Horizontal)) {
629 case QAbstractAxis::AxisTypeValue:
630 case QAbstractAxis::AxisTypeValue:
630 m_chart->setAxisX(new QValueAxis(this), series);
631 m_chart->setAxisX(new QValueAxis(this), series);
631 break;
632 break;
632 case QAbstractAxis::AxisTypeBarCategory:
633 case QAbstractAxis::AxisTypeBarCategory:
633 m_chart->setAxisX(new QBarCategoryAxis(this), series);
634 m_chart->setAxisX(new QBarCategoryAxis(this), series);
634 break;
635 break;
635 case QAbstractAxis::AxisTypeCategory:
636 case QAbstractAxis::AxisTypeCategory:
636 m_chart->setAxisX(new QCategoryAxis(this), series);
637 m_chart->setAxisX(new QCategoryAxis(this), series);
637 break;
638 break;
638 #ifndef QT_ON_ARM
639 #ifndef QT_ON_ARM
639 case QAbstractAxis::AxisTypeDateTime:
640 case QAbstractAxis::AxisTypeDateTime:
640 m_chart->setAxisX(new QDateTimeAxis(this), series);
641 m_chart->setAxisX(new QDateTimeAxis(this), series);
641 break;
642 break;
642 #endif
643 #endif
643 default:
644 default:
644 // Do nothing, assume AxisTypeNoAxis
645 // Do nothing, assume AxisTypeNoAxis
645 break;
646 break;
646 }
647 }
647 }
648 }
648
649
649 // If no y axis of correct type was found, create a new y axis based of default axis type
650 // If no y axis of correct type was found, create a new y axis based of default axis type
650 if (!m_chart->axisY(series)) {
651 if (!m_chart->axisY(series)) {
651 switch (series->d_ptr->defaultAxisType(Qt::Vertical)) {
652 switch (series->d_ptr->defaultAxisType(Qt::Vertical)) {
652 case QAbstractAxis::AxisTypeValue:
653 case QAbstractAxis::AxisTypeValue:
653 m_chart->setAxisY(new QValueAxis(this), series);
654 m_chart->setAxisY(new QValueAxis(this), series);
654 break;
655 break;
655 case QAbstractAxis::AxisTypeBarCategory:
656 case QAbstractAxis::AxisTypeBarCategory:
656 m_chart->setAxisY(new QBarCategoryAxis(this), series);
657 m_chart->setAxisY(new QBarCategoryAxis(this), series);
657 break;
658 break;
658 case QAbstractAxis::AxisTypeCategory:
659 case QAbstractAxis::AxisTypeCategory:
659 m_chart->setAxisY(new QCategoryAxis(this), series);
660 m_chart->setAxisY(new QCategoryAxis(this), series);
660 break;
661 break;
661 #ifndef QT_ON_ARM
662 #ifndef QT_ON_ARM
662 case QAbstractAxis::AxisTypeDateTime:
663 case QAbstractAxis::AxisTypeDateTime:
663 m_chart->setAxisY(new QDateTimeAxis(this), series);
664 m_chart->setAxisY(new QDateTimeAxis(this), series);
664 break;
665 break;
665 #endif
666 #endif
666 default:
667 default:
667 // Do nothing, assume AxisTypeNoAxis
668 // Do nothing, assume AxisTypeNoAxis
668 break;
669 break;
669 }
670 }
670 }
671 }
671
672
672 //qDebug() << "axis for series" << series << "x:" << m_chart->axisX(series) << "y:" << m_chart->axisY(series);
673 //qDebug() << "axis for series" << series << "x:" << m_chart->axisX(series) << "y:" << m_chart->axisY(series);
673 }
674 }
674
675
675 #include "moc_declarativechart.cpp"
676 #include "moc_declarativechart.cpp"
676
677
677 QTCOMMERCIALCHART_END_NAMESPACE
678 QTCOMMERCIALCHART_END_NAMESPACE
@@ -1,71 +1,58
1 /****************************************************************************
1 /****************************************************************************
2 **
2 **
3 ** Copyright (C) 2012 Digia Plc
3 ** Copyright (C) 2012 Digia Plc
4 ** All rights reserved.
4 ** All rights reserved.
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 **
6 **
7 ** This file is part of the Qt Commercial Charts Add-on.
7 ** This file is part of the Qt Commercial Charts Add-on.
8 **
8 **
9 ** $QT_BEGIN_LICENSE$
9 ** $QT_BEGIN_LICENSE$
10 ** Licensees holding valid Qt Commercial licenses may use this file in
10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 ** accordance with the Qt Commercial License Agreement provided with the
11 ** accordance with the Qt Commercial License Agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia.
13 ** a written agreement between you and Digia.
14 **
14 **
15 ** If you have questions regarding the use of this file, please use
15 ** If you have questions regarding the use of this file, please use
16 ** contact form at http://qt.digia.com
16 ** contact form at http://qt.digia.com
17 ** $QT_END_LICENSE$
17 ** $QT_END_LICENSE$
18 **
18 **
19 ****************************************************************************/
19 ****************************************************************************/
20
20
21 import QtQuick 1.0
21 import QtQuick 1.0
22 import QtCommercial.Chart 1.1
22 import QtCommercial.Chart 1.1
23
23
24 ChartView {
24 ChartView {
25 id: chartView
25 id: chartView
26 title: "user defined axes"
26 title: "chart axes reverted"
27
27
28 ValueAxis {
28 ValueAxis {
29 id: axisX
30 min: 0
29 min: 0
31 max: 10
30 max: 10
32 // TODO: property to fix orientation to "X" to make this the X default axis for all series
33 // that don't have user defined X axis
34 }
31 }
35
36 ValueAxis {
32 ValueAxis {
37 id: axisY
38 min: 0
33 min: 0
39 max: 5
34 max: 5
40 // TODO: property to fix orientation to "Y" to make this the Y default axis for all series
41 // that don't have user defined Y axis
42 }
43
44 LineSeries {
45 name: "line series"
46 XYPoint { x: 0; y: 0 }
47 XYPoint { x: 1.1; y: 2.1 }
48 XYPoint { x: 1.9; y: 3.3 }
49 XYPoint { x: 2.1; y: 2.1 }
50 XYPoint { x: 2.9; y: 4.9 }
51 XYPoint { x: 3.4; y: 3.0 }
52 XYPoint { x: 4.1; y: 3.3 }
53 }
35 }
54
36
55 ScatterSeries {
37 ScatterSeries {
56 name: "scatter series"
38 name: "scatter series"
57 id: scatter
58 XYPoint { x: 0; y: 0 }
39 XYPoint { x: 0; y: 0 }
59 XYPoint { x: 1.1; y: 2.1 }
40 XYPoint { x: 0.5; y: 1 }
60 XYPoint { x: 1.9; y: 3.3 }
41 XYPoint { x: 1; y: 2 }
61 XYPoint { x: 2.1; y: 2.1 }
42 XYPoint { x: 1.5; y: 3 }
62 XYPoint { x: 2.9; y: 4.9 }
43 XYPoint { x: 2; y: 4 }
63 XYPoint { x: 3.4; y: 3.0 }
44 XYPoint { x: 1; y: 1 }
64 XYPoint { x: 4.1; y: 3.3 }
45 XYPoint { x: 2; y: 2 }
46 XYPoint { x: 3; y: 3 }
47 XYPoint { x: 4; y: 4 }
65 }
48 }
66
49
67 Component.onCompleted: {
50 LineSeries {
68 // You can also set the axes dynamically
51 name: "line series"
69 chartView.setAxisX(axisX, scatter);
52 XYPoint { x: 0; y: 0 }
53 XYPoint { x: 1; y: 1 }
54 XYPoint { x: 2; y: 2 }
55 XYPoint { x: 3; y: 3 }
56 XYPoint { x: 4; y: 4 }
70 }
57 }
71 }
58 }
@@ -1,74 +1,74
1 /****************************************************************************
1 /****************************************************************************
2 **
2 **
3 ** Copyright (C) 2012 Digia Plc
3 ** Copyright (C) 2012 Digia Plc
4 ** All rights reserved.
4 ** All rights reserved.
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 **
6 **
7 ** This file is part of the Qt Commercial Charts Add-on.
7 ** This file is part of the Qt Commercial Charts Add-on.
8 **
8 **
9 ** $QT_BEGIN_LICENSE$
9 ** $QT_BEGIN_LICENSE$
10 ** Licensees holding valid Qt Commercial licenses may use this file in
10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 ** accordance with the Qt Commercial License Agreement provided with the
11 ** accordance with the Qt Commercial License Agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia.
13 ** a written agreement between you and Digia.
14 **
14 **
15 ** If you have questions regarding the use of this file, please use
15 ** If you have questions regarding the use of this file, please use
16 ** contact form at http://qt.digia.com
16 ** contact form at http://qt.digia.com
17 ** $QT_END_LICENSE$
17 ** $QT_END_LICENSE$
18 **
18 **
19 ****************************************************************************/
19 ****************************************************************************/
20
20
21 import QtQuick 1.0
21 import QtQuick 1.0
22 import QtCommercial.Chart 1.1
22 import QtCommercial.Chart 1.1
23
23
24 ChartView {
24 ChartView {
25 title: "configuring dynamically"
25 title: "configuring dynamically"
26 id: chartView
26 id: chartView
27 property int index: 0
27 property int index: 0
28
28
29 Timer {
29 Timer {
30 interval: 1000
30 interval: 1000
31 repeat: true
31 repeat: true
32 running: true
32 running: true
33 onTriggered: {
33 onTriggered: {
34 switch (index) {
34 switch (index) {
35 case 0:
35 case 0:
36 chartView.axisX(lineSeries).max = 5;
36 chartView.axisX(lineSeries).max = 6;
37 chartView.axisY(lineSeries).max = 5;
37 chartView.axisY(lineSeries).max = 6;
38 break;
38 break;
39 case 1:
39 case 1:
40 chartView.axisX(scatterSeries).max = 10;
40 chartView.axisX(scatterSeries).max = 10;
41 chartView.axisY(scatterSeries).max = 10;
41 chartView.axisY(scatterSeries).max = 10;
42 break;
42 break;
43 default:
43 default:
44 chartView.axisX().max = 15;
44 chartView.axisX().max = 4;
45 chartView.axisY().max = 15;
45 chartView.axisY().max = 4;
46 }
46 }
47 index = (index + 1) % 3;
47 index = (index + 1) % 3;
48 }
48 }
49 }
49 }
50
50
51 LineSeries {
51 LineSeries {
52 id: lineSeries
52 id: lineSeries
53 name: "line series"
53 name: "line series"
54 XYPoint { x: 0; y: 0 }
54 XYPoint { x: 0; y: 0 }
55 XYPoint { x: 1.1; y: 2.1 }
55 XYPoint { x: 1; y: 1 }
56 XYPoint { x: 1.9; y: 3.3 }
56 XYPoint { x: 2; y: 2 }
57 XYPoint { x: 2.1; y: 2.1 }
57 XYPoint { x: 3; y: 3 }
58 XYPoint { x: 2.9; y: 4.9 }
58 XYPoint { x: 4; y: 4 }
59 XYPoint { x: 3.4; y: 3.0 }
60 XYPoint { x: 4.1; y: 3.3 }
61 }
59 }
62
60
63 ScatterSeries {
61 ScatterSeries {
64 id: scatterSeries
62 id: scatterSeries
65 name: "scatter series"
63 name: "scatter series"
66 XYPoint { x: 0; y: 0 }
64 XYPoint { x: 0; y: 0 }
67 XYPoint { x: 1.1; y: 2.1 }
65 XYPoint { x: 0.5; y: 1 }
68 XYPoint { x: 1.9; y: 3.3 }
66 XYPoint { x: 1; y: 2 }
69 XYPoint { x: 2.1; y: 2.1 }
67 XYPoint { x: 1.5; y: 3 }
70 XYPoint { x: 2.9; y: 4.9 }
68 XYPoint { x: 2; y: 4 }
71 XYPoint { x: 3.4; y: 3.0 }
69 XYPoint { x: 1; y: 1 }
72 XYPoint { x: 4.1; y: 3.3 }
70 XYPoint { x: 2; y: 2 }
71 XYPoint { x: 3; y: 3 }
72 XYPoint { x: 4; y: 4 }
73 }
73 }
74 }
74 }
@@ -1,66 +1,68
1 /****************************************************************************
1 /****************************************************************************
2 **
2 **
3 ** Copyright (C) 2012 Digia Plc
3 ** Copyright (C) 2012 Digia Plc
4 ** All rights reserved.
4 ** All rights reserved.
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 **
6 **
7 ** This file is part of the Qt Commercial Charts Add-on.
7 ** This file is part of the Qt Commercial Charts Add-on.
8 **
8 **
9 ** $QT_BEGIN_LICENSE$
9 ** $QT_BEGIN_LICENSE$
10 ** Licensees holding valid Qt Commercial licenses may use this file in
10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 ** accordance with the Qt Commercial License Agreement provided with the
11 ** accordance with the Qt Commercial License Agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia.
13 ** a written agreement between you and Digia.
14 **
14 **
15 ** If you have questions regarding the use of this file, please use
15 ** If you have questions regarding the use of this file, please use
16 ** contact form at http://qt.digia.com
16 ** contact form at http://qt.digia.com
17 ** $QT_END_LICENSE$
17 ** $QT_END_LICENSE$
18 **
18 **
19 ****************************************************************************/
19 ****************************************************************************/
20
20
21 import QtQuick 1.0
21 import QtQuick 1.0
22 import QtCommercial.Chart 1.1
22 import QtCommercial.Chart 1.1
23
23
24 ChartView {
24 ChartView {
25 id: chartView
25 id: chartView
26 title: "dynamically created series"
26 title: "creating dyn. new series"
27 property int index: 0
27 property int index: 0
28
28
29 Timer {
29 Timer {
30 interval: 1000
30 interval: 1000
31 repeat: true
31 repeat: true
32 running: true
32 running: true
33 onTriggered: {
33 onTriggered: {
34 switch (index) {
34 switch (index) {
35 case 0:
35 case 0:
36 while (chartView.count)
36 while (chartView.count) {
37 console.log("Destroying series. Count: " + chartView.count);
37 chartView.series(0).destroy();
38 chartView.series(0).destroy();
39 }
38 var line = chartView.createSeries(ChartView.SeriesTypeLine, "line");
40 var line = chartView.createSeries(ChartView.SeriesTypeLine, "line");
39 line.append(0, 0);
41 line.append(0, 0);
40 line.append(1.1, 2.1);
42 line.append(1, 1);
41 line.append(1.9, 3.3);
43 line.append(2, 2);
42 line.append(2.1, 2.1);
44 line.append(3, 3);
43 line.append(2.9, 4.9);
45 line.append(4, 4);
44 line.append(3.4, 3.0);
45 line.append(4.1, 3.3);
46 break;
46 break;
47 case 1:
47 case 1:
48 chartView.axisX().min = 0;
48 chartView.axisX().min = 0;
49 chartView.axisX().max = 4.5;
49 chartView.axisX().max = 4.5;
50 chartView.axisY().min = 0;
50 chartView.axisY().min = 0;
51 chartView.axisY().max = 4.5;
51 chartView.axisY().max = 4.5;
52 break;
52 break;
53 default:
53 default:
54 var scatter = chartView.createSeries(ChartView.SeriesTypeScatter, "scatter");
54 var scatter = chartView.createSeries(ChartView.SeriesTypeScatter, "scatter");
55 scatter.append(0, 0);
55 scatter.append(0, 0);
56 scatter.append(1.1, 2.1);
56 scatter.append(0.5, 1);
57 scatter.append(1.9, 3.3);
57 scatter.append(1, 2);
58 scatter.append(2.1, 2.1);
58 scatter.append(1.5, 3);
59 scatter.append(2.9, 4.9);
59 scatter.append(2, 4);
60 scatter.append(3.4, 3.0);
60 scatter.append(1, 1);
61 scatter.append(4.1, 3.3);
61 scatter.append(2, 2);
62 scatter.append(3, 3);
63 scatter.append(4, 4);
62 }
64 }
63 index = (index + 1) % 3;
65 index = (index + 1) % 3;
64 }
66 }
65 }
67 }
66 }
68 }
@@ -1,49 +1,49
1 /****************************************************************************
1 /****************************************************************************
2 **
2 **
3 ** Copyright (C) 2012 Digia Plc
3 ** Copyright (C) 2012 Digia Plc
4 ** All rights reserved.
4 ** All rights reserved.
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 **
6 **
7 ** This file is part of the Qt Commercial Charts Add-on.
7 ** This file is part of the Qt Commercial Charts Add-on.
8 **
8 **
9 ** $QT_BEGIN_LICENSE$
9 ** $QT_BEGIN_LICENSE$
10 ** Licensees holding valid Qt Commercial licenses may use this file in
10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 ** accordance with the Qt Commercial License Agreement provided with the
11 ** accordance with the Qt Commercial License Agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia.
13 ** a written agreement between you and Digia.
14 **
14 **
15 ** If you have questions regarding the use of this file, please use
15 ** If you have questions regarding the use of this file, please use
16 ** contact form at http://qt.digia.com
16 ** contact form at http://qt.digia.com
17 ** $QT_END_LICENSE$
17 ** $QT_END_LICENSE$
18 **
18 **
19 ****************************************************************************/
19 ****************************************************************************/
20
20
21 import QtQuick 1.0
21 import QtQuick 1.0
22 import QtCommercial.Chart 1.1
22 import QtCommercial.Chart 1.1
23
23
24 ChartView {
24 ChartView {
25 id: chartView
25 id: chartView
26 title: "default axes"
26 title: "default axes"
27
27
28 LineSeries {
28 LineSeries {
29 name: "line series"
29 name: "line series"
30 XYPoint { x: 0; y: 0 }
30 XYPoint { x: 0; y: 0 }
31 XYPoint { x: 1.1; y: 2.1 }
31 XYPoint { x: 1; y: 1 }
32 XYPoint { x: 1.9; y: 3.3 }
32 XYPoint { x: 2; y: 2 }
33 XYPoint { x: 2.1; y: 2.1 }
33 XYPoint { x: 3; y: 3 }
34 XYPoint { x: 2.9; y: 4.9 }
34 XYPoint { x: 4; y: 4 }
35 XYPoint { x: 3.4; y: 3.0 }
36 XYPoint { x: 4.1; y: 3.3 }
37 }
35 }
38
36
39 ScatterSeries {
37 ScatterSeries {
40 name: "scatter series"
38 name: "scatter series"
41 XYPoint { x: 0; y: 0 }
39 XYPoint { x: 0; y: 0 }
42 XYPoint { x: 1.1; y: 2.1 }
40 XYPoint { x: 0.5; y: 1 }
43 XYPoint { x: 1.9; y: 3.3 }
41 XYPoint { x: 1; y: 2 }
44 XYPoint { x: 2.1; y: 2.1 }
42 XYPoint { x: 1.5; y: 3 }
45 XYPoint { x: 2.9; y: 4.9 }
43 XYPoint { x: 2; y: 4 }
46 XYPoint { x: 3.4; y: 3.0 }
44 XYPoint { x: 1; y: 1 }
47 XYPoint { x: 4.1; y: 3.3 }
45 XYPoint { x: 2; y: 2 }
46 XYPoint { x: 3; y: 3 }
47 XYPoint { x: 4; y: 4 }
48 }
48 }
49 }
49 }
@@ -1,43 +1,49
1 /****************************************************************************
1 /****************************************************************************
2 **
2 **
3 ** Copyright (C) 2012 Digia Plc
3 ** Copyright (C) 2012 Digia Plc
4 ** All rights reserved.
4 ** All rights reserved.
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 **
6 **
7 ** This file is part of the Qt Commercial Charts Add-on.
7 ** This file is part of the Qt Commercial Charts Add-on.
8 **
8 **
9 ** $QT_BEGIN_LICENSE$
9 ** $QT_BEGIN_LICENSE$
10 ** Licensees holding valid Qt Commercial licenses may use this file in
10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 ** accordance with the Qt Commercial License Agreement provided with the
11 ** accordance with the Qt Commercial License Agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia.
13 ** a written agreement between you and Digia.
14 **
14 **
15 ** If you have questions regarding the use of this file, please use
15 ** If you have questions regarding the use of this file, please use
16 ** contact form at http://qt.digia.com
16 ** contact form at http://qt.digia.com
17 ** $QT_END_LICENSE$
17 ** $QT_END_LICENSE$
18 **
18 **
19 ****************************************************************************/
19 ****************************************************************************/
20
20
21 import QtQuick 1.0
21 import QtQuick 1.0
22 import QtCommercial.Chart 1.1
22 import QtCommercial.Chart 1.1
23
23
24 ChartView {
24 ChartView {
25 id: chartView
25 id: chartView
26 title: "axis scale; different series"
26 title: "default axes"
27
27
28 LineSeries {
28 ScatterSeries {
29 name: "line series"
29 name: "scatter series"
30 XYPoint { x: 0; y: 0 }
30 XYPoint { x: 0; y: 0 }
31 XYPoint { x: 1.1; y: 2.1 }
31 XYPoint { x: 0.5; y: 1 }
32 XYPoint { x: 1.9; y: 3.3 }
32 XYPoint { x: 1; y: 2 }
33 XYPoint { x: 2.1; y: 2.1 }
33 XYPoint { x: 1.5; y: 3 }
34 XYPoint { x: 2; y: 4 }
35 XYPoint { x: 1; y: 1 }
36 XYPoint { x: 2; y: 2 }
37 XYPoint { x: 3; y: 3 }
38 XYPoint { x: 4; y: 4 }
34 }
39 }
35
40
36 ScatterSeries {
41 LineSeries {
37 name: "scatter series"
42 name: "line series"
38 XYPoint { x: 2.1; y: 2.1 }
43 XYPoint { x: 0; y: 0 }
39 XYPoint { x: 2.9; y: 4.9 }
44 XYPoint { x: 1; y: 1 }
40 XYPoint { x: 3.4; y: 3.0 }
45 XYPoint { x: 2; y: 2 }
41 XYPoint { x: 4.1; y: 3.3 }
46 XYPoint { x: 3; y: 3 }
47 XYPoint { x: 4; y: 4 }
42 }
48 }
43 }
49 }
@@ -1,56 +1,56
1 /****************************************************************************
1 /****************************************************************************
2 **
2 **
3 ** Copyright (C) 2012 Digia Plc
3 ** Copyright (C) 2012 Digia Plc
4 ** All rights reserved.
4 ** All rights reserved.
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 **
6 **
7 ** This file is part of the Qt Commercial Charts Add-on.
7 ** This file is part of the Qt Commercial Charts Add-on.
8 **
8 **
9 ** $QT_BEGIN_LICENSE$
9 ** $QT_BEGIN_LICENSE$
10 ** Licensees holding valid Qt Commercial licenses may use this file in
10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 ** accordance with the Qt Commercial License Agreement provided with the
11 ** accordance with the Qt Commercial License Agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia.
13 ** a written agreement between you and Digia.
14 **
14 **
15 ** If you have questions regarding the use of this file, please use
15 ** If you have questions regarding the use of this file, please use
16 ** contact form at http://qt.digia.com
16 ** contact form at http://qt.digia.com
17 ** $QT_END_LICENSE$
17 ** $QT_END_LICENSE$
18 **
18 **
19 ****************************************************************************/
19 ****************************************************************************/
20
20
21 import QtQuick 1.0
21 import QtQuick 1.0
22 import QtCommercial.Chart 1.1
22 import QtCommercial.Chart 1.1
23
23
24 ChartView {
24 ChartView {
25 id: chartView
25 id: chartView
26 title: "Deprecated code"
26 title: "Deprecated code"
27 property int index: 0
27 property int index: 0
28
28
29 Component.onCompleted: {
29 Component.onCompleted: {
30 // Calling createDefaultAxes in onCompleted is now deprecated. It needs to be tested,
30 // Calling createDefaultAxes in onCompleted is now deprecated. It needs to be tested,
31 // though, because some application may still use it
31 // though, because some application may still use it
32 chartView.createDefaultAxes();
32 chartView.createDefaultAxes();
33 }
33 }
34
34
35 LineSeries {
35 LineSeries {
36 name: "line series"
36 name: "line series"
37 XYPoint { x: 0; y: 0 }
37 XYPoint { x: 0; y: 0 }
38 XYPoint { x: 1.1; y: 2.1 }
38 XYPoint { x: 1; y: 1 }
39 XYPoint { x: 1.9; y: 3.3 }
39 XYPoint { x: 2; y: 2 }
40 XYPoint { x: 2.1; y: 2.1 }
40 XYPoint { x: 3; y: 3 }
41 XYPoint { x: 2.9; y: 4.9 }
41 XYPoint { x: 4; y: 4 }
42 XYPoint { x: 3.4; y: 3.0 }
43 XYPoint { x: 4.1; y: 3.3 }
44 }
42 }
45
43
46 ScatterSeries {
44 ScatterSeries {
47 name: "scatter series"
45 name: "scatter series"
48 XYPoint { x: 0; y: 0 }
46 XYPoint { x: 0; y: 0 }
49 XYPoint { x: 1.1; y: 2.1 }
47 XYPoint { x: 0.5; y: 1 }
50 XYPoint { x: 1.9; y: 3.3 }
48 XYPoint { x: 1; y: 2 }
51 XYPoint { x: 2.1; y: 2.1 }
49 XYPoint { x: 1.5; y: 3 }
52 XYPoint { x: 2.9; y: 4.9 }
50 XYPoint { x: 2; y: 4 }
53 XYPoint { x: 3.4; y: 3.0 }
51 XYPoint { x: 1; y: 1 }
54 XYPoint { x: 4.1; y: 3.3 }
52 XYPoint { x: 2; y: 2 }
53 XYPoint { x: 3; y: 3 }
54 XYPoint { x: 4; y: 4 }
55 }
55 }
56 }
56 }
@@ -1,84 +1,82
1 /****************************************************************************
1 /****************************************************************************
2 **
2 **
3 ** Copyright (C) 2012 Digia Plc
3 ** Copyright (C) 2012 Digia Plc
4 ** All rights reserved.
4 ** All rights reserved.
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 **
6 **
7 ** This file is part of the Qt Commercial Charts Add-on.
7 ** This file is part of the Qt Commercial Charts Add-on.
8 **
8 **
9 ** $QT_BEGIN_LICENSE$
9 ** $QT_BEGIN_LICENSE$
10 ** Licensees holding valid Qt Commercial licenses may use this file in
10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 ** accordance with the Qt Commercial License Agreement provided with the
11 ** accordance with the Qt Commercial License Agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia.
13 ** a written agreement between you and Digia.
14 **
14 **
15 ** If you have questions regarding the use of this file, please use
15 ** If you have questions regarding the use of this file, please use
16 ** contact form at http://qt.digia.com
16 ** contact form at http://qt.digia.com
17 ** $QT_END_LICENSE$
17 ** $QT_END_LICENSE$
18 **
18 **
19 ****************************************************************************/
19 ****************************************************************************/
20
20
21 import QtQuick 1.0
21 import QtQuick 1.0
22 import QtCommercial.Chart 1.1
22 import QtCommercial.Chart 1.1
23
23
24 ChartView {
24 ChartView {
25 title: "series specific dynamic axes"
25 title: "series specific dynamic axes"
26 id: chartView
26 id: chartView
27 property int index: 0
27 property int index: 0
28
28
29 Timer {
29 Timer {
30 interval: 1000
30 interval: 1000
31 repeat: true
31 repeat: true
32 running: true
32 running: true
33 onTriggered: {
33 onTriggered: {
34 switch (index) {
34 switch (index) {
35 case 0:
35 case 0:
36 lineAxisX.max = 5;
36 lineAxisX.max = 6;
37 lineAxisY.max = 5;
37 lineAxisY.max = 6;
38 scatterAxisX.max = 10;
38 scatterAxisX.max = 10;
39 scatterAxisY.max = 10;
39 scatterAxisY.max = 10;
40 break;
40 break;
41 case 1:
41 case 1:
42 lineAxisX.max = 10;
42 lineAxisX.max = 10;
43 lineAxisY.max = 10;
43 lineAxisY.max = 10;
44 scatterAxisX.max = 5;
44 scatterAxisX.max = 6;
45 scatterAxisY.max = 5;
45 scatterAxisY.max = 6;
46 break;
46 break;
47 default:
47 default:
48 chartView.axisX().max = 2;
48 chartView.axisX().max = 4;
49 chartView.axisY().max = 2;
49 chartView.axisY().max = 4;
50 }
50 }
51 index = (index + 1) % 3;
51 index = (index + 1) % 3;
52 }
52 }
53 }
53 }
54
54
55 LineSeries {
55 LineSeries {
56 id: lineSeries
56 id: lineSeries
57 name: "line series"
57 name: "line series"
58 axisX: ValueAxis { id: lineAxisX }
58 axisX: ValueAxis { id: lineAxisX }
59 axisY: ValueAxis { id: lineAxisY }
59 axisY: ValueAxis { id: lineAxisY }
60
61 XYPoint { x: 0; y: 0 }
60 XYPoint { x: 0; y: 0 }
62 XYPoint { x: 1.1; y: 2.1 }
61 XYPoint { x: 1; y: 1 }
63 XYPoint { x: 1.9; y: 3.3 }
62 XYPoint { x: 2; y: 2 }
64 XYPoint { x: 2.1; y: 2.1 }
63 XYPoint { x: 3; y: 3 }
65 XYPoint { x: 2.9; y: 4.9 }
64 XYPoint { x: 4; y: 4 }
66 XYPoint { x: 3.4; y: 3.0 }
67 XYPoint { x: 4.1; y: 3.3 }
68 }
65 }
69
66
70 ScatterSeries {
67 ScatterSeries {
71 id: scatterSeries
68 id: scatterSeries
72 name: "scatter series"
69 name: "scatter series"
73 axisX: ValueAxis { id: scatterAxisX }
70 axisX: ValueAxis { id: scatterAxisX }
74 axisY: ValueAxis { id: scatterAxisY }
71 axisY: ValueAxis { id: scatterAxisY }
75
76 XYPoint { x: 0; y: 0 }
72 XYPoint { x: 0; y: 0 }
77 XYPoint { x: 1.1; y: 2.1 }
73 XYPoint { x: 0.5; y: 1 }
78 XYPoint { x: 1.9; y: 3.3 }
74 XYPoint { x: 1; y: 2 }
79 XYPoint { x: 2.1; y: 2.1 }
75 XYPoint { x: 1.5; y: 3 }
80 XYPoint { x: 2.9; y: 4.9 }
76 XYPoint { x: 2; y: 4 }
81 XYPoint { x: 3.4; y: 3.0 }
77 XYPoint { x: 1; y: 1 }
82 XYPoint { x: 4.1; y: 3.3 }
78 XYPoint { x: 2; y: 2 }
79 XYPoint { x: 3; y: 3 }
80 XYPoint { x: 4; y: 4 }
83 }
81 }
84 }
82 }
@@ -1,64 +1,71
1 /****************************************************************************
1 /****************************************************************************
2 **
2 **
3 ** Copyright (C) 2012 Digia Plc
3 ** Copyright (C) 2012 Digia Plc
4 ** All rights reserved.
4 ** All rights reserved.
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 **
6 **
7 ** This file is part of the Qt Commercial Charts Add-on.
7 ** This file is part of the Qt Commercial Charts Add-on.
8 **
8 **
9 ** $QT_BEGIN_LICENSE$
9 ** $QT_BEGIN_LICENSE$
10 ** Licensees holding valid Qt Commercial licenses may use this file in
10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 ** accordance with the Qt Commercial License Agreement provided with the
11 ** accordance with the Qt Commercial License Agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia.
13 ** a written agreement between you and Digia.
14 **
14 **
15 ** If you have questions regarding the use of this file, please use
15 ** If you have questions regarding the use of this file, please use
16 ** contact form at http://qt.digia.com
16 ** contact form at http://qt.digia.com
17 ** $QT_END_LICENSE$
17 ** $QT_END_LICENSE$
18 **
18 **
19 ****************************************************************************/
19 ****************************************************************************/
20
20
21 import QtQuick 1.0
21 import QtQuick 1.0
22 import QtCommercial.Chart 1.1
22 import QtCommercial.Chart 1.1
23
23
24 ChartView {
24 ChartView {
25 id: chartView
25 id: chartView
26 title: "switching axes dynamically"
26 title: "switching axes dynamically"
27
27
28 Timer {
28 Timer {
29 interval: 1000
29 interval: 1000
30 repeat: true
30 repeat: true
31 running: true
31 running: true
32 onTriggered: {
32 onTriggered: {
33 //console.log("current axisX: " + lineSeries.axisX + " 1: " + valueAxis1 + " 2: " +valueAxis2);
34
35 // Note: an axis is destroyed if it is not used anymore
33 if (lineSeries.axisX == valueAxis1)
36 if (lineSeries.axisX == valueAxis1)
34 lineSeries.axisX = valueAxis2;
37 lineSeries.axisX = valueAxis2;
35 else
38 else if (lineSeries.axisX == valueAxis2)
36 lineSeries.axisX = valueAxis1;
39 lineSeries.axisX = valueAxis3;
37 }
40 }
38 }
41 }
39
42
40 ValueAxis {
43 ValueAxis {
41 id: valueAxis1
44 id: valueAxis1
42 min: 0
45 min: 0
43 max: 5
46 max: 5
44 }
47 }
45
48
46 ValueAxis {
49 ValueAxis {
47 id: valueAxis2
50 id: valueAxis2
48 min: 1
51 min: 1
49 max: 6
52 max: 6
50 }
53 }
51
54
55 ValueAxis {
56 id: valueAxis3
57 min: 2
58 max: 7
59 }
60
52 LineSeries {
61 LineSeries {
53 id: lineSeries
62 id: lineSeries
54 name: "line series"
63 name: "line series"
55 axisX: valueAxis1
64 axisX: valueAxis1
56 XYPoint { x: 0; y: 0 }
65 XYPoint { x: 0; y: 0 }
57 XYPoint { x: 1.1; y: 2.1 }
66 XYPoint { x: 1; y: 1 }
58 XYPoint { x: 1.9; y: 3.3 }
67 XYPoint { x: 2; y: 2 }
59 XYPoint { x: 2.1; y: 2.1 }
68 XYPoint { x: 3; y: 3 }
60 XYPoint { x: 2.9; y: 4.9 }
69 XYPoint { x: 4; y: 4 }
61 XYPoint { x: 3.4; y: 3.0 }
62 XYPoint { x: 4.1; y: 3.3 }
63 }
70 }
64 }
71 }
@@ -1,64 +1,64
1 /****************************************************************************
1 /****************************************************************************
2 **
2 **
3 ** Copyright (C) 2012 Digia Plc
3 ** Copyright (C) 2012 Digia Plc
4 ** All rights reserved.
4 ** All rights reserved.
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 **
6 **
7 ** This file is part of the Qt Commercial Charts Add-on.
7 ** This file is part of the Qt Commercial Charts Add-on.
8 **
8 **
9 ** $QT_BEGIN_LICENSE$
9 ** $QT_BEGIN_LICENSE$
10 ** Licensees holding valid Qt Commercial licenses may use this file in
10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 ** accordance with the Qt Commercial License Agreement provided with the
11 ** accordance with the Qt Commercial License Agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia.
13 ** a written agreement between you and Digia.
14 **
14 **
15 ** If you have questions regarding the use of this file, please use
15 ** If you have questions regarding the use of this file, please use
16 ** contact form at http://qt.digia.com
16 ** contact form at http://qt.digia.com
17 ** $QT_END_LICENSE$
17 ** $QT_END_LICENSE$
18 **
18 **
19 ****************************************************************************/
19 ****************************************************************************/
20
20
21 import QtQuick 1.0
21 import QtQuick 1.0
22 import QtCommercial.Chart 1.1
22 import QtCommercial.Chart 1.1
23
23
24 ChartView {
24 ChartView {
25 title: "user defined axes"
25 title: "user defined"
26
26
27 ValueAxis {
27 ValueAxis {
28 id: axisX
28 id: axisX
29 min: 0
29 min: 0
30 max: 10
30 max: 6
31 }
31 }
32
32
33 ValueAxis {
33 ValueAxis {
34 id: axisY
34 id: axisY
35 min: 0
35 min: 0
36 max: 6
36 max: 6
37 }
37 }
38
38
39 LineSeries {
39 LineSeries {
40 name: "line series"
40 name: "line series"
41 axisX: axisX
41 axisX: axisX
42 axisY: axisY
42 axisY: axisY
43 XYPoint { x: 0; y: 0 }
43 XYPoint { x: 0; y: 0 }
44 XYPoint { x: 1.1; y: 2.1 }
44 XYPoint { x: 1; y: 1 }
45 XYPoint { x: 1.9; y: 3.3 }
45 XYPoint { x: 2; y: 2 }
46 XYPoint { x: 2.1; y: 2.1 }
46 XYPoint { x: 3; y: 3 }
47 XYPoint { x: 2.9; y: 4.9 }
47 XYPoint { x: 4; y: 4 }
48 XYPoint { x: 3.4; y: 3.0 }
49 XYPoint { x: 4.1; y: 3.3 }
50 }
48 }
51
49
52 ScatterSeries {
50 ScatterSeries {
53 name: "scatter series"
51 name: "scatter series"
54 axisX: axisX
52 axisX: axisX
55 axisY: axisY
53 axisY: axisY
56 XYPoint { x: 0; y: 0 }
54 XYPoint { x: 0; y: 0 }
57 XYPoint { x: 1.1; y: 2.1 }
55 XYPoint { x: 0.5; y: 1 }
58 XYPoint { x: 1.9; y: 3.3 }
56 XYPoint { x: 1; y: 2 }
59 XYPoint { x: 2.1; y: 2.1 }
57 XYPoint { x: 1.5; y: 3 }
60 XYPoint { x: 2.9; y: 4.9 }
58 XYPoint { x: 2; y: 4 }
61 XYPoint { x: 3.4; y: 3.0 }
59 XYPoint { x: 1; y: 1 }
62 XYPoint { x: 4.1; y: 3.3 }
60 XYPoint { x: 2; y: 2 }
61 XYPoint { x: 3; y: 3 }
62 XYPoint { x: 4; y: 4 }
63 }
63 }
64 }
64 }
@@ -1,84 +1,96
1 /****************************************************************************
1 /****************************************************************************
2 **
2 **
3 ** Copyright (C) 2012 Digia Plc
3 ** Copyright (C) 2012 Digia Plc
4 ** All rights reserved.
4 ** All rights reserved.
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 **
6 **
7 ** This file is part of the Qt Commercial Charts Add-on.
7 ** This file is part of the Qt Commercial Charts Add-on.
8 **
8 **
9 ** $QT_BEGIN_LICENSE$
9 ** $QT_BEGIN_LICENSE$
10 ** Licensees holding valid Qt Commercial licenses may use this file in
10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 ** accordance with the Qt Commercial License Agreement provided with the
11 ** accordance with the Qt Commercial License Agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia.
13 ** a written agreement between you and Digia.
14 **
14 **
15 ** If you have questions regarding the use of this file, please use
15 ** If you have questions regarding the use of this file, please use
16 ** contact form at http://qt.digia.com
16 ** contact form at http://qt.digia.com
17 ** $QT_END_LICENSE$
17 ** $QT_END_LICENSE$
18 **
18 **
19 ****************************************************************************/
19 ****************************************************************************/
20
20
21 import QtQuick 1.0
21 import QtQuick 1.0
22
22
23 Rectangle {
23 Rectangle {
24 id: main
24 id: main
25 width: 400
25 width: 400
26 height: 300
26 height: 300
27 property int viewNumber: 0
27 property string viewName: "DefaultAxes"
28
28
29 Row {
29 Row {
30 anchors.fill: parent
30 anchors.fill: parent
31 anchors.topMargin: 10
31 anchors.topMargin: 10
32
32
33 Loader {
33 Loader {
34 id: chartLoader
34 id: chartLoader
35 width: parent.width - buttonColumn.width
35 width: parent.width - buttonColumn.width
36 height: parent.height
36 height: parent.height
37 source: "Chart" + viewNumber + ".qml"
37 source: viewName + ".qml"
38 }
38 }
39
39
40 Column {
40 Column {
41 id: buttonColumn
41 id: buttonColumn
42 width: 150
42 width: 150
43 height: parent.height
43 height: parent.height
44 spacing: 5
44 spacing: 5
45
45
46 Button {
46 Button {
47 text: "Default"
47 text: "Default axes"
48 onClicked: viewNumber = 0;
48 onClicked: viewName = "DefaultAxes";
49 }
50 Button {
51 text: "Default axes reverted"
52 onClicked: viewName = "DefaultAxesRevert";
49 }
53 }
50 Button {
54 Button {
51 text: "User defined"
55 text: "User defined"
52 onClicked: viewNumber = 1;
56 onClicked: viewName = "UserDefined";
57 }
58 Button {
59 text: "User defined reverted"
60 onClicked: viewName = "UserDefinedRevert";
53 }
61 }
54 Button {
62 Button {
55 text: "Chart axes"
63 text: "Chart axes"
56 onClicked: viewNumber = 2;
64 onClicked: viewName = "ChartAxes";
65 }
66 Button {
67 text: "Chart axes reverted"
68 onClicked: viewName = "ChartAxesRevert";
57 }
69 }
58 Button {
70 Button {
59 text: "Configuring dynamically"
71 text: "Configuring dynamically"
60 onClicked: viewNumber = 3;
72 onClicked: viewName = "ConfiguringDynamically";
61 }
73 }
62 Button {
74 Button {
63 text: "Series specific dynamic"
75 text: "Series specific dynamic"
64 onClicked: viewNumber = 4;
76 onClicked: viewName = "SeriesSpecificDynamic";
65 }
77 }
66 Button {
78 Button {
67 text: "Creating dynamically"
79 text: "Creating dynamically"
68 onClicked: viewNumber = 5;
80 onClicked: viewName = "CreatingDynamically";
69 }
81 }
70 Button {
82 Button {
71 text: "Switching dynamically"
83 text: "Switching dynamically"
72 onClicked: viewNumber = 6;
84 onClicked: viewName = "SwitchingDynamically";
73 }
85 }
74 Button {
86 Button {
75 text: "Axis scale"
87 text: "Default + User defined"
76 onClicked: viewNumber = 7;
88 onClicked: viewName = "DefaultAndUserDefined";
77 }
89 }
78 Button {
90 Button {
79 text: "Legacy"
91 text: "Legacy"
80 onClicked: viewNumber = 8;
92 onClicked: viewName = "Legacy";
81 }
93 }
82 }
94 }
83 }
95 }
84 }
96 }
@@ -1,15 +1,18
1 <RCC>
1 <RCC>
2 <qresource prefix="/">
2 <qresource prefix="/">
3 <file>qml/qmlchartaxis/main.qml</file>
3 <file>qml/qmlchartaxis/main.qml</file>
4 <file>qml/qmlchartaxis/Button.qml</file>
4 <file>qml/qmlchartaxis/Button.qml</file>
5 <file>qml/qmlchartaxis/Chart0.qml</file>
5 <file>qml/qmlchartaxis/DefaultAxes.qml</file>
6 <file>qml/qmlchartaxis/Chart1.qml</file>
6 <file>qml/qmlchartaxis/DefaultAxesRevert.qml</file>
7 <file>qml/qmlchartaxis/Chart2.qml</file>
7 <file>qml/qmlchartaxis/UserDefined.qml</file>
8 <file>qml/qmlchartaxis/Chart3.qml</file>
8 <file>qml/qmlchartaxis/UserDefinedRevert.qml</file>
9 <file>qml/qmlchartaxis/Chart4.qml</file>
9 <file>qml/qmlchartaxis/ChartAxes.qml</file>
10 <file>qml/qmlchartaxis/Chart5.qml</file>
10 <file>qml/qmlchartaxis/ChartAxesRevert.qml</file>
11 <file>qml/qmlchartaxis/Chart6.qml</file>
11 <file>qml/qmlchartaxis/ConfiguringDynamically.qml</file>
12 <file>qml/qmlchartaxis/Chart7.qml</file>
12 <file>qml/qmlchartaxis/SeriesSpecificDynamic.qml</file>
13 <file>qml/qmlchartaxis/Chart8.qml</file>
13 <file>qml/qmlchartaxis/CreatingDynamically.qml</file>
14 <file>qml/qmlchartaxis/SwitchingDynamically.qml</file>
15 <file>qml/qmlchartaxis/DefaultAndUserDefined.qml</file>
16 <file>qml/qmlchartaxis/Legacy.qml</file>
14 </qresource>
17 </qresource>
15 </RCC>
18 </RCC>
General Comments 0
You need to be logged in to leave comments. Login now