@@ -1,116 +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 | import QtCommercial.Chart 1.2 |
|
22 | import QtCommercial.Chart 1.2 | |
23 |
|
23 | |||
24 | //![1] |
|
24 | //![1] | |
25 | ChartView { |
|
25 | ChartView { | |
26 | id: chartView |
|
26 | id: chartView | |
27 | animationOptions: ChartView.NoAnimation |
|
27 | animationOptions: ChartView.NoAnimation | |
28 | theme: ChartView.ChartThemeDark |
|
28 | theme: ChartView.ChartThemeDark | |
29 |
|
29 | |||
30 | ValueAxis { |
|
30 | ValueAxis { | |
31 | id: axisY1 |
|
31 | id: axisY1 | |
32 | min: -1 |
|
32 | min: -1 | |
33 | max: 4 |
|
33 | max: 4 | |
34 | } |
|
34 | } | |
35 |
|
35 | |||
36 | ValueAxis { |
|
36 | ValueAxis { | |
37 | id: axisY2 |
|
37 | id: axisY2 | |
38 | min: -10 |
|
38 | min: -10 | |
39 | max: 5 |
|
39 | max: 5 | |
40 | } |
|
40 | } | |
41 |
|
41 | |||
42 | ValueAxis { |
|
42 | ValueAxis { | |
43 | id: axisX |
|
43 | id: axisX | |
44 | min: 0 |
|
44 | min: 0 | |
45 | max: 1000 |
|
45 | max: 1000 | |
46 | } |
|
46 | } | |
47 |
|
47 | |||
48 | LineSeries { |
|
48 | LineSeries { | |
49 | id: lineSeries1 |
|
49 | id: lineSeries1 | |
50 | name: "signal 1" |
|
50 | name: "signal 1" | |
51 | axisX: axisX |
|
51 | axisX: axisX | |
52 | axisY: axisY1 |
|
52 | axisY: axisY1 | |
53 | } |
|
53 | } | |
54 | LineSeries { |
|
54 | LineSeries { | |
55 | id: lineSeries2 |
|
55 | id: lineSeries2 | |
56 | name: "signal 2" |
|
56 | name: "signal 2" | |
57 | axisX: axisX |
|
57 | axisX: axisX | |
58 | axisYRight: axisY2 |
|
58 | axisYRight: axisY2 | |
59 | } |
|
59 | } | |
60 | // ... |
|
60 | // ... | |
61 | //![1] |
|
61 | //![1] | |
62 |
|
62 | |||
63 | //![2] |
|
63 | //![2] | |
64 | Timer { |
|
64 | Timer { | |
65 | id: refreshTimer |
|
65 | id: refreshTimer | |
66 | interval: 1 / 60 * 1000 // 60 Hz |
|
66 | interval: 1 / 60 * 1000 // 60 Hz | |
67 | running: true |
|
67 | running: true | |
68 | repeat: true |
|
68 | repeat: true | |
69 | onTriggered: { |
|
69 | onTriggered: { | |
70 | dataSource.update(chartView.series(0)); |
|
70 | dataSource.update(chartView.series(0)); | |
71 | dataSource.update(chartView.series(1)); |
|
71 | dataSource.update(chartView.series(1)); | |
72 | } |
|
72 | } | |
73 | } |
|
73 | } | |
74 | //![2] |
|
74 | //![2] | |
75 |
|
75 | |||
76 | //![3] |
|
76 | //![3] | |
77 | function changeSeriesType(type) { |
|
77 | function changeSeriesType(type) { | |
78 | chartView.removeAllSeries(); |
|
78 | chartView.removeAllSeries(); | |
79 |
|
79 | |||
80 | // Create two new series of the correct type. Axis x is the same for both of the series, |
|
80 | // Create two new series of the correct type. Axis x is the same for both of the series, | |
81 | // but the series have their own y-axes to make it possible to control the y-offset |
|
81 | // but the series have their own y-axes to make it possible to control the y-offset | |
82 | // of the "signal sources". |
|
82 | // of the "signal sources". | |
83 | if (type == "line") { |
|
83 | if (type == "line") { | |
84 |
|
|
84 | chartView.createSeries(ChartView.SeriesTypeLine, "signal 1", axisX, axisY1); | |
85 |
|
|
85 | chartView.createSeries(ChartView.SeriesTypeLine, "signal 2", axisX, axisY2); | |
86 | } else if (type == "spline") { |
|
86 | } else if (type == "spline") { | |
87 |
|
|
87 | chartView.createSeries(ChartView.SeriesTypeSpline, "signal 1", axisX, axisY1); | |
88 |
|
|
88 | chartView.createSeries(ChartView.SeriesTypeSpline, "signal 2", axisX, axisY2); | |
89 | } else { |
|
89 | } else { | |
90 |
var series1 = |
|
90 | var series1 = chartView.createSeries(ChartView.SeriesTypeScatter, "signal 1", axisX, axisY1); | |
91 | series1.markerSize = 3; |
|
91 | series1.markerSize = 3; | |
92 | series1.borderColor = "transparent"; |
|
92 | series1.borderColor = "transparent"; | |
93 |
var series2 = |
|
93 | var series2 = chartView.createSeries(ChartView.SeriesTypeScatter, "signal 2", axisX, axisY2); | |
94 | series2.markerSize = 3; |
|
94 | series2.markerSize = 3; | |
95 | series2.borderColor = "transparent"; |
|
95 | series2.borderColor = "transparent"; | |
96 | } |
|
96 | } | |
97 | } |
|
97 | } | |
98 |
|
98 | |||
99 | function createAxis(min, max) { |
|
99 | function createAxis(min, max) { | |
100 | // The following creates a ValueAxis object that can be then set as a x or y axis for a series |
|
100 | // The following creates a ValueAxis object that can be then set as a x or y axis for a series | |
101 | return Qt.createQmlObject("import QtQuick 1.1; import QtCommercial.Chart 1.1; ValueAxis { min: " |
|
101 | return Qt.createQmlObject("import QtQuick 1.1; import QtCommercial.Chart 1.1; ValueAxis { min: " | |
102 | + min + "; max: " + max + " }", chartView); |
|
102 | + min + "; max: " + max + " }", chartView); | |
103 | } |
|
103 | } | |
104 | //![3] |
|
104 | //![3] | |
105 |
|
105 | |||
106 | function setAnimations(enabled) { |
|
106 | function setAnimations(enabled) { | |
107 | if (enabled) |
|
107 | if (enabled) | |
108 |
|
|
108 | chartView.animationOptions = ChartView.SeriesAnimations; | |
109 | else |
|
109 | else | |
110 |
|
|
110 | chartView.animationOptions = ChartView.NoAnimation; | |
111 | } |
|
111 | } | |
112 |
|
112 | |||
113 | function changeRefreshRate(rate) { |
|
113 | function changeRefreshRate(rate) { | |
114 | refreshTimer.interval = 1 / Number(rate) * 1000; |
|
114 | refreshTimer.interval = 1 / Number(rate) * 1000; | |
115 | } |
|
115 | } | |
116 | } |
|
116 | } |
@@ -1,767 +1,762 | |||||
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 "chartdataset_p.h" |
|
35 | #include "chartdataset_p.h" | |
36 | #include "declarativeaxes.h" |
|
36 | #include "declarativeaxes.h" | |
37 | #include "qchart_p.h" |
|
37 | #include "qchart_p.h" | |
38 |
|
38 | |||
39 | #ifndef QT_ON_ARM |
|
39 | #ifndef QT_ON_ARM | |
40 | #include "qdatetimeaxis.h" |
|
40 | #include "qdatetimeaxis.h" | |
41 | #endif |
|
41 | #endif | |
42 |
|
42 | |||
43 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
43 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
44 |
|
44 | |||
45 | /*! |
|
45 | /*! | |
46 | \qmlclass ChartView DeclarativeChart |
|
46 | \qmlclass ChartView DeclarativeChart | |
47 |
|
47 | |||
48 | ChartView element is the parent that is responsible for showing different chart series types. |
|
48 | ChartView element is the parent that is responsible for showing different chart series types. | |
49 |
|
49 | |||
50 | The following QML shows how to create a simple chart with one pie series: |
|
50 | The following QML shows how to create a simple chart with one pie series: | |
51 | \snippet ../examples/qmlpiechart/qml/qmlpiechart/main.qml 1 |
|
51 | \snippet ../examples/qmlpiechart/qml/qmlpiechart/main.qml 1 | |
52 | \snippet ../examples/qmlpiechart/qml/qmlpiechart/main.qml 2 |
|
52 | \snippet ../examples/qmlpiechart/qml/qmlpiechart/main.qml 2 | |
53 | \snippet ../examples/qmlpiechart/qml/qmlpiechart/main.qml 3 |
|
53 | \snippet ../examples/qmlpiechart/qml/qmlpiechart/main.qml 3 | |
54 |
|
54 | |||
55 | \beginfloatleft |
|
55 | \beginfloatleft | |
56 | \image examples_qmlpiechart.png |
|
56 | \image examples_qmlpiechart.png | |
57 | \endfloat |
|
57 | \endfloat | |
58 | \clearfloat |
|
58 | \clearfloat | |
59 | */ |
|
59 | */ | |
60 |
|
60 | |||
61 | /*! |
|
61 | /*! | |
62 | \qmlproperty Theme ChartView::theme |
|
62 | \qmlproperty Theme ChartView::theme | |
63 | Theme defines the visual appearance of the chart, including for example colors, fonts, line |
|
63 | Theme defines the visual appearance of the chart, including for example colors, fonts, line | |
64 | widths and chart background. |
|
64 | widths and chart background. | |
65 | */ |
|
65 | */ | |
66 |
|
66 | |||
67 | /*! |
|
67 | /*! | |
68 | \qmlproperty Animation ChartView::animationOptions |
|
68 | \qmlproperty Animation ChartView::animationOptions | |
69 | Animation configuration of the chart. One of ChartView.NoAnimation, ChartView.GridAxisAnimations, |
|
69 | Animation configuration of the chart. One of ChartView.NoAnimation, ChartView.GridAxisAnimations, | |
70 | ChartView.SeriesAnimations or ChartView.AllAnimations. |
|
70 | ChartView.SeriesAnimations or ChartView.AllAnimations. | |
71 | */ |
|
71 | */ | |
72 |
|
72 | |||
73 | /*! |
|
73 | /*! | |
74 | \qmlproperty Font ChartView::titleFont |
|
74 | \qmlproperty Font ChartView::titleFont | |
75 | The title font of the chart |
|
75 | The title font of the chart | |
76 |
|
76 | |||
77 | See the \l {Font} {QML Font Element} for detailed documentation. |
|
77 | See the \l {Font} {QML Font Element} for detailed documentation. | |
78 | */ |
|
78 | */ | |
79 |
|
79 | |||
80 | /*! |
|
80 | /*! | |
81 | \qmlproperty string ChartView::title |
|
81 | \qmlproperty string ChartView::title | |
82 | The title of the chart, shown on top of the chart. |
|
82 | The title of the chart, shown on top of the chart. | |
83 | \sa ChartView::titleColor |
|
83 | \sa ChartView::titleColor | |
84 | */ |
|
84 | */ | |
85 |
|
85 | |||
86 | /*! |
|
86 | /*! | |
87 | \qmlproperty color ChartView::titleColor |
|
87 | \qmlproperty color ChartView::titleColor | |
88 | The color of the title text. |
|
88 | The color of the title text. | |
89 | */ |
|
89 | */ | |
90 |
|
90 | |||
91 | /*! |
|
91 | /*! | |
92 | \qmlproperty Legend ChartView::legend |
|
92 | \qmlproperty Legend ChartView::legend | |
93 | The legend of the chart. Legend lists all the series, pie slices and bar sets added on the chart. |
|
93 | The legend of the chart. Legend lists all the series, pie slices and bar sets added on the chart. | |
94 | */ |
|
94 | */ | |
95 |
|
95 | |||
96 | /*! |
|
96 | /*! | |
97 | \qmlproperty int ChartView::count |
|
97 | \qmlproperty int ChartView::count | |
98 | The count of series added to the chart. |
|
98 | The count of series added to the chart. | |
99 | */ |
|
99 | */ | |
100 |
|
100 | |||
101 | /*! |
|
101 | /*! | |
102 | \qmlproperty color ChartView::backgroundColor |
|
102 | \qmlproperty color ChartView::backgroundColor | |
103 | The color of the chart's background. By default background color is defined by chart theme. |
|
103 | The color of the chart's background. By default background color is defined by chart theme. | |
104 | \sa ChartView::theme |
|
104 | \sa ChartView::theme | |
105 | */ |
|
105 | */ | |
106 |
|
106 | |||
107 | /*! |
|
107 | /*! | |
108 | \qmlproperty bool ChartView::dropShadowEnabled |
|
108 | \qmlproperty bool ChartView::dropShadowEnabled | |
109 | The chart's border drop shadow. Set to true to enable drop shadow. |
|
109 | The chart's border drop shadow. Set to true to enable drop shadow. | |
110 | */ |
|
110 | */ | |
111 |
|
111 | |||
112 | /*! |
|
112 | /*! | |
113 | \qmlproperty real ChartView::topMargin |
|
113 | \qmlproperty real ChartView::topMargin | |
114 | */ |
|
114 | */ | |
115 |
|
115 | |||
116 | /*! |
|
116 | /*! | |
117 | \qmlproperty real ChartView::bottomMargin |
|
117 | \qmlproperty real ChartView::bottomMargin | |
118 | */ |
|
118 | */ | |
119 |
|
119 | |||
120 | /*! |
|
120 | /*! | |
121 | \qmlproperty real ChartView::leftMargin |
|
121 | \qmlproperty real ChartView::leftMargin | |
122 | */ |
|
122 | */ | |
123 |
|
123 | |||
124 | /*! |
|
124 | /*! | |
125 | \qmlproperty real ChartView::rightMargin |
|
125 | \qmlproperty real ChartView::rightMargin | |
126 | */ |
|
126 | */ | |
127 |
|
127 | |||
128 | /*! |
|
128 | /*! | |
129 | \qmlproperty Margins ChartView::minimumMargins |
|
129 | \qmlproperty Margins ChartView::minimumMargins | |
130 | Deprecated; use margins instead. |
|
130 | Deprecated; use margins instead. | |
131 | The minimum margins allowed between the outer bounds and the plotArea of the ChartView. Margins |
|
131 | The minimum margins allowed between the outer bounds and the plotArea of the ChartView. Margins | |
132 | area of ChartView is used for drawing title, axes and legend. Please note that setting the |
|
132 | area of ChartView is used for drawing title, axes and legend. Please note that setting the | |
133 | properties of minimumMargins may be bigger than the defined value, depending on other ChartView |
|
133 | properties of minimumMargins may be bigger than the defined value, depending on other ChartView | |
134 | properties that affect it's layout. If you need to know the actual plotting area used at any |
|
134 | properties that affect it's layout. If you need to know the actual plotting area used at any | |
135 | given time, you can check ChartView::plotArea instead. |
|
135 | given time, you can check ChartView::plotArea instead. | |
136 | */ |
|
136 | */ | |
137 |
|
137 | |||
138 | /*! |
|
138 | /*! | |
139 | \qmlproperty rect ChartView::plotArea |
|
139 | \qmlproperty rect ChartView::plotArea | |
140 | The area on the ChartView that is used for drawing series. This is the ChartView rect without the |
|
140 | The area on the ChartView that is used for drawing series. This is the ChartView rect without the | |
141 | margins. |
|
141 | margins. | |
142 | \sa ChartView::minimumMargins |
|
142 | \sa ChartView::minimumMargins | |
143 | */ |
|
143 | */ | |
144 |
|
144 | |||
145 | /*! |
|
145 | /*! | |
146 | \qmlproperty Margins ChartView::margins |
|
146 | \qmlproperty Margins ChartView::margins | |
147 | The minimum margins allowed between the outer bounds and the plotArea of the ChartView. Margins |
|
147 | The minimum margins allowed between the outer bounds and the plotArea of the ChartView. Margins | |
148 | area of ChartView is used for drawing title, axes and legend. |
|
148 | area of ChartView is used for drawing title, axes and legend. | |
149 | */ |
|
149 | */ | |
150 |
|
150 | |||
151 | /*! |
|
151 | /*! | |
152 | \qmlmethod AbstractSeries ChartView::series(int index) |
|
152 | \qmlmethod AbstractSeries ChartView::series(int index) | |
153 | Returns the series with \a index on the chart. This allows you to loop through the series of a chart together with |
|
153 | Returns the series with \a index on the chart. This allows you to loop through the series of a chart together with | |
154 | the count property of the chart. |
|
154 | the count property of the chart. | |
155 | */ |
|
155 | */ | |
156 |
|
156 | |||
157 | /*! |
|
157 | /*! | |
158 | \qmlmethod AbstractSeries ChartView::series(string name) |
|
158 | \qmlmethod AbstractSeries ChartView::series(string name) | |
159 | Returns the first series on the chart with \a name. If there is no series with that name, returns null. |
|
159 | Returns the first series on the chart with \a name. If there is no series with that name, returns null. | |
160 | */ |
|
160 | */ | |
161 |
|
161 | |||
162 | /*! |
|
162 | /*! | |
163 | \qmlmethod AbstractSeries ChartView::createSeries(SeriesType type, string name, AbstractAxis axisX, AbstractAxis axisY) |
|
163 | \qmlmethod AbstractSeries ChartView::createSeries(SeriesType type, string name, AbstractAxis axisX, AbstractAxis axisY) | |
164 | Creates a series object of \a type to the chart with name \a name, optional axis \a axisX and |
|
164 | Creates a series object of \a type to the chart with name \a name, optional axis \a axisX and | |
165 | optional axis \a axisY. For example: |
|
165 | optional axis \a axisY. For example: | |
166 | \code |
|
166 | \code | |
167 | // lineSeries is a LineSeries object that has already been added to the ChartView; re-use it's axes |
|
167 | // lineSeries is a LineSeries object that has already been added to the ChartView; re-use it's axes | |
168 | var myAxisX = chartView.axisX(lineSeries); |
|
168 | var myAxisX = chartView.axisX(lineSeries); | |
169 | var myAxisY = chartView.axisY(lineSeries); |
|
169 | var myAxisY = chartView.axisY(lineSeries); | |
170 | var scatter = chartView.createSeries(ChartView.SeriesTypeScatter, "scatter series", myAxisX, myAxisY); |
|
170 | var scatter = chartView.createSeries(ChartView.SeriesTypeScatter, "scatter series", myAxisX, myAxisY); | |
171 | \endcode |
|
171 | \endcode | |
172 | */ |
|
172 | */ | |
173 |
|
173 | |||
174 | /*! |
|
174 | /*! | |
175 | \qmlmethod ChartView::removeSeries(AbstractSeries series) |
|
175 | \qmlmethod ChartView::removeSeries(AbstractSeries series) | |
176 | Removes the \a series from the chart. The series object is also destroyed. |
|
176 | Removes the \a series from the chart. The series object is also destroyed. | |
177 | */ |
|
177 | */ | |
178 |
|
178 | |||
179 | /*! |
|
179 | /*! | |
180 | \qmlmethod ChartView::removeAllSeries() |
|
180 | \qmlmethod ChartView::removeAllSeries() | |
181 | Removes all series from the chart. All the series objects are also destroyed. |
|
181 | Removes all series from the chart. All the series objects are also destroyed. | |
182 | */ |
|
182 | */ | |
183 |
|
183 | |||
184 | /*! |
|
184 | /*! | |
185 | \qmlmethod Axis ChartView::axisX(AbstractSeries series) |
|
185 | \qmlmethod Axis ChartView::axisX(AbstractSeries series) | |
186 | The x-axis of the series. |
|
186 | The x-axis of the series. | |
187 | */ |
|
187 | */ | |
188 |
|
188 | |||
189 | /*! |
|
189 | /*! | |
190 | \qmlmethod Axis ChartView::axisY(AbstractSeries series) |
|
190 | \qmlmethod Axis ChartView::axisY(AbstractSeries series) | |
191 | The y-axis of the series. |
|
191 | The y-axis of the series. | |
192 | */ |
|
192 | */ | |
193 |
|
193 | |||
194 | /*! |
|
194 | /*! | |
195 | \qmlmethod ChartView::zoomY(real factor) |
|
195 | \qmlmethod ChartView::zoomY(real factor) | |
196 | Zooms in by \a factor on the center of the chart. |
|
196 | Zooms in by \a factor on the center of the chart. | |
197 | */ |
|
197 | */ | |
198 |
|
198 | |||
199 | /*! |
|
199 | /*! | |
200 | \qmlmethod ChartView::scrollLeft(real pixels) |
|
200 | \qmlmethod ChartView::scrollLeft(real pixels) | |
201 | Scrolls to left by \a pixels. This is a convenience function that suits for example for key navigation. |
|
201 | Scrolls to left by \a pixels. This is a convenience function that suits for example for key navigation. | |
202 | */ |
|
202 | */ | |
203 |
|
203 | |||
204 | /*! |
|
204 | /*! | |
205 | \qmlmethod ChartView::scrollRight(real pixels) |
|
205 | \qmlmethod ChartView::scrollRight(real pixels) | |
206 | Scrolls to right by \a pixels. This is a convenience function that suits for example for key navigation. |
|
206 | Scrolls to right by \a pixels. This is a convenience function that suits for example for key navigation. | |
207 | */ |
|
207 | */ | |
208 |
|
208 | |||
209 | /*! |
|
209 | /*! | |
210 | \qmlmethod ChartView::scrollUp(real pixels) |
|
210 | \qmlmethod ChartView::scrollUp(real pixels) | |
211 | Scrolls up by \a pixels. This is a convenience function that suits for example for key navigation. |
|
211 | Scrolls up by \a pixels. This is a convenience function that suits for example for key navigation. | |
212 | */ |
|
212 | */ | |
213 |
|
213 | |||
214 | /*! |
|
214 | /*! | |
215 | \qmlmethod ChartView::scrollDown(real pixels) |
|
215 | \qmlmethod ChartView::scrollDown(real pixels) | |
216 | Scrolls down by \a pixels. This is a convenience function that suits for example for key navigation. |
|
216 | Scrolls down by \a pixels. This is a convenience function that suits for example for key navigation. | |
217 | */ |
|
217 | */ | |
218 |
|
218 | |||
219 | /*! |
|
219 | /*! | |
220 | \qmlsignal ChartView::onPlotAreaChanged(rect plotArea) |
|
220 | \qmlsignal ChartView::onPlotAreaChanged(rect plotArea) | |
221 | The plot area of the chart has changed. This may happen for example, if you modify minimumMargins |
|
221 | The plot area of the chart has changed. This may happen for example, if you modify minimumMargins | |
222 | or if you resize the chart, or if you modify font size related properties of the legend or chart |
|
222 | or if you resize the chart, or if you modify font size related properties of the legend or chart | |
223 | title. |
|
223 | title. | |
224 | */ |
|
224 | */ | |
225 |
|
225 | |||
226 | /*! |
|
226 | /*! | |
227 | \qmlsignal ChartView::seriesAdded(AbstractSeries series) |
|
227 | \qmlsignal ChartView::seriesAdded(AbstractSeries series) | |
228 | The \a series has been added to the chart. |
|
228 | The \a series has been added to the chart. | |
229 | */ |
|
229 | */ | |
230 |
|
230 | |||
231 | /*! |
|
231 | /*! | |
232 | \qmlsignal ChartView::seriesRemoved(AbstractSeries series) |
|
232 | \qmlsignal ChartView::seriesRemoved(AbstractSeries series) | |
233 | The \a series has been removed from the chart. Please note that \a series is no longer a valid |
|
233 | The \a series has been removed from the chart. Please note that \a series is no longer a valid | |
234 | object after the signal handler has completed. |
|
234 | object after the signal handler has completed. | |
235 | */ |
|
235 | */ | |
236 |
|
236 | |||
237 | DeclarativeChart::DeclarativeChart(QDeclarativeItem *parent) |
|
237 | DeclarativeChart::DeclarativeChart(QDeclarativeItem *parent) | |
238 | : QDeclarativeItem(parent), |
|
238 | : QDeclarativeItem(parent), | |
239 | m_chart(new QChart(this)) |
|
239 | m_chart(new QChart(this)) | |
240 | { |
|
240 | { | |
241 | setFlag(QGraphicsItem::ItemHasNoContents, false); |
|
241 | setFlag(QGraphicsItem::ItemHasNoContents, false); | |
242 | m_margins = new DeclarativeMargins(this); |
|
242 | m_margins = new DeclarativeMargins(this); | |
243 | m_margins->setTop(m_chart->margins().top()); |
|
243 | m_margins->setTop(m_chart->margins().top()); | |
244 | m_margins->setLeft(m_chart->margins().left()); |
|
244 | m_margins->setLeft(m_chart->margins().left()); | |
245 | m_margins->setRight(m_chart->margins().right()); |
|
245 | m_margins->setRight(m_chart->margins().right()); | |
246 | m_margins->setBottom(m_chart->margins().bottom()); |
|
246 | m_margins->setBottom(m_chart->margins().bottom()); | |
247 | connect(m_margins, SIGNAL(topChanged(int,int,int,int)), this, SLOT(changeMinimumMargins(int,int,int,int))); |
|
247 | connect(m_margins, SIGNAL(topChanged(int,int,int,int)), this, SLOT(changeMinimumMargins(int,int,int,int))); | |
248 | connect(m_margins, SIGNAL(bottomChanged(int,int,int,int)), this, SLOT(changeMinimumMargins(int,int,int,int))); |
|
248 | connect(m_margins, SIGNAL(bottomChanged(int,int,int,int)), this, SLOT(changeMinimumMargins(int,int,int,int))); | |
249 | connect(m_margins, SIGNAL(leftChanged(int,int,int,int)), this, SLOT(changeMinimumMargins(int,int,int,int))); |
|
249 | connect(m_margins, SIGNAL(leftChanged(int,int,int,int)), this, SLOT(changeMinimumMargins(int,int,int,int))); | |
250 | connect(m_margins, SIGNAL(rightChanged(int,int,int,int)), this, SLOT(changeMinimumMargins(int,int,int,int))); |
|
250 | connect(m_margins, SIGNAL(rightChanged(int,int,int,int)), this, SLOT(changeMinimumMargins(int,int,int,int))); | |
251 | connect(m_chart->d_ptr->m_dataset, SIGNAL(seriesAdded(QAbstractSeries*)), this, SLOT(handleSeriesAdded(QAbstractSeries*))); |
|
251 | connect(m_chart->d_ptr->m_dataset, SIGNAL(seriesAdded(QAbstractSeries*)), this, SLOT(handleSeriesAdded(QAbstractSeries*))); | |
252 | connect(m_chart->d_ptr->m_dataset, SIGNAL(seriesRemoved(QAbstractSeries*)), this, SIGNAL(seriesRemoved(QAbstractSeries*))); |
|
252 | connect(m_chart->d_ptr->m_dataset, SIGNAL(seriesRemoved(QAbstractSeries*)), this, SIGNAL(seriesRemoved(QAbstractSeries*))); | |
253 | } |
|
253 | } | |
254 |
|
254 | |||
255 | void DeclarativeChart::handleSeriesAdded(QAbstractSeries *series) |
|
255 | void DeclarativeChart::handleSeriesAdded(QAbstractSeries *series) | |
256 | { |
|
256 | { | |
257 | emit seriesAdded(series); |
|
257 | emit seriesAdded(series); | |
258 | } |
|
258 | } | |
259 |
|
259 | |||
260 | void DeclarativeChart::changeMinimumMargins(int top, int bottom, int left, int right) |
|
260 | void DeclarativeChart::changeMinimumMargins(int top, int bottom, int left, int right) | |
261 | { |
|
261 | { | |
262 | m_chart->setMargins(QMargins(left, top, right, bottom)); |
|
262 | m_chart->setMargins(QMargins(left, top, right, bottom)); | |
263 | emit minimumMarginsChanged(); |
|
263 | emit minimumMarginsChanged(); | |
264 | emit plotAreaChanged(m_chart->plotArea()); |
|
264 | emit plotAreaChanged(m_chart->plotArea()); | |
265 | } |
|
265 | } | |
266 |
|
266 | |||
267 | DeclarativeChart::~DeclarativeChart() |
|
267 | DeclarativeChart::~DeclarativeChart() | |
268 | { |
|
268 | { | |
269 | delete m_chart; |
|
269 | delete m_chart; | |
270 | } |
|
270 | } | |
271 |
|
271 | |||
272 | void DeclarativeChart::childEvent(QChildEvent *event) |
|
272 | void DeclarativeChart::childEvent(QChildEvent *event) | |
273 | { |
|
273 | { | |
274 | if (event->type() == QEvent::ChildAdded) { |
|
274 | if (event->type() == QEvent::ChildAdded) { | |
275 | if (qobject_cast<QAbstractSeries *>(event->child())) { |
|
275 | if (qobject_cast<QAbstractSeries *>(event->child())) { | |
276 | m_chart->addSeries(qobject_cast<QAbstractSeries *>(event->child())); |
|
276 | m_chart->addSeries(qobject_cast<QAbstractSeries *>(event->child())); | |
277 | } |
|
277 | } | |
278 | } |
|
278 | } | |
279 | } |
|
279 | } | |
280 |
|
280 | |||
281 | void DeclarativeChart::componentComplete() |
|
281 | void DeclarativeChart::componentComplete() | |
282 | { |
|
282 | { | |
283 | foreach (QObject *child, children()) { |
|
283 | foreach (QObject *child, children()) { | |
284 | if (qobject_cast<QAbstractSeries *>(child)) { |
|
284 | if (qobject_cast<QAbstractSeries *>(child)) { | |
285 | // Add series to the chart |
|
285 | // Add series to the chart | |
286 | QAbstractSeries *series = qobject_cast<QAbstractSeries *>(child); |
|
286 | QAbstractSeries *series = qobject_cast<QAbstractSeries *>(child); | |
287 | m_chart->addSeries(series); |
|
287 | m_chart->addSeries(series); | |
288 |
|
288 | |||
289 | // Connect to axis changed signals (unless this is a pie series) |
|
289 | // Connect to axis changed signals (unless this is a pie series) | |
290 | if (!qobject_cast<DeclarativePieSeries *>(series)) { |
|
290 | if (!qobject_cast<DeclarativePieSeries *>(series)) { | |
291 | connect(series, SIGNAL(axisXChanged(QAbstractAxis*)), this, SLOT(handleAxisXSet(QAbstractAxis*))); |
|
291 | connect(series, SIGNAL(axisXChanged(QAbstractAxis*)), this, SLOT(handleAxisXSet(QAbstractAxis*))); | |
292 | connect(series, SIGNAL(axisXTopChanged(QAbstractAxis*)), this, SLOT(handleAxisXSet(QAbstractAxis*))); |
|
292 | connect(series, SIGNAL(axisXTopChanged(QAbstractAxis*)), this, SLOT(handleAxisXSet(QAbstractAxis*))); | |
293 | connect(series, SIGNAL(axisYChanged(QAbstractAxis*)), this, SLOT(handleAxisYSet(QAbstractAxis*))); |
|
293 | connect(series, SIGNAL(axisYChanged(QAbstractAxis*)), this, SLOT(handleAxisYSet(QAbstractAxis*))); | |
294 | connect(series, SIGNAL(axisYRightChanged(QAbstractAxis*)), this, SLOT(handleAxisYRightSet(QAbstractAxis*))); |
|
294 | connect(series, SIGNAL(axisYRightChanged(QAbstractAxis*)), this, SLOT(handleAxisYRightSet(QAbstractAxis*))); | |
295 | } |
|
295 | } | |
296 |
|
296 | |||
297 | initializeAxes(series); |
|
297 | initializeAxes(series); | |
298 | } |
|
298 | } | |
299 | } |
|
299 | } | |
300 |
|
300 | |||
301 | QDeclarativeItem::componentComplete(); |
|
301 | QDeclarativeItem::componentComplete(); | |
302 | } |
|
302 | } | |
303 |
|
303 | |||
304 | void DeclarativeChart::handleAxisXSet(QAbstractAxis *axis) |
|
304 | void DeclarativeChart::handleAxisXSet(QAbstractAxis *axis) | |
305 | { |
|
305 | { | |
306 | QAbstractSeries *s = qobject_cast<QAbstractSeries *>(sender()); |
|
306 | QAbstractSeries *s = qobject_cast<QAbstractSeries *>(sender()); | |
307 | if (axis && s) { |
|
307 | if (axis && s) { | |
308 | if (!m_chart->axes(Qt::Horizontal).contains(axis)) |
|
308 | if (!m_chart->axes(Qt::Horizontal).contains(axis)) | |
309 | m_chart->addAxis(axis, Qt::AlignBottom); |
|
309 | m_chart->addAxis(axis, Qt::AlignBottom); | |
310 | if (!s->attachedAxes().contains(axis)) |
|
310 | if (!s->attachedAxes().contains(axis)) | |
311 | s->attachAxis(axis); |
|
311 | s->attachAxis(axis); | |
312 | } else { |
|
312 | } else { | |
313 | qWarning() << "Trying to set axisX to null."; |
|
313 | qWarning() << "Trying to set axisX to null."; | |
314 | } |
|
314 | } | |
315 | } |
|
315 | } | |
316 |
|
316 | |||
317 | void DeclarativeChart::handleAxisXTopSet(QAbstractAxis *axis) |
|
317 | void DeclarativeChart::handleAxisXTopSet(QAbstractAxis *axis) | |
318 | { |
|
318 | { | |
319 | QAbstractSeries *s = qobject_cast<QAbstractSeries *>(sender()); |
|
319 | QAbstractSeries *s = qobject_cast<QAbstractSeries *>(sender()); | |
320 | if (axis && s) { |
|
320 | if (axis && s) { | |
321 | if (!m_chart->axes(Qt::Horizontal).contains(axis)) |
|
321 | if (!m_chart->axes(Qt::Horizontal).contains(axis)) | |
322 | m_chart->addAxis(axis, Qt::AlignTop); |
|
322 | m_chart->addAxis(axis, Qt::AlignTop); | |
323 | if (!s->attachedAxes().contains(axis)) |
|
323 | if (!s->attachedAxes().contains(axis)) | |
324 | s->attachAxis(axis); |
|
324 | s->attachAxis(axis); | |
325 | } else { |
|
325 | } else { | |
326 | qWarning() << "Trying to set axisXTop to null."; |
|
326 | qWarning() << "Trying to set axisXTop to null."; | |
327 | } |
|
327 | } | |
328 | } |
|
328 | } | |
329 |
|
329 | |||
330 | void DeclarativeChart::handleAxisYSet(QAbstractAxis *axis) |
|
330 | void DeclarativeChart::handleAxisYSet(QAbstractAxis *axis) | |
331 | { |
|
331 | { | |
332 | QAbstractSeries *s = qobject_cast<QAbstractSeries *>(sender()); |
|
332 | QAbstractSeries *s = qobject_cast<QAbstractSeries *>(sender()); | |
333 | if (axis && s) { |
|
333 | if (axis && s) { | |
334 | if (!m_chart->axes(Qt::Vertical).contains(axis)) |
|
334 | if (!m_chart->axes(Qt::Vertical).contains(axis)) | |
335 | m_chart->addAxis(axis, Qt::AlignLeft); |
|
335 | m_chart->addAxis(axis, Qt::AlignLeft); | |
336 | if (!s->attachedAxes().contains(axis)) |
|
336 | if (!s->attachedAxes().contains(axis)) | |
337 | s->attachAxis(axis); |
|
337 | s->attachAxis(axis); | |
338 | } else { |
|
338 | } else { | |
339 | qWarning() << "Trying to set axisY to null."; |
|
339 | qWarning() << "Trying to set axisY to null."; | |
340 | } |
|
340 | } | |
341 | } |
|
341 | } | |
342 |
|
342 | |||
343 | void DeclarativeChart::handleAxisYRightSet(QAbstractAxis *axis) |
|
343 | void DeclarativeChart::handleAxisYRightSet(QAbstractAxis *axis) | |
344 | { |
|
344 | { | |
345 | QAbstractSeries *s = qobject_cast<QAbstractSeries *>(sender()); |
|
345 | QAbstractSeries *s = qobject_cast<QAbstractSeries *>(sender()); | |
346 | if (axis && s) { |
|
346 | if (axis && s) { | |
347 | if (!m_chart->axes(Qt::Vertical).contains(axis)) |
|
347 | if (!m_chart->axes(Qt::Vertical).contains(axis)) | |
348 | m_chart->addAxis(axis, Qt::AlignRight); |
|
348 | m_chart->addAxis(axis, Qt::AlignRight); | |
349 | if (!s->attachedAxes().contains(axis)) |
|
349 | if (!s->attachedAxes().contains(axis)) | |
350 | s->attachAxis(axis); |
|
350 | s->attachAxis(axis); | |
351 | } else { |
|
351 | } else { | |
352 | qWarning() << "Trying to set axisYRight to null."; |
|
352 | qWarning() << "Trying to set axisYRight to null."; | |
353 | } |
|
353 | } | |
354 | } |
|
354 | } | |
355 |
|
355 | |||
356 | void DeclarativeChart::geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) |
|
356 | void DeclarativeChart::geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) | |
357 | { |
|
357 | { | |
358 | // qDebug() << "DeclarativeChart::geometryChanged" << newGeometry.width() << newGeometry.height(); |
|
358 | // qDebug() << "DeclarativeChart::geometryChanged" << newGeometry.width() << newGeometry.height(); | |
359 | if (newGeometry.isValid()) { |
|
359 | if (newGeometry.isValid()) { | |
360 | if (newGeometry.width() > 0 && newGeometry.height() > 0) { |
|
360 | if (newGeometry.width() > 0 && newGeometry.height() > 0) { | |
361 | m_chart->resize(newGeometry.width(), newGeometry.height()); |
|
361 | m_chart->resize(newGeometry.width(), newGeometry.height()); | |
362 | } |
|
362 | } | |
363 | } |
|
363 | } | |
364 | QDeclarativeItem::geometryChanged(newGeometry, oldGeometry); |
|
364 | QDeclarativeItem::geometryChanged(newGeometry, oldGeometry); | |
365 |
|
365 | |||
366 | // It would be better to trigger the plotAreaChanged signal from QChart::plotAreaChanged or |
|
366 | // It would be better to trigger the plotAreaChanged signal from QChart::plotAreaChanged or | |
367 | // similar. Since that kind of a signal is not clearly needed in the C++ API the work-around is |
|
367 | // similar. Since that kind of a signal is not clearly needed in the C++ API the work-around is | |
368 | // to implement it here for the QML API purposes. |
|
368 | // to implement it here for the QML API purposes. | |
369 | emit plotAreaChanged(m_chart->plotArea()); |
|
369 | emit plotAreaChanged(m_chart->plotArea()); | |
370 | } |
|
370 | } | |
371 |
|
371 | |||
372 | void DeclarativeChart::setTheme(DeclarativeChart::Theme theme) |
|
372 | void DeclarativeChart::setTheme(DeclarativeChart::Theme theme) | |
373 | { |
|
373 | { | |
374 | QChart::ChartTheme chartTheme = (QChart::ChartTheme) theme; |
|
374 | QChart::ChartTheme chartTheme = (QChart::ChartTheme) theme; | |
375 | if (chartTheme != m_chart->theme()) |
|
375 | if (chartTheme != m_chart->theme()) | |
376 | m_chart->setTheme(chartTheme); |
|
376 | m_chart->setTheme(chartTheme); | |
377 | } |
|
377 | } | |
378 |
|
378 | |||
379 | DeclarativeChart::Theme DeclarativeChart::theme() |
|
379 | DeclarativeChart::Theme DeclarativeChart::theme() | |
380 | { |
|
380 | { | |
381 | return (DeclarativeChart::Theme) m_chart->theme(); |
|
381 | return (DeclarativeChart::Theme) m_chart->theme(); | |
382 | } |
|
382 | } | |
383 |
|
383 | |||
384 | void DeclarativeChart::setAnimationOptions(DeclarativeChart::Animation animations) |
|
384 | void DeclarativeChart::setAnimationOptions(DeclarativeChart::Animation animations) | |
385 | { |
|
385 | { | |
386 | QChart::AnimationOption animationOptions = (QChart::AnimationOption) animations; |
|
386 | QChart::AnimationOption animationOptions = (QChart::AnimationOption) animations; | |
387 | if (animationOptions != m_chart->animationOptions()) |
|
387 | if (animationOptions != m_chart->animationOptions()) | |
388 | m_chart->setAnimationOptions(animationOptions); |
|
388 | m_chart->setAnimationOptions(animationOptions); | |
389 | } |
|
389 | } | |
390 |
|
390 | |||
391 | DeclarativeChart::Animation DeclarativeChart::animationOptions() |
|
391 | DeclarativeChart::Animation DeclarativeChart::animationOptions() | |
392 | { |
|
392 | { | |
393 | if (m_chart->animationOptions().testFlag(QChart::AllAnimations)) |
|
393 | if (m_chart->animationOptions().testFlag(QChart::AllAnimations)) | |
394 | return DeclarativeChart::AllAnimations; |
|
394 | return DeclarativeChart::AllAnimations; | |
395 | else if (m_chart->animationOptions().testFlag(QChart::GridAxisAnimations)) |
|
395 | else if (m_chart->animationOptions().testFlag(QChart::GridAxisAnimations)) | |
396 | return DeclarativeChart::GridAxisAnimations; |
|
396 | return DeclarativeChart::GridAxisAnimations; | |
397 | else if (m_chart->animationOptions().testFlag(QChart::SeriesAnimations)) |
|
397 | else if (m_chart->animationOptions().testFlag(QChart::SeriesAnimations)) | |
398 | return DeclarativeChart::SeriesAnimations; |
|
398 | return DeclarativeChart::SeriesAnimations; | |
399 | else |
|
399 | else | |
400 | return DeclarativeChart::NoAnimation; |
|
400 | return DeclarativeChart::NoAnimation; | |
401 | } |
|
401 | } | |
402 |
|
402 | |||
403 | void DeclarativeChart::setTitle(QString title) |
|
403 | void DeclarativeChart::setTitle(QString title) | |
404 | { |
|
404 | { | |
405 | if (title != m_chart->title()) |
|
405 | if (title != m_chart->title()) | |
406 | m_chart->setTitle(title); |
|
406 | m_chart->setTitle(title); | |
407 | } |
|
407 | } | |
408 | QString DeclarativeChart::title() |
|
408 | QString DeclarativeChart::title() | |
409 | { |
|
409 | { | |
410 | return m_chart->title(); |
|
410 | return m_chart->title(); | |
411 | } |
|
411 | } | |
412 |
|
412 | |||
413 | QAbstractAxis *DeclarativeChart::axisX(QAbstractSeries *series) |
|
413 | QAbstractAxis *DeclarativeChart::axisX(QAbstractSeries *series) | |
414 | { |
|
414 | { | |
415 | QList<QAbstractAxis *> axes = m_chart->axes(Qt::Horizontal, series); |
|
415 | QList<QAbstractAxis *> axes = m_chart->axes(Qt::Horizontal, series); | |
416 | if (axes.count()) |
|
416 | if (axes.count()) | |
417 | return axes[0]; |
|
417 | return axes[0]; | |
418 | return 0; |
|
418 | return 0; | |
419 | } |
|
419 | } | |
420 |
|
420 | |||
421 | QAbstractAxis *DeclarativeChart::axisY(QAbstractSeries *series) |
|
421 | QAbstractAxis *DeclarativeChart::axisY(QAbstractSeries *series) | |
422 | { |
|
422 | { | |
423 | QList<QAbstractAxis *> axes = m_chart->axes(Qt::Vertical, series); |
|
423 | QList<QAbstractAxis *> axes = m_chart->axes(Qt::Vertical, series); | |
424 | if (axes.count()) |
|
424 | if (axes.count()) | |
425 | return axes[0]; |
|
425 | return axes[0]; | |
426 | return 0; |
|
426 | return 0; | |
427 | } |
|
427 | } | |
428 |
|
428 | |||
429 | QLegend *DeclarativeChart::legend() |
|
429 | QLegend *DeclarativeChart::legend() | |
430 | { |
|
430 | { | |
431 | return m_chart->legend(); |
|
431 | return m_chart->legend(); | |
432 | } |
|
432 | } | |
433 |
|
433 | |||
434 | void DeclarativeChart::setTitleColor(QColor color) |
|
434 | void DeclarativeChart::setTitleColor(QColor color) | |
435 | { |
|
435 | { | |
436 | QBrush b = m_chart->titleBrush(); |
|
436 | QBrush b = m_chart->titleBrush(); | |
437 | if (color != b.color()) { |
|
437 | if (color != b.color()) { | |
438 | b.setColor(color); |
|
438 | b.setColor(color); | |
439 | m_chart->setTitleBrush(b); |
|
439 | m_chart->setTitleBrush(b); | |
440 | emit titleColorChanged(color); |
|
440 | emit titleColorChanged(color); | |
441 | } |
|
441 | } | |
442 | } |
|
442 | } | |
443 |
|
443 | |||
444 | QFont DeclarativeChart::titleFont() const |
|
444 | QFont DeclarativeChart::titleFont() const | |
445 | { |
|
445 | { | |
446 | return m_chart->titleFont(); |
|
446 | return m_chart->titleFont(); | |
447 | } |
|
447 | } | |
448 |
|
448 | |||
449 | void DeclarativeChart::setTitleFont(const QFont &font) |
|
449 | void DeclarativeChart::setTitleFont(const QFont &font) | |
450 | { |
|
450 | { | |
451 | m_chart->setTitleFont(font); |
|
451 | m_chart->setTitleFont(font); | |
452 | } |
|
452 | } | |
453 |
|
453 | |||
454 | QColor DeclarativeChart::titleColor() |
|
454 | QColor DeclarativeChart::titleColor() | |
455 | { |
|
455 | { | |
456 | return m_chart->titleBrush().color(); |
|
456 | return m_chart->titleBrush().color(); | |
457 | } |
|
457 | } | |
458 |
|
458 | |||
459 | void DeclarativeChart::setBackgroundColor(QColor color) |
|
459 | void DeclarativeChart::setBackgroundColor(QColor color) | |
460 | { |
|
460 | { | |
461 | QBrush b = m_chart->backgroundBrush(); |
|
461 | QBrush b = m_chart->backgroundBrush(); | |
462 | if (b.style() != Qt::SolidPattern || color != b.color()) { |
|
462 | if (b.style() != Qt::SolidPattern || color != b.color()) { | |
463 | b.setStyle(Qt::SolidPattern); |
|
463 | b.setStyle(Qt::SolidPattern); | |
464 | b.setColor(color); |
|
464 | b.setColor(color); | |
465 | m_chart->setBackgroundBrush(b); |
|
465 | m_chart->setBackgroundBrush(b); | |
466 | emit backgroundColorChanged(); |
|
466 | emit backgroundColorChanged(); | |
467 | } |
|
467 | } | |
468 | } |
|
468 | } | |
469 |
|
469 | |||
470 | QColor DeclarativeChart::backgroundColor() |
|
470 | QColor DeclarativeChart::backgroundColor() | |
471 | { |
|
471 | { | |
472 | return m_chart->backgroundBrush().color(); |
|
472 | return m_chart->backgroundBrush().color(); | |
473 | } |
|
473 | } | |
474 |
|
474 | |||
475 | int DeclarativeChart::count() |
|
475 | int DeclarativeChart::count() | |
476 | { |
|
476 | { | |
477 | return m_chart->series().count(); |
|
477 | return m_chart->series().count(); | |
478 | } |
|
478 | } | |
479 |
|
479 | |||
480 | void DeclarativeChart::setDropShadowEnabled(bool enabled) |
|
480 | void DeclarativeChart::setDropShadowEnabled(bool enabled) | |
481 | { |
|
481 | { | |
482 | if (enabled != m_chart->isDropShadowEnabled()) { |
|
482 | if (enabled != m_chart->isDropShadowEnabled()) { | |
483 | m_chart->setDropShadowEnabled(enabled); |
|
483 | m_chart->setDropShadowEnabled(enabled); | |
484 | dropShadowEnabledChanged(enabled); |
|
484 | dropShadowEnabledChanged(enabled); | |
485 | } |
|
485 | } | |
486 | } |
|
486 | } | |
487 |
|
487 | |||
488 | bool DeclarativeChart::dropShadowEnabled() |
|
488 | bool DeclarativeChart::dropShadowEnabled() | |
489 | { |
|
489 | { | |
490 | return m_chart->isDropShadowEnabled(); |
|
490 | return m_chart->isDropShadowEnabled(); | |
491 | } |
|
491 | } | |
492 |
|
492 | |||
493 | qreal DeclarativeChart::topMargin() |
|
493 | qreal DeclarativeChart::topMargin() | |
494 | { |
|
494 | { | |
495 | qWarning() << "ChartView.topMargin is deprecated. Use margins instead."; |
|
495 | qWarning() << "ChartView.topMargin is deprecated. Use margins instead."; | |
496 | return m_chart->margins().top(); |
|
496 | return m_chart->margins().top(); | |
497 | } |
|
497 | } | |
498 |
|
498 | |||
499 | qreal DeclarativeChart::bottomMargin() |
|
499 | qreal DeclarativeChart::bottomMargin() | |
500 | { |
|
500 | { | |
501 | qWarning() << "ChartView.bottomMargin is deprecated. Use margins instead."; |
|
501 | qWarning() << "ChartView.bottomMargin is deprecated. Use margins instead."; | |
502 | return m_chart->margins().bottom(); |
|
502 | return m_chart->margins().bottom(); | |
503 | } |
|
503 | } | |
504 |
|
504 | |||
505 | qreal DeclarativeChart::leftMargin() |
|
505 | qreal DeclarativeChart::leftMargin() | |
506 | { |
|
506 | { | |
507 | qWarning() << "ChartView.leftMargin is deprecated. Use margins instead."; |
|
507 | qWarning() << "ChartView.leftMargin is deprecated. Use margins instead."; | |
508 | return m_chart->margins().left(); |
|
508 | return m_chart->margins().left(); | |
509 | } |
|
509 | } | |
510 |
|
510 | |||
511 | qreal DeclarativeChart::rightMargin() |
|
511 | qreal DeclarativeChart::rightMargin() | |
512 | { |
|
512 | { | |
513 | qWarning() << "ChartView.rightMargin is deprecated. Use margins instead."; |
|
513 | qWarning() << "ChartView.rightMargin is deprecated. Use margins instead."; | |
514 | return m_chart->margins().right(); |
|
514 | return m_chart->margins().right(); | |
515 | } |
|
515 | } | |
516 |
|
516 | |||
517 | void DeclarativeChart::zoom(qreal factor) |
|
517 | void DeclarativeChart::zoom(qreal factor) | |
518 | { |
|
518 | { | |
519 | m_chart->zoom(factor); |
|
519 | m_chart->zoom(factor); | |
520 | } |
|
520 | } | |
521 |
|
521 | |||
522 | void DeclarativeChart::scrollLeft(qreal pixels) |
|
522 | void DeclarativeChart::scrollLeft(qreal pixels) | |
523 | { |
|
523 | { | |
524 | m_chart->scroll(-pixels, 0); |
|
524 | m_chart->scroll(-pixels, 0); | |
525 | } |
|
525 | } | |
526 |
|
526 | |||
527 | void DeclarativeChart::scrollRight(qreal pixels) |
|
527 | void DeclarativeChart::scrollRight(qreal pixels) | |
528 | { |
|
528 | { | |
529 | m_chart->scroll(pixels, 0); |
|
529 | m_chart->scroll(pixels, 0); | |
530 | } |
|
530 | } | |
531 |
|
531 | |||
532 | void DeclarativeChart::scrollUp(qreal pixels) |
|
532 | void DeclarativeChart::scrollUp(qreal pixels) | |
533 | { |
|
533 | { | |
534 | m_chart->scroll(0, pixels); |
|
534 | m_chart->scroll(0, pixels); | |
535 | } |
|
535 | } | |
536 |
|
536 | |||
537 | void DeclarativeChart::scrollDown(qreal pixels) |
|
537 | void DeclarativeChart::scrollDown(qreal pixels) | |
538 | { |
|
538 | { | |
539 | m_chart->scroll(0, -pixels); |
|
539 | m_chart->scroll(0, -pixels); | |
540 | } |
|
540 | } | |
541 |
|
541 | |||
542 | QDeclarativeListProperty<QAbstractAxis> DeclarativeChart::axes() |
|
542 | QDeclarativeListProperty<QAbstractAxis> DeclarativeChart::axes() | |
543 | { |
|
543 | { | |
544 | return QDeclarativeListProperty<QAbstractAxis>(this, 0, |
|
544 | return QDeclarativeListProperty<QAbstractAxis>(this, 0, | |
545 | &DeclarativeChart::axesAppendFunc, |
|
545 | &DeclarativeChart::axesAppendFunc, | |
546 | &DeclarativeChart::axesCountFunc, |
|
546 | &DeclarativeChart::axesCountFunc, | |
547 | &DeclarativeChart::axesAtFunc); |
|
547 | &DeclarativeChart::axesAtFunc); | |
548 | } |
|
548 | } | |
549 |
|
549 | |||
550 | void DeclarativeChart::axesAppendFunc(QDeclarativeListProperty<QAbstractAxis> *list, QAbstractAxis *element) |
|
550 | void DeclarativeChart::axesAppendFunc(QDeclarativeListProperty<QAbstractAxis> *list, QAbstractAxis *element) | |
551 | { |
|
551 | { | |
552 | // Empty implementation |
|
552 | // Empty implementation | |
553 | Q_UNUSED(list); |
|
553 | Q_UNUSED(list); | |
554 | Q_UNUSED(element); |
|
554 | Q_UNUSED(element); | |
555 | } |
|
555 | } | |
556 |
|
556 | |||
557 | int DeclarativeChart::axesCountFunc(QDeclarativeListProperty<QAbstractAxis> *list) |
|
557 | int DeclarativeChart::axesCountFunc(QDeclarativeListProperty<QAbstractAxis> *list) | |
558 | { |
|
558 | { | |
559 | if (qobject_cast<DeclarativeChart *>(list->object)) { |
|
559 | if (qobject_cast<DeclarativeChart *>(list->object)) { | |
560 | DeclarativeChart *chart = qobject_cast<DeclarativeChart *>(list->object); |
|
560 | DeclarativeChart *chart = qobject_cast<DeclarativeChart *>(list->object); | |
561 | return chart->m_chart->axes(Qt::Horizontal | Qt::Vertical).count(); |
|
561 | return chart->m_chart->axes(Qt::Horizontal | Qt::Vertical).count(); | |
562 | } |
|
562 | } | |
563 | return 0; |
|
563 | return 0; | |
564 | } |
|
564 | } | |
565 |
|
565 | |||
566 | QAbstractAxis *DeclarativeChart::axesAtFunc(QDeclarativeListProperty<QAbstractAxis> *list, int index) |
|
566 | QAbstractAxis *DeclarativeChart::axesAtFunc(QDeclarativeListProperty<QAbstractAxis> *list, int index) | |
567 | { |
|
567 | { | |
568 | if (qobject_cast<DeclarativeChart *>(list->object)) { |
|
568 | if (qobject_cast<DeclarativeChart *>(list->object)) { | |
569 | DeclarativeChart *chart = qobject_cast<DeclarativeChart *>(list->object); |
|
569 | DeclarativeChart *chart = qobject_cast<DeclarativeChart *>(list->object); | |
570 | QList<QAbstractAxis *> axes = chart->m_chart->axes(Qt::Horizontal | Qt::Vertical, chart->m_chart->series()[0]); |
|
570 | QList<QAbstractAxis *> axes = chart->m_chart->axes(Qt::Horizontal | Qt::Vertical, chart->m_chart->series()[0]); | |
571 | return axes.at(index); |
|
571 | return axes.at(index); | |
572 | } |
|
572 | } | |
573 | return 0; |
|
573 | return 0; | |
574 | } |
|
574 | } | |
575 |
|
575 | |||
576 | QAbstractSeries *DeclarativeChart::series(int index) |
|
576 | QAbstractSeries *DeclarativeChart::series(int index) | |
577 | { |
|
577 | { | |
578 | if (index < m_chart->series().count()) { |
|
578 | if (index < m_chart->series().count()) { | |
579 | return m_chart->series().at(index); |
|
579 | return m_chart->series().at(index); | |
580 | } |
|
580 | } | |
581 | return 0; |
|
581 | return 0; | |
582 | } |
|
582 | } | |
583 |
|
583 | |||
584 | QAbstractSeries *DeclarativeChart::series(QString seriesName) |
|
584 | QAbstractSeries *DeclarativeChart::series(QString seriesName) | |
585 | { |
|
585 | { | |
586 | foreach (QAbstractSeries *series, m_chart->series()) { |
|
586 | foreach (QAbstractSeries *series, m_chart->series()) { | |
587 | if (series->name() == seriesName) |
|
587 | if (series->name() == seriesName) | |
588 | return series; |
|
588 | return series; | |
589 | } |
|
589 | } | |
590 | return 0; |
|
590 | return 0; | |
591 | } |
|
591 | } | |
592 |
|
592 | |||
593 |
QAbstractSeries *DeclarativeChart::createSeries( |
|
593 | QAbstractSeries *DeclarativeChart::createSeries(int type, QString name, QAbstractAxis *axisX, QAbstractAxis *axisY) | |
594 | { |
|
|||
595 | return createSeries(type, name, 0, 0); |
|
|||
596 | } |
|
|||
597 |
|
||||
598 | QAbstractSeries *DeclarativeChart::createSeries(DeclarativeChart::SeriesType type, QString name, QAbstractAxis *axisX, QAbstractAxis *axisY) |
|
|||
599 | { |
|
594 | { | |
600 | QAbstractSeries *series = 0; |
|
595 | QAbstractSeries *series = 0; | |
601 |
|
596 | |||
602 | switch (type) { |
|
597 | switch (type) { | |
603 | case DeclarativeChart::SeriesTypeLine: |
|
598 | case DeclarativeChart::SeriesTypeLine: | |
604 | series = new DeclarativeLineSeries(); |
|
599 | series = new DeclarativeLineSeries(); | |
605 | break; |
|
600 | break; | |
606 | case DeclarativeChart::SeriesTypeArea: { |
|
601 | case DeclarativeChart::SeriesTypeArea: { | |
607 | DeclarativeAreaSeries *area = new DeclarativeAreaSeries(); |
|
602 | DeclarativeAreaSeries *area = new DeclarativeAreaSeries(); | |
608 | area->setUpperSeries(new DeclarativeLineSeries()); |
|
603 | area->setUpperSeries(new DeclarativeLineSeries()); | |
609 | series = area; |
|
604 | series = area; | |
610 | break; |
|
605 | break; | |
611 | } |
|
606 | } | |
612 | case DeclarativeChart::SeriesTypeStackedBar: |
|
607 | case DeclarativeChart::SeriesTypeStackedBar: | |
613 | series = new DeclarativeStackedBarSeries(); |
|
608 | series = new DeclarativeStackedBarSeries(); | |
614 | break; |
|
609 | break; | |
615 | case DeclarativeChart::SeriesTypePercentBar: |
|
610 | case DeclarativeChart::SeriesTypePercentBar: | |
616 | series = new DeclarativePercentBarSeries(); |
|
611 | series = new DeclarativePercentBarSeries(); | |
617 | break; |
|
612 | break; | |
618 | case DeclarativeChart::SeriesTypeBar: |
|
613 | case DeclarativeChart::SeriesTypeBar: | |
619 | series = new DeclarativeBarSeries(); |
|
614 | series = new DeclarativeBarSeries(); | |
620 | break; |
|
615 | break; | |
621 | case DeclarativeChart::SeriesTypeHorizontalBar: |
|
616 | case DeclarativeChart::SeriesTypeHorizontalBar: | |
622 | series = new DeclarativeHorizontalBarSeries(); |
|
617 | series = new DeclarativeHorizontalBarSeries(); | |
623 | break; |
|
618 | break; | |
624 | case DeclarativeChart::SeriesTypeHorizontalPercentBar: |
|
619 | case DeclarativeChart::SeriesTypeHorizontalPercentBar: | |
625 | series = new DeclarativeHorizontalPercentBarSeries(); |
|
620 | series = new DeclarativeHorizontalPercentBarSeries(); | |
626 | break; |
|
621 | break; | |
627 | case DeclarativeChart::SeriesTypeHorizontalStackedBar: |
|
622 | case DeclarativeChart::SeriesTypeHorizontalStackedBar: | |
628 | series = new DeclarativeHorizontalStackedBarSeries(); |
|
623 | series = new DeclarativeHorizontalStackedBarSeries(); | |
629 | break; |
|
624 | break; | |
630 | case DeclarativeChart::SeriesTypePie: |
|
625 | case DeclarativeChart::SeriesTypePie: | |
631 | series = new DeclarativePieSeries(); |
|
626 | series = new DeclarativePieSeries(); | |
632 | break; |
|
627 | break; | |
633 | case DeclarativeChart::SeriesTypeScatter: |
|
628 | case DeclarativeChart::SeriesTypeScatter: | |
634 | series = new DeclarativeScatterSeries(); |
|
629 | series = new DeclarativeScatterSeries(); | |
635 | break; |
|
630 | break; | |
636 | case DeclarativeChart::SeriesTypeSpline: |
|
631 | case DeclarativeChart::SeriesTypeSpline: | |
637 | series = new DeclarativeSplineSeries(); |
|
632 | series = new DeclarativeSplineSeries(); | |
638 | break; |
|
633 | break; | |
639 | default: |
|
634 | default: | |
640 | qWarning() << "Illegal series type"; |
|
635 | qWarning() << "Illegal series type"; | |
641 | } |
|
636 | } | |
642 |
|
637 | |||
643 | if (series) { |
|
638 | if (series) { | |
644 | // Connect to axis changed signals (unless this is a pie series) |
|
639 | // Connect to axis changed signals (unless this is a pie series) | |
645 | if (!qobject_cast<DeclarativePieSeries *>(series)) { |
|
640 | if (!qobject_cast<DeclarativePieSeries *>(series)) { | |
646 | connect(series, SIGNAL(axisXChanged(QAbstractAxis*)), this, SLOT(handleAxisXSet(QAbstractAxis*))); |
|
641 | connect(series, SIGNAL(axisXChanged(QAbstractAxis*)), this, SLOT(handleAxisXSet(QAbstractAxis*))); | |
647 | connect(series, SIGNAL(axisXTopChanged(QAbstractAxis*)), this, SLOT(handleAxisXSet(QAbstractAxis*))); |
|
642 | connect(series, SIGNAL(axisXTopChanged(QAbstractAxis*)), this, SLOT(handleAxisXSet(QAbstractAxis*))); | |
648 | connect(series, SIGNAL(axisYChanged(QAbstractAxis*)), this, SLOT(handleAxisYSet(QAbstractAxis*))); |
|
643 | connect(series, SIGNAL(axisYChanged(QAbstractAxis*)), this, SLOT(handleAxisYSet(QAbstractAxis*))); | |
649 | connect(series, SIGNAL(axisYRightChanged(QAbstractAxis*)), this, SLOT(handleAxisYRightSet(QAbstractAxis*))); |
|
644 | connect(series, SIGNAL(axisYRightChanged(QAbstractAxis*)), this, SLOT(handleAxisYRightSet(QAbstractAxis*))); | |
650 | } |
|
645 | } | |
651 |
|
646 | |||
652 | series->setName(name); |
|
647 | series->setName(name); | |
653 | m_chart->addSeries(series); |
|
648 | m_chart->addSeries(series); | |
654 |
|
649 | |||
655 | if (axisX) |
|
650 | if (axisX) | |
656 | setAxisX(axisX, series); |
|
651 | setAxisX(axisX, series); | |
657 | if (axisY) |
|
652 | if (axisY) | |
658 | setAxisY(axisY, series); |
|
653 | setAxisY(axisY, series); | |
659 |
|
654 | |||
660 | if (series->attachedAxes().count() < 2) |
|
655 | if (series->attachedAxes().count() < 2) | |
661 | initializeAxes(series); |
|
656 | initializeAxes(series); | |
662 | } |
|
657 | } | |
663 |
|
658 | |||
664 | return series; |
|
659 | return series; | |
665 | } |
|
660 | } | |
666 |
|
661 | |||
667 | void DeclarativeChart::removeSeries(QAbstractSeries *series) |
|
662 | void DeclarativeChart::removeSeries(QAbstractSeries *series) | |
668 | { |
|
663 | { | |
669 | if (series) |
|
664 | if (series) | |
670 | m_chart->removeSeries(series); |
|
665 | m_chart->removeSeries(series); | |
671 | else |
|
666 | else | |
672 | qWarning("removeSeries: cannot remove null"); |
|
667 | qWarning("removeSeries: cannot remove null"); | |
673 | } |
|
668 | } | |
674 |
|
669 | |||
675 | void DeclarativeChart::setAxisX(QAbstractAxis *axis, QAbstractSeries *series) |
|
670 | void DeclarativeChart::setAxisX(QAbstractAxis *axis, QAbstractSeries *series) | |
676 | { |
|
671 | { | |
677 | if (axis) |
|
672 | if (axis) | |
678 | m_chart->setAxisX(axis, series); |
|
673 | m_chart->setAxisX(axis, series); | |
679 | } |
|
674 | } | |
680 |
|
675 | |||
681 | void DeclarativeChart::setAxisY(QAbstractAxis *axis, QAbstractSeries *series) |
|
676 | void DeclarativeChart::setAxisY(QAbstractAxis *axis, QAbstractSeries *series) | |
682 | { |
|
677 | { | |
683 | if (axis) |
|
678 | if (axis) | |
684 | m_chart->setAxisY(axis, series); |
|
679 | m_chart->setAxisY(axis, series); | |
685 | } |
|
680 | } | |
686 |
|
681 | |||
687 | void DeclarativeChart::createDefaultAxes() |
|
682 | void DeclarativeChart::createDefaultAxes() | |
688 | { |
|
683 | { | |
689 | qWarning() << "ChartView.createDefaultAxes() is deprecated. Axes are created automatically."; |
|
684 | qWarning() << "ChartView.createDefaultAxes() is deprecated. Axes are created automatically."; | |
690 | } |
|
685 | } | |
691 |
|
686 | |||
692 | QAbstractAxis *DeclarativeChart::defaultAxis(Qt::Orientation orientation, QAbstractSeries *series) |
|
687 | QAbstractAxis *DeclarativeChart::defaultAxis(Qt::Orientation orientation, QAbstractSeries *series) | |
693 | { |
|
688 | { | |
694 | if (!series) { |
|
689 | if (!series) { | |
695 | qWarning() << "No axis type defined for null series"; |
|
690 | qWarning() << "No axis type defined for null series"; | |
696 | return 0; |
|
691 | return 0; | |
697 | } |
|
692 | } | |
698 |
|
693 | |||
699 | foreach (QAbstractAxis *existingAxis, m_chart->axes(orientation)) { |
|
694 | foreach (QAbstractAxis *existingAxis, m_chart->axes(orientation)) { | |
700 | if (existingAxis->type() == series->d_ptr->defaultAxisType(orientation)) |
|
695 | if (existingAxis->type() == series->d_ptr->defaultAxisType(orientation)) | |
701 | return existingAxis; |
|
696 | return existingAxis; | |
702 | } |
|
697 | } | |
703 |
|
698 | |||
704 | switch (series->d_ptr->defaultAxisType(orientation)) { |
|
699 | switch (series->d_ptr->defaultAxisType(orientation)) { | |
705 | case QAbstractAxis::AxisTypeValue: |
|
700 | case QAbstractAxis::AxisTypeValue: | |
706 | return new QValueAxis(this); |
|
701 | return new QValueAxis(this); | |
707 | case QAbstractAxis::AxisTypeBarCategory: |
|
702 | case QAbstractAxis::AxisTypeBarCategory: | |
708 | return new QBarCategoryAxis(this); |
|
703 | return new QBarCategoryAxis(this); | |
709 | case QAbstractAxis::AxisTypeCategory: |
|
704 | case QAbstractAxis::AxisTypeCategory: | |
710 | return new QCategoryAxis(this); |
|
705 | return new QCategoryAxis(this); | |
711 | #ifndef QT_ON_ARM |
|
706 | #ifndef QT_ON_ARM | |
712 | case QAbstractAxis::AxisTypeDateTime: |
|
707 | case QAbstractAxis::AxisTypeDateTime: | |
713 | return new QDateTimeAxis(this); |
|
708 | return new QDateTimeAxis(this); | |
714 | #endif |
|
709 | #endif | |
715 | default: |
|
710 | default: | |
716 | // assume AxisTypeNoAxis |
|
711 | // assume AxisTypeNoAxis | |
717 | return 0; |
|
712 | return 0; | |
718 | } |
|
713 | } | |
719 | } |
|
714 | } | |
720 |
|
715 | |||
721 | void DeclarativeChart::initializeAxes(QAbstractSeries *series) |
|
716 | void DeclarativeChart::initializeAxes(QAbstractSeries *series) | |
722 | { |
|
717 | { | |
723 | if (qobject_cast<DeclarativeLineSeries *>(series)) |
|
718 | if (qobject_cast<DeclarativeLineSeries *>(series)) | |
724 | doInitializeAxes(series, qobject_cast<DeclarativeLineSeries *>(series)->m_axes); |
|
719 | doInitializeAxes(series, qobject_cast<DeclarativeLineSeries *>(series)->m_axes); | |
725 | else if (qobject_cast<DeclarativeScatterSeries *>(series)) |
|
720 | else if (qobject_cast<DeclarativeScatterSeries *>(series)) | |
726 | doInitializeAxes(series, qobject_cast<DeclarativeScatterSeries *>(series)->m_axes); |
|
721 | doInitializeAxes(series, qobject_cast<DeclarativeScatterSeries *>(series)->m_axes); | |
727 | else if (qobject_cast<DeclarativeSplineSeries *>(series)) |
|
722 | else if (qobject_cast<DeclarativeSplineSeries *>(series)) | |
728 | doInitializeAxes(series, qobject_cast<DeclarativeSplineSeries *>(series)->m_axes); |
|
723 | doInitializeAxes(series, qobject_cast<DeclarativeSplineSeries *>(series)->m_axes); | |
729 | else if (qobject_cast<DeclarativeAreaSeries *>(series)) |
|
724 | else if (qobject_cast<DeclarativeAreaSeries *>(series)) | |
730 | doInitializeAxes(series, qobject_cast<DeclarativeAreaSeries *>(series)->m_axes); |
|
725 | doInitializeAxes(series, qobject_cast<DeclarativeAreaSeries *>(series)->m_axes); | |
731 | else if (qobject_cast<DeclarativeBarSeries *>(series)) |
|
726 | else if (qobject_cast<DeclarativeBarSeries *>(series)) | |
732 | doInitializeAxes(series, qobject_cast<DeclarativeBarSeries *>(series)->m_axes); |
|
727 | doInitializeAxes(series, qobject_cast<DeclarativeBarSeries *>(series)->m_axes); | |
733 | else if (qobject_cast<DeclarativeStackedBarSeries *>(series)) |
|
728 | else if (qobject_cast<DeclarativeStackedBarSeries *>(series)) | |
734 | doInitializeAxes(series, qobject_cast<DeclarativeStackedBarSeries *>(series)->m_axes); |
|
729 | doInitializeAxes(series, qobject_cast<DeclarativeStackedBarSeries *>(series)->m_axes); | |
735 | else if (qobject_cast<DeclarativePercentBarSeries *>(series)) |
|
730 | else if (qobject_cast<DeclarativePercentBarSeries *>(series)) | |
736 | doInitializeAxes(series, qobject_cast<DeclarativePercentBarSeries *>(series)->m_axes); |
|
731 | doInitializeAxes(series, qobject_cast<DeclarativePercentBarSeries *>(series)->m_axes); | |
737 | else if (qobject_cast<DeclarativeHorizontalBarSeries *>(series)) |
|
732 | else if (qobject_cast<DeclarativeHorizontalBarSeries *>(series)) | |
738 | doInitializeAxes(series, qobject_cast<DeclarativeHorizontalBarSeries *>(series)->m_axes); |
|
733 | doInitializeAxes(series, qobject_cast<DeclarativeHorizontalBarSeries *>(series)->m_axes); | |
739 | else if (qobject_cast<DeclarativeHorizontalStackedBarSeries *>(series)) |
|
734 | else if (qobject_cast<DeclarativeHorizontalStackedBarSeries *>(series)) | |
740 | doInitializeAxes(series, qobject_cast<DeclarativeHorizontalStackedBarSeries *>(series)->m_axes); |
|
735 | doInitializeAxes(series, qobject_cast<DeclarativeHorizontalStackedBarSeries *>(series)->m_axes); | |
741 | else if (qobject_cast<DeclarativeHorizontalPercentBarSeries *>(series)) |
|
736 | else if (qobject_cast<DeclarativeHorizontalPercentBarSeries *>(series)) | |
742 | doInitializeAxes(series, qobject_cast<DeclarativeHorizontalPercentBarSeries *>(series)->m_axes); |
|
737 | doInitializeAxes(series, qobject_cast<DeclarativeHorizontalPercentBarSeries *>(series)->m_axes); | |
743 | // else: do nothing |
|
738 | // else: do nothing | |
744 | } |
|
739 | } | |
745 |
|
740 | |||
746 | void DeclarativeChart::doInitializeAxes(QAbstractSeries *series, DeclarativeAxes *axes) |
|
741 | void DeclarativeChart::doInitializeAxes(QAbstractSeries *series, DeclarativeAxes *axes) | |
747 | { |
|
742 | { | |
748 | // Initialize axis X |
|
743 | // Initialize axis X | |
749 | if (axes->axisX()) |
|
744 | if (axes->axisX()) | |
750 | axes->emitAxisXChanged(); |
|
745 | axes->emitAxisXChanged(); | |
751 | else if (axes->axisXTop()) |
|
746 | else if (axes->axisXTop()) | |
752 | axes->emitAxisXTopChanged(); |
|
747 | axes->emitAxisXTopChanged(); | |
753 | else |
|
748 | else | |
754 | axes->setAxisX(defaultAxis(Qt::Horizontal, series)); |
|
749 | axes->setAxisX(defaultAxis(Qt::Horizontal, series)); | |
755 |
|
750 | |||
756 | // Initialize axis Y |
|
751 | // Initialize axis Y | |
757 | if (axes->axisY()) |
|
752 | if (axes->axisY()) | |
758 | axes->emitAxisYChanged(); |
|
753 | axes->emitAxisYChanged(); | |
759 | else if (axes->axisYRight()) |
|
754 | else if (axes->axisYRight()) | |
760 | axes->emitAxisYRightChanged(); |
|
755 | axes->emitAxisYRightChanged(); | |
761 | else |
|
756 | else | |
762 | axes->setAxisY(defaultAxis(Qt::Vertical, series)); |
|
757 | axes->setAxisY(defaultAxis(Qt::Vertical, series)); | |
763 | } |
|
758 | } | |
764 |
|
759 | |||
765 | #include "moc_declarativechart.cpp" |
|
760 | #include "moc_declarativechart.cpp" | |
766 |
|
761 | |||
767 | QTCOMMERCIALCHART_END_NAMESPACE |
|
762 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -1,184 +1,183 | |||||
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 | #include <QtDeclarative/QDeclarativeItem> |
|
25 | #include <QtDeclarative/QDeclarativeItem> | |
26 |
|
26 | |||
27 | #include "qchart.h" |
|
27 | #include "qchart.h" | |
28 |
|
28 | |||
29 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
29 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
30 |
|
30 | |||
31 | class DeclarativeMargins; |
|
31 | class DeclarativeMargins; | |
32 | class Domain; |
|
32 | class Domain; | |
33 | class DeclarativeAxes; |
|
33 | class DeclarativeAxes; | |
34 |
|
34 | |||
35 | class DeclarativeChart : public QDeclarativeItem |
|
35 | class DeclarativeChart : public QDeclarativeItem | |
36 | { |
|
36 | { | |
37 | Q_OBJECT |
|
37 | Q_OBJECT | |
38 | Q_PROPERTY(Theme theme READ theme WRITE setTheme) |
|
38 | Q_PROPERTY(Theme theme READ theme WRITE setTheme) | |
39 | Q_PROPERTY(Animation animationOptions READ animationOptions WRITE setAnimationOptions) |
|
39 | Q_PROPERTY(Animation animationOptions READ animationOptions WRITE setAnimationOptions) | |
40 | Q_PROPERTY(QString title READ title WRITE setTitle) |
|
40 | Q_PROPERTY(QString title READ title WRITE setTitle) | |
41 | Q_PROPERTY(QFont titleFont READ titleFont WRITE setTitleFont) |
|
41 | Q_PROPERTY(QFont titleFont READ titleFont WRITE setTitleFont) | |
42 | Q_PROPERTY(QColor titleColor READ titleColor WRITE setTitleColor NOTIFY titleColorChanged) |
|
42 | Q_PROPERTY(QColor titleColor READ titleColor WRITE setTitleColor NOTIFY titleColorChanged) | |
43 | Q_PROPERTY(QLegend *legend READ legend) |
|
43 | Q_PROPERTY(QLegend *legend READ legend) | |
44 | Q_PROPERTY(int count READ count) |
|
44 | Q_PROPERTY(int count READ count) | |
45 | Q_PROPERTY(QColor backgroundColor READ backgroundColor WRITE setBackgroundColor NOTIFY backgroundColorChanged) |
|
45 | Q_PROPERTY(QColor backgroundColor READ backgroundColor WRITE setBackgroundColor NOTIFY backgroundColorChanged) | |
46 | Q_PROPERTY(bool dropShadowEnabled READ dropShadowEnabled WRITE setDropShadowEnabled NOTIFY dropShadowEnabledChanged) |
|
46 | Q_PROPERTY(bool dropShadowEnabled READ dropShadowEnabled WRITE setDropShadowEnabled NOTIFY dropShadowEnabledChanged) | |
47 | Q_PROPERTY(qreal topMargin READ topMargin) |
|
47 | Q_PROPERTY(qreal topMargin READ topMargin) | |
48 | Q_PROPERTY(qreal bottomMargin READ bottomMargin) |
|
48 | Q_PROPERTY(qreal bottomMargin READ bottomMargin) | |
49 | Q_PROPERTY(qreal leftMargin READ leftMargin) |
|
49 | Q_PROPERTY(qreal leftMargin READ leftMargin) | |
50 | Q_PROPERTY(qreal rightMargin READ rightMargin) |
|
50 | Q_PROPERTY(qreal rightMargin READ rightMargin) | |
51 | Q_PROPERTY(DeclarativeMargins *minimumMargins READ minimumMargins NOTIFY minimumMarginsChanged REVISION 1) |
|
51 | Q_PROPERTY(DeclarativeMargins *minimumMargins READ minimumMargins NOTIFY minimumMarginsChanged REVISION 1) | |
52 | Q_PROPERTY(DeclarativeMargins *margins READ margins NOTIFY marginsChanged REVISION 2) |
|
52 | Q_PROPERTY(DeclarativeMargins *margins READ margins NOTIFY marginsChanged REVISION 2) | |
53 | Q_PROPERTY(QRectF plotArea READ plotArea NOTIFY plotAreaChanged REVISION 1) |
|
53 | Q_PROPERTY(QRectF plotArea READ plotArea NOTIFY plotAreaChanged REVISION 1) | |
54 | Q_PROPERTY(QDeclarativeListProperty<QAbstractAxis> axes READ axes REVISION 2) |
|
54 | Q_PROPERTY(QDeclarativeListProperty<QAbstractAxis> axes READ axes REVISION 2) | |
55 | Q_ENUMS(Animation) |
|
55 | Q_ENUMS(Animation) | |
56 | Q_ENUMS(Theme) |
|
56 | Q_ENUMS(Theme) | |
57 | Q_ENUMS(SeriesType) |
|
57 | Q_ENUMS(SeriesType) | |
58 |
|
58 | |||
59 | public: |
|
59 | public: | |
60 | // 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 | |
61 | enum Theme { |
|
61 | enum Theme { | |
62 | ChartThemeLight = 0, |
|
62 | ChartThemeLight = 0, | |
63 | ChartThemeBlueCerulean, |
|
63 | ChartThemeBlueCerulean, | |
64 | ChartThemeDark, |
|
64 | ChartThemeDark, | |
65 | ChartThemeBrownSand, |
|
65 | ChartThemeBrownSand, | |
66 | ChartThemeBlueNcs, |
|
66 | ChartThemeBlueNcs, | |
67 | ChartThemeHighContrast, |
|
67 | ChartThemeHighContrast, | |
68 | ChartThemeBlueIcy |
|
68 | ChartThemeBlueIcy | |
69 | }; |
|
69 | }; | |
70 |
|
70 | |||
71 | enum Animation { |
|
71 | enum Animation { | |
72 | NoAnimation = 0x0, |
|
72 | NoAnimation = 0x0, | |
73 | GridAxisAnimations = 0x1, |
|
73 | GridAxisAnimations = 0x1, | |
74 | SeriesAnimations = 0x2, |
|
74 | SeriesAnimations = 0x2, | |
75 | AllAnimations = 0x3 |
|
75 | AllAnimations = 0x3 | |
76 | }; |
|
76 | }; | |
77 |
|
77 | |||
78 | enum SeriesType { |
|
78 | enum SeriesType { | |
79 | SeriesTypeLine, |
|
79 | SeriesTypeLine, | |
80 | SeriesTypeArea, |
|
80 | SeriesTypeArea, | |
81 | SeriesTypeBar, |
|
81 | SeriesTypeBar, | |
82 | SeriesTypeStackedBar, |
|
82 | SeriesTypeStackedBar, | |
83 | SeriesTypePercentBar, |
|
83 | SeriesTypePercentBar, | |
84 | SeriesTypePie, |
|
84 | SeriesTypePie, | |
85 | SeriesTypeScatter, |
|
85 | SeriesTypeScatter, | |
86 | SeriesTypeSpline, |
|
86 | SeriesTypeSpline, | |
87 | SeriesTypeHorizontalBar, |
|
87 | SeriesTypeHorizontalBar, | |
88 | SeriesTypeHorizontalStackedBar, |
|
88 | SeriesTypeHorizontalStackedBar, | |
89 | SeriesTypeHorizontalPercentBar |
|
89 | SeriesTypeHorizontalPercentBar | |
90 | }; |
|
90 | }; | |
91 |
|
91 | |||
92 | public: |
|
92 | public: | |
93 | DeclarativeChart(QDeclarativeItem *parent = 0); |
|
93 | DeclarativeChart(QDeclarativeItem *parent = 0); | |
94 | ~DeclarativeChart(); |
|
94 | ~DeclarativeChart(); | |
95 |
|
95 | |||
96 | public: // From QDeclarativeItem/QGraphicsItem |
|
96 | public: // From QDeclarativeItem/QGraphicsItem | |
97 | void childEvent(QChildEvent *event); |
|
97 | void childEvent(QChildEvent *event); | |
98 | void componentComplete(); |
|
98 | void componentComplete(); | |
99 | void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry); |
|
99 | void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry); | |
100 |
|
100 | |||
101 | public: |
|
101 | public: | |
102 | void setTheme(DeclarativeChart::Theme theme); |
|
102 | void setTheme(DeclarativeChart::Theme theme); | |
103 | DeclarativeChart::Theme theme(); |
|
103 | DeclarativeChart::Theme theme(); | |
104 | void setAnimationOptions(DeclarativeChart::Animation animations); |
|
104 | void setAnimationOptions(DeclarativeChart::Animation animations); | |
105 | DeclarativeChart::Animation animationOptions(); |
|
105 | DeclarativeChart::Animation animationOptions(); | |
106 | void setTitle(QString title); |
|
106 | void setTitle(QString title); | |
107 | QString title(); |
|
107 | QString title(); | |
108 | QLegend *legend(); |
|
108 | QLegend *legend(); | |
109 | QFont titleFont() const; |
|
109 | QFont titleFont() const; | |
110 | void setTitleFont(const QFont &font); |
|
110 | void setTitleFont(const QFont &font); | |
111 | void setTitleColor(QColor color); |
|
111 | void setTitleColor(QColor color); | |
112 | QColor titleColor(); |
|
112 | QColor titleColor(); | |
113 | void setBackgroundColor(QColor color); |
|
113 | void setBackgroundColor(QColor color); | |
114 | QColor backgroundColor(); |
|
114 | QColor backgroundColor(); | |
115 | int count(); |
|
115 | int count(); | |
116 | void setDropShadowEnabled(bool enabled); |
|
116 | void setDropShadowEnabled(bool enabled); | |
117 | bool dropShadowEnabled(); |
|
117 | bool dropShadowEnabled(); | |
118 |
|
118 | |||
119 | // Margins & plotArea |
|
119 | // Margins & plotArea | |
120 | qreal topMargin(); |
|
120 | qreal topMargin(); | |
121 | qreal bottomMargin(); |
|
121 | qreal bottomMargin(); | |
122 | qreal leftMargin(); |
|
122 | qreal leftMargin(); | |
123 | qreal rightMargin(); |
|
123 | qreal rightMargin(); | |
124 | DeclarativeMargins *minimumMargins() { return m_margins; } |
|
124 | DeclarativeMargins *minimumMargins() { return m_margins; } | |
125 | Q_REVISION(2) DeclarativeMargins *margins() { return m_margins; } |
|
125 | Q_REVISION(2) DeclarativeMargins *margins() { return m_margins; } | |
126 | QRectF plotArea() { return m_chart->plotArea(); } |
|
126 | QRectF plotArea() { return m_chart->plotArea(); } | |
127 |
|
127 | |||
128 | // Axis handling |
|
128 | // Axis handling | |
129 | QAbstractAxis *defaultAxis(Qt::Orientation orientation, QAbstractSeries *series); |
|
129 | QAbstractAxis *defaultAxis(Qt::Orientation orientation, QAbstractSeries *series); | |
130 | void initializeAxes(QAbstractSeries *series); |
|
130 | void initializeAxes(QAbstractSeries *series); | |
131 | void doInitializeAxes(QAbstractSeries *series, DeclarativeAxes *axes); |
|
131 | void doInitializeAxes(QAbstractSeries *series, DeclarativeAxes *axes); | |
132 | QDeclarativeListProperty<QAbstractAxis> axes(); |
|
132 | QDeclarativeListProperty<QAbstractAxis> axes(); | |
133 | static void axesAppendFunc(QDeclarativeListProperty<QAbstractAxis> *list, QAbstractAxis *element); |
|
133 | static void axesAppendFunc(QDeclarativeListProperty<QAbstractAxis> *list, QAbstractAxis *element); | |
134 | static int axesCountFunc(QDeclarativeListProperty<QAbstractAxis> *list); |
|
134 | static int axesCountFunc(QDeclarativeListProperty<QAbstractAxis> *list); | |
135 | static QAbstractAxis *axesAtFunc(QDeclarativeListProperty<QAbstractAxis> *list, int index); |
|
135 | static QAbstractAxis *axesAtFunc(QDeclarativeListProperty<QAbstractAxis> *list, int index); | |
136 |
|
136 | |||
137 | public: |
|
137 | public: | |
138 | Q_INVOKABLE QAbstractSeries *series(int index); |
|
138 | Q_INVOKABLE QAbstractSeries *series(int index); | |
139 | Q_INVOKABLE QAbstractSeries *series(QString seriesName); |
|
139 | Q_INVOKABLE QAbstractSeries *series(QString seriesName); | |
140 |
Q_INVOKABLE QAbstractSeries *createSeries( |
|
140 | Q_INVOKABLE QAbstractSeries *createSeries(int type, QString name = "", QAbstractAxis *axisX = 0, QAbstractAxis *axisY = 0); | |
141 | Q_INVOKABLE QAbstractSeries *createSeries(DeclarativeChart::SeriesType type, QString name, QAbstractAxis *axisX, QAbstractAxis *axisY); |
|
|||
142 | Q_INVOKABLE void removeSeries(QAbstractSeries *series); |
|
141 | Q_INVOKABLE void removeSeries(QAbstractSeries *series); | |
143 | Q_INVOKABLE void removeAllSeries() { m_chart->removeAllSeries(); } |
|
142 | Q_INVOKABLE void removeAllSeries() { m_chart->removeAllSeries(); } | |
144 | Q_INVOKABLE void setAxisX(QAbstractAxis *axis, QAbstractSeries *series = 0); |
|
143 | Q_INVOKABLE void setAxisX(QAbstractAxis *axis, QAbstractSeries *series = 0); | |
145 | Q_INVOKABLE void setAxisY(QAbstractAxis *axis, QAbstractSeries *series = 0); |
|
144 | Q_INVOKABLE void setAxisY(QAbstractAxis *axis, QAbstractSeries *series = 0); | |
146 | Q_INVOKABLE void createDefaultAxes(); |
|
145 | Q_INVOKABLE void createDefaultAxes(); | |
147 | Q_INVOKABLE QAbstractAxis *axisX(QAbstractSeries *series = 0); |
|
146 | Q_INVOKABLE QAbstractAxis *axisX(QAbstractSeries *series = 0); | |
148 | Q_INVOKABLE QAbstractAxis *axisY(QAbstractSeries *series = 0); |
|
147 | Q_INVOKABLE QAbstractAxis *axisY(QAbstractSeries *series = 0); | |
149 | Q_INVOKABLE void zoom(qreal factor); |
|
148 | Q_INVOKABLE void zoom(qreal factor); | |
150 | Q_INVOKABLE void scrollLeft(qreal pixels); |
|
149 | Q_INVOKABLE void scrollLeft(qreal pixels); | |
151 | Q_INVOKABLE void scrollRight(qreal pixels); |
|
150 | Q_INVOKABLE void scrollRight(qreal pixels); | |
152 | Q_INVOKABLE void scrollUp(qreal pixels); |
|
151 | Q_INVOKABLE void scrollUp(qreal pixels); | |
153 | Q_INVOKABLE void scrollDown(qreal pixels); |
|
152 | Q_INVOKABLE void scrollDown(qreal pixels); | |
154 |
|
153 | |||
155 | Q_SIGNALS: |
|
154 | Q_SIGNALS: | |
156 | void axisLabelsChanged(); |
|
155 | void axisLabelsChanged(); | |
157 | void titleColorChanged(QColor color); |
|
156 | void titleColorChanged(QColor color); | |
158 | void backgroundColorChanged(); |
|
157 | void backgroundColorChanged(); | |
159 | void dropShadowEnabledChanged(bool enabled); |
|
158 | void dropShadowEnabledChanged(bool enabled); | |
160 | void minimumMarginsChanged(); |
|
159 | void minimumMarginsChanged(); | |
161 | Q_REVISION(2) void marginsChanged(); |
|
160 | Q_REVISION(2) void marginsChanged(); | |
162 | void plotAreaChanged(QRectF plotArea); |
|
161 | void plotAreaChanged(QRectF plotArea); | |
163 | void seriesAdded(QAbstractSeries *series); |
|
162 | void seriesAdded(QAbstractSeries *series); | |
164 | void seriesRemoved(QAbstractSeries *series); |
|
163 | void seriesRemoved(QAbstractSeries *series); | |
165 |
|
164 | |||
166 | private Q_SLOTS: |
|
165 | private Q_SLOTS: | |
167 | void changeMinimumMargins(int top, int bottom, int left, int right); |
|
166 | void changeMinimumMargins(int top, int bottom, int left, int right); | |
168 | void handleAxisXSet(QAbstractAxis *axis); |
|
167 | void handleAxisXSet(QAbstractAxis *axis); | |
169 | void handleAxisYSet(QAbstractAxis *axis); |
|
168 | void handleAxisYSet(QAbstractAxis *axis); | |
170 | void handleAxisXTopSet(QAbstractAxis *axis); |
|
169 | void handleAxisXTopSet(QAbstractAxis *axis); | |
171 | void handleAxisYRightSet(QAbstractAxis *axis); |
|
170 | void handleAxisYRightSet(QAbstractAxis *axis); | |
172 | void handleSeriesAdded(QAbstractSeries *series); |
|
171 | void handleSeriesAdded(QAbstractSeries *series); | |
173 |
|
172 | |||
174 | private: |
|
173 | private: | |
175 | // Extending QChart with DeclarativeChart is not possible because QObject does not support |
|
174 | // Extending QChart with DeclarativeChart is not possible because QObject does not support | |
176 | // multi inheritance, so we now have a QChart as a member instead |
|
175 | // multi inheritance, so we now have a QChart as a member instead | |
177 | QChart *m_chart; |
|
176 | QChart *m_chart; | |
178 | //QMargins m_chartMargins; |
|
177 | //QMargins m_chartMargins; | |
179 | DeclarativeMargins *m_margins; |
|
178 | DeclarativeMargins *m_margins; | |
180 | }; |
|
179 | }; | |
181 |
|
180 | |||
182 | QTCOMMERCIALCHART_END_NAMESPACE |
|
181 | QTCOMMERCIALCHART_END_NAMESPACE | |
183 |
|
182 | |||
184 | #endif // DECLARATIVECHART_H |
|
183 | #endif // DECLARATIVECHART_H |
@@ -1,230 +1,227 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2012 Digia Plc |
|
3 | ** Copyright (C) 2012 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
8 | ** |
|
8 | ** | |
9 | ** $QT_BEGIN_LICENSE$ |
|
9 | ** $QT_BEGIN_LICENSE$ | |
10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and Digia. |
|
13 | ** a written agreement between you and Digia. | |
14 | ** |
|
14 | ** | |
15 | ** If you have questions regarding the use of this file, please use |
|
15 | ** If you have questions regarding the use of this file, please use | |
16 | ** contact form at http://qt.digia.com |
|
16 | ** contact form at http://qt.digia.com | |
17 | ** $QT_END_LICENSE$ |
|
17 | ** $QT_END_LICENSE$ | |
18 | ** |
|
18 | ** | |
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 | #include "qchart.h" |
|
21 | #include "qchart.h" | |
22 | #include "qabstractaxis.h" |
|
22 | #include "qabstractaxis.h" | |
23 | #include "qvalueaxis.h" |
|
23 | #include "qvalueaxis.h" | |
24 | #include "declarativecategoryaxis.h" |
|
24 | #include "declarativecategoryaxis.h" | |
25 | #include "qbarcategoryaxis.h" |
|
25 | #include "qbarcategoryaxis.h" | |
26 | #include "declarativechart.h" |
|
26 | #include "declarativechart.h" | |
27 | #include "declarativexypoint.h" |
|
27 | #include "declarativexypoint.h" | |
28 | #include "declarativelineseries.h" |
|
28 | #include "declarativelineseries.h" | |
29 | #include "declarativesplineseries.h" |
|
29 | #include "declarativesplineseries.h" | |
30 | #include "declarativeareaseries.h" |
|
30 | #include "declarativeareaseries.h" | |
31 | #include "declarativescatterseries.h" |
|
31 | #include "declarativescatterseries.h" | |
32 | #include "declarativebarseries.h" |
|
32 | #include "declarativebarseries.h" | |
33 | #include "declarativepieseries.h" |
|
33 | #include "declarativepieseries.h" | |
34 | #include "declarativeaxes.h" |
|
34 | #include "declarativeaxes.h" | |
35 | #include "qvxymodelmapper.h" |
|
35 | #include "qvxymodelmapper.h" | |
36 | #include "qhxymodelmapper.h" |
|
36 | #include "qhxymodelmapper.h" | |
37 | #include "qhpiemodelmapper.h" |
|
37 | #include "qhpiemodelmapper.h" | |
38 | #include "qvpiemodelmapper.h" |
|
38 | #include "qvpiemodelmapper.h" | |
39 | #include "qhbarmodelmapper.h" |
|
39 | #include "qhbarmodelmapper.h" | |
40 | #include "qvbarmodelmapper.h" |
|
40 | #include "qvbarmodelmapper.h" | |
41 | #include "declarativemargins.h" |
|
41 | #include "declarativemargins.h" | |
42 | #include "qarealegendmarker.h" |
|
42 | #include "qarealegendmarker.h" | |
43 | #include "qbarlegendmarker.h" |
|
43 | #include "qbarlegendmarker.h" | |
44 | #include "qpielegendmarker.h" |
|
44 | #include "qpielegendmarker.h" | |
45 | #include "qxylegendmarker.h" |
|
45 | #include "qxylegendmarker.h" | |
46 | #ifndef QT_ON_ARM |
|
46 | #ifndef QT_ON_ARM | |
47 | #include "qdatetimeaxis.h" |
|
47 | #include "qdatetimeaxis.h" | |
48 | #endif |
|
48 | #endif | |
49 | #include <QAbstractItemModel> |
|
49 | #include <QAbstractItemModel> | |
50 | #include <QtDeclarative/qdeclarativeextensionplugin.h> |
|
50 | #include <QtDeclarative/qdeclarativeextensionplugin.h> | |
51 | #include <QtDeclarative/qdeclarative.h> |
|
51 | #include <QtDeclarative/qdeclarative.h> | |
52 |
|
52 | |||
53 | QTCOMMERCIALCHART_USE_NAMESPACE |
|
53 | QTCOMMERCIALCHART_USE_NAMESPACE | |
54 |
|
54 | |||
55 | Q_DECLARE_METATYPE(QList<QPieSlice *>) |
|
55 | Q_DECLARE_METATYPE(QList<QPieSlice *>) | |
56 | Q_DECLARE_METATYPE(QList<QBarSet *>) |
|
56 | Q_DECLARE_METATYPE(QList<QBarSet *>) | |
57 | Q_DECLARE_METATYPE(QList<QAbstractAxis *>) |
|
57 | Q_DECLARE_METATYPE(QList<QAbstractAxis *>) | |
58 |
|
58 | |||
59 | #if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)) |
|
59 | #if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)) | |
60 |
|
60 | |||
61 | // NOTE: Hackish fixes for Qt5 (beta2). |
|
61 | // NOTE: Hackish fixes for Qt5 (beta2). | |
62 | // These should not be needed or at least they are not needed in Qt4. |
|
62 | // These should not be needed or at least they are not needed in Qt4. | |
63 |
|
63 | |||
64 |
Q_DECLARE_METATYPE(DeclarativeChart |
|
64 | Q_DECLARE_METATYPE(DeclarativeChart *) | |
65 | Q_DECLARE_METATYPE(DeclarativeMargins *) |
|
65 | Q_DECLARE_METATYPE(DeclarativeMargins *) | |
66 | Q_DECLARE_METATYPE(DeclarativeAreaSeries *) |
|
66 | Q_DECLARE_METATYPE(DeclarativeAreaSeries *) | |
67 | Q_DECLARE_METATYPE(DeclarativeBarSeries *) |
|
67 | Q_DECLARE_METATYPE(DeclarativeBarSeries *) | |
68 | Q_DECLARE_METATYPE(DeclarativeLineSeries *) |
|
68 | Q_DECLARE_METATYPE(DeclarativeLineSeries *) | |
69 | Q_DECLARE_METATYPE(DeclarativePieSeries *) |
|
69 | Q_DECLARE_METATYPE(DeclarativePieSeries *) | |
70 | Q_DECLARE_METATYPE(DeclarativeScatterSeries *) |
|
70 | Q_DECLARE_METATYPE(DeclarativeScatterSeries *) | |
71 | Q_DECLARE_METATYPE(DeclarativeSplineSeries *) |
|
71 | Q_DECLARE_METATYPE(DeclarativeSplineSeries *) | |
72 |
|
72 | |||
73 | Q_DECLARE_METATYPE(QAbstractAxis *) |
|
73 | Q_DECLARE_METATYPE(QAbstractAxis *) | |
74 | Q_DECLARE_METATYPE(QValueAxis *) |
|
74 | Q_DECLARE_METATYPE(QValueAxis *) | |
75 | Q_DECLARE_METATYPE(QBarCategoryAxis *) |
|
75 | Q_DECLARE_METATYPE(QBarCategoryAxis *) | |
76 | Q_DECLARE_METATYPE(QCategoryAxis *) |
|
76 | Q_DECLARE_METATYPE(QCategoryAxis *) | |
77 | Q_DECLARE_METATYPE(QDateTimeAxis *) |
|
77 | Q_DECLARE_METATYPE(QDateTimeAxis *) | |
78 |
|
78 | |||
79 | Q_DECLARE_METATYPE(QLegend *) |
|
79 | Q_DECLARE_METATYPE(QLegend *) | |
80 | Q_DECLARE_METATYPE(QLegendMarker *) |
|
80 | Q_DECLARE_METATYPE(QLegendMarker *) | |
81 | Q_DECLARE_METATYPE(QAreaLegendMarker *) |
|
81 | Q_DECLARE_METATYPE(QAreaLegendMarker *) | |
82 | Q_DECLARE_METATYPE(QBarLegendMarker *) |
|
82 | Q_DECLARE_METATYPE(QBarLegendMarker *) | |
83 | Q_DECLARE_METATYPE(QPieLegendMarker *) |
|
83 | Q_DECLARE_METATYPE(QPieLegendMarker *) | |
84 |
|
84 | |||
85 | Q_DECLARE_METATYPE(QHPieModelMapper *) |
|
85 | Q_DECLARE_METATYPE(QHPieModelMapper *) | |
86 | Q_DECLARE_METATYPE(QHXYModelMapper *) |
|
86 | Q_DECLARE_METATYPE(QHXYModelMapper *) | |
87 | Q_DECLARE_METATYPE(QPieModelMapper *) |
|
87 | Q_DECLARE_METATYPE(QPieModelMapper *) | |
88 | Q_DECLARE_METATYPE(QHBarModelMapper *) |
|
88 | Q_DECLARE_METATYPE(QHBarModelMapper *) | |
89 | Q_DECLARE_METATYPE(QBarModelMapper *) |
|
89 | Q_DECLARE_METATYPE(QBarModelMapper *) | |
90 | Q_DECLARE_METATYPE(QVBarModelMapper *) |
|
90 | Q_DECLARE_METATYPE(QVBarModelMapper *) | |
91 | Q_DECLARE_METATYPE(QVPieModelMapper *) |
|
91 | Q_DECLARE_METATYPE(QVPieModelMapper *) | |
92 | Q_DECLARE_METATYPE(QVXYModelMapper *) |
|
92 | Q_DECLARE_METATYPE(QVXYModelMapper *) | |
93 | Q_DECLARE_METATYPE(QXYLegendMarker *) |
|
93 | Q_DECLARE_METATYPE(QXYLegendMarker *) | |
94 | Q_DECLARE_METATYPE(QXYModelMapper *) |
|
94 | Q_DECLARE_METATYPE(QXYModelMapper *) | |
95 |
|
95 | |||
96 | Q_DECLARE_METATYPE(QAbstractSeries *) |
|
96 | Q_DECLARE_METATYPE(QAbstractSeries *) | |
97 | Q_DECLARE_METATYPE(QXYSeries *) |
|
97 | Q_DECLARE_METATYPE(QXYSeries *) | |
98 | Q_DECLARE_METATYPE(QAbstractBarSeries *) |
|
98 | Q_DECLARE_METATYPE(QAbstractBarSeries *) | |
99 | Q_DECLARE_METATYPE(QBarSeries *) |
|
99 | Q_DECLARE_METATYPE(QBarSeries *) | |
100 | Q_DECLARE_METATYPE(QBarSet *) |
|
100 | Q_DECLARE_METATYPE(QBarSet *) | |
101 | Q_DECLARE_METATYPE(QAreaSeries *) |
|
101 | Q_DECLARE_METATYPE(QAreaSeries *) | |
102 | Q_DECLARE_METATYPE(QHorizontalBarSeries *) |
|
102 | Q_DECLARE_METATYPE(QHorizontalBarSeries *) | |
103 | Q_DECLARE_METATYPE(QHorizontalPercentBarSeries *) |
|
103 | Q_DECLARE_METATYPE(QHorizontalPercentBarSeries *) | |
104 | Q_DECLARE_METATYPE(QHorizontalStackedBarSeries *) |
|
104 | Q_DECLARE_METATYPE(QHorizontalStackedBarSeries *) | |
105 | Q_DECLARE_METATYPE(QLineSeries *) |
|
105 | Q_DECLARE_METATYPE(QLineSeries *) | |
106 | Q_DECLARE_METATYPE(QPercentBarSeries *) |
|
106 | Q_DECLARE_METATYPE(QPercentBarSeries *) | |
107 | Q_DECLARE_METATYPE(QPieSeries *) |
|
107 | Q_DECLARE_METATYPE(QPieSeries *) | |
108 | Q_DECLARE_METATYPE(QPieSlice *) |
|
108 | Q_DECLARE_METATYPE(QPieSlice *) | |
109 | Q_DECLARE_METATYPE(QScatterSeries *) |
|
109 | Q_DECLARE_METATYPE(QScatterSeries *) | |
110 | Q_DECLARE_METATYPE(QSplineSeries *) |
|
110 | Q_DECLARE_METATYPE(QSplineSeries *) | |
111 | Q_DECLARE_METATYPE(QStackedBarSeries *) |
|
111 | Q_DECLARE_METATYPE(QStackedBarSeries *) | |
112 |
|
112 | |||
113 | #endif |
|
113 | #endif | |
114 |
|
114 | |||
115 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
115 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
116 |
|
116 | |||
117 | class ChartQmlPlugin : public QDeclarativeExtensionPlugin |
|
117 | class ChartQmlPlugin : public QDeclarativeExtensionPlugin | |
118 | { |
|
118 | { | |
119 | Q_OBJECT |
|
119 | Q_OBJECT | |
120 |
|
120 | |||
121 | #if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)) |
|
121 | #if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)) | |
122 | Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QDeclarativeExtensionInterface") |
|
122 | Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QDeclarativeExtensionInterface") | |
123 | #endif |
|
123 | #endif | |
124 |
|
124 | |||
125 | public: |
|
125 | public: | |
126 | virtual void registerTypes(const char *uri) |
|
126 | virtual void registerTypes(const char *uri) | |
127 | { |
|
127 | { | |
128 | Q_ASSERT(QLatin1String(uri) == QLatin1String("QtCommercial.Chart")); |
|
128 | Q_ASSERT(QLatin1String(uri) == QLatin1String("QtCommercial.Chart")); | |
129 |
|
129 | |||
130 | qRegisterMetaType<QList<QPieSlice *> >(); |
|
130 | qRegisterMetaType<QList<QPieSlice *> >(); | |
131 | qRegisterMetaType<QList<QBarSet *> >(); |
|
131 | qRegisterMetaType<QList<QBarSet *> >(); | |
132 | qRegisterMetaType<QList<QAbstractAxis *> >(); |
|
132 | qRegisterMetaType<QList<QAbstractAxis *> >(); | |
133 | #if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)) |
|
|||
134 | qRegisterMetaType<DeclarativeChart::SeriesType>(); |
|
|||
135 | #endif |
|
|||
136 |
|
133 | |||
137 | // QtCommercial.Chart 1.0 |
|
134 | // QtCommercial.Chart 1.0 | |
138 | qmlRegisterType<DeclarativeChart>(uri, 1, 0, "ChartView"); |
|
135 | qmlRegisterType<DeclarativeChart>(uri, 1, 0, "ChartView"); | |
139 | qmlRegisterType<DeclarativeXYPoint>(uri, 1, 0, "XYPoint"); |
|
136 | qmlRegisterType<DeclarativeXYPoint>(uri, 1, 0, "XYPoint"); | |
140 | qmlRegisterType<DeclarativeScatterSeries>(uri, 1, 0, "ScatterSeries"); |
|
137 | qmlRegisterType<DeclarativeScatterSeries>(uri, 1, 0, "ScatterSeries"); | |
141 | qmlRegisterType<DeclarativeLineSeries>(uri, 1, 0, "LineSeries"); |
|
138 | qmlRegisterType<DeclarativeLineSeries>(uri, 1, 0, "LineSeries"); | |
142 | qmlRegisterType<DeclarativeSplineSeries>(uri, 1, 0, "SplineSeries"); |
|
139 | qmlRegisterType<DeclarativeSplineSeries>(uri, 1, 0, "SplineSeries"); | |
143 | qmlRegisterType<DeclarativeAreaSeries>(uri, 1, 0, "AreaSeries"); |
|
140 | qmlRegisterType<DeclarativeAreaSeries>(uri, 1, 0, "AreaSeries"); | |
144 | qmlRegisterType<DeclarativeBarSeries>(uri, 1, 0, "BarSeries"); |
|
141 | qmlRegisterType<DeclarativeBarSeries>(uri, 1, 0, "BarSeries"); | |
145 | qmlRegisterType<DeclarativeStackedBarSeries>(uri, 1, 0, "StackedBarSeries"); |
|
142 | qmlRegisterType<DeclarativeStackedBarSeries>(uri, 1, 0, "StackedBarSeries"); | |
146 | qmlRegisterType<DeclarativePercentBarSeries>(uri, 1, 0, "PercentBarSeries"); |
|
143 | qmlRegisterType<DeclarativePercentBarSeries>(uri, 1, 0, "PercentBarSeries"); | |
147 | qmlRegisterType<DeclarativePieSeries>(uri, 1, 0, "PieSeries"); |
|
144 | qmlRegisterType<DeclarativePieSeries>(uri, 1, 0, "PieSeries"); | |
148 | qmlRegisterType<QPieSlice>(uri, 1, 0, "PieSlice"); |
|
145 | qmlRegisterType<QPieSlice>(uri, 1, 0, "PieSlice"); | |
149 | qmlRegisterType<DeclarativeBarSet>(uri, 1, 0, "BarSet"); |
|
146 | qmlRegisterType<DeclarativeBarSet>(uri, 1, 0, "BarSet"); | |
150 | qmlRegisterType<QHXYModelMapper>(uri, 1, 0, "HXYModelMapper"); |
|
147 | qmlRegisterType<QHXYModelMapper>(uri, 1, 0, "HXYModelMapper"); | |
151 | qmlRegisterType<QVXYModelMapper>(uri, 1, 0, "VXYModelMapper"); |
|
148 | qmlRegisterType<QVXYModelMapper>(uri, 1, 0, "VXYModelMapper"); | |
152 | qmlRegisterType<QHPieModelMapper>(uri, 1, 0, "HPieModelMapper"); |
|
149 | qmlRegisterType<QHPieModelMapper>(uri, 1, 0, "HPieModelMapper"); | |
153 | qmlRegisterType<QVPieModelMapper>(uri, 1, 0, "VPieModelMapper"); |
|
150 | qmlRegisterType<QVPieModelMapper>(uri, 1, 0, "VPieModelMapper"); | |
154 | qmlRegisterType<QHBarModelMapper>(uri, 1, 0, "HBarModelMapper"); |
|
151 | qmlRegisterType<QHBarModelMapper>(uri, 1, 0, "HBarModelMapper"); | |
155 | qmlRegisterType<QVBarModelMapper>(uri, 1, 0, "VBarModelMapper"); |
|
152 | qmlRegisterType<QVBarModelMapper>(uri, 1, 0, "VBarModelMapper"); | |
156 | qmlRegisterType<QValueAxis>(uri, 1, 0, "ValuesAxis"); |
|
153 | qmlRegisterType<QValueAxis>(uri, 1, 0, "ValuesAxis"); | |
157 | qmlRegisterType<QBarCategoryAxis>(uri, 1, 0, "BarCategoriesAxis"); |
|
154 | qmlRegisterType<QBarCategoryAxis>(uri, 1, 0, "BarCategoriesAxis"); | |
158 | qmlRegisterUncreatableType<QLegend>(uri, 1, 0, "Legend", |
|
155 | qmlRegisterUncreatableType<QLegend>(uri, 1, 0, "Legend", | |
159 | QLatin1String("Trying to create uncreatable: Legend.")); |
|
156 | QLatin1String("Trying to create uncreatable: Legend.")); | |
160 | qmlRegisterUncreatableType<QXYSeries>(uri, 1, 0, "XYSeries", |
|
157 | qmlRegisterUncreatableType<QXYSeries>(uri, 1, 0, "XYSeries", | |
161 | QLatin1String("Trying to create uncreatable: XYSeries.")); |
|
158 | QLatin1String("Trying to create uncreatable: XYSeries.")); | |
162 | qmlRegisterUncreatableType<QAbstractItemModel>(uri, 1, 0, "AbstractItemModel", |
|
159 | qmlRegisterUncreatableType<QAbstractItemModel>(uri, 1, 0, "AbstractItemModel", | |
163 | QLatin1String("Trying to create uncreatable: AbstractItemModel.")); |
|
160 | QLatin1String("Trying to create uncreatable: AbstractItemModel.")); | |
164 | qmlRegisterUncreatableType<QXYModelMapper>(uri, 1, 0, "XYModelMapper", |
|
161 | qmlRegisterUncreatableType<QXYModelMapper>(uri, 1, 0, "XYModelMapper", | |
165 | QLatin1String("Trying to create uncreatable: XYModelMapper.")); |
|
162 | QLatin1String("Trying to create uncreatable: XYModelMapper.")); | |
166 | qmlRegisterUncreatableType<QPieModelMapper>(uri, 1, 0, "PieModelMapper", |
|
163 | qmlRegisterUncreatableType<QPieModelMapper>(uri, 1, 0, "PieModelMapper", | |
167 | QLatin1String("Trying to create uncreatable: PieModelMapper.")); |
|
164 | QLatin1String("Trying to create uncreatable: PieModelMapper.")); | |
168 | qmlRegisterUncreatableType<QBarModelMapper>(uri, 1, 0, "BarModelMapper", |
|
165 | qmlRegisterUncreatableType<QBarModelMapper>(uri, 1, 0, "BarModelMapper", | |
169 | QLatin1String("Trying to create uncreatable: BarModelMapper.")); |
|
166 | QLatin1String("Trying to create uncreatable: BarModelMapper.")); | |
170 | qmlRegisterUncreatableType<QAbstractSeries>(uri, 1, 0, "AbstractSeries", |
|
167 | qmlRegisterUncreatableType<QAbstractSeries>(uri, 1, 0, "AbstractSeries", | |
171 | QLatin1String("Trying to create uncreatable: AbstractSeries.")); |
|
168 | QLatin1String("Trying to create uncreatable: AbstractSeries.")); | |
172 | qmlRegisterUncreatableType<QAbstractBarSeries>(uri, 1, 0, "AbstractBarSeries", |
|
169 | qmlRegisterUncreatableType<QAbstractBarSeries>(uri, 1, 0, "AbstractBarSeries", | |
173 | QLatin1String("Trying to create uncreatable: AbstractBarSeries.")); |
|
170 | QLatin1String("Trying to create uncreatable: AbstractBarSeries.")); | |
174 | qmlRegisterUncreatableType<QAbstractAxis>(uri, 1, 0, "AbstractAxis", |
|
171 | qmlRegisterUncreatableType<QAbstractAxis>(uri, 1, 0, "AbstractAxis", | |
175 | QLatin1String("Trying to create uncreatable: AbstractAxis. Use specific types of axis instead.")); |
|
172 | QLatin1String("Trying to create uncreatable: AbstractAxis. Use specific types of axis instead.")); | |
176 | qmlRegisterUncreatableType<QBarSet>(uri, 1, 0, "BarSetBase", |
|
173 | qmlRegisterUncreatableType<QBarSet>(uri, 1, 0, "BarSetBase", | |
177 | QLatin1String("Trying to create uncreatable: BarsetBase.")); |
|
174 | QLatin1String("Trying to create uncreatable: BarsetBase.")); | |
178 | qmlRegisterUncreatableType<QPieSeries>(uri, 1, 0, "QPieSeries", |
|
175 | qmlRegisterUncreatableType<QPieSeries>(uri, 1, 0, "QPieSeries", | |
179 | QLatin1String("Trying to create uncreatable: QPieSeries. Use PieSeries instead.")); |
|
176 | QLatin1String("Trying to create uncreatable: QPieSeries. Use PieSeries instead.")); | |
180 | qmlRegisterUncreatableType<DeclarativeAxes>(uri, 1, 0, "DeclarativeAxes", |
|
177 | qmlRegisterUncreatableType<DeclarativeAxes>(uri, 1, 0, "DeclarativeAxes", | |
181 | QLatin1String("Trying to create uncreatable: DeclarativeAxes.")); |
|
178 | QLatin1String("Trying to create uncreatable: DeclarativeAxes.")); | |
182 |
|
179 | |||
183 | // QtCommercial.Chart 1.1 |
|
180 | // QtCommercial.Chart 1.1 | |
184 | qmlRegisterType<DeclarativeChart, 1>(uri, 1, 1, "ChartView"); |
|
181 | qmlRegisterType<DeclarativeChart, 1>(uri, 1, 1, "ChartView"); | |
185 | qmlRegisterType<DeclarativeScatterSeries, 1>(uri, 1, 1, "ScatterSeries"); |
|
182 | qmlRegisterType<DeclarativeScatterSeries, 1>(uri, 1, 1, "ScatterSeries"); | |
186 | qmlRegisterType<DeclarativeLineSeries, 1>(uri, 1, 1, "LineSeries"); |
|
183 | qmlRegisterType<DeclarativeLineSeries, 1>(uri, 1, 1, "LineSeries"); | |
187 | qmlRegisterType<DeclarativeSplineSeries, 1>(uri, 1, 1, "SplineSeries"); |
|
184 | qmlRegisterType<DeclarativeSplineSeries, 1>(uri, 1, 1, "SplineSeries"); | |
188 | qmlRegisterType<DeclarativeAreaSeries, 1>(uri, 1, 1, "AreaSeries"); |
|
185 | qmlRegisterType<DeclarativeAreaSeries, 1>(uri, 1, 1, "AreaSeries"); | |
189 | qmlRegisterType<DeclarativeBarSeries, 1>(uri, 1, 1, "BarSeries"); |
|
186 | qmlRegisterType<DeclarativeBarSeries, 1>(uri, 1, 1, "BarSeries"); | |
190 | qmlRegisterType<DeclarativeStackedBarSeries, 1>(uri, 1, 1, "StackedBarSeries"); |
|
187 | qmlRegisterType<DeclarativeStackedBarSeries, 1>(uri, 1, 1, "StackedBarSeries"); | |
191 | qmlRegisterType<DeclarativePercentBarSeries, 1>(uri, 1, 1, "PercentBarSeries"); |
|
188 | qmlRegisterType<DeclarativePercentBarSeries, 1>(uri, 1, 1, "PercentBarSeries"); | |
192 | qmlRegisterType<DeclarativeHorizontalBarSeries, 1>(uri, 1, 1, "HorizontalBarSeries"); |
|
189 | qmlRegisterType<DeclarativeHorizontalBarSeries, 1>(uri, 1, 1, "HorizontalBarSeries"); | |
193 | qmlRegisterType<DeclarativeHorizontalStackedBarSeries, 1>(uri, 1, 1, "HorizontalStackedBarSeries"); |
|
190 | qmlRegisterType<DeclarativeHorizontalStackedBarSeries, 1>(uri, 1, 1, "HorizontalStackedBarSeries"); | |
194 | qmlRegisterType<DeclarativeHorizontalPercentBarSeries, 1>(uri, 1, 1, "HorizontalPercentBarSeries"); |
|
191 | qmlRegisterType<DeclarativeHorizontalPercentBarSeries, 1>(uri, 1, 1, "HorizontalPercentBarSeries"); | |
195 | qmlRegisterType<DeclarativePieSeries>(uri, 1, 1, "PieSeries"); |
|
192 | qmlRegisterType<DeclarativePieSeries>(uri, 1, 1, "PieSeries"); | |
196 | qmlRegisterType<DeclarativeBarSet>(uri, 1, 1, "BarSet"); |
|
193 | qmlRegisterType<DeclarativeBarSet>(uri, 1, 1, "BarSet"); | |
197 | qmlRegisterType<QValueAxis>(uri, 1, 1, "ValueAxis"); |
|
194 | qmlRegisterType<QValueAxis>(uri, 1, 1, "ValueAxis"); | |
198 | #ifndef QT_ON_ARM |
|
195 | #ifndef QT_ON_ARM | |
199 | qmlRegisterType<QDateTimeAxis>(uri, 1, 1, "DateTimeAxis"); |
|
196 | qmlRegisterType<QDateTimeAxis>(uri, 1, 1, "DateTimeAxis"); | |
200 | #endif |
|
197 | #endif | |
201 | qmlRegisterType<DeclarativeCategoryAxis>(uri, 1, 1, "CategoryAxis"); |
|
198 | qmlRegisterType<DeclarativeCategoryAxis>(uri, 1, 1, "CategoryAxis"); | |
202 | qmlRegisterType<DeclarativeCategoryRange>(uri, 1, 1, "CategoryRange"); |
|
199 | qmlRegisterType<DeclarativeCategoryRange>(uri, 1, 1, "CategoryRange"); | |
203 | qmlRegisterType<QBarCategoryAxis>(uri, 1, 1, "BarCategoryAxis"); |
|
200 | qmlRegisterType<QBarCategoryAxis>(uri, 1, 1, "BarCategoryAxis"); | |
204 | qmlRegisterUncreatableType<DeclarativeMargins>(uri, 1, 1, "Margins", |
|
201 | qmlRegisterUncreatableType<DeclarativeMargins>(uri, 1, 1, "Margins", | |
205 | QLatin1String("Trying to create uncreatable: Margins.")); |
|
202 | QLatin1String("Trying to create uncreatable: Margins.")); | |
206 |
|
203 | |||
207 | // QtCommercial.Chart 1.2 |
|
204 | // QtCommercial.Chart 1.2 | |
208 | qmlRegisterType<DeclarativeChart, 2>(uri, 1, 2, "ChartView"); |
|
205 | qmlRegisterType<DeclarativeChart, 2>(uri, 1, 2, "ChartView"); | |
209 | qmlRegisterType<DeclarativeScatterSeries, 2>(uri, 1, 2, "ScatterSeries"); |
|
206 | qmlRegisterType<DeclarativeScatterSeries, 2>(uri, 1, 2, "ScatterSeries"); | |
210 | qmlRegisterType<DeclarativeLineSeries, 2>(uri, 1, 2, "LineSeries"); |
|
207 | qmlRegisterType<DeclarativeLineSeries, 2>(uri, 1, 2, "LineSeries"); | |
211 | qmlRegisterType<DeclarativeSplineSeries, 2>(uri, 1, 2, "SplineSeries"); |
|
208 | qmlRegisterType<DeclarativeSplineSeries, 2>(uri, 1, 2, "SplineSeries"); | |
212 | qmlRegisterType<DeclarativeAreaSeries, 2>(uri, 1, 2, "AreaSeries"); |
|
209 | qmlRegisterType<DeclarativeAreaSeries, 2>(uri, 1, 2, "AreaSeries"); | |
213 | qmlRegisterType<DeclarativeBarSeries, 2>(uri, 1, 2, "BarSeries"); |
|
210 | qmlRegisterType<DeclarativeBarSeries, 2>(uri, 1, 2, "BarSeries"); | |
214 | qmlRegisterType<DeclarativeStackedBarSeries, 2>(uri, 1, 2, "StackedBarSeries"); |
|
211 | qmlRegisterType<DeclarativeStackedBarSeries, 2>(uri, 1, 2, "StackedBarSeries"); | |
215 | qmlRegisterType<DeclarativePercentBarSeries, 2>(uri, 1, 2, "PercentBarSeries"); |
|
212 | qmlRegisterType<DeclarativePercentBarSeries, 2>(uri, 1, 2, "PercentBarSeries"); | |
216 | qmlRegisterType<DeclarativeHorizontalBarSeries, 2>(uri, 1, 2, "HorizontalBarSeries"); |
|
213 | qmlRegisterType<DeclarativeHorizontalBarSeries, 2>(uri, 1, 2, "HorizontalBarSeries"); | |
217 | qmlRegisterType<DeclarativeHorizontalStackedBarSeries, 2>(uri, 1, 2, "HorizontalStackedBarSeries"); |
|
214 | qmlRegisterType<DeclarativeHorizontalStackedBarSeries, 2>(uri, 1, 2, "HorizontalStackedBarSeries"); | |
218 | qmlRegisterType<DeclarativeHorizontalPercentBarSeries, 2>(uri, 1, 2, "HorizontalPercentBarSeries"); |
|
215 | qmlRegisterType<DeclarativeHorizontalPercentBarSeries, 2>(uri, 1, 2, "HorizontalPercentBarSeries"); | |
219 | } |
|
216 | } | |
220 | }; |
|
217 | }; | |
221 |
|
218 | |||
222 | #include "plugin.moc" |
|
219 | #include "plugin.moc" | |
223 |
|
220 | |||
224 | QTCOMMERCIALCHART_END_NAMESPACE |
|
221 | QTCOMMERCIALCHART_END_NAMESPACE | |
225 |
|
222 | |||
226 | QTCOMMERCIALCHART_USE_NAMESPACE |
|
223 | QTCOMMERCIALCHART_USE_NAMESPACE | |
227 |
|
224 | |||
228 | #if (QT_VERSION < QT_VERSION_CHECK(5, 0, 0)) |
|
225 | #if (QT_VERSION < QT_VERSION_CHECK(5, 0, 0)) | |
229 | Q_EXPORT_PLUGIN2(qtcommercialchartqml, QT_PREPEND_NAMESPACE(ChartQmlPlugin)) |
|
226 | Q_EXPORT_PLUGIN2(qtcommercialchartqml, QT_PREPEND_NAMESPACE(ChartQmlPlugin)) | |
230 | #endif |
|
227 | #endif |
General Comments 0
You need to be logged in to leave comments.
Login now