@@ -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 | Flow { | |||
|
25 | anchors.fill: parent | |||
|
26 | property variant chart | |||
|
27 | flow: Flow.TopToBottom | |||
|
28 | spacing: 5 | |||
|
29 | ||||
|
30 | Button { | |||
|
31 | text: "add line" | |||
|
32 | onClicked: addXYSeries(ChartView.SeriesTypeLine, "line"); | |||
|
33 | } | |||
|
34 | Button { | |||
|
35 | text: "add spline" | |||
|
36 | onClicked: addXYSeries(ChartView.SeriesTypeSpline, "spline"); | |||
|
37 | } | |||
|
38 | Button { | |||
|
39 | text: "add scatter" | |||
|
40 | onClicked: addXYSeries(ChartView.SeriesTypeScatter, "scatter"); | |||
|
41 | } | |||
|
42 | Button { | |||
|
43 | text: "remove last" | |||
|
44 | onClicked: { | |||
|
45 | if (chart.count > 0) | |||
|
46 | chart.removeSeries(chart.series(chart.count - 1)); | |||
|
47 | else | |||
|
48 | chart.removeSeries(0); | |||
|
49 | } | |||
|
50 | } | |||
|
51 | Button { | |||
|
52 | text: "remove all" | |||
|
53 | onClicked: chart.removeAllSeries(); | |||
|
54 | } | |||
|
55 | ||||
|
56 | function addXYSeries(type, name) { | |||
|
57 | var series = chart.createSeries(type, name + " " + chart.count); | |||
|
58 | for (var i = chart.axisX().min; i < chart.axisX().max; i++) { | |||
|
59 | var y = Math.random() * (chart.axisY().max - chart.axisY().min) + chart.axisY().min; | |||
|
60 | var x = Math.random() + i; | |||
|
61 | series.append(x, y); | |||
|
62 | } | |||
|
63 | } | |||
|
64 | } |
@@ -1,705 +1,733 | |||||
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 | #include "qchart_p.h" | |||
35 |
|
36 | |||
36 | #ifndef QT_ON_ARM |
|
37 | #ifndef QT_ON_ARM | |
37 | #include "qdatetimeaxis.h" |
|
38 | #include "qdatetimeaxis.h" | |
38 | #endif |
|
39 | #endif | |
39 |
|
40 | |||
40 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
41 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
41 |
|
42 | |||
42 | /*! |
|
43 | /*! | |
43 | \qmlclass ChartView DeclarativeChart |
|
44 | \qmlclass ChartView DeclarativeChart | |
44 |
|
45 | |||
45 | ChartView element is the parent that is responsible for showing different chart series types. |
|
46 | ChartView element is the parent that is responsible for showing different chart series types. | |
46 |
|
47 | |||
47 | The following QML shows how to create a simple chart with one pie series: |
|
48 | The following QML shows how to create a simple chart with one pie series: | |
48 | \snippet ../examples/qmlpiechart/qml/qmlpiechart/main.qml 1 |
|
49 | \snippet ../examples/qmlpiechart/qml/qmlpiechart/main.qml 1 | |
49 | \snippet ../examples/qmlpiechart/qml/qmlpiechart/main.qml 2 |
|
50 | \snippet ../examples/qmlpiechart/qml/qmlpiechart/main.qml 2 | |
50 | \snippet ../examples/qmlpiechart/qml/qmlpiechart/main.qml 3 |
|
51 | \snippet ../examples/qmlpiechart/qml/qmlpiechart/main.qml 3 | |
51 |
|
52 | |||
52 | \beginfloatleft |
|
53 | \beginfloatleft | |
53 | \image examples_qmlpiechart.png |
|
54 | \image examples_qmlpiechart.png | |
54 | \endfloat |
|
55 | \endfloat | |
55 | \clearfloat |
|
56 | \clearfloat | |
56 | */ |
|
57 | */ | |
57 |
|
58 | |||
58 | /*! |
|
59 | /*! | |
59 | \qmlproperty Theme ChartView::theme |
|
60 | \qmlproperty Theme ChartView::theme | |
60 | Theme defines the visual appearance of the chart, including for example colors, fonts, line |
|
61 | Theme defines the visual appearance of the chart, including for example colors, fonts, line | |
61 | widths and chart background. |
|
62 | widths and chart background. | |
62 | */ |
|
63 | */ | |
63 |
|
64 | |||
64 | /*! |
|
65 | /*! | |
65 | \qmlproperty Animation ChartView::animation |
|
66 | \qmlproperty Animation ChartView::animation | |
66 | Animation configuration of the chart. One of ChartView.NoAnimation, ChartView.GridAxisAnimations, |
|
67 | Animation configuration of the chart. One of ChartView.NoAnimation, ChartView.GridAxisAnimations, | |
67 | ChartView.SeriesAnimations or ChartView.AllAnimations. |
|
68 | ChartView.SeriesAnimations or ChartView.AllAnimations. | |
68 | */ |
|
69 | */ | |
69 |
|
70 | |||
70 | /*! |
|
71 | /*! | |
71 | \qmlproperty Font ChartView::titleFont |
|
72 | \qmlproperty Font ChartView::titleFont | |
72 | The title font of the chart |
|
73 | The title font of the chart | |
73 |
|
74 | |||
74 | See the \l {Font} {QML Font Element} for detailed documentation. |
|
75 | See the \l {Font} {QML Font Element} for detailed documentation. | |
75 | */ |
|
76 | */ | |
76 |
|
77 | |||
77 | /*! |
|
78 | /*! | |
78 | \qmlproperty string ChartView::title |
|
79 | \qmlproperty string ChartView::title | |
79 | The title of the chart, shown on top of the chart. |
|
80 | The title of the chart, shown on top of the chart. | |
80 | \sa ChartView::titleColor |
|
81 | \sa ChartView::titleColor | |
81 | */ |
|
82 | */ | |
82 |
|
83 | |||
83 | /*! |
|
84 | /*! | |
84 | \qmlproperty string ChartView::titleColor |
|
85 | \qmlproperty string ChartView::titleColor | |
85 | The color of the title text. |
|
86 | The color of the title text. | |
86 | */ |
|
87 | */ | |
87 |
|
88 | |||
88 | /*! |
|
89 | /*! | |
89 | \qmlproperty Axis ChartView::axisX |
|
90 | \qmlproperty Axis ChartView::axisX | |
90 | The x-axis of the chart. |
|
91 | The x-axis of the chart. | |
91 | */ |
|
92 | */ | |
92 |
|
93 | |||
93 | /*! |
|
94 | /*! | |
94 | \qmlproperty Axis ChartView::axisY |
|
95 | \qmlproperty Axis ChartView::axisY | |
95 | The default y-axis of the chart. |
|
96 | The default y-axis of the chart. | |
96 | */ |
|
97 | */ | |
97 |
|
98 | |||
98 | /*! |
|
99 | /*! | |
99 | \qmlproperty Legend ChartView::legend |
|
100 | \qmlproperty Legend ChartView::legend | |
100 | The legend of the chart. Legend lists all the series, pie slices and bar sets added on the chart. |
|
101 | The legend of the chart. Legend lists all the series, pie slices and bar sets added on the chart. | |
101 | */ |
|
102 | */ | |
102 |
|
103 | |||
103 | /*! |
|
104 | /*! | |
104 | \qmlproperty int ChartView::count |
|
105 | \qmlproperty int ChartView::count | |
105 | The count of series added to the chart. |
|
106 | The count of series added to the chart. | |
106 | */ |
|
107 | */ | |
107 |
|
108 | |||
108 | /*! |
|
109 | /*! | |
109 | \qmlproperty color ChartView::backgroundColor |
|
110 | \qmlproperty color ChartView::backgroundColor | |
110 | The color of the chart's background. By default background color is defined by chart theme. |
|
111 | The color of the chart's background. By default background color is defined by chart theme. | |
111 | \sa ChartView::theme |
|
112 | \sa ChartView::theme | |
112 | */ |
|
113 | */ | |
113 |
|
114 | |||
114 | /*! |
|
115 | /*! | |
115 | \qmlproperty bool ChartView::dropShadowEnabled |
|
116 | \qmlproperty bool ChartView::dropShadowEnabled | |
116 | The chart's border drop shadow. Set to true to enable drop shadow. |
|
117 | The chart's border drop shadow. Set to true to enable drop shadow. | |
117 | */ |
|
118 | */ | |
118 |
|
119 | |||
119 | /*! |
|
120 | /*! | |
120 | \qmlproperty real ChartView::topMargin |
|
121 | \qmlproperty real ChartView::topMargin | |
121 | Deprecated. Use minimumMargins and plotArea instead. |
|
122 | Deprecated. Use minimumMargins and plotArea instead. | |
122 | */ |
|
123 | */ | |
123 |
|
124 | |||
124 | /*! |
|
125 | /*! | |
125 | \qmlproperty real ChartView::bottomMargin |
|
126 | \qmlproperty real ChartView::bottomMargin | |
126 | Deprecated. Use minimumMargins and plotArea instead. |
|
127 | Deprecated. Use minimumMargins and plotArea instead. | |
127 | */ |
|
128 | */ | |
128 |
|
129 | |||
129 | /*! |
|
130 | /*! | |
130 | \qmlproperty real ChartView::leftMargin |
|
131 | \qmlproperty real ChartView::leftMargin | |
131 | Deprecated. Use minimumMargins and plotArea instead. |
|
132 | Deprecated. Use minimumMargins and plotArea instead. | |
132 | */ |
|
133 | */ | |
133 |
|
134 | |||
134 | /*! |
|
135 | /*! | |
135 | \qmlproperty real ChartView::rightMargin |
|
136 | \qmlproperty real ChartView::rightMargin | |
136 | Deprecated. Use minimumMargins and plotArea instead. |
|
137 | Deprecated. Use minimumMargins and plotArea instead. | |
137 | */ |
|
138 | */ | |
138 |
|
139 | |||
139 | /*! |
|
140 | /*! | |
140 | \qmlproperty Margins ChartView::minimumMargins |
|
141 | \qmlproperty Margins ChartView::minimumMargins | |
141 | The minimum margins allowed between the outer bounds and the plotArea of the ChartView. Margins |
|
142 | 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 |
|
143 | 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 |
|
144 | 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 |
|
145 | 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. |
|
146 | given time, you can check ChartView::plotArea instead. | |
146 | */ |
|
147 | */ | |
147 |
|
148 | |||
148 | /*! |
|
149 | /*! | |
149 | \qmlproperty rect ChartView::plotArea |
|
150 | \qmlproperty rect ChartView::plotArea | |
150 | The area on the ChartView that is used for drawing series. This is the ChartView rect without the |
|
151 | The area on the ChartView that is used for drawing series. This is the ChartView rect without the | |
151 | margins. |
|
152 | margins. | |
152 | \sa ChartView::minimumMargins |
|
153 | \sa ChartView::minimumMargins | |
153 | */ |
|
154 | */ | |
154 |
|
155 | |||
155 | /*! |
|
156 | /*! | |
156 | \qmlmethod AbstractSeries ChartView::series(int index) |
|
157 | \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 |
|
158 | 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. |
|
159 | the count property of the chart. | |
159 | */ |
|
160 | */ | |
160 |
|
161 | |||
161 | /*! |
|
162 | /*! | |
162 | \qmlmethod AbstractSeries ChartView::series(string name) |
|
163 | \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. |
|
164 | Returns the first series on the chart with \a name. If there is no series with that name, returns null. | |
164 | */ |
|
165 | */ | |
165 |
|
166 | |||
166 | /*! |
|
167 | /*! | |
167 | \qmlmethod AbstractSeries ChartView::createSeries(SeriesType type, string name, AbstractAxis axisX, AbstractAxis axisY) |
|
168 | \qmlmethod AbstractSeries ChartView::createSeries(SeriesType type, string name, AbstractAxis axisX, AbstractAxis axisY) | |
168 | Creates a series object of \a type to the chart with name \a name, optional axis \a axisX and |
|
169 | Creates a series object of \a type to the chart with name \a name, optional axis \a axisX and | |
169 | optional axis \a axisY. For example: |
|
170 | optional axis \a axisY. For example: | |
170 | \code |
|
171 | \code | |
171 | // lineSeries is a LineSeries object that has already been added to the ChartView; re-use it's axes |
|
172 | // lineSeries is a LineSeries object that has already been added to the ChartView; re-use it's axes | |
172 | var myAxisX = chartView.axisX(lineSeries); |
|
173 | var myAxisX = chartView.axisX(lineSeries); | |
173 | var myAxisY = chartView.axisY(lineSeries); |
|
174 | var myAxisY = chartView.axisY(lineSeries); | |
174 | var scatter = chartView.createSeries(ChartView.SeriesTypeScatter, "scatter series", myAxisX, myAxisY); |
|
175 | var scatter = chartView.createSeries(ChartView.SeriesTypeScatter, "scatter series", myAxisX, myAxisY); | |
175 | \endcode |
|
176 | \endcode | |
176 | */ |
|
177 | */ | |
177 |
|
178 | |||
178 | /*! |
|
179 | /*! | |
179 | \qmlmethod ChartView::removeSeries(AbstractSeries series) |
|
180 | \qmlmethod ChartView::removeSeries(AbstractSeries series) | |
180 | Removes the \a series from the chart. The series object is also destroyed. |
|
181 | Removes the \a series from the chart. The series object is also destroyed. | |
181 | */ |
|
182 | */ | |
182 |
|
183 | |||
183 | /*! |
|
184 | /*! | |
184 | \qmlmethod ChartView::removeAllSeries() |
|
185 | \qmlmethod ChartView::removeAllSeries() | |
185 | Removes all series from the chart. All the series objects are also destroyed. |
|
186 | Removes all series from the chart. All the series objects are also destroyed. | |
186 | */ |
|
187 | */ | |
187 |
|
188 | |||
188 | /*! |
|
189 | /*! | |
189 |
\qmlmethod Axis ChartView::axisX( |
|
190 | \qmlmethod Axis ChartView::axisX(AbstractSeries series) | |
190 | The x-axis of the series. |
|
191 | The x-axis of the series. | |
191 | */ |
|
192 | */ | |
192 |
|
193 | |||
193 | /*! |
|
194 | /*! | |
194 |
\qmlmethod Axis ChartView::axisY( |
|
195 | \qmlmethod Axis ChartView::axisY(AbstractSeries series) | |
195 | The y-axis of the series. |
|
196 | The y-axis of the series. | |
196 | */ |
|
197 | */ | |
197 |
|
198 | |||
198 | /*! |
|
199 | /*! | |
199 | \qmlmethod ChartView::zoomY(real factor) |
|
200 | \qmlmethod ChartView::zoomY(real factor) | |
200 | Zooms in by \a factor on the center of the chart. |
|
201 | Zooms in by \a factor on the center of the chart. | |
201 | */ |
|
202 | */ | |
202 |
|
203 | |||
203 | /*! |
|
204 | /*! | |
204 | \qmlmethod ChartView::scrollLeft(real pixels) |
|
205 | \qmlmethod ChartView::scrollLeft(real pixels) | |
205 | Scrolls to left by \a pixels. This is a convenience function that suits for example for key navigation. |
|
206 | Scrolls to left by \a pixels. This is a convenience function that suits for example for key navigation. | |
206 | \sa ValueAxis::min, ValueAxis::max, BarCategoryAxis::min, BarCategoryAxis::max |
|
207 | \sa ValueAxis::min, ValueAxis::max, BarCategoryAxis::min, BarCategoryAxis::max | |
207 | */ |
|
208 | */ | |
208 |
|
209 | |||
209 | /*! |
|
210 | /*! | |
210 | \qmlmethod ChartView::scrollRight(real pixels) |
|
211 | \qmlmethod ChartView::scrollRight(real pixels) | |
211 | Scrolls to right by \a pixels. This is a convenience function that suits for example for key navigation. |
|
212 | Scrolls to right by \a pixels. This is a convenience function that suits for example for key navigation. | |
212 | \sa ValueAxis::min, ValueAxis::max, BarCategoryAxis::min, BarCategoryAxis::max |
|
213 | \sa ValueAxis::min, ValueAxis::max, BarCategoryAxis::min, BarCategoryAxis::max | |
213 | */ |
|
214 | */ | |
214 |
|
215 | |||
215 | /*! |
|
216 | /*! | |
216 | \qmlmethod ChartView::scrollUp(real pixels) |
|
217 | \qmlmethod ChartView::scrollUp(real pixels) | |
217 | Scrolls up by \a pixels. This is a convenience function that suits for example for key navigation. |
|
218 | Scrolls up by \a pixels. This is a convenience function that suits for example for key navigation. | |
218 | \sa ValueAxis::min, ValueAxis::max, BarCategoryAxis::min, BarCategoryAxis::max |
|
219 | \sa ValueAxis::min, ValueAxis::max, BarCategoryAxis::min, BarCategoryAxis::max | |
219 | */ |
|
220 | */ | |
220 |
|
221 | |||
221 | /*! |
|
222 | /*! | |
222 | \qmlmethod ChartView::scrollDown(real pixels) |
|
223 | \qmlmethod ChartView::scrollDown(real pixels) | |
223 | Scrolls down by \a pixels. This is a convenience function that suits for example for key navigation. |
|
224 | Scrolls down by \a pixels. This is a convenience function that suits for example for key navigation. | |
224 | \sa ValueAxis::min, ValueAxis::max, BarCategoryAxis::min, BarCategoryAxis::max |
|
225 | \sa ValueAxis::min, ValueAxis::max, BarCategoryAxis::min, BarCategoryAxis::max | |
225 | */ |
|
226 | */ | |
226 |
|
227 | |||
227 | /*! |
|
228 | /*! | |
228 | \qmlsignal ChartView::onPlotAreaChanged(rect plotArea) |
|
229 | \qmlsignal ChartView::onPlotAreaChanged(rect plotArea) | |
229 | The plot area of the chart has changed. This may happen for example, if you modify minimumMargins |
|
230 | The plot area of the chart has changed. This may happen for example, if you modify minimumMargins | |
230 | or if you resize the chart, or if you modify font size related properties of the legend or chart |
|
231 | or if you resize the chart, or if you modify font size related properties of the legend or chart | |
231 | title. |
|
232 | title. | |
232 | */ |
|
233 | */ | |
233 |
|
234 | |||
|
235 | /*! | |||
|
236 | \qmlsignal ChartView::seriesAdded(AbstractSeries series) | |||
|
237 | The \a series has been added to the chart. | |||
|
238 | */ | |||
|
239 | ||||
|
240 | /*! | |||
|
241 | \qmlsignal ChartView::seriesRemoved(AbstractSeries series) | |||
|
242 | The \a series has been removed from the chart. Please note that \a series is no longer a valid | |||
|
243 | object after the signal handler has completed. | |||
|
244 | */ | |||
|
245 | ||||
234 | DeclarativeChart::DeclarativeChart(QDeclarativeItem *parent) |
|
246 | DeclarativeChart::DeclarativeChart(QDeclarativeItem *parent) | |
235 | : QDeclarativeItem(parent), |
|
247 | : QDeclarativeItem(parent), | |
236 | m_chart(new QChart(this)) |
|
248 | m_chart(new QChart(this)) | |
237 | { |
|
249 | { | |
238 | setFlag(QGraphicsItem::ItemHasNoContents, false); |
|
250 | setFlag(QGraphicsItem::ItemHasNoContents, false); | |
239 | m_minMargins = new DeclarativeMargins(this); |
|
251 | m_minMargins = new DeclarativeMargins(this); | |
240 | connect(m_minMargins, SIGNAL(topChanged(int, int, int, int)), this, SLOT(changeMinimumMargins(int, int, int, int))); |
|
252 | connect(m_minMargins, SIGNAL(topChanged(int, int, int, int)), this, SLOT(changeMinimumMargins(int, int, int, int))); | |
241 | connect(m_minMargins, SIGNAL(bottomChanged(int, int, int, int)), this, SLOT(changeMinimumMargins(int, int, int, int))); |
|
253 | connect(m_minMargins, SIGNAL(bottomChanged(int, int, int, int)), this, SLOT(changeMinimumMargins(int, int, int, int))); | |
242 | connect(m_minMargins, SIGNAL(leftChanged(int, int, int, int)), this, SLOT(changeMinimumMargins(int, int, int, int))); |
|
254 | connect(m_minMargins, SIGNAL(leftChanged(int, int, int, int)), this, SLOT(changeMinimumMargins(int, int, int, int))); | |
243 | connect(m_minMargins, SIGNAL(rightChanged(int, int, int, int)), this, SLOT(changeMinimumMargins(int, int, int, int))); |
|
255 | connect(m_minMargins, SIGNAL(rightChanged(int, int, int, int)), this, SLOT(changeMinimumMargins(int, int, int, int))); | |
|
256 | connect(m_chart->d_ptr->m_dataset, SIGNAL(seriesAdded(QAbstractSeries *, Domain *)), this, SLOT(handleSeriesAdded(QAbstractSeries *, Domain *))); | |||
|
257 | connect(m_chart->d_ptr->m_dataset, SIGNAL(seriesRemoved(QAbstractSeries *)), this, SIGNAL(seriesRemoved(QAbstractSeries *))); | |||
|
258 | } | |||
|
259 | ||||
|
260 | void DeclarativeChart::handleSeriesAdded(QAbstractSeries *series, Domain *domain) | |||
|
261 | { | |||
|
262 | Q_UNUSED(domain) | |||
|
263 | emit seriesAdded(series); | |||
244 | } |
|
264 | } | |
245 |
|
265 | |||
246 | void DeclarativeChart::changeMinimumMargins(int top, int bottom, int left, int right) |
|
266 | void DeclarativeChart::changeMinimumMargins(int top, int bottom, int left, int right) | |
247 | { |
|
267 | { | |
248 | m_chart->setMargins(QMargins(left, top, right, bottom)); |
|
268 | m_chart->setMargins(QMargins(left, top, right, bottom)); | |
249 | emit minimumMarginsChanged(); |
|
269 | emit minimumMarginsChanged(); | |
250 | emit plotAreaChanged(m_chart->plotArea()); |
|
270 | emit plotAreaChanged(m_chart->plotArea()); | |
251 | } |
|
271 | } | |
252 |
|
272 | |||
253 | DeclarativeChart::~DeclarativeChart() |
|
273 | DeclarativeChart::~DeclarativeChart() | |
254 | { |
|
274 | { | |
255 | delete m_chart; |
|
275 | delete m_chart; | |
256 | } |
|
276 | } | |
257 |
|
277 | |||
258 | void DeclarativeChart::childEvent(QChildEvent *event) |
|
278 | void DeclarativeChart::childEvent(QChildEvent *event) | |
259 | { |
|
279 | { | |
260 | if (event->type() == QEvent::ChildAdded) { |
|
280 | if (event->type() == QEvent::ChildAdded) { | |
261 | if (qobject_cast<QAbstractSeries *>(event->child())) { |
|
281 | if (qobject_cast<QAbstractSeries *>(event->child())) { | |
262 | m_chart->addSeries(qobject_cast<QAbstractSeries *>(event->child())); |
|
282 | m_chart->addSeries(qobject_cast<QAbstractSeries *>(event->child())); | |
263 | } |
|
283 | } | |
264 | } |
|
284 | } | |
265 | } |
|
285 | } | |
266 |
|
286 | |||
267 | void DeclarativeChart::componentComplete() |
|
287 | void DeclarativeChart::componentComplete() | |
268 | { |
|
288 | { | |
269 | foreach(QObject *child, children()) { |
|
289 | foreach(QObject *child, children()) { | |
270 | if (qobject_cast<QAbstractSeries *>(child)) { |
|
290 | if (qobject_cast<QAbstractSeries *>(child)) { | |
271 | // Add series to the chart |
|
291 | // Add series to the chart | |
272 | QAbstractSeries *series = qobject_cast<QAbstractSeries *>(child); |
|
292 | QAbstractSeries *series = qobject_cast<QAbstractSeries *>(child); | |
273 | m_chart->addSeries(series); |
|
293 | m_chart->addSeries(series); | |
274 |
|
294 | |||
275 | // Set optional user defined axes for the series and connect axis related signals |
|
295 | // Set optional user defined axes for the series and connect axis related signals | |
276 | if (qobject_cast<DeclarativeLineSeries *>(child)) { |
|
296 | if (qobject_cast<DeclarativeLineSeries *>(child)) { | |
277 | DeclarativeLineSeries *s = qobject_cast<DeclarativeLineSeries *>(child); |
|
297 | DeclarativeLineSeries *s = qobject_cast<DeclarativeLineSeries *>(child); | |
278 | connect(s, SIGNAL(axisXChanged(QAbstractAxis*)), this, SLOT(handleAxisXSet(QAbstractAxis*))); |
|
298 | connect(s, SIGNAL(axisXChanged(QAbstractAxis*)), this, SLOT(handleAxisXSet(QAbstractAxis*))); | |
279 | connect(s, SIGNAL(axisYChanged(QAbstractAxis*)), this, SLOT(handleAxisYSet(QAbstractAxis*))); |
|
299 | connect(s, SIGNAL(axisYChanged(QAbstractAxis*)), this, SLOT(handleAxisYSet(QAbstractAxis*))); | |
280 | setAxisX(s->axisX(), s); |
|
300 | setAxisX(s->axisX(), s); | |
281 | setAxisY(s->axisY(), s); |
|
301 | setAxisY(s->axisY(), s); | |
282 | } else if (qobject_cast<DeclarativeSplineSeries *>(child)) { |
|
302 | } else if (qobject_cast<DeclarativeSplineSeries *>(child)) { | |
283 | DeclarativeSplineSeries *s = qobject_cast<DeclarativeSplineSeries *>(child); |
|
303 | DeclarativeSplineSeries *s = qobject_cast<DeclarativeSplineSeries *>(child); | |
284 | connect(s, SIGNAL(axisXChanged(QAbstractAxis*)), this, SLOT(handleAxisXSet(QAbstractAxis*))); |
|
304 | connect(s, SIGNAL(axisXChanged(QAbstractAxis*)), this, SLOT(handleAxisXSet(QAbstractAxis*))); | |
285 | connect(s, SIGNAL(axisYChanged(QAbstractAxis*)), this, SLOT(handleAxisYSet(QAbstractAxis*))); |
|
305 | connect(s, SIGNAL(axisYChanged(QAbstractAxis*)), this, SLOT(handleAxisYSet(QAbstractAxis*))); | |
286 | setAxisX(s->axisX(), s); |
|
306 | setAxisX(s->axisX(), s); | |
287 | setAxisY(s->axisY(), s); |
|
307 | setAxisY(s->axisY(), s); | |
288 | } else if (qobject_cast<DeclarativeScatterSeries *>(child)) { |
|
308 | } else if (qobject_cast<DeclarativeScatterSeries *>(child)) { | |
289 | DeclarativeScatterSeries *s = qobject_cast<DeclarativeScatterSeries *>(child); |
|
309 | DeclarativeScatterSeries *s = qobject_cast<DeclarativeScatterSeries *>(child); | |
290 | connect(s, SIGNAL(axisXChanged(QAbstractAxis*)), this, SLOT(handleAxisXSet(QAbstractAxis*))); |
|
310 | connect(s, SIGNAL(axisXChanged(QAbstractAxis*)), this, SLOT(handleAxisXSet(QAbstractAxis*))); | |
291 | connect(s, SIGNAL(axisYChanged(QAbstractAxis*)), this, SLOT(handleAxisYSet(QAbstractAxis*))); |
|
311 | connect(s, SIGNAL(axisYChanged(QAbstractAxis*)), this, SLOT(handleAxisYSet(QAbstractAxis*))); | |
292 | setAxisX(s->axisX(), s); |
|
312 | setAxisX(s->axisX(), s); | |
293 | setAxisY(s->axisY(), s); |
|
313 | setAxisY(s->axisY(), s); | |
294 | } else if (qobject_cast<DeclarativeAreaSeries *>(child)) { |
|
314 | } else if (qobject_cast<DeclarativeAreaSeries *>(child)) { | |
295 | DeclarativeAreaSeries *s = qobject_cast<DeclarativeAreaSeries *>(child); |
|
315 | DeclarativeAreaSeries *s = qobject_cast<DeclarativeAreaSeries *>(child); | |
296 | connect(s, SIGNAL(axisXChanged(QAbstractAxis*)), this, SLOT(handleAxisXSet(QAbstractAxis*))); |
|
316 | connect(s, SIGNAL(axisXChanged(QAbstractAxis*)), this, SLOT(handleAxisXSet(QAbstractAxis*))); | |
297 | connect(s, SIGNAL(axisYChanged(QAbstractAxis*)), this, SLOT(handleAxisYSet(QAbstractAxis*))); |
|
317 | connect(s, SIGNAL(axisYChanged(QAbstractAxis*)), this, SLOT(handleAxisYSet(QAbstractAxis*))); | |
298 | setAxisX(s->axisX(), s); |
|
318 | setAxisX(s->axisX(), s); | |
299 | setAxisY(s->axisY(), s); |
|
319 | setAxisY(s->axisY(), s); | |
300 | } else if (qobject_cast<DeclarativeBarSeries *>(child)) { |
|
320 | } else if (qobject_cast<DeclarativeBarSeries *>(child)) { | |
301 | DeclarativeBarSeries *s = qobject_cast<DeclarativeBarSeries *>(child); |
|
321 | DeclarativeBarSeries *s = qobject_cast<DeclarativeBarSeries *>(child); | |
302 | connect(s, SIGNAL(axisXChanged(QAbstractAxis*)), this, SLOT(handleAxisXSet(QAbstractAxis*))); |
|
322 | connect(s, SIGNAL(axisXChanged(QAbstractAxis*)), this, SLOT(handleAxisXSet(QAbstractAxis*))); | |
303 | connect(s, SIGNAL(axisYChanged(QAbstractAxis*)), this, SLOT(handleAxisYSet(QAbstractAxis*))); |
|
323 | connect(s, SIGNAL(axisYChanged(QAbstractAxis*)), this, SLOT(handleAxisYSet(QAbstractAxis*))); | |
304 | setAxisX(s->axisX(), s); |
|
324 | setAxisX(s->axisX(), s); | |
305 | setAxisY(s->axisY(), s); |
|
325 | setAxisY(s->axisY(), s); | |
306 | } else if (qobject_cast<DeclarativeStackedBarSeries *>(child)) { |
|
326 | } else if (qobject_cast<DeclarativeStackedBarSeries *>(child)) { | |
307 | DeclarativeStackedBarSeries *s = qobject_cast<DeclarativeStackedBarSeries *>(child); |
|
327 | DeclarativeStackedBarSeries *s = qobject_cast<DeclarativeStackedBarSeries *>(child); | |
308 | connect(s, SIGNAL(axisXChanged(QAbstractAxis*)), this, SLOT(handleAxisXSet(QAbstractAxis*))); |
|
328 | connect(s, SIGNAL(axisXChanged(QAbstractAxis*)), this, SLOT(handleAxisXSet(QAbstractAxis*))); | |
309 | connect(s, SIGNAL(axisYChanged(QAbstractAxis*)), this, SLOT(handleAxisYSet(QAbstractAxis*))); |
|
329 | connect(s, SIGNAL(axisYChanged(QAbstractAxis*)), this, SLOT(handleAxisYSet(QAbstractAxis*))); | |
310 | setAxisX(s->axisX(), s); |
|
330 | setAxisX(s->axisX(), s); | |
311 | setAxisY(s->axisY(), s); |
|
331 | setAxisY(s->axisY(), s); | |
312 | } else if (qobject_cast<DeclarativePercentBarSeries *>(child)) { |
|
332 | } else if (qobject_cast<DeclarativePercentBarSeries *>(child)) { | |
313 | DeclarativePercentBarSeries *s = qobject_cast<DeclarativePercentBarSeries *>(child); |
|
333 | DeclarativePercentBarSeries *s = qobject_cast<DeclarativePercentBarSeries *>(child); | |
314 | connect(s, SIGNAL(axisXChanged(QAbstractAxis*)), this, SLOT(handleAxisXSet(QAbstractAxis*))); |
|
334 | connect(s, SIGNAL(axisXChanged(QAbstractAxis*)), this, SLOT(handleAxisXSet(QAbstractAxis*))); | |
315 | connect(s, SIGNAL(axisYChanged(QAbstractAxis*)), this, SLOT(handleAxisYSet(QAbstractAxis*))); |
|
335 | connect(s, SIGNAL(axisYChanged(QAbstractAxis*)), this, SLOT(handleAxisYSet(QAbstractAxis*))); | |
316 | setAxisX(s->axisX(), s); |
|
336 | setAxisX(s->axisX(), s); | |
317 | setAxisY(s->axisY(), s); |
|
337 | setAxisY(s->axisY(), s); | |
318 | } else if (qobject_cast<DeclarativeHorizontalBarSeries *>(child)) { |
|
338 | } else if (qobject_cast<DeclarativeHorizontalBarSeries *>(child)) { | |
319 | DeclarativeHorizontalBarSeries *s = qobject_cast<DeclarativeHorizontalBarSeries *>(child); |
|
339 | DeclarativeHorizontalBarSeries *s = qobject_cast<DeclarativeHorizontalBarSeries *>(child); | |
320 | connect(s, SIGNAL(axisXChanged(QAbstractAxis*)), this, SLOT(handleAxisXSet(QAbstractAxis*))); |
|
340 | connect(s, SIGNAL(axisXChanged(QAbstractAxis*)), this, SLOT(handleAxisXSet(QAbstractAxis*))); | |
321 | connect(s, SIGNAL(axisYChanged(QAbstractAxis*)), this, SLOT(handleAxisYSet(QAbstractAxis*))); |
|
341 | connect(s, SIGNAL(axisYChanged(QAbstractAxis*)), this, SLOT(handleAxisYSet(QAbstractAxis*))); | |
322 | setAxisX(s->axisX(), s); |
|
342 | setAxisX(s->axisX(), s); | |
323 | setAxisY(s->axisY(), s); |
|
343 | setAxisY(s->axisY(), s); | |
324 | } else if (qobject_cast<DeclarativeHorizontalStackedBarSeries *>(child)) { |
|
344 | } else if (qobject_cast<DeclarativeHorizontalStackedBarSeries *>(child)) { | |
325 | DeclarativeHorizontalStackedBarSeries *s = qobject_cast<DeclarativeHorizontalStackedBarSeries *>(child); |
|
345 | DeclarativeHorizontalStackedBarSeries *s = qobject_cast<DeclarativeHorizontalStackedBarSeries *>(child); | |
326 | connect(s, SIGNAL(axisXChanged(QAbstractAxis*)), this, SLOT(handleAxisXSet(QAbstractAxis*))); |
|
346 | connect(s, SIGNAL(axisXChanged(QAbstractAxis*)), this, SLOT(handleAxisXSet(QAbstractAxis*))); | |
327 | connect(s, SIGNAL(axisYChanged(QAbstractAxis*)), this, SLOT(handleAxisYSet(QAbstractAxis*))); |
|
347 | connect(s, SIGNAL(axisYChanged(QAbstractAxis*)), this, SLOT(handleAxisYSet(QAbstractAxis*))); | |
328 | setAxisX(s->axisX(), s); |
|
348 | setAxisX(s->axisX(), s); | |
329 | setAxisY(s->axisY(), s); |
|
349 | setAxisY(s->axisY(), s); | |
330 | } else if (qobject_cast<DeclarativeHorizontalPercentBarSeries *>(child)) { |
|
350 | } else if (qobject_cast<DeclarativeHorizontalPercentBarSeries *>(child)) { | |
331 | DeclarativeHorizontalPercentBarSeries *s = qobject_cast<DeclarativeHorizontalPercentBarSeries *>(child); |
|
351 | DeclarativeHorizontalPercentBarSeries *s = qobject_cast<DeclarativeHorizontalPercentBarSeries *>(child); | |
332 | connect(s, SIGNAL(axisXChanged(QAbstractAxis*)), this, SLOT(handleAxisXSet(QAbstractAxis*))); |
|
352 | connect(s, SIGNAL(axisXChanged(QAbstractAxis*)), this, SLOT(handleAxisXSet(QAbstractAxis*))); | |
333 | connect(s, SIGNAL(axisYChanged(QAbstractAxis*)), this, SLOT(handleAxisYSet(QAbstractAxis*))); |
|
353 | connect(s, SIGNAL(axisYChanged(QAbstractAxis*)), this, SLOT(handleAxisYSet(QAbstractAxis*))); | |
334 | setAxisX(s->axisX(), s); |
|
354 | setAxisX(s->axisX(), s); | |
335 | setAxisY(s->axisY(), s); |
|
355 | setAxisY(s->axisY(), s); | |
336 | } |
|
356 | } | |
337 | } |
|
357 | } | |
338 | } |
|
358 | } | |
339 |
|
359 | |||
340 | // Create the missing axes for the series that cannot be painted without axes |
|
360 | // Create the missing axes for the series that cannot be painted without axes | |
341 | foreach (QAbstractSeries *chartSeries, m_chart->series()) |
|
361 | foreach (QAbstractSeries *chartSeries, m_chart->series()) | |
342 | createDefaultAxes(chartSeries); |
|
362 | createDefaultAxes(chartSeries); | |
343 |
|
363 | |||
344 | QDeclarativeItem::componentComplete(); |
|
364 | QDeclarativeItem::componentComplete(); | |
345 | } |
|
365 | } | |
346 |
|
366 | |||
347 | void DeclarativeChart::handleAxisXSet(QAbstractAxis* axis) |
|
367 | void DeclarativeChart::handleAxisXSet(QAbstractAxis* axis) | |
348 | { |
|
368 | { | |
349 | // qDebug() << "DeclarativeChart::handleAxisXSet" << sender() << axis; |
|
369 | // qDebug() << "DeclarativeChart::handleAxisXSet" << sender() << axis; | |
350 | if (axis && qobject_cast<QAbstractSeries *>(sender())) |
|
370 | if (axis && qobject_cast<QAbstractSeries *>(sender())) | |
351 | m_chart->setAxisX(axis, qobject_cast<QAbstractSeries *>(sender())); |
|
371 | m_chart->setAxisX(axis, qobject_cast<QAbstractSeries *>(sender())); | |
352 | else |
|
372 | else | |
353 | qWarning() << "Trying to set axisX to null."; |
|
373 | qWarning() << "Trying to set axisX to null."; | |
354 | } |
|
374 | } | |
355 |
|
375 | |||
356 | void DeclarativeChart::handleAxisYSet(QAbstractAxis* axis) |
|
376 | void DeclarativeChart::handleAxisYSet(QAbstractAxis* axis) | |
357 | { |
|
377 | { | |
358 | // qDebug() << "DeclarativeChart::handleAxisYSet" << sender() << axis; |
|
378 | // qDebug() << "DeclarativeChart::handleAxisYSet" << sender() << axis; | |
359 | if (axis && qobject_cast<QAbstractSeries *>(sender())) |
|
379 | if (axis && qobject_cast<QAbstractSeries *>(sender())) | |
360 | m_chart->setAxisY(axis, qobject_cast<QAbstractSeries *>(sender())); |
|
380 | m_chart->setAxisY(axis, qobject_cast<QAbstractSeries *>(sender())); | |
361 | else |
|
381 | else | |
362 | qWarning() << "Trying to set axisY to null."; |
|
382 | qWarning() << "Trying to set axisY to null."; | |
363 | } |
|
383 | } | |
364 |
|
384 | |||
365 | void DeclarativeChart::geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) |
|
385 | void DeclarativeChart::geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) | |
366 | { |
|
386 | { | |
367 | // qDebug() << "DeclarativeChart::geometryChanged" << newGeometry.width() << newGeometry.height(); |
|
387 | // qDebug() << "DeclarativeChart::geometryChanged" << newGeometry.width() << newGeometry.height(); | |
368 | if (newGeometry.isValid()) { |
|
388 | if (newGeometry.isValid()) { | |
369 | if (newGeometry.width() > 0 && newGeometry.height() > 0) { |
|
389 | if (newGeometry.width() > 0 && newGeometry.height() > 0) { | |
370 | m_chart->resize(newGeometry.width(), newGeometry.height()); |
|
390 | m_chart->resize(newGeometry.width(), newGeometry.height()); | |
371 | } |
|
391 | } | |
372 | } |
|
392 | } | |
373 | QDeclarativeItem::geometryChanged(newGeometry, oldGeometry); |
|
393 | QDeclarativeItem::geometryChanged(newGeometry, oldGeometry); | |
374 |
|
394 | |||
375 | // It would be better to trigger the plotAreaChanged signal from QChart::plotAreaChanged or |
|
395 | // It would be better to trigger the plotAreaChanged signal from QChart::plotAreaChanged or | |
376 | // similar. Since that kind of a signal is not clearly needed in the C++ API the work-around is |
|
396 | // similar. Since that kind of a signal is not clearly needed in the C++ API the work-around is | |
377 | // to implement it here for the QML API purposes. |
|
397 | // to implement it here for the QML API purposes. | |
378 | emit plotAreaChanged(m_chart->plotArea()); |
|
398 | emit plotAreaChanged(m_chart->plotArea()); | |
379 | } |
|
399 | } | |
380 |
|
400 | |||
381 | void DeclarativeChart::setTheme(DeclarativeChart::Theme theme) |
|
401 | void DeclarativeChart::setTheme(DeclarativeChart::Theme theme) | |
382 | { |
|
402 | { | |
383 | QChart::ChartTheme chartTheme = (QChart::ChartTheme) theme; |
|
403 | QChart::ChartTheme chartTheme = (QChart::ChartTheme) theme; | |
384 | if (chartTheme != m_chart->theme()) |
|
404 | if (chartTheme != m_chart->theme()) | |
385 | m_chart->setTheme(chartTheme); |
|
405 | m_chart->setTheme(chartTheme); | |
386 | } |
|
406 | } | |
387 |
|
407 | |||
388 | DeclarativeChart::Theme DeclarativeChart::theme() |
|
408 | DeclarativeChart::Theme DeclarativeChart::theme() | |
389 | { |
|
409 | { | |
390 | return (DeclarativeChart::Theme) m_chart->theme(); |
|
410 | return (DeclarativeChart::Theme) m_chart->theme(); | |
391 | } |
|
411 | } | |
392 |
|
412 | |||
393 | void DeclarativeChart::setAnimationOptions(DeclarativeChart::Animation animations) |
|
413 | void DeclarativeChart::setAnimationOptions(DeclarativeChart::Animation animations) | |
394 | { |
|
414 | { | |
395 | QChart::AnimationOption animationOptions = (QChart::AnimationOption) animations; |
|
415 | QChart::AnimationOption animationOptions = (QChart::AnimationOption) animations; | |
396 | if (animationOptions != m_chart->animationOptions()) |
|
416 | if (animationOptions != m_chart->animationOptions()) | |
397 | m_chart->setAnimationOptions(animationOptions); |
|
417 | m_chart->setAnimationOptions(animationOptions); | |
398 | } |
|
418 | } | |
399 |
|
419 | |||
400 | DeclarativeChart::Animation DeclarativeChart::animationOptions() |
|
420 | DeclarativeChart::Animation DeclarativeChart::animationOptions() | |
401 | { |
|
421 | { | |
402 | if (m_chart->animationOptions().testFlag(QChart::AllAnimations)) |
|
422 | if (m_chart->animationOptions().testFlag(QChart::AllAnimations)) | |
403 | return DeclarativeChart::AllAnimations; |
|
423 | return DeclarativeChart::AllAnimations; | |
404 | else if (m_chart->animationOptions().testFlag(QChart::GridAxisAnimations)) |
|
424 | else if (m_chart->animationOptions().testFlag(QChart::GridAxisAnimations)) | |
405 | return DeclarativeChart::GridAxisAnimations; |
|
425 | return DeclarativeChart::GridAxisAnimations; | |
406 | else if (m_chart->animationOptions().testFlag(QChart::SeriesAnimations)) |
|
426 | else if (m_chart->animationOptions().testFlag(QChart::SeriesAnimations)) | |
407 | return DeclarativeChart::SeriesAnimations; |
|
427 | return DeclarativeChart::SeriesAnimations; | |
408 | else |
|
428 | else | |
409 | return DeclarativeChart::NoAnimation; |
|
429 | return DeclarativeChart::NoAnimation; | |
410 | } |
|
430 | } | |
411 |
|
431 | |||
412 | void DeclarativeChart::setTitle(QString title) |
|
432 | void DeclarativeChart::setTitle(QString title) | |
413 | { |
|
433 | { | |
414 | if (title != m_chart->title()) |
|
434 | if (title != m_chart->title()) | |
415 | m_chart->setTitle(title); |
|
435 | m_chart->setTitle(title); | |
416 | } |
|
436 | } | |
417 | QString DeclarativeChart::title() |
|
437 | QString DeclarativeChart::title() | |
418 | { |
|
438 | { | |
419 | return m_chart->title(); |
|
439 | return m_chart->title(); | |
420 | } |
|
440 | } | |
421 |
|
441 | |||
422 | QAbstractAxis *DeclarativeChart::axisX(QAbstractSeries *series) |
|
442 | QAbstractAxis *DeclarativeChart::axisX(QAbstractSeries *series) | |
423 | { |
|
443 | { | |
424 | return m_chart->axisX(series); |
|
444 | return m_chart->axisX(series); | |
425 | } |
|
445 | } | |
426 |
|
446 | |||
427 | QAbstractAxis *DeclarativeChart::axisY(QAbstractSeries *series) |
|
447 | QAbstractAxis *DeclarativeChart::axisY(QAbstractSeries *series) | |
428 | { |
|
448 | { | |
429 | return m_chart->axisY(series); |
|
449 | return m_chart->axisY(series); | |
430 | } |
|
450 | } | |
431 |
|
451 | |||
432 | QLegend *DeclarativeChart::legend() |
|
452 | QLegend *DeclarativeChart::legend() | |
433 | { |
|
453 | { | |
434 | return m_chart->legend(); |
|
454 | return m_chart->legend(); | |
435 | } |
|
455 | } | |
436 |
|
456 | |||
437 | void DeclarativeChart::setTitleColor(QColor color) |
|
457 | void DeclarativeChart::setTitleColor(QColor color) | |
438 | { |
|
458 | { | |
439 | QBrush b = m_chart->titleBrush(); |
|
459 | QBrush b = m_chart->titleBrush(); | |
440 | if (color != b.color()) { |
|
460 | if (color != b.color()) { | |
441 | b.setColor(color); |
|
461 | b.setColor(color); | |
442 | m_chart->setTitleBrush(b); |
|
462 | m_chart->setTitleBrush(b); | |
443 | emit titleColorChanged(color); |
|
463 | emit titleColorChanged(color); | |
444 | } |
|
464 | } | |
445 | } |
|
465 | } | |
446 |
|
466 | |||
447 | QFont DeclarativeChart::titleFont() const |
|
467 | QFont DeclarativeChart::titleFont() const | |
448 | { |
|
468 | { | |
449 | return m_chart->titleFont(); |
|
469 | return m_chart->titleFont(); | |
450 | } |
|
470 | } | |
451 |
|
471 | |||
452 | void DeclarativeChart::setTitleFont(const QFont& font) |
|
472 | void DeclarativeChart::setTitleFont(const QFont& font) | |
453 | { |
|
473 | { | |
454 | m_chart->setTitleFont(font); |
|
474 | m_chart->setTitleFont(font); | |
455 | } |
|
475 | } | |
456 |
|
476 | |||
457 | QColor DeclarativeChart::titleColor() |
|
477 | QColor DeclarativeChart::titleColor() | |
458 | { |
|
478 | { | |
459 | return m_chart->titleBrush().color(); |
|
479 | return m_chart->titleBrush().color(); | |
460 | } |
|
480 | } | |
461 |
|
481 | |||
462 | void DeclarativeChart::setBackgroundColor(QColor color) |
|
482 | void DeclarativeChart::setBackgroundColor(QColor color) | |
463 | { |
|
483 | { | |
464 | QBrush b = m_chart->backgroundBrush(); |
|
484 | QBrush b = m_chart->backgroundBrush(); | |
465 | if (b.style() != Qt::SolidPattern || color != b.color()) { |
|
485 | if (b.style() != Qt::SolidPattern || color != b.color()) { | |
466 | b.setStyle(Qt::SolidPattern); |
|
486 | b.setStyle(Qt::SolidPattern); | |
467 | b.setColor(color); |
|
487 | b.setColor(color); | |
468 | m_chart->setBackgroundBrush(b); |
|
488 | m_chart->setBackgroundBrush(b); | |
469 | emit backgroundColorChanged(); |
|
489 | emit backgroundColorChanged(); | |
470 | } |
|
490 | } | |
471 | } |
|
491 | } | |
472 |
|
492 | |||
473 | QColor DeclarativeChart::backgroundColor() |
|
493 | QColor DeclarativeChart::backgroundColor() | |
474 | { |
|
494 | { | |
475 | return m_chart->backgroundBrush().color(); |
|
495 | return m_chart->backgroundBrush().color(); | |
476 | } |
|
496 | } | |
477 |
|
497 | |||
478 | int DeclarativeChart::count() |
|
498 | int DeclarativeChart::count() | |
479 | { |
|
499 | { | |
480 | return m_chart->series().count(); |
|
500 | return m_chart->series().count(); | |
481 | } |
|
501 | } | |
482 |
|
502 | |||
483 | void DeclarativeChart::setDropShadowEnabled(bool enabled) |
|
503 | void DeclarativeChart::setDropShadowEnabled(bool enabled) | |
484 | { |
|
504 | { | |
485 | if (enabled != m_chart->isDropShadowEnabled()) { |
|
505 | if (enabled != m_chart->isDropShadowEnabled()) { | |
486 | m_chart->setDropShadowEnabled(enabled); |
|
506 | m_chart->setDropShadowEnabled(enabled); | |
487 | dropShadowEnabledChanged(enabled); |
|
507 | dropShadowEnabledChanged(enabled); | |
488 | } |
|
508 | } | |
489 | } |
|
509 | } | |
490 |
|
510 | |||
491 | bool DeclarativeChart::dropShadowEnabled() |
|
511 | bool DeclarativeChart::dropShadowEnabled() | |
492 | { |
|
512 | { | |
493 | return m_chart->isDropShadowEnabled(); |
|
513 | return m_chart->isDropShadowEnabled(); | |
494 | } |
|
514 | } | |
495 |
|
515 | |||
496 | qreal DeclarativeChart::topMargin() |
|
516 | qreal DeclarativeChart::topMargin() | |
497 | { |
|
517 | { | |
498 | qWarning() << "ChartView.topMargin is deprecated. Use minimumMargins and plotArea instead."; |
|
518 | qWarning() << "ChartView.topMargin is deprecated. Use minimumMargins and plotArea instead."; | |
499 | return m_chart->plotArea().top(); |
|
519 | return m_chart->plotArea().top(); | |
500 | } |
|
520 | } | |
501 |
|
521 | |||
502 | qreal DeclarativeChart::bottomMargin() |
|
522 | qreal DeclarativeChart::bottomMargin() | |
503 | { |
|
523 | { | |
504 |
|
524 | |||
505 | qWarning() << "ChartView.bottomMargin is deprecated. Use minimumMargins and plotArea instead."; |
|
525 | qWarning() << "ChartView.bottomMargin is deprecated. Use minimumMargins and plotArea instead."; | |
506 | return m_chart->plotArea().bottom(); |
|
526 | return m_chart->plotArea().bottom(); | |
507 | } |
|
527 | } | |
508 |
|
528 | |||
509 | qreal DeclarativeChart::leftMargin() |
|
529 | qreal DeclarativeChart::leftMargin() | |
510 | { |
|
530 | { | |
511 | qWarning() << "ChartView.leftMargin is deprecated. Use minimumMargins and plotArea instead."; |
|
531 | qWarning() << "ChartView.leftMargin is deprecated. Use minimumMargins and plotArea instead."; | |
512 | return m_chart->plotArea().left(); |
|
532 | return m_chart->plotArea().left(); | |
513 | } |
|
533 | } | |
514 |
|
534 | |||
515 | qreal DeclarativeChart::rightMargin() |
|
535 | qreal DeclarativeChart::rightMargin() | |
516 | { |
|
536 | { | |
517 | qWarning() << "ChartView.rightMargin is deprecated. Use minimumMargins and plotArea instead."; |
|
537 | qWarning() << "ChartView.rightMargin is deprecated. Use minimumMargins and plotArea instead."; | |
518 | return m_chart->plotArea().right(); |
|
538 | return m_chart->plotArea().right(); | |
519 | } |
|
539 | } | |
520 |
|
540 | |||
521 | void DeclarativeChart::zoom(qreal factor) |
|
541 | void DeclarativeChart::zoom(qreal factor) | |
522 | { |
|
542 | { | |
523 | m_chart->zoom(factor); |
|
543 | m_chart->zoom(factor); | |
524 | } |
|
544 | } | |
525 |
|
545 | |||
526 | void DeclarativeChart::scrollLeft(qreal pixels) |
|
546 | void DeclarativeChart::scrollLeft(qreal pixels) | |
527 | { |
|
547 | { | |
528 | m_chart->scroll(-pixels, 0); |
|
548 | m_chart->scroll(-pixels, 0); | |
529 | } |
|
549 | } | |
530 |
|
550 | |||
531 | void DeclarativeChart::scrollRight(qreal pixels) |
|
551 | void DeclarativeChart::scrollRight(qreal pixels) | |
532 | { |
|
552 | { | |
533 | m_chart->scroll(pixels, 0); |
|
553 | m_chart->scroll(pixels, 0); | |
534 | } |
|
554 | } | |
535 |
|
555 | |||
536 | void DeclarativeChart::scrollUp(qreal pixels) |
|
556 | void DeclarativeChart::scrollUp(qreal pixels) | |
537 | { |
|
557 | { | |
538 | m_chart->scroll(0, pixels); |
|
558 | m_chart->scroll(0, pixels); | |
539 | } |
|
559 | } | |
540 |
|
560 | |||
541 | void DeclarativeChart::scrollDown(qreal pixels) |
|
561 | void DeclarativeChart::scrollDown(qreal pixels) | |
542 | { |
|
562 | { | |
543 | m_chart->scroll(0, -pixels); |
|
563 | m_chart->scroll(0, -pixels); | |
544 | } |
|
564 | } | |
545 |
|
565 | |||
546 | QAbstractSeries *DeclarativeChart::series(int index) |
|
566 | QAbstractSeries *DeclarativeChart::series(int index) | |
547 | { |
|
567 | { | |
548 | if (index < m_chart->series().count()) { |
|
568 | if (index < m_chart->series().count()) { | |
549 | return m_chart->series().at(index); |
|
569 | return m_chart->series().at(index); | |
550 | } |
|
570 | } | |
551 | return 0; |
|
571 | return 0; | |
552 | } |
|
572 | } | |
553 |
|
573 | |||
554 | QAbstractSeries *DeclarativeChart::series(QString seriesName) |
|
574 | QAbstractSeries *DeclarativeChart::series(QString seriesName) | |
555 | { |
|
575 | { | |
556 | foreach(QAbstractSeries *series, m_chart->series()) { |
|
576 | foreach(QAbstractSeries *series, m_chart->series()) { | |
557 | if (series->name() == seriesName) |
|
577 | if (series->name() == seriesName) | |
558 | return series; |
|
578 | return series; | |
559 | } |
|
579 | } | |
560 | return 0; |
|
580 | return 0; | |
561 | } |
|
581 | } | |
562 |
|
582 | |||
563 | QAbstractSeries *DeclarativeChart::createSeries(DeclarativeChart::SeriesType type, QString name) |
|
583 | QAbstractSeries *DeclarativeChart::createSeries(DeclarativeChart::SeriesType type, QString name) | |
564 | { |
|
584 | { | |
565 | return createSeries(type, name, 0, 0); |
|
585 | return createSeries(type, name, 0, 0); | |
566 | } |
|
586 | } | |
567 |
|
587 | |||
568 | QAbstractSeries *DeclarativeChart::createSeries(DeclarativeChart::SeriesType type, QString name, QAbstractAxis *axisX, QAbstractAxis *axisY) |
|
588 | QAbstractSeries *DeclarativeChart::createSeries(DeclarativeChart::SeriesType type, QString name, QAbstractAxis *axisX, QAbstractAxis *axisY) | |
569 | { |
|
589 | { | |
570 | QAbstractSeries *series = 0; |
|
590 | QAbstractSeries *series = 0; | |
571 |
|
591 | |||
572 | switch (type) { |
|
592 | switch (type) { | |
573 | case DeclarativeChart::SeriesTypeLine: |
|
593 | case DeclarativeChart::SeriesTypeLine: | |
574 | series = new DeclarativeLineSeries(); |
|
594 | series = new DeclarativeLineSeries(); | |
575 | break; |
|
595 | break; | |
576 | case DeclarativeChart::SeriesTypeArea: |
|
596 | case DeclarativeChart::SeriesTypeArea: | |
577 | series = new DeclarativeAreaSeries(); |
|
597 | series = new DeclarativeAreaSeries(); | |
578 | break; |
|
598 | break; | |
579 | case DeclarativeChart::SeriesTypeStackedBar: |
|
599 | case DeclarativeChart::SeriesTypeStackedBar: | |
580 | series = new DeclarativeStackedBarSeries(); |
|
600 | series = new DeclarativeStackedBarSeries(); | |
581 | break; |
|
601 | break; | |
582 | case DeclarativeChart::SeriesTypePercentBar: |
|
602 | case DeclarativeChart::SeriesTypePercentBar: | |
583 | series = new DeclarativePercentBarSeries(); |
|
603 | series = new DeclarativePercentBarSeries(); | |
584 | break; |
|
604 | break; | |
585 | case DeclarativeChart::SeriesTypeBar: |
|
605 | case DeclarativeChart::SeriesTypeBar: | |
586 | series = new DeclarativeBarSeries(); |
|
606 | series = new DeclarativeBarSeries(); | |
587 | break; |
|
607 | break; | |
588 | case DeclarativeChart::SeriesTypeHorizontalBar: |
|
608 | case DeclarativeChart::SeriesTypeHorizontalBar: | |
589 | series = new DeclarativeHorizontalBarSeries(); |
|
609 | series = new DeclarativeHorizontalBarSeries(); | |
590 | break; |
|
610 | break; | |
591 | case DeclarativeChart::SeriesTypeHorizontalPercentBar: |
|
611 | case DeclarativeChart::SeriesTypeHorizontalPercentBar: | |
592 | series = new DeclarativeHorizontalPercentBarSeries(); |
|
612 | series = new DeclarativeHorizontalPercentBarSeries(); | |
593 | break; |
|
613 | break; | |
594 | case DeclarativeChart::SeriesTypeHorizontalStackedBar: |
|
614 | case DeclarativeChart::SeriesTypeHorizontalStackedBar: | |
595 | series = new DeclarativeHorizontalStackedBarSeries(); |
|
615 | series = new DeclarativeHorizontalStackedBarSeries(); | |
596 | break; |
|
616 | break; | |
597 | case DeclarativeChart::SeriesTypePie: |
|
617 | case DeclarativeChart::SeriesTypePie: | |
598 | series = new DeclarativePieSeries(); |
|
618 | series = new DeclarativePieSeries(); | |
599 | break; |
|
619 | break; | |
600 | case DeclarativeChart::SeriesTypeScatter: |
|
620 | case DeclarativeChart::SeriesTypeScatter: | |
601 | series = new DeclarativeScatterSeries(); |
|
621 | series = new DeclarativeScatterSeries(); | |
602 | break; |
|
622 | break; | |
603 | case DeclarativeChart::SeriesTypeSpline: |
|
623 | case DeclarativeChart::SeriesTypeSpline: | |
604 | series = new DeclarativeSplineSeries(); |
|
624 | series = new DeclarativeSplineSeries(); | |
605 | break; |
|
625 | break; | |
606 | default: |
|
626 | default: | |
607 | qWarning() << "Illegal series type"; |
|
627 | qWarning() << "Illegal series type"; | |
608 | } |
|
628 | } | |
609 |
|
629 | |||
610 | if (series) { |
|
630 | if (series) { | |
611 | series->setName(name); |
|
631 | series->setName(name); | |
612 | m_chart->addSeries(series); |
|
632 | m_chart->addSeries(series); | |
613 | // Set possible user defined axes |
|
633 | // Set possible user defined axes | |
614 | setAxisX(axisX, series); |
|
634 | setAxisX(axisX, series); | |
615 | setAxisY(axisY, series); |
|
635 | setAxisY(axisY, series); | |
616 | // Then create the missing axes |
|
636 | // Then create the missing axes | |
617 | createDefaultAxes(series); |
|
637 | createDefaultAxes(series); | |
618 | } |
|
638 | } | |
619 |
|
639 | |||
620 | return series; |
|
640 | return series; | |
621 | } |
|
641 | } | |
622 |
|
642 | |||
|
643 | void DeclarativeChart::removeSeries(QAbstractSeries *series) | |||
|
644 | { | |||
|
645 | if (series) | |||
|
646 | m_chart->removeSeries(series); | |||
|
647 | else | |||
|
648 | qWarning("removeSeries: cannot remove null"); | |||
|
649 | } | |||
|
650 | ||||
623 | void DeclarativeChart::setAxisX(QAbstractAxis *axis, QAbstractSeries *series) |
|
651 | void DeclarativeChart::setAxisX(QAbstractAxis *axis, QAbstractSeries *series) | |
624 | { |
|
652 | { | |
625 | if (axis) |
|
653 | if (axis) | |
626 | m_chart->setAxisX(axis, series); |
|
654 | m_chart->setAxisX(axis, series); | |
627 | } |
|
655 | } | |
628 |
|
656 | |||
629 | void DeclarativeChart::setAxisY(QAbstractAxis *axis, QAbstractSeries *series) |
|
657 | void DeclarativeChart::setAxisY(QAbstractAxis *axis, QAbstractSeries *series) | |
630 | { |
|
658 | { | |
631 | if (axis) |
|
659 | if (axis) | |
632 | m_chart->setAxisY(axis, series); |
|
660 | m_chart->setAxisY(axis, series); | |
633 | } |
|
661 | } | |
634 |
|
662 | |||
635 | void DeclarativeChart::createDefaultAxes() |
|
663 | void DeclarativeChart::createDefaultAxes() | |
636 | { |
|
664 | { | |
637 | qWarning() << "ChartView.createDefaultAxes() is deprecated. Axes are created automatically."; |
|
665 | qWarning() << "ChartView.createDefaultAxes() is deprecated. Axes are created automatically."; | |
638 | } |
|
666 | } | |
639 |
|
667 | |||
640 | void DeclarativeChart::createDefaultAxes(QAbstractSeries* series) |
|
668 | void DeclarativeChart::createDefaultAxes(QAbstractSeries* series) | |
641 | { |
|
669 | { | |
642 | foreach (QAbstractSeries *s, m_chart->series()) { |
|
670 | foreach (QAbstractSeries *s, m_chart->series()) { | |
643 | // If there is already an x axis of the correct type, re-use it |
|
671 | // If there is already an x axis of the correct type, re-use it | |
644 | if (!m_chart->axisX(series) && s != series && m_chart->axisX(s) |
|
672 | if (!m_chart->axisX(series) && s != series && m_chart->axisX(s) | |
645 | && m_chart->axisX(s)->type() == series->d_ptr->defaultAxisType(Qt::Horizontal)) |
|
673 | && m_chart->axisX(s)->type() == series->d_ptr->defaultAxisType(Qt::Horizontal)) | |
646 | m_chart->setAxisX(m_chart->axisX(s), series); |
|
674 | m_chart->setAxisX(m_chart->axisX(s), series); | |
647 |
|
675 | |||
648 | // If there is already a y axis of the correct type, re-use it |
|
676 | // If there is already a y axis of the correct type, re-use it | |
649 | if (!m_chart->axisY(series) && s != series && m_chart->axisY(s) |
|
677 | if (!m_chart->axisY(series) && s != series && m_chart->axisY(s) | |
650 | && m_chart->axisY(s)->type() == series->d_ptr->defaultAxisType(Qt::Vertical)) |
|
678 | && m_chart->axisY(s)->type() == series->d_ptr->defaultAxisType(Qt::Vertical)) | |
651 | m_chart->setAxisY(m_chart->axisY(s), series); |
|
679 | m_chart->setAxisY(m_chart->axisY(s), series); | |
652 | } |
|
680 | } | |
653 |
|
681 | |||
654 | // If no x axis of correct type was found, create a new x axis based of default axis type |
|
682 | // If no x axis of correct type was found, create a new x axis based of default axis type | |
655 | if (!m_chart->axisX(series)) { |
|
683 | if (!m_chart->axisX(series)) { | |
656 | switch (series->d_ptr->defaultAxisType(Qt::Horizontal)) { |
|
684 | switch (series->d_ptr->defaultAxisType(Qt::Horizontal)) { | |
657 | case QAbstractAxis::AxisTypeValue: |
|
685 | case QAbstractAxis::AxisTypeValue: | |
658 | m_chart->setAxisX(new QValueAxis(this), series); |
|
686 | m_chart->setAxisX(new QValueAxis(this), series); | |
659 | break; |
|
687 | break; | |
660 | case QAbstractAxis::AxisTypeBarCategory: |
|
688 | case QAbstractAxis::AxisTypeBarCategory: | |
661 | m_chart->setAxisX(new QBarCategoryAxis(this), series); |
|
689 | m_chart->setAxisX(new QBarCategoryAxis(this), series); | |
662 | break; |
|
690 | break; | |
663 | case QAbstractAxis::AxisTypeCategory: |
|
691 | case QAbstractAxis::AxisTypeCategory: | |
664 | m_chart->setAxisX(new QCategoryAxis(this), series); |
|
692 | m_chart->setAxisX(new QCategoryAxis(this), series); | |
665 | break; |
|
693 | break; | |
666 | #ifndef QT_ON_ARM |
|
694 | #ifndef QT_ON_ARM | |
667 | case QAbstractAxis::AxisTypeDateTime: |
|
695 | case QAbstractAxis::AxisTypeDateTime: | |
668 | m_chart->setAxisX(new QDateTimeAxis(this), series); |
|
696 | m_chart->setAxisX(new QDateTimeAxis(this), series); | |
669 | break; |
|
697 | break; | |
670 | #endif |
|
698 | #endif | |
671 | default: |
|
699 | default: | |
672 | // Do nothing, assume AxisTypeNoAxis |
|
700 | // Do nothing, assume AxisTypeNoAxis | |
673 | break; |
|
701 | break; | |
674 | } |
|
702 | } | |
675 | } |
|
703 | } | |
676 |
|
704 | |||
677 | // If no y axis of correct type was found, create a new y axis based of default axis type |
|
705 | // If no y axis of correct type was found, create a new y axis based of default axis type | |
678 | if (!m_chart->axisY(series)) { |
|
706 | if (!m_chart->axisY(series)) { | |
679 | switch (series->d_ptr->defaultAxisType(Qt::Vertical)) { |
|
707 | switch (series->d_ptr->defaultAxisType(Qt::Vertical)) { | |
680 | case QAbstractAxis::AxisTypeValue: |
|
708 | case QAbstractAxis::AxisTypeValue: | |
681 | m_chart->setAxisY(new QValueAxis(this), series); |
|
709 | m_chart->setAxisY(new QValueAxis(this), series); | |
682 | break; |
|
710 | break; | |
683 | case QAbstractAxis::AxisTypeBarCategory: |
|
711 | case QAbstractAxis::AxisTypeBarCategory: | |
684 | m_chart->setAxisY(new QBarCategoryAxis(this), series); |
|
712 | m_chart->setAxisY(new QBarCategoryAxis(this), series); | |
685 | break; |
|
713 | break; | |
686 | case QAbstractAxis::AxisTypeCategory: |
|
714 | case QAbstractAxis::AxisTypeCategory: | |
687 | m_chart->setAxisY(new QCategoryAxis(this), series); |
|
715 | m_chart->setAxisY(new QCategoryAxis(this), series); | |
688 | break; |
|
716 | break; | |
689 | #ifndef QT_ON_ARM |
|
717 | #ifndef QT_ON_ARM | |
690 | case QAbstractAxis::AxisTypeDateTime: |
|
718 | case QAbstractAxis::AxisTypeDateTime: | |
691 | m_chart->setAxisY(new QDateTimeAxis(this), series); |
|
719 | m_chart->setAxisY(new QDateTimeAxis(this), series); | |
692 | break; |
|
720 | break; | |
693 | #endif |
|
721 | #endif | |
694 | default: |
|
722 | default: | |
695 | // Do nothing, assume AxisTypeNoAxis |
|
723 | // Do nothing, assume AxisTypeNoAxis | |
696 | break; |
|
724 | break; | |
697 | } |
|
725 | } | |
698 | } |
|
726 | } | |
699 |
|
727 | |||
700 | //qDebug() << "axis for series" << series << "x:" << m_chart->axisX(series) << "y:" << m_chart->axisY(series); |
|
728 | //qDebug() << "axis for series" << series << "x:" << m_chart->axisX(series) << "y:" << m_chart->axisY(series); | |
701 | } |
|
729 | } | |
702 |
|
730 | |||
703 | #include "moc_declarativechart.cpp" |
|
731 | #include "moc_declarativechart.cpp" | |
704 |
|
732 | |||
705 | QTCOMMERCIALCHART_END_NAMESPACE |
|
733 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -1,166 +1,170 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2012 Digia Plc |
|
3 | ** Copyright (C) 2012 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
8 | ** |
|
8 | ** | |
9 | ** $QT_BEGIN_LICENSE$ |
|
9 | ** $QT_BEGIN_LICENSE$ | |
10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and Digia. |
|
13 | ** a written agreement between you and Digia. | |
14 | ** |
|
14 | ** | |
15 | ** If you have questions regarding the use of this file, please use |
|
15 | ** If you have questions regarding the use of this file, please use | |
16 | ** contact form at http://qt.digia.com |
|
16 | ** contact form at http://qt.digia.com | |
17 | ** $QT_END_LICENSE$ |
|
17 | ** $QT_END_LICENSE$ | |
18 | ** |
|
18 | ** | |
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 | #ifndef 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 | #ifdef QT5_QUICK_1 |
|
25 | #ifdef QT5_QUICK_1 | |
26 | #include <QtQuick1/QDeclarativeItem> |
|
26 | #include <QtQuick1/QDeclarativeItem> | |
27 | #else |
|
27 | #else | |
28 | #include <QtDeclarative/QDeclarativeItem> |
|
28 | #include <QtDeclarative/QDeclarativeItem> | |
29 | #endif |
|
29 | #endif | |
30 | #include "qchart.h" |
|
30 | #include "qchart.h" | |
31 |
|
31 | |||
32 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
32 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
33 |
|
33 | |||
34 | class DeclarativeMargins; |
|
34 | class DeclarativeMargins; | |
|
35 | class Domain; | |||
35 |
|
36 | |||
36 | class DeclarativeChart : public QDeclarativeItem |
|
37 | class DeclarativeChart : public QDeclarativeItem | |
37 | { |
|
38 | { | |
38 | Q_OBJECT |
|
39 | Q_OBJECT | |
39 | Q_PROPERTY(Theme theme READ theme WRITE setTheme) |
|
40 | Q_PROPERTY(Theme theme READ theme WRITE setTheme) | |
40 | Q_PROPERTY(Animation animationOptions READ animationOptions WRITE setAnimationOptions) |
|
41 | Q_PROPERTY(Animation animationOptions READ animationOptions WRITE setAnimationOptions) | |
41 | Q_PROPERTY(QString title READ title WRITE setTitle) |
|
42 | Q_PROPERTY(QString title READ title WRITE setTitle) | |
42 | Q_PROPERTY(QFont titleFont READ titleFont WRITE setTitleFont) |
|
43 | Q_PROPERTY(QFont titleFont READ titleFont WRITE setTitleFont) | |
43 | Q_PROPERTY(QColor titleColor READ titleColor WRITE setTitleColor NOTIFY titleColorChanged) |
|
44 | Q_PROPERTY(QColor titleColor READ titleColor WRITE setTitleColor NOTIFY titleColorChanged) | |
44 | Q_PROPERTY(QLegend *legend READ legend) |
|
45 | Q_PROPERTY(QLegend *legend READ legend) | |
45 | Q_PROPERTY(int count READ count) |
|
46 | Q_PROPERTY(int count READ count) | |
46 | Q_PROPERTY(QColor backgroundColor READ backgroundColor WRITE setBackgroundColor NOTIFY backgroundColorChanged) |
|
47 | Q_PROPERTY(QColor backgroundColor READ backgroundColor WRITE setBackgroundColor NOTIFY backgroundColorChanged) | |
47 | Q_PROPERTY(bool dropShadowEnabled READ dropShadowEnabled WRITE setDropShadowEnabled NOTIFY dropShadowEnabledChanged) |
|
48 | Q_PROPERTY(bool dropShadowEnabled READ dropShadowEnabled WRITE setDropShadowEnabled NOTIFY dropShadowEnabledChanged) | |
48 | Q_PROPERTY(qreal topMargin READ topMargin) |
|
49 | Q_PROPERTY(qreal topMargin READ topMargin) | |
49 | Q_PROPERTY(qreal bottomMargin READ bottomMargin) |
|
50 | Q_PROPERTY(qreal bottomMargin READ bottomMargin) | |
50 | Q_PROPERTY(qreal leftMargin READ leftMargin) |
|
51 | Q_PROPERTY(qreal leftMargin READ leftMargin) | |
51 | Q_PROPERTY(qreal rightMargin READ rightMargin) |
|
52 | Q_PROPERTY(qreal rightMargin READ rightMargin) | |
52 | Q_PROPERTY(DeclarativeMargins *minimumMargins READ minimumMargins NOTIFY minimumMarginsChanged REVISION 1) |
|
53 | Q_PROPERTY(DeclarativeMargins *minimumMargins READ minimumMargins NOTIFY minimumMarginsChanged REVISION 1) | |
53 | Q_PROPERTY(QRectF plotArea READ plotArea NOTIFY plotAreaChanged REVISION 1) |
|
54 | Q_PROPERTY(QRectF plotArea READ plotArea NOTIFY plotAreaChanged REVISION 1) | |
54 | Q_ENUMS(Animation) |
|
55 | Q_ENUMS(Animation) | |
55 | Q_ENUMS(Theme) |
|
56 | Q_ENUMS(Theme) | |
56 | Q_ENUMS(SeriesType) |
|
57 | Q_ENUMS(SeriesType) | |
57 |
|
58 | |||
58 | public: |
|
59 | public: | |
59 | // duplicating enums from QChart to make the QML api namings 1-to-1 with the C++ api |
|
60 | // duplicating enums from QChart to make the QML api namings 1-to-1 with the C++ api | |
60 | enum Theme { |
|
61 | enum Theme { | |
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 Animation { |
|
71 | enum Animation { | |
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 | enum SeriesType { |
|
78 | enum SeriesType { | |
78 | SeriesTypeLine, |
|
79 | SeriesTypeLine, | |
79 | SeriesTypeArea, |
|
80 | SeriesTypeArea, | |
80 | SeriesTypeBar, |
|
81 | SeriesTypeBar, | |
81 | SeriesTypeStackedBar, |
|
82 | SeriesTypeStackedBar, | |
82 | SeriesTypePercentBar, |
|
83 | SeriesTypePercentBar, | |
83 | SeriesTypePie, |
|
84 | SeriesTypePie, | |
84 | SeriesTypeScatter, |
|
85 | SeriesTypeScatter, | |
85 | SeriesTypeSpline, |
|
86 | SeriesTypeSpline, | |
86 | SeriesTypeHorizontalBar, |
|
87 | SeriesTypeHorizontalBar, | |
87 | SeriesTypeHorizontalStackedBar, |
|
88 | SeriesTypeHorizontalStackedBar, | |
88 | SeriesTypeHorizontalPercentBar |
|
89 | SeriesTypeHorizontalPercentBar | |
89 | }; |
|
90 | }; | |
90 |
|
91 | |||
91 | public: |
|
92 | public: | |
92 | DeclarativeChart(QDeclarativeItem *parent = 0); |
|
93 | DeclarativeChart(QDeclarativeItem *parent = 0); | |
93 | ~DeclarativeChart(); |
|
94 | ~DeclarativeChart(); | |
94 |
|
95 | |||
95 | public: // From QDeclarativeItem/QGraphicsItem |
|
96 | public: // From QDeclarativeItem/QGraphicsItem | |
96 | void childEvent(QChildEvent *event); |
|
97 | void childEvent(QChildEvent *event); | |
97 | void componentComplete(); |
|
98 | void componentComplete(); | |
98 | void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry); |
|
99 | void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry); | |
99 |
|
100 | |||
100 | public: |
|
101 | public: | |
101 | void setTheme(DeclarativeChart::Theme theme); |
|
102 | void setTheme(DeclarativeChart::Theme theme); | |
102 | DeclarativeChart::Theme theme(); |
|
103 | DeclarativeChart::Theme theme(); | |
103 | void setAnimationOptions(DeclarativeChart::Animation animations); |
|
104 | void setAnimationOptions(DeclarativeChart::Animation animations); | |
104 | DeclarativeChart::Animation animationOptions(); |
|
105 | DeclarativeChart::Animation animationOptions(); | |
105 | void setTitle(QString title); |
|
106 | void setTitle(QString title); | |
106 | QString title(); |
|
107 | QString title(); | |
107 | QLegend *legend(); |
|
108 | QLegend *legend(); | |
108 | QFont titleFont() const; |
|
109 | QFont titleFont() const; | |
109 | void setTitleFont(const QFont& font); |
|
110 | void setTitleFont(const QFont& font); | |
110 | void setTitleColor(QColor color); |
|
111 | void setTitleColor(QColor color); | |
111 | QColor titleColor(); |
|
112 | QColor titleColor(); | |
112 | void setBackgroundColor(QColor color); |
|
113 | void setBackgroundColor(QColor color); | |
113 | QColor backgroundColor(); |
|
114 | QColor backgroundColor(); | |
114 | int count(); |
|
115 | int count(); | |
115 | void setDropShadowEnabled(bool enabled); |
|
116 | void setDropShadowEnabled(bool enabled); | |
116 | bool dropShadowEnabled(); |
|
117 | bool dropShadowEnabled(); | |
117 | qreal topMargin(); |
|
118 | qreal topMargin(); | |
118 | qreal bottomMargin(); |
|
119 | qreal bottomMargin(); | |
119 | qreal leftMargin(); |
|
120 | qreal leftMargin(); | |
120 | qreal rightMargin(); |
|
121 | qreal rightMargin(); | |
121 | void createDefaultAxes(QAbstractSeries* series); |
|
122 | void createDefaultAxes(QAbstractSeries* series); | |
122 | DeclarativeMargins *minimumMargins() { return m_minMargins; } |
|
123 | DeclarativeMargins *minimumMargins() { return m_minMargins; } | |
123 | QRectF plotArea() { return m_chart->plotArea(); } |
|
124 | QRectF plotArea() { return m_chart->plotArea(); } | |
124 |
|
125 | |||
125 | public: |
|
126 | public: | |
126 | Q_INVOKABLE QAbstractSeries *series(int index); |
|
127 | Q_INVOKABLE QAbstractSeries *series(int index); | |
127 | Q_INVOKABLE QAbstractSeries *series(QString seriesName); |
|
128 | Q_INVOKABLE QAbstractSeries *series(QString seriesName); | |
128 | Q_INVOKABLE QAbstractSeries *createSeries(DeclarativeChart::SeriesType type, QString name = ""); |
|
129 | Q_INVOKABLE QAbstractSeries *createSeries(DeclarativeChart::SeriesType type, QString name = ""); | |
129 | Q_INVOKABLE QAbstractSeries *createSeries(DeclarativeChart::SeriesType type, QString name, QAbstractAxis *axisX, QAbstractAxis *axisY); |
|
130 | Q_INVOKABLE QAbstractSeries *createSeries(DeclarativeChart::SeriesType type, QString name, QAbstractAxis *axisX, QAbstractAxis *axisY); | |
130 |
Q_INVOKABLE void removeSeries(QAbstractSeries *series) |
|
131 | Q_INVOKABLE void removeSeries(QAbstractSeries *series); | |
131 | Q_INVOKABLE void removeAllSeries() { m_chart->removeAllSeries(); } |
|
132 | Q_INVOKABLE void removeAllSeries() { m_chart->removeAllSeries(); } | |
132 | Q_INVOKABLE void setAxisX(QAbstractAxis *axis, QAbstractSeries *series = 0); |
|
133 | Q_INVOKABLE void setAxisX(QAbstractAxis *axis, QAbstractSeries *series = 0); | |
133 | Q_INVOKABLE void setAxisY(QAbstractAxis *axis, QAbstractSeries *series = 0); |
|
134 | Q_INVOKABLE void setAxisY(QAbstractAxis *axis, QAbstractSeries *series = 0); | |
134 | Q_INVOKABLE void createDefaultAxes(); |
|
135 | Q_INVOKABLE void createDefaultAxes(); | |
135 | Q_INVOKABLE QAbstractAxis *axisX(QAbstractSeries *series = 0); |
|
136 | Q_INVOKABLE QAbstractAxis *axisX(QAbstractSeries *series = 0); | |
136 | Q_INVOKABLE QAbstractAxis *axisY(QAbstractSeries *series = 0); |
|
137 | Q_INVOKABLE QAbstractAxis *axisY(QAbstractSeries *series = 0); | |
137 | Q_INVOKABLE void zoom(qreal factor); |
|
138 | Q_INVOKABLE void zoom(qreal factor); | |
138 | Q_INVOKABLE void scrollLeft(qreal pixels); |
|
139 | Q_INVOKABLE void scrollLeft(qreal pixels); | |
139 | Q_INVOKABLE void scrollRight(qreal pixels); |
|
140 | Q_INVOKABLE void scrollRight(qreal pixels); | |
140 | Q_INVOKABLE void scrollUp(qreal pixels); |
|
141 | Q_INVOKABLE void scrollUp(qreal pixels); | |
141 | Q_INVOKABLE void scrollDown(qreal pixels); |
|
142 | Q_INVOKABLE void scrollDown(qreal pixels); | |
142 |
|
143 | |||
143 | Q_SIGNALS: |
|
144 | Q_SIGNALS: | |
144 | void axisLabelsChanged(); |
|
145 | void axisLabelsChanged(); | |
145 | void titleColorChanged(QColor color); |
|
146 | void titleColorChanged(QColor color); | |
146 | void backgroundColorChanged(); |
|
147 | void backgroundColorChanged(); | |
147 | void dropShadowEnabledChanged(bool enabled); |
|
148 | void dropShadowEnabledChanged(bool enabled); | |
148 | void minimumMarginsChanged(); |
|
149 | void minimumMarginsChanged(); | |
149 | void plotAreaChanged(QRectF plotArea); |
|
150 | void plotAreaChanged(QRectF plotArea); | |
|
151 | void seriesAdded(QAbstractSeries* series); | |||
|
152 | void seriesRemoved(QAbstractSeries* series); | |||
150 |
|
153 | |||
151 | public Q_SLOTS: |
|
154 | public Q_SLOTS: | |
152 | void changeMinimumMargins(int top, int bottom, int left, int right); |
|
155 | void changeMinimumMargins(int top, int bottom, int left, int right); | |
153 | void handleAxisXSet(QAbstractAxis *axis); |
|
156 | void handleAxisXSet(QAbstractAxis *axis); | |
154 | void handleAxisYSet(QAbstractAxis *axis); |
|
157 | void handleAxisYSet(QAbstractAxis *axis); | |
|
158 | void handleSeriesAdded(QAbstractSeries *series, Domain *domain); | |||
155 |
|
159 | |||
156 | private: |
|
160 | private: | |
157 | // Extending QChart with DeclarativeChart is not possible because QObject does not support |
|
161 | // Extending QChart with DeclarativeChart is not possible because QObject does not support | |
158 | // multi inheritance, so we now have a QChart as a member instead |
|
162 | // multi inheritance, so we now have a QChart as a member instead | |
159 | QChart *m_chart; |
|
163 | QChart *m_chart; | |
160 | //QMargins m_chartMargins; |
|
164 | //QMargins m_chartMargins; | |
161 | DeclarativeMargins *m_minMargins; |
|
165 | DeclarativeMargins *m_minMargins; | |
162 | }; |
|
166 | }; | |
163 |
|
167 | |||
164 | QTCOMMERCIALCHART_END_NAMESPACE |
|
168 | QTCOMMERCIALCHART_END_NAMESPACE | |
165 |
|
169 | |||
166 | #endif // DECLARATIVECHART_H |
|
170 | #endif // DECLARATIVECHART_H |
@@ -1,223 +1,244 | |||||
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 "qabstractseries.h" |
|
21 | #include "qabstractseries.h" | |
22 | #include "qabstractseries_p.h" |
|
22 | #include "qabstractseries_p.h" | |
23 | #include "chartdataset_p.h" |
|
23 | #include "chartdataset_p.h" | |
24 |
|
24 | |||
25 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
25 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
26 |
|
26 | |||
27 | /*! |
|
27 | /*! | |
28 | \class QAbstractSeries |
|
28 | \class QAbstractSeries | |
29 | \brief Base class for all QtCommercial Chart series. |
|
29 | \brief Base class for all QtCommercial Chart series. | |
30 | \mainclass |
|
30 | \mainclass | |
31 |
|
31 | |||
32 | Usually you use the series type specific inherited classes instead of the base class. |
|
32 | Usually you use the series type specific inherited classes instead of the base class. | |
33 | \sa QXYSeries, QLineSeries, QSplineSeries, QScatterSeries, QAreaSeries, QAbstractBarSeries, QStackedBarSeries, |
|
33 | \sa QXYSeries, QLineSeries, QSplineSeries, QScatterSeries, QAreaSeries, QAbstractBarSeries, QStackedBarSeries, | |
34 | QPercentBarSeries, QPieSeries |
|
34 | QPercentBarSeries, QPieSeries | |
35 | */ |
|
35 | */ | |
36 | /*! |
|
36 | /*! | |
37 | \qmlclass AbstractSeries |
|
37 | \qmlclass AbstractSeries | |
38 | AbstractSeries is the base class for all series. |
|
38 | AbstractSeries is the base class for all series. | |
39 | The class cannot be instantiated by the user. |
|
39 | The class cannot be instantiated by the user. | |
40 | */ |
|
40 | */ | |
41 |
|
41 | |||
42 | /*! |
|
42 | /*! | |
43 | \enum QAbstractSeries::SeriesType |
|
43 | \enum QAbstractSeries::SeriesType | |
44 |
|
44 | |||
45 | The type of the series object. |
|
45 | The type of the series object. | |
46 |
|
46 | |||
47 | \value SeriesTypeLine |
|
47 | \value SeriesTypeLine | |
48 | \value SeriesTypeArea |
|
48 | \value SeriesTypeArea | |
49 | \value SeriesTypeBar |
|
49 | \value SeriesTypeBar | |
50 | \value SeriesTypeStackedBar |
|
50 | \value SeriesTypeStackedBar | |
51 | \value SeriesTypePercentBar |
|
51 | \value SeriesTypePercentBar | |
52 | \value SeriesTypePie |
|
52 | \value SeriesTypePie | |
53 | \value SeriesTypeScatter |
|
53 | \value SeriesTypeScatter | |
54 | \value SeriesTypeSpline |
|
54 | \value SeriesTypeSpline | |
55 | \value SeriesTypeHorizontalBar |
|
55 | \value SeriesTypeHorizontalBar | |
56 | \value SeriesTypeHorizontalStackedBar |
|
56 | \value SeriesTypeHorizontalStackedBar | |
57 | \value SeriesTypeHorizontalPercentBar |
|
57 | \value SeriesTypeHorizontalPercentBar | |
58 | */ |
|
58 | */ | |
59 |
|
59 | |||
60 | /*! |
|
60 | /*! | |
61 | \property QAbstractSeries::type |
|
61 | \property QAbstractSeries::type | |
62 | The type of the series. |
|
62 | The type of the series. | |
63 | */ |
|
63 | */ | |
64 | /*! |
|
64 | /*! | |
65 | \qmlproperty ChartView.SeriesType AbstractSeries::type |
|
65 | \qmlproperty ChartView.SeriesType AbstractSeries::type | |
66 | The type of the series. |
|
66 | The type of the series. | |
67 | */ |
|
67 | */ | |
68 |
|
68 | |||
69 | /*! |
|
69 | /*! | |
70 | \property QAbstractSeries::name |
|
70 | \property QAbstractSeries::name | |
71 | \brief name of the series property. The name is shown in legend for QXYSeries. |
|
71 | \brief name of the series property. The name is shown in legend for QXYSeries. | |
72 | */ |
|
72 | */ | |
73 | /*! |
|
73 | /*! | |
74 | \qmlproperty string AbstractSeries::name |
|
74 | \qmlproperty string AbstractSeries::name | |
75 | Name of the series. The name is shown in legend for QXYSeries. |
|
75 | Name of the series. The name is shown in legend for QXYSeries. | |
76 | */ |
|
76 | */ | |
77 |
|
77 | |||
78 | /*! |
|
78 | /*! | |
79 | \fn void QAbstractSeries::nameChanged() |
|
79 | \fn void QAbstractSeries::nameChanged() | |
80 | This signal is emitted when the series name changes. |
|
80 | This signal is emitted when the series name changes. | |
81 | */ |
|
81 | */ | |
82 | /*! |
|
82 | /*! | |
83 | \qmlsignal AbstractSeries::onNameChanged() |
|
83 | \qmlsignal AbstractSeries::onNameChanged() | |
84 | This signal is emitted when the series name changes. |
|
84 | This signal is emitted when the series name changes. | |
85 | */ |
|
85 | */ | |
86 |
|
86 | |||
87 | /*! |
|
87 | /*! | |
88 | \property QAbstractSeries::visible |
|
88 | \property QAbstractSeries::visible | |
89 | \brief whether the series is visible or not; true by default. |
|
89 | \brief whether the series is visible or not; true by default. | |
90 | */ |
|
90 | */ | |
91 | /*! |
|
91 | /*! | |
92 |
\qmlproperty |
|
92 | \qmlproperty bool AbstractSeries::visible | |
93 | Visibility of the series. True by default. |
|
93 | Visibility of the series. True by default. | |
94 | */ |
|
94 | */ | |
95 |
|
95 | |||
96 | /*! |
|
96 | /*! | |
97 | \fn void QAbstractSeries::visibleChanged() |
|
97 | \fn void QAbstractSeries::visibleChanged() | |
98 | Emitted when the series visibility changes. |
|
98 | Emitted when the series visibility changes. | |
99 | */ |
|
99 | */ | |
100 | /*! |
|
100 | /*! | |
101 | \qmlsignal AbstractSeries::onVisibleChanged() |
|
101 | \qmlsignal AbstractSeries::onVisibleChanged() | |
102 | Emitted when the series visibility changes. |
|
102 | Emitted when the series visibility changes. | |
103 | */ |
|
103 | */ | |
|
104 | ||||
|
105 | /*! | |||
|
106 | \property QAbstractSeries::opacity | |||
|
107 | \brief The opacity of the series. | |||
|
108 | By default the opacity is 1.0. The valid values range from 0.0 (transparent) to 1.0 (opaque). | |||
|
109 | */ | |||
|
110 | /*! | |||
|
111 | \qmlproperty real AbstractSeries::opacity | |||
|
112 | The opacity of the series. By default the opacity is 1.0. | |||
|
113 | The valid values range from 0.0 (transparent) to 1.0 (opaque). | |||
|
114 | */ | |||
|
115 | ||||
|
116 | /*! | |||
|
117 | \fn void QAbstractSeries::opacityChanged() | |||
|
118 | Emitted when the opacity of the series changes. | |||
|
119 | */ | |||
|
120 | /*! | |||
|
121 | \qmlsignal AbstractSeries::onOpacityChanged() | |||
|
122 | Emitted when the opacity of the series changes. | |||
|
123 | */ | |||
|
124 | ||||
104 | /*! |
|
125 | /*! | |
105 | \internal |
|
126 | \internal | |
106 | \brief Constructs ChartSeries object with \a parent. |
|
127 | \brief Constructs ChartSeries object with \a parent. | |
107 | */ |
|
128 | */ | |
108 | QAbstractSeries::QAbstractSeries(QAbstractSeriesPrivate &d, QObject *parent) : |
|
129 | QAbstractSeries::QAbstractSeries(QAbstractSeriesPrivate &d, QObject *parent) : | |
109 | QObject(parent), |
|
130 | QObject(parent), | |
110 | d_ptr(&d) |
|
131 | d_ptr(&d) | |
111 | { |
|
132 | { | |
112 | } |
|
133 | } | |
113 |
|
134 | |||
114 | /*! |
|
135 | /*! | |
115 | \brief Virtual destructor for the chart series. |
|
136 | \brief Virtual destructor for the chart series. | |
116 | */ |
|
137 | */ | |
117 | QAbstractSeries::~QAbstractSeries() |
|
138 | QAbstractSeries::~QAbstractSeries() | |
118 | { |
|
139 | { | |
119 | if(d_ptr->m_dataset) qFatal("Still binded series detected !"); |
|
140 | if(d_ptr->m_dataset) qFatal("Still binded series detected !"); | |
120 | } |
|
141 | } | |
121 |
|
142 | |||
122 | void QAbstractSeries::setName(const QString& name) |
|
143 | void QAbstractSeries::setName(const QString& name) | |
123 | { |
|
144 | { | |
124 | if (name != d_ptr->m_name) { |
|
145 | if (name != d_ptr->m_name) { | |
125 | d_ptr->m_name = name; |
|
146 | d_ptr->m_name = name; | |
126 | emit nameChanged(); |
|
147 | emit nameChanged(); | |
127 | } |
|
148 | } | |
128 | } |
|
149 | } | |
129 |
|
150 | |||
130 | QString QAbstractSeries::name() const |
|
151 | QString QAbstractSeries::name() const | |
131 | { |
|
152 | { | |
132 | return d_ptr->m_name; |
|
153 | return d_ptr->m_name; | |
133 | } |
|
154 | } | |
134 |
|
155 | |||
135 | /*! |
|
156 | /*! | |
136 | Sets the visibility of series to \a visible |
|
157 | Sets the visibility of series to \a visible | |
137 | */ |
|
158 | */ | |
138 | void QAbstractSeries::setVisible(bool visible) |
|
159 | void QAbstractSeries::setVisible(bool visible) | |
139 | { |
|
160 | { | |
140 | if (visible != d_ptr->m_visible) { |
|
161 | if (visible != d_ptr->m_visible) { | |
141 | d_ptr->m_visible = visible; |
|
162 | d_ptr->m_visible = visible; | |
142 | emit visibleChanged(); |
|
163 | emit visibleChanged(); | |
143 | } |
|
164 | } | |
144 | } |
|
165 | } | |
145 |
|
166 | |||
146 | /*! |
|
167 | /*! | |
147 | Returns the visibility of series |
|
168 | Returns the visibility of series | |
148 | */ |
|
169 | */ | |
149 | bool QAbstractSeries::isVisible() const |
|
170 | bool QAbstractSeries::isVisible() const | |
150 | { |
|
171 | { | |
151 | return d_ptr->m_visible; |
|
172 | return d_ptr->m_visible; | |
152 | } |
|
173 | } | |
153 |
|
174 | |||
154 | qreal QAbstractSeries::opacity() const |
|
175 | qreal QAbstractSeries::opacity() const | |
155 | { |
|
176 | { | |
156 | return d_ptr->m_opacity; |
|
177 | return d_ptr->m_opacity; | |
157 | } |
|
178 | } | |
158 |
|
179 | |||
159 | void QAbstractSeries::setOpacity(qreal opacity) |
|
180 | void QAbstractSeries::setOpacity(qreal opacity) | |
160 | { |
|
181 | { | |
161 | if (opacity != d_ptr->m_opacity) { |
|
182 | if (opacity != d_ptr->m_opacity) { | |
162 | d_ptr->m_opacity = opacity; |
|
183 | d_ptr->m_opacity = opacity; | |
163 | emit opacityChanged(); |
|
184 | emit opacityChanged(); | |
164 | } |
|
185 | } | |
165 | } |
|
186 | } | |
166 |
|
187 | |||
167 | /*! |
|
188 | /*! | |
168 | \brief Returns the chart where series belongs to. |
|
189 | \brief Returns the chart where series belongs to. | |
169 |
|
190 | |||
170 | Set automatically when the series is added to the chart |
|
191 | Set automatically when the series is added to the chart | |
171 | and unset when the series is removed from the chart. |
|
192 | and unset when the series is removed from the chart. | |
172 | */ |
|
193 | */ | |
173 | QChart* QAbstractSeries::chart() const |
|
194 | QChart* QAbstractSeries::chart() const | |
174 | { |
|
195 | { | |
175 | return d_ptr->m_chart; |
|
196 | return d_ptr->m_chart; | |
176 | } |
|
197 | } | |
177 |
|
198 | |||
178 | //void QAbstractSeries::adjustView() |
|
199 | //void QAbstractSeries::adjustView() | |
179 | //{ |
|
200 | //{ | |
180 | // //TODO: |
|
201 | // //TODO: | |
181 | //} |
|
202 | //} | |
182 |
|
203 | |||
183 | /*! |
|
204 | /*! | |
184 | \brief Sets the visibility of the series to true |
|
205 | \brief Sets the visibility of the series to true | |
185 |
|
206 | |||
186 | \sa setVisible(), isVisible() |
|
207 | \sa setVisible(), isVisible() | |
187 | */ |
|
208 | */ | |
188 | void QAbstractSeries::show() |
|
209 | void QAbstractSeries::show() | |
189 | { |
|
210 | { | |
190 | setVisible(true); |
|
211 | setVisible(true); | |
191 | } |
|
212 | } | |
192 |
|
213 | |||
193 | /*! |
|
214 | /*! | |
194 | \brief Sets the visibility of the series to false |
|
215 | \brief Sets the visibility of the series to false | |
195 |
|
216 | |||
196 | \sa setVisible(), isVisible() |
|
217 | \sa setVisible(), isVisible() | |
197 | */ |
|
218 | */ | |
198 | void QAbstractSeries::hide() |
|
219 | void QAbstractSeries::hide() | |
199 | { |
|
220 | { | |
200 | setVisible(false); |
|
221 | setVisible(false); | |
201 | } |
|
222 | } | |
202 |
|
223 | |||
203 | /////////////////////////////////////////////////////////////////////////////////////////////////// |
|
224 | /////////////////////////////////////////////////////////////////////////////////////////////////// | |
204 |
|
225 | |||
205 | QAbstractSeriesPrivate::QAbstractSeriesPrivate(QAbstractSeries* q): |
|
226 | QAbstractSeriesPrivate::QAbstractSeriesPrivate(QAbstractSeries* q): | |
206 | q_ptr(q), |
|
227 | q_ptr(q), | |
207 | m_chart(0), |
|
228 | m_chart(0), | |
208 | m_dataset(0), |
|
229 | m_dataset(0), | |
209 | m_visible(true), |
|
230 | m_visible(true), | |
210 | m_opacity(1.0) |
|
231 | m_opacity(1.0) | |
211 | { |
|
232 | { | |
212 | } |
|
233 | } | |
213 |
|
234 | |||
214 | QAbstractSeriesPrivate::~QAbstractSeriesPrivate() |
|
235 | QAbstractSeriesPrivate::~QAbstractSeriesPrivate() | |
215 | { |
|
236 | { | |
216 | } |
|
237 | } | |
217 |
|
238 | |||
218 | #include "moc_qabstractseries.cpp" |
|
239 | #include "moc_qabstractseries.cpp" | |
219 | #include "moc_qabstractseries_p.cpp" |
|
240 | #include "moc_qabstractseries_p.cpp" | |
220 |
|
241 | |||
221 | QTCOMMERCIALCHART_END_NAMESPACE |
|
242 | QTCOMMERCIALCHART_END_NAMESPACE | |
222 |
|
243 | |||
223 |
|
244 |
@@ -1,133 +1,133 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2012 Digia Plc |
|
3 | ** Copyright (C) 2012 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
8 | ** |
|
8 | ** | |
9 | ** $QT_BEGIN_LICENSE$ |
|
9 | ** $QT_BEGIN_LICENSE$ | |
10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and Digia. |
|
13 | ** a written agreement between you and Digia. | |
14 | ** |
|
14 | ** | |
15 | ** If you have questions regarding the use of this file, please use |
|
15 | ** If you have questions regarding the use of this file, please use | |
16 | ** contact form at http://qt.digia.com |
|
16 | ** contact form at http://qt.digia.com | |
17 | ** $QT_END_LICENSE$ |
|
17 | ** $QT_END_LICENSE$ | |
18 | ** |
|
18 | ** | |
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 | #ifndef QCHART_H |
|
21 | #ifndef QCHART_H | |
22 | #define QCHART_H |
|
22 | #define QCHART_H | |
23 |
|
23 | |||
24 | #include <QAbstractSeries> |
|
24 | #include <QAbstractSeries> | |
25 | #include <QLegend> |
|
25 | #include <QLegend> | |
26 | #include <QGraphicsWidget> |
|
26 | #include <QGraphicsWidget> | |
27 | #include <QMargins> |
|
27 | #include <QMargins> | |
28 |
|
28 | |||
29 | class QGraphicsSceneResizeEvent; |
|
29 | class QGraphicsSceneResizeEvent; | |
30 |
|
30 | |||
31 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
31 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
32 |
|
32 | |||
33 | class QAbstractSeries; |
|
33 | class QAbstractSeries; | |
34 | class QAbstractAxis; |
|
34 | class QAbstractAxis; | |
35 | class QLegend; |
|
35 | class QLegend; | |
36 | struct QChartPrivate; |
|
36 | struct QChartPrivate; | |
37 |
|
37 | |||
38 | class QTCOMMERCIALCHART_EXPORT QChart : public QGraphicsWidget |
|
38 | class QTCOMMERCIALCHART_EXPORT QChart : public QGraphicsWidget | |
39 | { |
|
39 | { | |
40 | Q_OBJECT |
|
40 | Q_OBJECT | |
41 | Q_PROPERTY(QChart::ChartTheme theme READ theme WRITE setTheme) |
|
41 | Q_PROPERTY(QChart::ChartTheme theme READ theme WRITE setTheme) | |
42 | Q_PROPERTY(QString title READ title WRITE setTitle) |
|
42 | Q_PROPERTY(QString title READ title WRITE setTitle) | |
43 | Q_PROPERTY(bool backgroundVisible READ isBackgroundVisible WRITE setBackgroundVisible) |
|
43 | Q_PROPERTY(bool backgroundVisible READ isBackgroundVisible WRITE setBackgroundVisible) | |
44 | Q_PROPERTY(bool dropShadowEnabled READ isDropShadowEnabled WRITE setDropShadowEnabled) |
|
44 | Q_PROPERTY(bool dropShadowEnabled READ isDropShadowEnabled WRITE setDropShadowEnabled) | |
45 | Q_PROPERTY(QChart::AnimationOptions animationOptions READ animationOptions WRITE setAnimationOptions) |
|
45 | Q_PROPERTY(QChart::AnimationOptions animationOptions READ animationOptions WRITE setAnimationOptions) | |
46 | Q_PROPERTY(QMargins margins READ margins WRITE setMargins) |
|
46 | Q_PROPERTY(QMargins margins READ margins WRITE setMargins) | |
47 | Q_ENUMS(ChartTheme) |
|
47 | Q_ENUMS(ChartTheme) | |
48 | Q_ENUMS(AnimationOption) |
|
48 | Q_ENUMS(AnimationOption) | |
49 |
|
49 | |||
50 | public: |
|
50 | public: | |
51 | enum ChartTheme { |
|
51 | enum ChartTheme { | |
52 | ChartThemeLight = 0, |
|
52 | ChartThemeLight = 0, | |
53 | ChartThemeBlueCerulean, |
|
53 | ChartThemeBlueCerulean, | |
54 | ChartThemeDark, |
|
54 | ChartThemeDark, | |
55 | ChartThemeBrownSand, |
|
55 | ChartThemeBrownSand, | |
56 | ChartThemeBlueNcs, |
|
56 | ChartThemeBlueNcs, | |
57 | ChartThemeHighContrast, |
|
57 | ChartThemeHighContrast, | |
58 | ChartThemeBlueIcy |
|
58 | ChartThemeBlueIcy | |
59 | }; |
|
59 | }; | |
60 |
|
60 | |||
61 | enum AnimationOption { |
|
61 | enum AnimationOption { | |
62 | NoAnimation = 0x0, |
|
62 | NoAnimation = 0x0, | |
63 | GridAxisAnimations = 0x1, |
|
63 | GridAxisAnimations = 0x1, | |
64 | SeriesAnimations =0x2, |
|
64 | SeriesAnimations =0x2, | |
65 | AllAnimations = 0x3 |
|
65 | AllAnimations = 0x3 | |
66 | }; |
|
66 | }; | |
67 |
|
67 | |||
68 | Q_DECLARE_FLAGS(AnimationOptions, AnimationOption) |
|
68 | Q_DECLARE_FLAGS(AnimationOptions, AnimationOption) | |
69 |
|
69 | |||
70 | public: |
|
70 | public: | |
71 | explicit QChart(QGraphicsItem *parent = 0, Qt::WindowFlags wFlags = 0); |
|
71 | explicit QChart(QGraphicsItem *parent = 0, Qt::WindowFlags wFlags = 0); | |
72 | ~QChart(); |
|
72 | ~QChart(); | |
73 |
|
73 | |||
74 | void addSeries(QAbstractSeries *series); |
|
74 | void addSeries(QAbstractSeries *series); | |
75 | void removeSeries(QAbstractSeries *series); |
|
75 | void removeSeries(QAbstractSeries *series); | |
76 | void removeAllSeries(); |
|
76 | void removeAllSeries(); | |
77 | QList<QAbstractSeries*> series() const; |
|
77 | QList<QAbstractSeries*> series() const; | |
78 |
|
78 | |||
79 | void setAxisX(QAbstractAxis* axis, QAbstractSeries *series = 0); |
|
79 | void setAxisX(QAbstractAxis* axis, QAbstractSeries *series = 0); | |
80 | void setAxisY(QAbstractAxis* axis, QAbstractSeries *series = 0); |
|
80 | void setAxisY(QAbstractAxis* axis, QAbstractSeries *series = 0); | |
81 |
|
81 | |||
82 | QAbstractAxis* axisX(QAbstractSeries* series = 0) const; |
|
82 | QAbstractAxis* axisX(QAbstractSeries* series = 0) const; | |
83 | QAbstractAxis* axisY(QAbstractSeries* series = 0) const; |
|
83 | QAbstractAxis* axisY(QAbstractSeries* series = 0) const; | |
84 |
|
84 | |||
85 | void createDefaultAxes(); |
|
85 | void createDefaultAxes(); | |
86 |
|
86 | |||
87 | void setTheme(QChart::ChartTheme theme); |
|
87 | void setTheme(QChart::ChartTheme theme); | |
88 | QChart::ChartTheme theme() const; |
|
88 | QChart::ChartTheme theme() const; | |
89 |
|
89 | |||
90 | void setTitle(const QString& title); |
|
90 | void setTitle(const QString& title); | |
91 | QString title() const; |
|
91 | QString title() const; | |
92 | void setTitleFont(const QFont& font); |
|
92 | void setTitleFont(const QFont& font); | |
93 | QFont titleFont() const; |
|
93 | QFont titleFont() const; | |
94 | void setTitleBrush(const QBrush &brush); |
|
94 | void setTitleBrush(const QBrush &brush); | |
95 | QBrush titleBrush() const; |
|
95 | QBrush titleBrush() const; | |
96 |
|
96 | |||
97 | void setBackgroundBrush(const QBrush &brush); |
|
97 | void setBackgroundBrush(const QBrush &brush); | |
98 | QBrush backgroundBrush() const; |
|
98 | QBrush backgroundBrush() const; | |
99 | void setBackgroundPen(const QPen &pen); |
|
99 | void setBackgroundPen(const QPen &pen); | |
100 | QPen backgroundPen() const; |
|
100 | QPen backgroundPen() const; | |
101 | void setBackgroundVisible(bool visible = true); |
|
101 | void setBackgroundVisible(bool visible = true); | |
102 | bool isBackgroundVisible() const; |
|
102 | bool isBackgroundVisible() const; | |
103 |
|
103 | |||
104 | void setDropShadowEnabled(bool enabled = true); |
|
104 | void setDropShadowEnabled(bool enabled = true); | |
105 | bool isDropShadowEnabled() const; |
|
105 | bool isDropShadowEnabled() const; | |
106 | void setAnimationOptions(AnimationOptions options); |
|
106 | void setAnimationOptions(AnimationOptions options); | |
107 | AnimationOptions animationOptions() const; |
|
107 | AnimationOptions animationOptions() const; | |
108 |
|
108 | |||
109 | void zoomIn(); |
|
109 | void zoomIn(); | |
110 | void zoomIn(const QRectF &rect); |
|
110 | void zoomIn(const QRectF &rect); | |
111 | void zoomOut(); |
|
111 | void zoomOut(); | |
112 | void zoom(qreal factor); |
|
112 | void zoom(qreal factor); | |
113 | void scroll(qreal dx, qreal dy); |
|
113 | void scroll(qreal dx, qreal dy); | |
114 |
|
114 | |||
115 | QLegend* legend() const; |
|
115 | QLegend* legend() const; | |
116 |
|
116 | |||
117 | void setMargins(const QMargins& margins); |
|
117 | void setMargins(const QMargins& margins); | |
118 | QMargins margins() const; |
|
118 | QMargins margins() const; | |
119 |
|
119 | |||
120 | QRectF plotArea() const; |
|
120 | QRectF plotArea() const; | |
121 |
|
121 | |||
122 | protected: |
|
122 | protected: | |
123 | QScopedPointer<QChartPrivate> d_ptr; |
|
123 | QScopedPointer<QChartPrivate> d_ptr; | |
124 | friend class QLegend; |
|
124 | friend class QLegend; | |
125 |
friend class |
|
125 | friend class DeclarativeChart; | |
126 | Q_DISABLE_COPY(QChart) |
|
126 | Q_DISABLE_COPY(QChart) | |
127 | }; |
|
127 | }; | |
128 |
|
128 | |||
129 | QTCOMMERCIALCHART_END_NAMESPACE |
|
129 | QTCOMMERCIALCHART_END_NAMESPACE | |
130 |
|
130 | |||
131 | Q_DECLARE_OPERATORS_FOR_FLAGS(QTCOMMERCIALCHART_NAMESPACE::QChart::AnimationOptions) |
|
131 | Q_DECLARE_OPERATORS_FOR_FLAGS(QTCOMMERCIALCHART_NAMESPACE::QChart::AnimationOptions) | |
132 |
|
132 | |||
133 | #endif // QCHART_H |
|
133 | #endif // QCHART_H |
@@ -1,104 +1,106 | |||||
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: "Chart Title" |
|
26 | title: "Chart Title" | |
27 | anchors.fill: parent |
|
27 | anchors.fill: parent | |
28 |
property variant |
|
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: " + |
|
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); | |||
|
46 | onSeriesRemoved: console.log("chart.onSeriesRemoved: " + series.name); | |||
45 |
|
47 | |||
46 |
legend.onVisibleChanged: console.log("legend.onVisibleChanged: " + |
|
48 | legend.onVisibleChanged: console.log("legend.onVisibleChanged: " + chart.legend.visible); | |
47 | legend.onBackgroundVisibleChanged: console.log("legend.onBackgroundVisibleChanged: " + visible); |
|
49 | legend.onBackgroundVisibleChanged: console.log("legend.onBackgroundVisibleChanged: " + visible); | |
48 | legend.onColorChanged: console.log("legend.onColorChanged: " + color); |
|
50 | legend.onColorChanged: console.log("legend.onColorChanged: " + color); | |
49 | legend.onBorderColorChanged: console.log("legend.onBorderColorChanged: " + color); |
|
51 | legend.onBorderColorChanged: console.log("legend.onBorderColorChanged: " + color); | |
50 | legend.onLabelColorChanged: console.log("legend.onLabelColorChanged: " + color); |
|
52 | legend.onLabelColorChanged: console.log("legend.onLabelColorChanged: " + color); | |
51 | minimumMargins.onTopChanged: console.log("chart.minimumMargins.onTopChanged: " + top ); |
|
53 | minimumMargins.onTopChanged: console.log("chart.minimumMargins.onTopChanged: " + top ); | |
52 | minimumMargins.onBottomChanged: console.log("chart.minimumMargins.onBottomChanged: " + bottom); |
|
54 | minimumMargins.onBottomChanged: console.log("chart.minimumMargins.onBottomChanged: " + bottom); | |
53 | minimumMargins.onLeftChanged: console.log("chart.minimumMargins.onLeftChanged: " + left); |
|
55 | minimumMargins.onLeftChanged: console.log("chart.minimumMargins.onLeftChanged: " + left); | |
54 | minimumMargins.onRightChanged: console.log("chart.minimumMargins.onRightChanged: " + right); |
|
56 | minimumMargins.onRightChanged: console.log("chart.minimumMargins.onRightChanged: " + right); | |
55 | onPlotAreaChanged: { |
|
57 | onPlotAreaChanged: { | |
56 | console.log("chart.onPlotAreaChanged, width: " + chartView.plotArea.width |
|
58 | console.log("chart.onPlotAreaChanged, width: " + chartView.plotArea.width | |
57 | + " height: " + chartView.plotArea.height |
|
59 | + " height: " + chartView.plotArea.height | |
58 | + " y: " + chartView.plotArea.y |
|
60 | + " y: " + chartView.plotArea.y | |
59 | + " x: " + chartView.plotArea.x); |
|
61 | + " x: " + chartView.plotArea.x); | |
60 | marginVisualizer.opacity = 1.0; |
|
62 | marginVisualizer.opacity = 1.0; | |
61 | } |
|
63 | } | |
62 |
|
64 | |||
63 | ValueAxis{ |
|
65 | ValueAxis{ | |
64 | onColorChanged: console.log("axisX.onColorChanged: " + color); |
|
66 | onColorChanged: console.log("axisX.onColorChanged: " + color); | |
65 | onLabelsVisibleChanged: console.log("axisX.onLabelsVisibleChanged: " + visible); |
|
67 | onLabelsVisibleChanged: console.log("axisX.onLabelsVisibleChanged: " + visible); | |
66 | onLabelsColorChanged: console.log("axisX.onLabelsColorChanged: " + color); |
|
68 | onLabelsColorChanged: console.log("axisX.onLabelsColorChanged: " + color); | |
67 | onVisibleChanged: console.log("axisX.onVisibleChanged: " + visible); |
|
69 | onVisibleChanged: console.log("axisX.onVisibleChanged: " + visible); | |
68 | onGridVisibleChanged: console.log("axisX.onGridVisibleChanged: " + visible); |
|
70 | onGridVisibleChanged: console.log("axisX.onGridVisibleChanged: " + visible); | |
69 | onShadesVisibleChanged: console.log("axisX.onShadesVisibleChanged: " + visible); |
|
71 | onShadesVisibleChanged: console.log("axisX.onShadesVisibleChanged: " + visible); | |
70 | onShadesColorChanged: console.log("axisX.onShadesColorChanged: " + color); |
|
72 | onShadesColorChanged: console.log("axisX.onShadesColorChanged: " + color); | |
71 | onShadesBorderColorChanged: console.log("axisX.onShadesBorderColorChanged: " + color); |
|
73 | onShadesBorderColorChanged: console.log("axisX.onShadesBorderColorChanged: " + color); | |
72 | onMinChanged: console.log("axisX.onMinChanged: " + min); |
|
74 | onMinChanged: console.log("axisX.onMinChanged: " + min); | |
73 | onMaxChanged: console.log("axisX.onMaxChanged: " + max); |
|
75 | onMaxChanged: console.log("axisX.onMaxChanged: " + max); | |
74 | } |
|
76 | } | |
75 |
|
77 | |||
76 | ValueAxis{ |
|
78 | ValueAxis{ | |
77 | onColorChanged: console.log("axisY.onColorChanged: " + color); |
|
79 | onColorChanged: console.log("axisY.onColorChanged: " + color); | |
78 | onLabelsVisibleChanged: console.log("axisY.onLabelsVisibleChanged: " + visible); |
|
80 | onLabelsVisibleChanged: console.log("axisY.onLabelsVisibleChanged: " + visible); | |
79 | onLabelsColorChanged: console.log("axisY.onLabelsColorChanged: " + color); |
|
81 | onLabelsColorChanged: console.log("axisY.onLabelsColorChanged: " + color); | |
80 | onVisibleChanged: console.log("axisY.onVisibleChanged: " + visible); |
|
82 | onVisibleChanged: console.log("axisY.onVisibleChanged: " + visible); | |
81 | onGridVisibleChanged: console.log("axisY.onGridVisibleChanged: " + visible); |
|
83 | onGridVisibleChanged: console.log("axisY.onGridVisibleChanged: " + visible); | |
82 | onShadesVisibleChanged: console.log("axisY.onShadesVisibleChanged: " + visible); |
|
84 | onShadesVisibleChanged: console.log("axisY.onShadesVisibleChanged: " + visible); | |
83 | onShadesColorChanged: console.log("axisY.onShadesColorChanged: " + color); |
|
85 | onShadesColorChanged: console.log("axisY.onShadesColorChanged: " + color); | |
84 | onShadesBorderColorChanged: console.log("axisY.onShadesBorderColorChanged: " + color); |
|
86 | onShadesBorderColorChanged: console.log("axisY.onShadesBorderColorChanged: " + color); | |
85 | onMinChanged: console.log("axisY.onMinChanged: " + min); |
|
87 | onMinChanged: console.log("axisY.onMinChanged: " + min); | |
86 | onMaxChanged: console.log("axisY.onMaxChanged: " + max); |
|
88 | onMaxChanged: console.log("axisY.onMaxChanged: " + max); | |
87 | } |
|
89 | } | |
88 |
|
90 | |||
89 | Rectangle { |
|
91 | Rectangle { | |
90 | id: marginVisualizer |
|
92 | id: marginVisualizer | |
91 | color: "transparent" |
|
93 | color: "transparent" | |
92 | border.color: "red" |
|
94 | border.color: "red" | |
93 | anchors.fill: parent |
|
95 | anchors.fill: parent | |
94 | anchors.topMargin: chartView.minimumMargins.top |
|
96 | anchors.topMargin: chartView.minimumMargins.top | |
95 | anchors.bottomMargin: chartView.minimumMargins.bottom |
|
97 | anchors.bottomMargin: chartView.minimumMargins.bottom | |
96 | anchors.leftMargin: chartView.minimumMargins.left |
|
98 | anchors.leftMargin: chartView.minimumMargins.left | |
97 | anchors.rightMargin: chartView.minimumMargins.right |
|
99 | anchors.rightMargin: chartView.minimumMargins.right | |
98 | opacity: 0.0 |
|
100 | opacity: 0.0 | |
99 | onOpacityChanged: if (opacity > 0.9) opacity = 0.0; |
|
101 | onOpacityChanged: if (opacity > 0.9) opacity = 0.0; | |
100 | Behavior on opacity { |
|
102 | Behavior on opacity { | |
101 | NumberAnimation { duration: 800 } |
|
103 | NumberAnimation { duration: 800 } | |
102 | } |
|
104 | } | |
103 | } |
|
105 | } | |
104 | } |
|
106 | } |
@@ -1,108 +1,119 | |||||
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 | Item { |
|
23 | Item { | |
24 | id: chartEditor |
|
24 | id: chartEditor | |
25 |
property variant |
|
25 | property variant chart | |
26 |
|
|
26 | onChartChanged: { | |
27 | if (loader.item != undefined) |
|
27 | if (loader.item != undefined) | |
28 |
loader.item.chart = |
|
28 | loader.item.chart = chart; | |
29 | } |
|
29 | } | |
30 |
|
30 | |||
31 | function selectButton(button) { |
|
31 | function selectButton(button) { | |
32 | chartButton.color = "#79bd8f"; |
|
32 | chartButton.color = "#79bd8f"; | |
33 | titleButton.color = "#79bd8f"; |
|
33 | titleButton.color = "#79bd8f"; | |
34 | legendButton.color = "#79bd8f"; |
|
34 | legendButton.color = "#79bd8f"; | |
35 | axisXButton.color = "#79bd8f"; |
|
35 | axisXButton.color = "#79bd8f"; | |
36 | axisYButton.color = "#79bd8f"; |
|
36 | axisYButton.color = "#79bd8f"; | |
|
37 | seriesButton.color = "#79bd8f"; | |||
37 | button.color = "#00a388"; |
|
38 | button.color = "#00a388"; | |
38 | } |
|
39 | } | |
39 |
|
40 | |||
40 | Flow { |
|
41 | Flow { | |
41 | id: selectorFlow |
|
42 | id: selectorFlow | |
42 | anchors.top: parent.top |
|
43 | anchors.top: parent.top | |
43 | height: 90 |
|
44 | height: 90 | |
44 | anchors.left: parent.left |
|
45 | anchors.left: parent.left | |
45 | anchors.right: parent.right |
|
46 | anchors.right: parent.right | |
46 | spacing: 5 |
|
47 | spacing: 5 | |
47 | flow: Flow.TopToBottom |
|
48 | flow: Flow.TopToBottom | |
48 |
|
49 | |||
49 | Button { |
|
50 | Button { | |
50 | id: chartButton |
|
51 | id: chartButton | |
51 | text: "Chart properties" |
|
52 | text: "Chart properties" | |
52 | unpressedColor: "#79bd8f" |
|
53 | unpressedColor: "#79bd8f" | |
53 | onClicked: { |
|
54 | onClicked: { | |
54 | selectButton(chartButton); |
|
55 | selectButton(chartButton); | |
55 | loader.source = "ChartEditorProperties.qml"; |
|
56 | loader.source = "ChartEditorProperties.qml"; | |
56 |
loader.item.chart = |
|
57 | loader.item.chart = chart; | |
57 | } |
|
58 | } | |
58 | } |
|
59 | } | |
59 | Button { |
|
60 | Button { | |
60 | id: titleButton |
|
61 | id: titleButton | |
61 | text: "Title properties" |
|
62 | text: "Title properties" | |
62 | unpressedColor: "#79bd8f" |
|
63 | unpressedColor: "#79bd8f" | |
63 | onClicked: { |
|
64 | onClicked: { | |
64 | selectButton(titleButton); |
|
65 | selectButton(titleButton); | |
65 | loader.source = "ChartEditorTitle.qml"; |
|
66 | loader.source = "ChartEditorTitle.qml"; | |
66 |
loader.item.chart = |
|
67 | loader.item.chart = chart; | |
67 | } |
|
68 | } | |
68 | } |
|
69 | } | |
69 | Button { |
|
70 | Button { | |
70 | id: legendButton |
|
71 | id: legendButton | |
71 | text: "Legend properties" |
|
72 | text: "Legend properties" | |
72 | unpressedColor: "#79bd8f" |
|
73 | unpressedColor: "#79bd8f" | |
73 | onClicked: { |
|
74 | onClicked: { | |
74 | selectButton(legendButton); |
|
75 | selectButton(legendButton); | |
75 | loader.source = "ChartEditorLegend.qml"; |
|
76 | loader.source = "ChartEditorLegend.qml"; | |
76 |
loader.item.chartLegend = |
|
77 | loader.item.chartLegend = chart.legend; | |
77 | } |
|
78 | } | |
78 | } |
|
79 | } | |
79 | Button { |
|
80 | Button { | |
80 | id: axisXButton |
|
81 | id: axisXButton | |
81 | text: "Axis X properties" |
|
82 | text: "Axis X properties" | |
82 | unpressedColor: "#79bd8f" |
|
83 | unpressedColor: "#79bd8f" | |
83 | onClicked: { |
|
84 | onClicked: { | |
84 | selectButton(axisXButton); |
|
85 | selectButton(axisXButton); | |
85 | loader.source = "ChartEditorAxis.qml"; |
|
86 | loader.source = "ChartEditorAxis.qml"; | |
86 |
loader.item.axis = |
|
87 | loader.item.axis = chart.axisX; | |
87 | } |
|
88 | } | |
88 | } |
|
89 | } | |
89 | Button { |
|
90 | Button { | |
90 | id: axisYButton |
|
91 | id: axisYButton | |
91 | text: "Axis Y properties" |
|
92 | text: "Axis Y properties" | |
92 | unpressedColor: "#79bd8f" |
|
93 | unpressedColor: "#79bd8f" | |
93 | onClicked: { |
|
94 | onClicked: { | |
94 | selectButton(axisYButton); |
|
95 | selectButton(axisYButton); | |
95 | loader.source = "ChartEditorAxis.qml"; |
|
96 | loader.source = "ChartEditorAxis.qml"; | |
96 |
loader.item.axis = |
|
97 | loader.item.axis = chart.axisY; | |
|
98 | } | |||
|
99 | } | |||
|
100 | Button { | |||
|
101 | id: seriesButton | |||
|
102 | text: "Series" | |||
|
103 | unpressedColor: "#79bd8f" | |||
|
104 | onClicked: { | |||
|
105 | selectButton(seriesButton); | |||
|
106 | loader.source = "ChartEditorSeries.qml"; | |||
|
107 | loader.item.chart = chart; | |||
97 | } |
|
108 | } | |
98 | } |
|
109 | } | |
99 | } |
|
110 | } | |
100 |
|
111 | |||
101 | Loader { |
|
112 | Loader { | |
102 | id: loader |
|
113 | id: loader | |
103 | anchors.top: selectorFlow.bottom |
|
114 | anchors.top: selectorFlow.bottom | |
104 | anchors.bottom: parent.bottom |
|
115 | anchors.bottom: parent.bottom | |
105 | anchors.left: parent.left |
|
116 | anchors.left: parent.left | |
106 | anchors.right: parent.right |
|
117 | anchors.right: parent.right | |
107 | } |
|
118 | } | |
108 | } |
|
119 | } |
@@ -1,120 +1,116 | |||||
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 | 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: "drop shadow enabled" |
|
53 | text: "drop shadow enabled" | |
54 | onClicked: chart.dropShadowEnabled = !chart.dropShadowEnabled; |
|
54 | onClicked: chart.dropShadowEnabled = !chart.dropShadowEnabled; | |
55 | } |
|
55 | } | |
56 | Button { |
|
56 | Button { | |
57 | text: "zoom +" |
|
57 | text: "zoom +" | |
58 | onClicked: chart.zoom(2); |
|
58 | onClicked: chart.zoom(2); | |
59 | } |
|
59 | } | |
60 | Button { |
|
60 | Button { | |
61 | text: "zoom -" |
|
61 | text: "zoom -" | |
62 | onClicked: chart.zoom(0.5); |
|
62 | onClicked: chart.zoom(0.5); | |
63 | } |
|
63 | } | |
64 | Button { |
|
64 | Button { | |
65 | text: "scroll left" |
|
65 | text: "scroll left" | |
66 | onClicked: chart.scrollLeft(10); |
|
66 | onClicked: chart.scrollLeft(10); | |
67 | } |
|
67 | } | |
68 | Button { |
|
68 | Button { | |
69 | text: "scroll right" |
|
69 | text: "scroll right" | |
70 | onClicked: chart.scrollRight(10); |
|
70 | onClicked: chart.scrollRight(10); | |
71 | } |
|
71 | } | |
72 | Button { |
|
72 | Button { | |
73 | text: "scroll up" |
|
73 | text: "scroll up" | |
74 | onClicked: chart.scrollUp(10); |
|
74 | onClicked: chart.scrollUp(10); | |
75 | } |
|
75 | } | |
76 | Button { |
|
76 | Button { | |
77 | text: "scroll down" |
|
77 | text: "scroll down" | |
78 | onClicked: chart.scrollDown(10); |
|
78 | onClicked: chart.scrollDown(10); | |
79 | } |
|
79 | } | |
80 | Button { |
|
80 | Button { | |
81 | text: "title color" |
|
81 | text: "title color" | |
82 | onClicked: chart.titleColor = main.nextColor(); |
|
82 | onClicked: chart.titleColor = main.nextColor(); | |
83 | } |
|
83 | } | |
84 | Button { |
|
84 | Button { | |
85 | text: "zoom -" |
|
|||
86 | onClicked: chart.zoom(0.5); |
|
|||
87 | } |
|
|||
88 | Button { |
|
|||
89 | text: "top min margin +" |
|
85 | text: "top min margin +" | |
90 | onClicked: chart.minimumMargins.top += 5; |
|
86 | onClicked: chart.minimumMargins.top += 5; | |
91 | } |
|
87 | } | |
92 | Button { |
|
88 | Button { | |
93 | text: "top min margin -" |
|
89 | text: "top min margin -" | |
94 | onClicked: chart.minimumMargins.top -= 5; |
|
90 | onClicked: chart.minimumMargins.top -= 5; | |
95 | } |
|
91 | } | |
96 | Button { |
|
92 | Button { | |
97 | text: "bottom min margin +" |
|
93 | text: "bottom min margin +" | |
98 | onClicked: chart.minimumMargins.bottom += 5; |
|
94 | onClicked: chart.minimumMargins.bottom += 5; | |
99 | } |
|
95 | } | |
100 | Button { |
|
96 | Button { | |
101 | text: "bottom min margin -" |
|
97 | text: "bottom min margin -" | |
102 | onClicked: chart.minimumMargins.bottom -= 5; |
|
98 | onClicked: chart.minimumMargins.bottom -= 5; | |
103 | } |
|
99 | } | |
104 | Button { |
|
100 | Button { | |
105 | text: "left min margin +" |
|
101 | text: "left min margin +" | |
106 | onClicked: chart.minimumMargins.left += 5; |
|
102 | onClicked: chart.minimumMargins.left += 5; | |
107 | } |
|
103 | } | |
108 | Button { |
|
104 | Button { | |
109 | text: "left min margin -" |
|
105 | text: "left min margin -" | |
110 | onClicked: chart.minimumMargins.left -= 5; |
|
106 | onClicked: chart.minimumMargins.left -= 5; | |
111 | } |
|
107 | } | |
112 | Button { |
|
108 | Button { | |
113 | text: "right min margin +" |
|
109 | text: "right min margin +" | |
114 | onClicked: chart.minimumMargins.right += 5; |
|
110 | onClicked: chart.minimumMargins.right += 5; | |
115 | } |
|
111 | } | |
116 | Button { |
|
112 | Button { | |
117 | text: "right min margin -" |
|
113 | text: "right min margin -" | |
118 | onClicked: chart.minimumMargins.right -= 5; |
|
114 | onClicked: chart.minimumMargins.right -= 5; | |
119 | } |
|
115 | } | |
120 | } |
|
116 | } |
@@ -1,171 +1,179 | |||||
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: parent.width |
|
25 | width: parent.width | |
26 | height: parent.height |
|
26 | height: parent.height | |
27 | property int viewCount: 9 |
|
27 | property int viewCount: 9 | |
28 | property variant colors: ["#637D74", "#403D3A", "#8C3B3B", "#AB6937", "#D4A960"] |
|
28 | property variant colors: ["#637D74", "#403D3A", "#8C3B3B", "#AB6937", "#D4A960"] | |
29 | property int colorIndex: 0 |
|
29 | property int colorIndex: 0 | |
30 | property int buttonWidth: 42 |
|
30 | property int buttonWidth: 42 | |
31 |
|
31 | |||
32 | function nextColor() { |
|
32 | function nextColor() { | |
33 | colorIndex++; |
|
33 | colorIndex++; | |
34 | return colors[colorIndex % colors.length]; |
|
34 | return colors[colorIndex % colors.length]; | |
35 | } |
|
35 | } | |
36 |
|
36 | |||
37 | Row { |
|
37 | Row { | |
38 | anchors.top: parent.top |
|
38 | anchors.top: parent.top | |
39 | anchors.bottom: buttonRow.top |
|
39 | anchors.bottom: buttonRow.top | |
40 | anchors.bottomMargin: 10 |
|
40 | anchors.bottomMargin: 10 | |
41 | anchors.left: parent.left |
|
41 | anchors.left: parent.left | |
42 | anchors.right: parent.right |
|
42 | anchors.right: parent.right | |
43 |
|
43 | |||
44 | Loader { |
|
44 | Loader { | |
45 | id: chartLoader |
|
45 | id: chartLoader | |
46 | width: main.width - editorLoader.width |
|
46 | width: main.width - editorLoader.width | |
47 | height: parent.height |
|
47 | height: parent.height | |
48 | source: "Chart.qml" |
|
48 | source: "Chart.qml" | |
49 | onStatusChanged: { |
|
49 | onStatusChanged: { | |
50 | if (status == Loader.Ready && editorLoader.status == Loader.Ready && chartLoader.item) |
|
50 | if (status == Loader.Ready && editorLoader.status == Loader.Ready && chartLoader.item) { | |
51 | editorLoader.item.series = chartLoader.item.series; |
|
51 | if (source.toString().search("Chart.qml") > 0) | |
|
52 | editorLoader.item.chart = chartLoader.item.chart; | |||
|
53 | else | |||
|
54 | editorLoader.item.series = chartLoader.item.series; | |||
|
55 | } | |||
52 | } |
|
56 | } | |
53 | } |
|
57 | } | |
54 |
|
58 | |||
55 | Loader { |
|
59 | Loader { | |
56 | id: editorLoader |
|
60 | id: editorLoader | |
57 | width: 280 |
|
61 | width: 280 | |
58 | height: parent.height |
|
62 | height: parent.height | |
59 | source: "ChartEditor.qml" |
|
63 | source: "ChartEditor.qml" | |
60 | onStatusChanged: { |
|
64 | onStatusChanged: { | |
61 | if (status == Loader.Ready && chartLoader.status == Loader.Ready && chartLoader.item) |
|
65 | if (status == Loader.Ready && chartLoader.status == Loader.Ready && chartLoader.item) { | |
62 | editorLoader.item.series = chartLoader.item.series; |
|
66 | if (source.toString().search("ChartEditor.qml") > 0) | |
|
67 | editorLoader.item.chart = chartLoader.item.chart; | |||
|
68 | else | |||
|
69 | editorLoader.item.series = chartLoader.item.series; | |||
|
70 | } | |||
63 | } |
|
71 | } | |
64 | } |
|
72 | } | |
65 | } |
|
73 | } | |
66 |
|
74 | |||
67 | Row { |
|
75 | Row { | |
68 | id: buttonRow |
|
76 | id: buttonRow | |
69 | height: 40 |
|
77 | height: 40 | |
70 | anchors.bottom: parent.bottom |
|
78 | anchors.bottom: parent.bottom | |
71 | anchors.horizontalCenter: parent.horizontalCenter |
|
79 | anchors.horizontalCenter: parent.horizontalCenter | |
72 | spacing: 10 |
|
80 | spacing: 10 | |
73 |
|
81 | |||
74 | Button { |
|
82 | Button { | |
75 | text: "chart" |
|
83 | text: "chart" | |
76 | width: buttonWidth |
|
84 | width: buttonWidth | |
77 | onClicked: { |
|
85 | onClicked: { | |
78 | chartLoader.source = "Chart.qml"; |
|
86 | chartLoader.source = "Chart.qml"; | |
79 | editorLoader.source = "ChartEditor.qml"; |
|
87 | editorLoader.source = "ChartEditor.qml"; | |
80 | } |
|
88 | } | |
81 | } |
|
89 | } | |
82 | Button { |
|
90 | Button { | |
83 | text: "pie" |
|
91 | text: "pie" | |
84 | width: buttonWidth |
|
92 | width: buttonWidth | |
85 | onClicked: { |
|
93 | onClicked: { | |
86 | chartLoader.source = "PieChart.qml"; |
|
94 | chartLoader.source = "PieChart.qml"; | |
87 | editorLoader.source = "PieEditor.qml"; |
|
95 | editorLoader.source = "PieEditor.qml"; | |
88 | } |
|
96 | } | |
89 | } |
|
97 | } | |
90 | Button { |
|
98 | Button { | |
91 | text: "line" |
|
99 | text: "line" | |
92 | width: buttonWidth |
|
100 | width: buttonWidth | |
93 | onClicked: { |
|
101 | onClicked: { | |
94 | chartLoader.source = "LineChart.qml"; |
|
102 | chartLoader.source = "LineChart.qml"; | |
95 | editorLoader.source = "LineEditor.qml"; |
|
103 | editorLoader.source = "LineEditor.qml"; | |
96 | } |
|
104 | } | |
97 | } |
|
105 | } | |
98 | Button { |
|
106 | Button { | |
99 | text: "spline" |
|
107 | text: "spline" | |
100 | width: buttonWidth |
|
108 | width: buttonWidth | |
101 | onClicked: { |
|
109 | onClicked: { | |
102 | chartLoader.source = "SplineChart.qml"; |
|
110 | chartLoader.source = "SplineChart.qml"; | |
103 | editorLoader.source = "LineEditor.qml"; |
|
111 | editorLoader.source = "LineEditor.qml"; | |
104 | } |
|
112 | } | |
105 | } |
|
113 | } | |
106 | Button { |
|
114 | Button { | |
107 | text: "scatter" |
|
115 | text: "scatter" | |
108 | width: buttonWidth |
|
116 | width: buttonWidth | |
109 | onClicked: { |
|
117 | onClicked: { | |
110 | chartLoader.source = "ScatterChart.qml"; |
|
118 | chartLoader.source = "ScatterChart.qml"; | |
111 | editorLoader.source = "ScatterEditor.qml"; |
|
119 | editorLoader.source = "ScatterEditor.qml"; | |
112 | } |
|
120 | } | |
113 | } |
|
121 | } | |
114 | Button { |
|
122 | Button { | |
115 | text: "area" |
|
123 | text: "area" | |
116 | width: buttonWidth |
|
124 | width: buttonWidth | |
117 | onClicked: { |
|
125 | onClicked: { | |
118 | chartLoader.source = "AreaChart.qml"; |
|
126 | chartLoader.source = "AreaChart.qml"; | |
119 | editorLoader.source = "AreaEditor.qml"; |
|
127 | editorLoader.source = "AreaEditor.qml"; | |
120 | } |
|
128 | } | |
121 | } |
|
129 | } | |
122 | Button { |
|
130 | Button { | |
123 | text: "bar" |
|
131 | text: "bar" | |
124 | width: buttonWidth |
|
132 | width: buttonWidth | |
125 | onClicked: { |
|
133 | onClicked: { | |
126 | chartLoader.source = "BarChart.qml"; |
|
134 | chartLoader.source = "BarChart.qml"; | |
127 | editorLoader.source = "BarEditor.qml"; |
|
135 | editorLoader.source = "BarEditor.qml"; | |
128 | } |
|
136 | } | |
129 | } |
|
137 | } | |
130 | Button { |
|
138 | Button { | |
131 | text: "sbar" |
|
139 | text: "sbar" | |
132 | width: buttonWidth |
|
140 | width: buttonWidth | |
133 | onClicked: { |
|
141 | onClicked: { | |
134 | chartLoader.source = "StackedBarChart.qml"; |
|
142 | chartLoader.source = "StackedBarChart.qml"; | |
135 | editorLoader.source = "BarEditor.qml"; |
|
143 | editorLoader.source = "BarEditor.qml"; | |
136 | } |
|
144 | } | |
137 | } |
|
145 | } | |
138 | Button { |
|
146 | Button { | |
139 | text: "pbar" |
|
147 | text: "pbar" | |
140 | width: buttonWidth |
|
148 | width: buttonWidth | |
141 | onClicked: { |
|
149 | onClicked: { | |
142 | chartLoader.source = "PercentBarChart.qml"; |
|
150 | chartLoader.source = "PercentBarChart.qml"; | |
143 | editorLoader.source = "BarEditor.qml"; |
|
151 | editorLoader.source = "BarEditor.qml"; | |
144 | } |
|
152 | } | |
145 | } |
|
153 | } | |
146 | Button { |
|
154 | Button { | |
147 | text: "hbar" |
|
155 | text: "hbar" | |
148 | width: buttonWidth |
|
156 | width: buttonWidth | |
149 | onClicked: { |
|
157 | onClicked: { | |
150 | chartLoader.source = "HorizontalBarChart.qml"; |
|
158 | chartLoader.source = "HorizontalBarChart.qml"; | |
151 | editorLoader.source = "BarEditor.qml"; |
|
159 | editorLoader.source = "BarEditor.qml"; | |
152 | } |
|
160 | } | |
153 | } |
|
161 | } | |
154 | Button { |
|
162 | Button { | |
155 | text: "hsbar" |
|
163 | text: "hsbar" | |
156 | width: buttonWidth |
|
164 | width: buttonWidth | |
157 | onClicked: { |
|
165 | onClicked: { | |
158 | chartLoader.source = "HorizontalStackedBarChart.qml"; |
|
166 | chartLoader.source = "HorizontalStackedBarChart.qml"; | |
159 | editorLoader.source = "BarEditor.qml"; |
|
167 | editorLoader.source = "BarEditor.qml"; | |
160 | } |
|
168 | } | |
161 | } |
|
169 | } | |
162 | Button { |
|
170 | Button { | |
163 | text: "hpbar" |
|
171 | text: "hpbar" | |
164 | width: buttonWidth |
|
172 | width: buttonWidth | |
165 | onClicked: { |
|
173 | onClicked: { | |
166 | chartLoader.source = "HorizontalPercentBarChart.qml"; |
|
174 | chartLoader.source = "HorizontalPercentBarChart.qml"; | |
167 | editorLoader.source = "BarEditor.qml"; |
|
175 | editorLoader.source = "BarEditor.qml"; | |
168 | } |
|
176 | } | |
169 | } |
|
177 | } | |
170 | } |
|
178 | } | |
171 | } |
|
179 | } |
@@ -1,30 +1,31 | |||||
1 | <RCC> |
|
1 | <RCC> | |
2 | <qresource prefix="/"> |
|
2 | <qresource prefix="/"> | |
3 | <file>qml/qmlchartproperties/loader.qml</file> |
|
3 | <file>qml/qmlchartproperties/loader.qml</file> | |
4 | <file>qml/qmlchartproperties/main.qml</file> |
|
4 | <file>qml/qmlchartproperties/main.qml</file> | |
5 | <file>qml/qmlchartproperties/Button.qml</file> |
|
5 | <file>qml/qmlchartproperties/Button.qml</file> | |
6 | <file>qml/qmlchartproperties/PieChart.qml</file> |
|
6 | <file>qml/qmlchartproperties/PieChart.qml</file> | |
7 | <file>qml/qmlchartproperties/PieEditor.qml</file> |
|
7 | <file>qml/qmlchartproperties/PieEditor.qml</file> | |
8 | <file>qml/qmlchartproperties/LineChart.qml</file> |
|
8 | <file>qml/qmlchartproperties/LineChart.qml</file> | |
9 | <file>qml/qmlchartproperties/LineEditor.qml</file> |
|
9 | <file>qml/qmlchartproperties/LineEditor.qml</file> | |
10 | <file>qml/qmlchartproperties/SplineChart.qml</file> |
|
10 | <file>qml/qmlchartproperties/SplineChart.qml</file> | |
11 | <file>qml/qmlchartproperties/ScatterChart.qml</file> |
|
11 | <file>qml/qmlchartproperties/ScatterChart.qml</file> | |
12 | <file>qml/qmlchartproperties/AreaChart.qml</file> |
|
12 | <file>qml/qmlchartproperties/AreaChart.qml</file> | |
13 | <file>qml/qmlchartproperties/BarChart.qml</file> |
|
13 | <file>qml/qmlchartproperties/BarChart.qml</file> | |
14 | <file>qml/qmlchartproperties/BarEditor.qml</file> |
|
14 | <file>qml/qmlchartproperties/BarEditor.qml</file> | |
15 | <file>qml/qmlchartproperties/ScatterEditor.qml</file> |
|
15 | <file>qml/qmlchartproperties/ScatterEditor.qml</file> | |
16 | <file>qml/qmlchartproperties/AreaEditor.qml</file> |
|
16 | <file>qml/qmlchartproperties/AreaEditor.qml</file> | |
17 | <file>qml/qmlchartproperties/StackedBarChart.qml</file> |
|
17 | <file>qml/qmlchartproperties/StackedBarChart.qml</file> | |
18 | <file>qml/qmlchartproperties/PercentBarChart.qml</file> |
|
18 | <file>qml/qmlchartproperties/PercentBarChart.qml</file> | |
19 | <file>qml/qmlchartproperties/Chart.qml</file> |
|
19 | <file>qml/qmlchartproperties/Chart.qml</file> | |
20 | <file>qml/qmlchartproperties/ChartEditor.qml</file> |
|
20 | <file>qml/qmlchartproperties/ChartEditor.qml</file> | |
21 | <file>qml/qmlchartproperties/FontEditor.qml</file> |
|
21 | <file>qml/qmlchartproperties/FontEditor.qml</file> | |
22 | <file>qml/qmlchartproperties/HorizontalBarChart.qml</file> |
|
22 | <file>qml/qmlchartproperties/HorizontalBarChart.qml</file> | |
23 | <file>qml/qmlchartproperties/HorizontalPercentBarChart.qml</file> |
|
23 | <file>qml/qmlchartproperties/HorizontalPercentBarChart.qml</file> | |
24 | <file>qml/qmlchartproperties/HorizontalStackedBarChart.qml</file> |
|
24 | <file>qml/qmlchartproperties/HorizontalStackedBarChart.qml</file> | |
25 | <file>qml/qmlchartproperties/ChartEditorAxis.qml</file> |
|
25 | <file>qml/qmlchartproperties/ChartEditorAxis.qml</file> | |
26 | <file>qml/qmlchartproperties/ChartEditorLegend.qml</file> |
|
26 | <file>qml/qmlchartproperties/ChartEditorLegend.qml</file> | |
27 | <file>qml/qmlchartproperties/ChartEditorProperties.qml</file> |
|
27 | <file>qml/qmlchartproperties/ChartEditorProperties.qml</file> | |
28 | <file>qml/qmlchartproperties/ChartEditorTitle.qml</file> |
|
28 | <file>qml/qmlchartproperties/ChartEditorTitle.qml</file> | |
|
29 | <file>qml/qmlchartproperties/ChartEditorSeries.qml</file> | |||
29 | </qresource> |
|
30 | </qresource> | |
30 | </RCC> |
|
31 | </RCC> |
General Comments 0
You need to be logged in to leave comments.
Login now