##// END OF EJS Templates
Added axisXTop and axisYRight properties to QML series APIs
Tero Ahola -
r2296:6bd1dc9d15e0
parent child
Show More
@@ -0,0 +1,61
1 /****************************************************************************
2 **
3 ** Copyright (C) 2012 Digia Plc
4 ** All rights reserved.
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 **
7 ** This file is part of the Qt Commercial Charts Add-on.
8 **
9 ** $QT_BEGIN_LICENSE$
10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 ** accordance with the Qt Commercial License Agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia.
14 **
15 ** If you have questions regarding the use of this file, please use
16 ** contact form at http://qt.digia.com
17 ** $QT_END_LICENSE$
18 **
19 ****************************************************************************/
20
21 #include "declarativeaxes.h"
22 #include "qabstractaxis.h"
23
24 QTCOMMERCIALCHART_BEGIN_NAMESPACE
25
26 DeclarativeAxes::DeclarativeAxes(QObject *parent) :
27 QObject(parent),
28 m_axisX(0),
29 m_axisY(0),
30 m_axisXTop(0),
31 m_axisYRight(0)
32 {
33 }
34
35 void DeclarativeAxes::setAxisX(QAbstractAxis *axis)
36 {
37 m_axisX = axis;
38 emit axisXChanged(axis);
39 }
40
41 void DeclarativeAxes::setAxisY(QAbstractAxis *axis)
42 {
43 m_axisY = axis;
44 emit axisYChanged(axis);
45 }
46
47 void DeclarativeAxes::setAxisXTop(QAbstractAxis *axis)
48 {
49 m_axisXTop = axis;
50 emit axisXTopChanged(axis);
51 }
52
53 void DeclarativeAxes::setAxisYRight(QAbstractAxis *axis)
54 {
55 m_axisYRight = axis;
56 emit axisYRightChanged(axis);
57 }
58
59 #include "moc_declarativeaxes.cpp"
60
61 QTCOMMERCIALCHART_END_NAMESPACE
@@ -0,0 +1,72
1 /****************************************************************************
2 **
3 ** Copyright (C) 2012 Digia Plc
4 ** All rights reserved.
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 **
7 ** This file is part of the Qt Commercial Charts Add-on.
8 **
9 ** $QT_BEGIN_LICENSE$
10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 ** accordance with the Qt Commercial License Agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia.
14 **
15 ** If you have questions regarding the use of this file, please use
16 ** contact form at http://qt.digia.com
17 ** $QT_END_LICENSE$
18 **
19 ****************************************************************************/
20
21 #ifndef DECLARATIVEAXES_H
22 #define DECLARATIVEAXES_H
23
24 #include "qchartglobal.h"
25 #include <QObject>
26
27 QTCOMMERCIALCHART_BEGIN_NAMESPACE
28
29 class QAbstractAxis;
30
31 class DeclarativeAxes : public QObject
32 {
33 Q_OBJECT
34 Q_PROPERTY(QAbstractAxis *axisX READ axisX WRITE setAxisX NOTIFY axisXChanged)
35 Q_PROPERTY(QAbstractAxis *axisY READ axisY WRITE setAxisY NOTIFY axisYChanged)
36 Q_PROPERTY(QAbstractAxis *axisXTop READ axisXTop WRITE setAxisXTop NOTIFY axisXTopChanged)
37 Q_PROPERTY(QAbstractAxis *axisYRight READ axisYRight WRITE setAxisYRight NOTIFY axisYRightChanged)
38
39 public:
40 explicit DeclarativeAxes(QObject *parent = 0);
41
42 QAbstractAxis *axisX() { return m_axisX; }
43 void setAxisX(QAbstractAxis *axis);
44 QAbstractAxis *axisY() { return m_axisY; }
45 void setAxisY(QAbstractAxis *axis);
46 QAbstractAxis *axisXTop() { return m_axisXTop; }
47 void setAxisXTop(QAbstractAxis *axis);
48 QAbstractAxis *axisYRight() { return m_axisYRight; }
49 void setAxisYRight(QAbstractAxis *axis);
50
51 public:
52 void emitAxisXChanged() { emit axisXChanged(m_axisX); }
53 void emitAxisYChanged() { emit axisYChanged(m_axisY); }
54 void emitAxisXTopChanged() { emit axisXTopChanged(m_axisXTop); }
55 void emitAxisYRightChanged() { emit axisYRightChanged(m_axisYRight); }
56
57 signals:
58 void axisXChanged(QAbstractAxis *axis);
59 void axisYChanged(QAbstractAxis *axis);
60 void axisXTopChanged(QAbstractAxis *axis);
61 void axisYRightChanged(QAbstractAxis *axis);
62
63 private:
64 QAbstractAxis *m_axisX;
65 QAbstractAxis *m_axisY;
66 QAbstractAxis *m_axisXTop;
67 QAbstractAxis *m_axisYRight;
68 };
69
70 QTCOMMERCIALCHART_END_NAMESPACE
71
72 #endif // DECLARATIVEAXES_H
@@ -1,183 +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 import QtQuick 1.0
21 import QtQuick 1.0
22 import QtCommercial.Chart 1.1
22 import QtCommercial.Chart 1.1
23 import QmlCustomModel 1.0
23 import QmlCustomModel 1.0
24
24
25 Rectangle {
25 Rectangle {
26 anchors.fill: parent
26 anchors.fill: parent
27
27
28 //![1]
28 //![1]
29 ChartView {
29 ChartView {
30 id: chartView
30 id: chartView
31 title: "Top-5 car brand shares in Finland"
31 title: "Top-5 car brand shares in Finland"
32 anchors.fill: parent
32 anchors.fill: parent
33 animationOptions: ChartView.SeriesAnimations
33 animationOptions: ChartView.SeriesAnimations
34
34
35 BarCategoriesAxis {
35 BarCategoriesAxis {
36 id: categoriesAxis
36 id: categoriesAxis
37 categories: ["2007", "2008", "2009", "2010", "2011", "2012", "2013", "2014" ]
37 categories: ["2007", "2008", "2009", "2010", "2011", "2012", "2013", "2014" ]
38 min: "2007"
38 min: "2007"
39 max: "2014"
39 max: "2014"
40 title: "Year"
40 titleText: "Year"
41 }
41 }
42
42
43 ValueAxis {
43 ValueAxis {
44 id: valueAxis
44 id: valueAxis
45 min: 0
45 min: 0
46 max: 60
46 max: 60
47 title: "Sales count [ku]"
47 titleText: "Sales count [ku]"
48 }
48 }
49 // ...
49 // ...
50 //![1]
50 //![1]
51
51
52 //![2]
52 //![2]
53 CustomModel {
53 CustomModel {
54 id: customModel
54 id: customModel
55 verticalHeaders: ["Manufacturer", "Volkswagen", "Toyota", "Ford", "Skoda", "Volvo", "Others"]
55 verticalHeaders: ["Manufacturer", "Volkswagen", "Toyota", "Ford", "Skoda", "Volvo", "Others"]
56 CustomModelElement { values: [0, "Manufacturer", 0, 1, 2, 3, 4] }
56 CustomModelElement { values: [0, "Manufacturer", 0, 1, 2, 3, 4] }
57 CustomModelElement { values: [1, "Volkswagen", 10.3, 12.0, 12.8, 13.0, 13.8] }
57 CustomModelElement { values: [1, "Volkswagen", 10.3, 12.0, 12.8, 13.0, 13.8] }
58 CustomModelElement { values: [2, "Toyota", 13.8, 13.5, 16.2, 13.7, 10.7] }
58 CustomModelElement { values: [2, "Toyota", 13.8, 13.5, 16.2, 13.7, 10.7] }
59 CustomModelElement { values: [3, "Ford", 6.4, 7.1, 8.9, 8.2, 8.6] }
59 CustomModelElement { values: [3, "Ford", 6.4, 7.1, 8.9, 8.2, 8.6] }
60 CustomModelElement { values: [4, "Skoda", 4.7, 5.8, 6.9, 8.3, 8.2] }
60 CustomModelElement { values: [4, "Skoda", 4.7, 5.8, 6.9, 8.3, 8.2] }
61 CustomModelElement { values: [5, "Volvo", 7.1, 6.7, 6.5, 6.3, 7.0] }
61 CustomModelElement { values: [5, "Volvo", 7.1, 6.7, 6.5, 6.3, 7.0] }
62 CustomModelElement { values: [6, "Others", 57.7, 54.9, 48.7, 50.5, 51.7] }
62 CustomModelElement { values: [6, "Others", 57.7, 54.9, 48.7, 50.5, 51.7] }
63 }
63 }
64 //![2]
64 //![2]
65
65
66 //![5]
66 //![5]
67 BarSeries {
67 BarSeries {
68 id: myBarSeries
68 id: myBarSeries
69 name: "Others"
69 name: "Others"
70 axisX: categoriesAxis
70 axisX: categoriesAxis
71 axisY: valueAxis
71 axisY: valueAxis
72 barWidth: 0.9
72 barWidth: 0.9
73 visible: false
73 visible: false
74 HBarModelMapper {
74 HBarModelMapper {
75 model: customModel
75 model: customModel
76 firstBarSetRow: 6
76 firstBarSetRow: 6
77 lastBarSetRow: 6
77 lastBarSetRow: 6
78 firstColumn: 2
78 firstColumn: 2
79 }
79 }
80 }
80 }
81 //![5]
81 //![5]
82
82
83 //![4]
83 //![4]
84 LineSeries {
84 LineSeries {
85 id: lineSeries1
85 id: lineSeries1
86 name: "Volkswagen"
86 name: "Volkswagen"
87 axisX: categoriesAxis
87 axisX: categoriesAxis
88 axisY: valueAxis
88 axisY: valueAxis
89 visible: false
89 visible: false
90 HXYModelMapper {
90 HXYModelMapper {
91 model: customModel
91 model: customModel
92 xRow: 0
92 xRow: 0
93 yRow: 1
93 yRow: 1
94 firstColumn: 2
94 firstColumn: 2
95 }
95 }
96 }
96 }
97 //![4]
97 //![4]
98
98
99 LineSeries {
99 LineSeries {
100 id: lineSeries2
100 id: lineSeries2
101 name: "Toyota"
101 name: "Toyota"
102 axisX: categoriesAxis
102 axisX: categoriesAxis
103 axisY: valueAxis
103 axisY: valueAxis
104 visible: false
104 visible: false
105 HXYModelMapper {
105 HXYModelMapper {
106 model: customModel
106 model: customModel
107 xRow: 0
107 xRow: 0
108 yRow: 2
108 yRow: 2
109 firstColumn: 2
109 firstColumn: 2
110 }
110 }
111 }
111 }
112
112
113 LineSeries {
113 LineSeries {
114 id: lineSeries3
114 id: lineSeries3
115 name: "Ford"
115 name: "Ford"
116 axisX: categoriesAxis
116 axisX: categoriesAxis
117 axisY: valueAxis
117 axisY: valueAxis
118 visible: false
118 visible: false
119 HXYModelMapper {
119 HXYModelMapper {
120 model: customModel
120 model: customModel
121 xRow: 0
121 xRow: 0
122 yRow: 3
122 yRow: 3
123 firstColumn: 2
123 firstColumn: 2
124 }
124 }
125 }
125 }
126
126
127 LineSeries {
127 LineSeries {
128 id: lineSeries4
128 id: lineSeries4
129 name: "Skoda"
129 name: "Skoda"
130 axisX: categoriesAxis
130 axisX: categoriesAxis
131 axisY: valueAxis
131 axisY: valueAxis
132 visible: false
132 visible: false
133 HXYModelMapper {
133 HXYModelMapper {
134 model: customModel
134 model: customModel
135 xRow: 0
135 xRow: 0
136 yRow: 4
136 yRow: 4
137 firstColumn: 2
137 firstColumn: 2
138 }
138 }
139 }
139 }
140
140
141 LineSeries {
141 LineSeries {
142 id: lineSeries5
142 id: lineSeries5
143 name: "Volvo"
143 name: "Volvo"
144 axisX: categoriesAxis
144 axisX: categoriesAxis
145 axisY: valueAxis
145 axisY: valueAxis
146 visible: false
146 visible: false
147 HXYModelMapper {
147 HXYModelMapper {
148 model: customModel
148 model: customModel
149 xRow: 0
149 xRow: 0
150 yRow: 5
150 yRow: 5
151 firstColumn: 2
151 firstColumn: 2
152 }
152 }
153 }
153 }
154
154
155 //![3]
155 //![3]
156 PieSeries {
156 PieSeries {
157 id: pieSeries
157 id: pieSeries
158 size: 0.4
158 size: 0.4
159 horizontalPosition: 0.85
159 horizontalPosition: 0.85
160 verticalPosition: 0.4
160 verticalPosition: 0.4
161 onClicked: {
161 onClicked: {
162 // Show the selection by exploding the slice
162 // Show the selection by exploding the slice
163 slice.exploded = !slice.exploded;
163 slice.exploded = !slice.exploded;
164
164
165 // Update the line series to show the yearly data for this slice
165 // Update the line series to show the yearly data for this slice
166 for (var i = 0; i < chartView.count; i++) {
166 for (var i = 0; i < chartView.count; i++) {
167 if (chartView.series(i).name == slice.label) {
167 if (chartView.series(i).name == slice.label) {
168 chartView.series(i).visible = slice.exploded;
168 chartView.series(i).visible = slice.exploded;
169 }
169 }
170 }
170 }
171 }
171 }
172
172
173 }
173 }
174 VPieModelMapper {
174 VPieModelMapper {
175 model: customModel
175 model: customModel
176 series: pieSeries
176 series: pieSeries
177 labelsColumn: 1
177 labelsColumn: 1
178 valuesColumn: 2
178 valuesColumn: 2
179 firstRow: 1
179 firstRow: 1
180 }
180 }
181 //![3]
181 //![3]
182 }
182 }
183 }
183 }
@@ -1,201 +1,200
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.1
21 import QtQuick 1.1
22 import QtCommercial.Chart 1.1
22 import QtCommercial.Chart 1.2
23
23
24 Rectangle {
24 Rectangle {
25 width: 360
25 width: 360
26 height: 360
26 height: 360
27 gradient: Gradient {
27 gradient: Gradient {
28 GradientStop { position: 0.0; color: "lightblue" }
28 GradientStop { position: 0.0; color: "lightblue" }
29 GradientStop { position: 1.0; color: "white" }
29 GradientStop { position: 1.0; color: "white" }
30 }
30 }
31
31
32 //![1]
32 //![1]
33 ChartView {
33 ChartView {
34 id: chartView
34 id: chartView
35 title: "Weather forecast"
35 title: "Weather forecast"
36 //![1]
36 //![1]
37 anchors.top: parent.top
37 anchors.top: parent.top
38 anchors.bottom: weatherImageRow.top
38 anchors.bottom: weatherImageRow.top
39 anchors.left: parent.left
39 anchors.left: parent.left
40 anchors.right: parent.right
40 anchors.right: parent.right
41 legend.alignment: Qt.AlignTop
41 legend.alignment: Qt.AlignTop
42
42
43 //![2]
43 //![2]
44 BarCategoriesAxis {
44 BarCategoriesAxis {
45 id: barCategoriesAxis
45 id: barCategoriesAxis
46 title: "Date"
46 titleText: "Date"
47 }
47 }
48
48
49 ValueAxis{
49 ValueAxis{
50 id: valueAxisY2
50 id: valueAxisY2
51 min: 0
51 min: 0
52 max: 10
52 max: 10
53 title: "Rainfall [mm]"
53 titleText: "Rainfall [mm]"
54 alignment: Qt.AlignRight
55 }
54 }
56
55
57 BarSeries {
56 BarSeries {
58 id: myBarSeries
57 id: myBarSeries
59 axisX: barCategoriesAxis
58 axisX: barCategoriesAxis
60 axisY: valueAxisY2
59 axisYRight: valueAxisY2
61 BarSet {
60 BarSet {
62 id: rainfallSet
61 id: rainfallSet
63 label: "Rainfall"
62 label: "Rainfall"
64 }
63 }
65 }
64 }
66
65
67 ValueAxis {
66 ValueAxis {
68 id: valueAxisX
67 id: valueAxisX
69 // Hide the value axis; it is only used to map the line series to bar categories axis
68 // Hide the value axis; it is only used to map the line series to bar categories axis
70 visible: false
69 visible: false
71 min: 0
70 min: 0
72 max: 5
71 max: 5
73 }
72 }
74
73
75 ValueAxis{
74 ValueAxis{
76 id: valueAxisY
75 id: valueAxisY
77 min: 0
76 min: 0
78 max: 15
77 max: 15
79 title: "Temperature [\u00B0C]"
78 titleText: "Temperature [\u00B0C]"
80 }
79 }
81
80
82 LineSeries {
81 LineSeries {
83 id: maxTempSeries
82 id: maxTempSeries
84 axisX: valueAxisX
83 axisX: valueAxisX
85 axisY: valueAxisY
84 axisY: valueAxisY
86 name: "Max. temperature"
85 name: "Max. temperature"
87 }
86 }
88
87
89 LineSeries {
88 LineSeries {
90 id: minTempSeries
89 id: minTempSeries
91 axisX: valueAxisX
90 axisX: valueAxisX
92 axisY: valueAxisY
91 axisY: valueAxisY
93 name: "Min. temperature"
92 name: "Min. temperature"
94 }
93 }
95 //![2]
94 //![2]
96 }
95 }
97
96
98 // A timer to refresh the forecast every 5 minutes
97 // A timer to refresh the forecast every 5 minutes
99 Timer {
98 Timer {
100 interval: 300000
99 interval: 300000
101 repeat: true
100 repeat: true
102 triggeredOnStart: true
101 triggeredOnStart: true
103 running: true
102 running: true
104 onTriggered: {
103 onTriggered: {
105 if (weatherAppKey != "") {
104 if (weatherAppKey != "") {
106 //![3]
105 //![3]
107 // Make HTTP GET request and parse the result
106 // Make HTTP GET request and parse the result
108 var xhr = new XMLHttpRequest;
107 var xhr = new XMLHttpRequest;
109 xhr.open("GET",
108 xhr.open("GET",
110 "http://free.worldweatheronline.com/feed/weather.ashx?q=Jyv%c3%a4skyl%c3%a4,Finland&format=json&num_of_days=5&key="
109 "http://free.worldweatheronline.com/feed/weather.ashx?q=Jyv%c3%a4skyl%c3%a4,Finland&format=json&num_of_days=5&key="
111 + weatherAppKey);
110 + weatherAppKey);
112 xhr.onreadystatechange = function() {
111 xhr.onreadystatechange = function() {
113 if (xhr.readyState == XMLHttpRequest.DONE) {
112 if (xhr.readyState == XMLHttpRequest.DONE) {
114 var a = JSON.parse(xhr.responseText);
113 var a = JSON.parse(xhr.responseText);
115 parseWeatherData(a);
114 parseWeatherData(a);
116 }
115 }
117 }
116 }
118 xhr.send();
117 xhr.send();
119 //![3]
118 //![3]
120 } else {
119 } else {
121 // No app key for worldweatheronline.com given by the user -> use dummy static data
120 // No app key for worldweatheronline.com given by the user -> use dummy static data
122 var responseText = "{ \"data\": { \"current_condition\": [ {\"cloudcover\": \"10\", \"humidity\": \"61\", \"observation_time\": \"06:26 AM\", \"precipMM\": \"0.0\", \"pressure\": \"1022\", \"temp_C\": \"6\", \"temp_F\": \"43\", \"visibility\": \"10\", \"weatherCode\": \"113\", \"weatherDesc\": [ {\"value\": \"Sunny\" } ], \"weatherIconUrl\": [ {\"value\": \"http:\/\/www.worldweatheronline.com\/images\/wsymbols01_png_64\/wsymbol_0001_sunny.png\" } ], \"winddir16Point\": \"SE\", \"winddirDegree\": \"140\", \"windspeedKmph\": \"7\", \"windspeedMiles\": \"4\" } ], \"request\": [ {\"query\": \"Jyvaskyla, Finland\", \"type\": \"City\" } ], \"weather\": [ {\"date\": \"2012-05-09\", \"precipMM\": \"0.4\", \"tempMaxC\": \"14\", \"tempMaxF\": \"57\", \"tempMinC\": \"7\", \"tempMinF\": \"45\", \"weatherCode\": \"116\", \"weatherDesc\": [ {\"value\": \"Partly Cloudy\" } ], \"weatherIconUrl\": [ {\"value\": \"http:\/\/www.worldweatheronline.com\/images\/wsymbols01_png_64\/wsymbol_0002_sunny_intervals.png\" } ], \"winddir16Point\": \"S\", \"winddirDegree\": \"179\", \"winddirection\": \"S\", \"windspeedKmph\": \"20\", \"windspeedMiles\": \"12\" }, {\"date\": \"2012-05-10\", \"precipMM\": \"2.4\", \"tempMaxC\": \"13\", \"tempMaxF\": \"55\", \"tempMinC\": \"8\", \"tempMinF\": \"46\", \"weatherCode\": \"266\", \"weatherDesc\": [ {\"value\": \"Light drizzle\" } ], \"weatherIconUrl\": [ {\"value\": \"http:\/\/www.worldweatheronline.com\/images\/wsymbols01_png_64\/wsymbol_0017_cloudy_with_light_rain.png\" } ], \"winddir16Point\": \"SW\", \"winddirDegree\": \"219\", \"winddirection\": \"SW\", \"windspeedKmph\": \"21\", \"windspeedMiles\": \"13\" }, {\"date\": \"2012-05-11\", \"precipMM\": \"11.1\", \"tempMaxC\": \"15\", \"tempMaxF\": \"59\", \"tempMinC\": \"7\", \"tempMinF\": \"44\", \"weatherCode\": \"266\", \"weatherDesc\": [ {\"value\": \"Light drizzle\" } ], \"weatherIconUrl\": [ {\"value\": \"http:\/\/www.worldweatheronline.com\/images\/wsymbols01_png_64\/wsymbol_0017_cloudy_with_light_rain.png\" } ], \"winddir16Point\": \"SSW\", \"winddirDegree\": \"200\", \"winddirection\": \"SSW\", \"windspeedKmph\": \"20\", \"windspeedMiles\": \"12\" }, {\"date\": \"2012-05-12\", \"precipMM\": \"2.8\", \"tempMaxC\": \"7\", \"tempMaxF\": \"44\", \"tempMinC\": \"2\", \"tempMinF\": \"35\", \"weatherCode\": \"317\", \"weatherDesc\": [ {\"value\": \"Light sleet\" } ], \"weatherIconUrl\": [ {\"value\": \"http:\/\/www.worldweatheronline.com\/images\/wsymbols01_png_64\/wsymbol_0021_cloudy_with_sleet.png\" } ], \"winddir16Point\": \"NW\", \"winddirDegree\": \"311\", \"winddirection\": \"NW\", \"windspeedKmph\": \"24\", \"windspeedMiles\": \"15\" }, {\"date\": \"2012-05-13\", \"precipMM\": \"0.4\", \"tempMaxC\": \"6\", \"tempMaxF\": \"42\", \"tempMinC\": \"2\", \"tempMinF\": \"35\", \"weatherCode\": \"116\", \"weatherDesc\": [ {\"value\": \"Partly Cloudy\" } ], \"weatherIconUrl\": [ {\"value\": \"http:\/\/www.worldweatheronline.com\/images\/wsymbols01_png_64\/wsymbol_0002_sunny_intervals.png\" } ], \"winddir16Point\": \"WNW\", \"winddirDegree\": \"281\", \"winddirection\": \"WNW\", \"windspeedKmph\": \"21\", \"windspeedMiles\": \"13\" } ] }}";
121 var responseText = "{ \"data\": { \"current_condition\": [ {\"cloudcover\": \"10\", \"humidity\": \"61\", \"observation_time\": \"06:26 AM\", \"precipMM\": \"0.0\", \"pressure\": \"1022\", \"temp_C\": \"6\", \"temp_F\": \"43\", \"visibility\": \"10\", \"weatherCode\": \"113\", \"weatherDesc\": [ {\"value\": \"Sunny\" } ], \"weatherIconUrl\": [ {\"value\": \"http:\/\/www.worldweatheronline.com\/images\/wsymbols01_png_64\/wsymbol_0001_sunny.png\" } ], \"winddir16Point\": \"SE\", \"winddirDegree\": \"140\", \"windspeedKmph\": \"7\", \"windspeedMiles\": \"4\" } ], \"request\": [ {\"query\": \"Jyvaskyla, Finland\", \"type\": \"City\" } ], \"weather\": [ {\"date\": \"2012-05-09\", \"precipMM\": \"0.4\", \"tempMaxC\": \"14\", \"tempMaxF\": \"57\", \"tempMinC\": \"7\", \"tempMinF\": \"45\", \"weatherCode\": \"116\", \"weatherDesc\": [ {\"value\": \"Partly Cloudy\" } ], \"weatherIconUrl\": [ {\"value\": \"http:\/\/www.worldweatheronline.com\/images\/wsymbols01_png_64\/wsymbol_0002_sunny_intervals.png\" } ], \"winddir16Point\": \"S\", \"winddirDegree\": \"179\", \"winddirection\": \"S\", \"windspeedKmph\": \"20\", \"windspeedMiles\": \"12\" }, {\"date\": \"2012-05-10\", \"precipMM\": \"2.4\", \"tempMaxC\": \"13\", \"tempMaxF\": \"55\", \"tempMinC\": \"8\", \"tempMinF\": \"46\", \"weatherCode\": \"266\", \"weatherDesc\": [ {\"value\": \"Light drizzle\" } ], \"weatherIconUrl\": [ {\"value\": \"http:\/\/www.worldweatheronline.com\/images\/wsymbols01_png_64\/wsymbol_0017_cloudy_with_light_rain.png\" } ], \"winddir16Point\": \"SW\", \"winddirDegree\": \"219\", \"winddirection\": \"SW\", \"windspeedKmph\": \"21\", \"windspeedMiles\": \"13\" }, {\"date\": \"2012-05-11\", \"precipMM\": \"11.1\", \"tempMaxC\": \"15\", \"tempMaxF\": \"59\", \"tempMinC\": \"7\", \"tempMinF\": \"44\", \"weatherCode\": \"266\", \"weatherDesc\": [ {\"value\": \"Light drizzle\" } ], \"weatherIconUrl\": [ {\"value\": \"http:\/\/www.worldweatheronline.com\/images\/wsymbols01_png_64\/wsymbol_0017_cloudy_with_light_rain.png\" } ], \"winddir16Point\": \"SSW\", \"winddirDegree\": \"200\", \"winddirection\": \"SSW\", \"windspeedKmph\": \"20\", \"windspeedMiles\": \"12\" }, {\"date\": \"2012-05-12\", \"precipMM\": \"2.8\", \"tempMaxC\": \"7\", \"tempMaxF\": \"44\", \"tempMinC\": \"2\", \"tempMinF\": \"35\", \"weatherCode\": \"317\", \"weatherDesc\": [ {\"value\": \"Light sleet\" } ], \"weatherIconUrl\": [ {\"value\": \"http:\/\/www.worldweatheronline.com\/images\/wsymbols01_png_64\/wsymbol_0021_cloudy_with_sleet.png\" } ], \"winddir16Point\": \"NW\", \"winddirDegree\": \"311\", \"winddirection\": \"NW\", \"windspeedKmph\": \"24\", \"windspeedMiles\": \"15\" }, {\"date\": \"2012-05-13\", \"precipMM\": \"0.4\", \"tempMaxC\": \"6\", \"tempMaxF\": \"42\", \"tempMinC\": \"2\", \"tempMinF\": \"35\", \"weatherCode\": \"116\", \"weatherDesc\": [ {\"value\": \"Partly Cloudy\" } ], \"weatherIconUrl\": [ {\"value\": \"http:\/\/www.worldweatheronline.com\/images\/wsymbols01_png_64\/wsymbol_0002_sunny_intervals.png\" } ], \"winddir16Point\": \"WNW\", \"winddirDegree\": \"281\", \"winddirection\": \"WNW\", \"windspeedKmph\": \"21\", \"windspeedMiles\": \"13\" } ] }}";
123 var a = JSON.parse(responseText);
122 var a = JSON.parse(responseText);
124 parseWeatherData(a);
123 parseWeatherData(a);
125 }
124 }
126 }
125 }
127 }
126 }
128
127
129 Row {
128 Row {
130 id: weatherImageRow
129 id: weatherImageRow
131 anchors.bottom: poweredByText.top
130 anchors.bottom: poweredByText.top
132 anchors.bottomMargin: 10
131 anchors.bottomMargin: 10
133 anchors.left: parent.left
132 anchors.left: parent.left
134 anchors.leftMargin: 25
133 anchors.leftMargin: 25
135 anchors.right: parent.right
134 anchors.right: parent.right
136 anchors.rightMargin: 25
135 anchors.rightMargin: 25
137
136
138 ListModel {
137 ListModel {
139 id: weatherImageModel
138 id: weatherImageModel
140 }
139 }
141
140
142 Repeater {
141 Repeater {
143 id: repeater
142 id: repeater
144 model: weatherImageModel
143 model: weatherImageModel
145 delegate: Image {
144 delegate: Image {
146 source: imageSource
145 source: imageSource
147 width: weatherImageRow.width / weatherImageModel.count
146 width: weatherImageRow.width / weatherImageModel.count
148 height: width
147 height: width
149 fillMode: Image.PreserveAspectCrop
148 fillMode: Image.PreserveAspectCrop
150 }
149 }
151 }
150 }
152 }
151 }
153
152
154 Text {
153 Text {
155 id: poweredByText
154 id: poweredByText
156 anchors.bottom: parent.bottom
155 anchors.bottom: parent.bottom
157 anchors.bottomMargin: 10
156 anchors.bottomMargin: 10
158 anchors.left: parent.left
157 anchors.left: parent.left
159 anchors.leftMargin: 25
158 anchors.leftMargin: 25
160 text: "Powered by World Weather Online"
159 text: "Powered by World Weather Online"
161 }
160 }
162
161
163 function parseWeatherData(weatherData) {
162 function parseWeatherData(weatherData) {
164 // Clear previous values
163 // Clear previous values
165 maxTempSeries.clear();
164 maxTempSeries.clear();
166 minTempSeries.clear();
165 minTempSeries.clear();
167 weatherImageModel.clear();
166 weatherImageModel.clear();
168
167
169 //![4]
168 //![4]
170 // Loop through the parsed JSON
169 // Loop through the parsed JSON
171 for (var i in weatherData.data.weather) {
170 for (var i in weatherData.data.weather) {
172 var weatherObj = weatherData.data.weather[i];
171 var weatherObj = weatherData.data.weather[i];
173 //![4]
172 //![4]
174
173
175 //![5]
174 //![5]
176 // Store temperature values, rainfall and weather icon.
175 // Store temperature values, rainfall and weather icon.
177 // The temperature values begin from 0.5 instead of 0.0 to make the start from the
176 // The temperature values begin from 0.5 instead of 0.0 to make the start from the
178 // middle of the rainfall bars. This makes the temperature lines visually better
177 // middle of the rainfall bars. This makes the temperature lines visually better
179 // synchronized with the rainfall bars.
178 // synchronized with the rainfall bars.
180 maxTempSeries.append(Number(i) + 0.5, weatherObj.tempMaxC);
179 maxTempSeries.append(Number(i) + 0.5, weatherObj.tempMaxC);
181 minTempSeries.append(Number(i) + 0.5, weatherObj.tempMinC);
180 minTempSeries.append(Number(i) + 0.5, weatherObj.tempMinC);
182 rainfallSet.append(i, weatherObj.precipMM);
181 rainfallSet.append(i, weatherObj.precipMM);
183 weatherImageModel.append({"imageSource":weatherObj.weatherIconUrl[0].value});
182 weatherImageModel.append({"imageSource":weatherObj.weatherIconUrl[0].value});
184 //![5]
183 //![5]
185
184
186 // Update scale of the chart
185 // Update scale of the chart
187 valueAxisY.max = Math.max(chartView.axisY().max,weatherObj.tempMaxC);
186 valueAxisY.max = Math.max(chartView.axisY().max,weatherObj.tempMaxC);
188 valueAxisX.min = 0;
187 valueAxisX.min = 0;
189 valueAxisX.max = Number(i) + 1;
188 valueAxisX.max = Number(i) + 1;
190
189
191 // Set the x-axis labels to the dates of the forecast
190 // Set the x-axis labels to the dates of the forecast
192 var xLabels = barCategoriesAxis.categories;
191 var xLabels = barCategoriesAxis.categories;
193 xLabels[Number(i)] = weatherObj.date.substring(5, 10);
192 xLabels[Number(i)] = weatherObj.date.substring(5, 10);
194 barCategoriesAxis.categories = xLabels;
193 barCategoriesAxis.categories = xLabels;
195 barCategoriesAxis.visible = true;
194 barCategoriesAxis.visible = true;
196 barCategoriesAxis.min = 0;
195 barCategoriesAxis.min = 0;
197 barCategoriesAxis.max = xLabels.length - 1;
196 barCategoriesAxis.max = xLabels.length - 1;
198 }
197 }
199 }
198 }
200
199
201 }
200 }
@@ -1,50 +1,52
1 !include( ../plugins.pri ) {
1 !include( ../plugins.pri ) {
2 error( "Couldn't find the plugins.pri file!" )
2 error( "Couldn't find the plugins.pri file!" )
3 }
3 }
4
4
5 TARGET = qtcommercialchartqml
5 TARGET = qtcommercialchartqml
6 QT += declarative
6 QT += declarative
7 DESTDIR = $$CHART_BUILD_QML_PLUGIN_DIR
7 DESTDIR = $$CHART_BUILD_QML_PLUGIN_DIR
8 INCLUDEPATH += $$CHART_BUILD_PRIVATE_HEADER_DIR
8 INCLUDEPATH += $$CHART_BUILD_PRIVATE_HEADER_DIR
9
9
10 CONFIG(debug, debug|release) {
10 CONFIG(debug, debug|release) {
11 mac: TARGET = $$join(TARGET,,,_debug)
11 mac: TARGET = $$join(TARGET,,,_debug)
12 win32: TARGET = $$join(TARGET,,,d)
12 win32: TARGET = $$join(TARGET,,,d)
13 }
13 }
14
14
15 SOURCES += \
15 SOURCES += \
16 plugin.cpp \
16 plugin.cpp \
17 declarativechart.cpp \
17 declarativechart.cpp \
18 declarativexypoint.cpp \
18 declarativexypoint.cpp \
19 declarativexyseries.cpp \
19 declarativexyseries.cpp \
20 declarativelineseries.cpp \
20 declarativelineseries.cpp \
21 declarativesplineseries.cpp \
21 declarativesplineseries.cpp \
22 declarativeareaseries.cpp \
22 declarativeareaseries.cpp \
23 declarativescatterseries.cpp \
23 declarativescatterseries.cpp \
24 declarativepieseries.cpp \
24 declarativepieseries.cpp \
25 declarativebarseries.cpp \
25 declarativebarseries.cpp \
26 declarativecategoryaxis.cpp \
26 declarativecategoryaxis.cpp \
27 declarativemargins.cpp
27 declarativemargins.cpp \
28 declarativeaxes.cpp
28
29
29 HEADERS += \
30 HEADERS += \
30 declarativechart.h \
31 declarativechart.h \
31 declarativexypoint.h \
32 declarativexypoint.h \
32 declarativexyseries.h \
33 declarativexyseries.h \
33 declarativelineseries.h \
34 declarativelineseries.h \
34 declarativesplineseries.h \
35 declarativesplineseries.h \
35 declarativeareaseries.h \
36 declarativeareaseries.h \
36 declarativescatterseries.h \
37 declarativescatterseries.h \
37 declarativepieseries.h \
38 declarativepieseries.h \
38 declarativebarseries.h \
39 declarativebarseries.h \
39 declarativecategoryaxis.h \
40 declarativecategoryaxis.h \
40 declarativemargins.h
41 declarativemargins.h \
42 declarativeaxes.h
41
43
42 TARGETPATH = QtCommercial/Chart
44 TARGETPATH = QtCommercial/Chart
43 target.path = $$[QT_INSTALL_IMPORTS]/$$TARGETPATH
45 target.path = $$[QT_INSTALL_IMPORTS]/$$TARGETPATH
44 qmldir.files += $$PWD/qmldir
46 qmldir.files += $$PWD/qmldir
45 qmldir.path += $$[QT_INSTALL_IMPORTS]/$$TARGETPATH
47 qmldir.path += $$[QT_INSTALL_IMPORTS]/$$TARGETPATH
46 INSTALLS += target qmldir
48 INSTALLS += target qmldir
47
49
48 FILE = $$PWD/qmldir
50 FILE = $$PWD/qmldir
49 win32:{FILE = $$replace(FILE, "/","\\")}
51 win32:{FILE = $$replace(FILE, "/","\\")}
50 QMAKE_POST_LINK += $$QMAKE_COPY $$FILE $$CHART_BUILD_QML_PLUGIN_DIR
52 QMAKE_POST_LINK += $$QMAKE_COPY $$FILE $$CHART_BUILD_QML_PLUGIN_DIR
@@ -1,70 +1,73
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 "declarativeareaseries.h"
21 #include "declarativeareaseries.h"
22 #include "declarativelineseries.h"
22 #include "declarativelineseries.h"
23
23
24 QTCOMMERCIALCHART_BEGIN_NAMESPACE
24 QTCOMMERCIALCHART_BEGIN_NAMESPACE
25
25
26 DeclarativeAreaSeries::DeclarativeAreaSeries(QObject *parent) :
26 DeclarativeAreaSeries::DeclarativeAreaSeries(QObject *parent) :
27 QAreaSeries(parent),
27 QAreaSeries(parent),
28 m_axisX(0),
28 m_axes(new DeclarativeAxes(this))
29 m_axisY(0)
30 {
29 {
30 connect(m_axes, SIGNAL(axisXChanged(QAbstractAxis*)), this, SIGNAL(axisXChanged(QAbstractAxis*)));
31 connect(m_axes, SIGNAL(axisYChanged(QAbstractAxis*)), this, SIGNAL(axisYChanged(QAbstractAxis*)));
32 connect(m_axes, SIGNAL(axisXTopChanged(QAbstractAxis*)), this, SIGNAL(axisXTopChanged(QAbstractAxis*)));
33 connect(m_axes, SIGNAL(axisYRightChanged(QAbstractAxis*)), this, SIGNAL(axisYRightChanged(QAbstractAxis*)));
31 }
34 }
32
35
33 void DeclarativeAreaSeries::setUpperSeries(DeclarativeLineSeries *series)
36 void DeclarativeAreaSeries::setUpperSeries(DeclarativeLineSeries *series)
34 {
37 {
35 QAreaSeries::setUpperSeries(series);
38 QAreaSeries::setUpperSeries(series);
36 }
39 }
37
40
38 DeclarativeLineSeries *DeclarativeAreaSeries::upperSeries() const
41 DeclarativeLineSeries *DeclarativeAreaSeries::upperSeries() const
39 {
42 {
40 return qobject_cast<DeclarativeLineSeries *>(QAreaSeries::upperSeries());
43 return qobject_cast<DeclarativeLineSeries *>(QAreaSeries::upperSeries());
41 }
44 }
42
45
43 void DeclarativeAreaSeries::setLowerSeries(DeclarativeLineSeries *series)
46 void DeclarativeAreaSeries::setLowerSeries(DeclarativeLineSeries *series)
44 {
47 {
45 QAreaSeries::setLowerSeries(series);
48 QAreaSeries::setLowerSeries(series);
46 }
49 }
47
50
48 DeclarativeLineSeries *DeclarativeAreaSeries::lowerSeries() const
51 DeclarativeLineSeries *DeclarativeAreaSeries::lowerSeries() const
49 {
52 {
50 return qobject_cast<DeclarativeLineSeries *>(QAreaSeries::lowerSeries());
53 return qobject_cast<DeclarativeLineSeries *>(QAreaSeries::lowerSeries());
51 }
54 }
52
55
53 qreal DeclarativeAreaSeries::borderWidth() const
56 qreal DeclarativeAreaSeries::borderWidth() const
54 {
57 {
55 return pen().widthF();
58 return pen().widthF();
56 }
59 }
57
60
58 void DeclarativeAreaSeries::setBorderWidth(qreal width)
61 void DeclarativeAreaSeries::setBorderWidth(qreal width)
59 {
62 {
60 if (width != pen().widthF()) {
63 if (width != pen().widthF()) {
61 QPen p = pen();
64 QPen p = pen();
62 p.setWidthF(width);
65 p.setWidthF(width);
63 setPen(p);
66 setPen(p);
64 emit borderWidthChanged(width);
67 emit borderWidthChanged(width);
65 }
68 }
66 }
69 }
67
70
68 #include "moc_declarativeareaseries.cpp"
71 #include "moc_declarativeareaseries.cpp"
69
72
70 QTCOMMERCIALCHART_END_NAMESPACE
73 QTCOMMERCIALCHART_END_NAMESPACE
@@ -1,63 +1,71
1 /****************************************************************************
1 /****************************************************************************
2 **
2 **
3 ** Copyright (C) 2012 Digia Plc
3 ** Copyright (C) 2012 Digia Plc
4 ** All rights reserved.
4 ** All rights reserved.
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 **
6 **
7 ** This file is part of the Qt Commercial Charts Add-on.
7 ** This file is part of the Qt Commercial Charts Add-on.
8 **
8 **
9 ** $QT_BEGIN_LICENSE$
9 ** $QT_BEGIN_LICENSE$
10 ** Licensees holding valid Qt Commercial licenses may use this file in
10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 ** accordance with the Qt Commercial License Agreement provided with the
11 ** accordance with the Qt Commercial License Agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia.
13 ** a written agreement between you and Digia.
14 **
14 **
15 ** If you have questions regarding the use of this file, please use
15 ** If you have questions regarding the use of this file, please use
16 ** contact form at http://qt.digia.com
16 ** contact form at http://qt.digia.com
17 ** $QT_END_LICENSE$
17 ** $QT_END_LICENSE$
18 **
18 **
19 ****************************************************************************/
19 ****************************************************************************/
20
20
21 #ifndef DECLARATIVEAREASERIES_H
21 #ifndef DECLARATIVEAREASERIES_H
22 #define DECLARATIVEAREASERIES_H
22 #define DECLARATIVEAREASERIES_H
23
23
24 #include "qareaseries.h"
24 #include "qareaseries.h"
25 #include "declarativeaxes.h"
25
26
26 QTCOMMERCIALCHART_BEGIN_NAMESPACE
27 QTCOMMERCIALCHART_BEGIN_NAMESPACE
27 class DeclarativeLineSeries;
28 class DeclarativeLineSeries;
28
29
29 class DeclarativeAreaSeries : public QAreaSeries
30 class DeclarativeAreaSeries : public QAreaSeries
30 {
31 {
31 Q_OBJECT
32 Q_OBJECT
32 Q_PROPERTY(DeclarativeLineSeries *upperSeries READ upperSeries WRITE setUpperSeries)
33 Q_PROPERTY(DeclarativeLineSeries *upperSeries READ upperSeries WRITE setUpperSeries)
33 Q_PROPERTY(DeclarativeLineSeries *lowerSeries READ lowerSeries WRITE setLowerSeries)
34 Q_PROPERTY(DeclarativeLineSeries *lowerSeries READ lowerSeries WRITE setLowerSeries)
34 Q_PROPERTY(QAbstractAxis *axisX READ axisX WRITE setAxisX NOTIFY axisXChanged REVISION 1)
35 Q_PROPERTY(QAbstractAxis *axisX READ axisX WRITE setAxisX NOTIFY axisXChanged REVISION 1)
35 Q_PROPERTY(QAbstractAxis *axisY READ axisY WRITE setAxisY NOTIFY axisYChanged REVISION 1)
36 Q_PROPERTY(QAbstractAxis *axisY READ axisY WRITE setAxisY NOTIFY axisYChanged REVISION 1)
37 Q_PROPERTY(QAbstractAxis *axisXTop READ axisXTop WRITE setAxisXTop NOTIFY axisXTopChanged REVISION 2)
38 Q_PROPERTY(QAbstractAxis *axisYRight READ axisYRight WRITE setAxisYRight NOTIFY axisYRightChanged REVISION 2)
36 Q_PROPERTY(qreal borderWidth READ borderWidth WRITE setBorderWidth NOTIFY borderWidthChanged REVISION 1)
39 Q_PROPERTY(qreal borderWidth READ borderWidth WRITE setBorderWidth NOTIFY borderWidthChanged REVISION 1)
37
40
38 public:
41 public:
39 explicit DeclarativeAreaSeries(QObject *parent = 0);
42 explicit DeclarativeAreaSeries(QObject *parent = 0);
40 void setUpperSeries(DeclarativeLineSeries *series);
43 void setUpperSeries(DeclarativeLineSeries *series);
41 DeclarativeLineSeries *upperSeries() const;
44 DeclarativeLineSeries *upperSeries() const;
42 void setLowerSeries(DeclarativeLineSeries *series);
45 void setLowerSeries(DeclarativeLineSeries *series);
43 DeclarativeLineSeries *lowerSeries() const;
46 DeclarativeLineSeries *lowerSeries() const;
44 QAbstractAxis *axisX() { return m_axisX; }
47 QAbstractAxis *axisX() { return m_axes->axisX(); }
45 void setAxisX(QAbstractAxis *axis) { m_axisX = axis; emit axisXChanged(axis); }
48 void setAxisX(QAbstractAxis *axis) { m_axes->setAxisX(axis); }
46 QAbstractAxis *axisY() { return m_axisY; }
49 QAbstractAxis *axisY() { return m_axes->axisY(); }
47 void setAxisY(QAbstractAxis *axis) { m_axisY = axis; emit axisYChanged(axis); }
50 void setAxisY(QAbstractAxis *axis) { m_axes->setAxisY(axis); }
51 Q_REVISION(2) QAbstractAxis *axisXTop() { return m_axes->axisXTop(); }
52 Q_REVISION(2) void setAxisXTop(QAbstractAxis *axis) { m_axes->setAxisXTop(axis); }
53 Q_REVISION(2) QAbstractAxis *axisYRight() { return m_axes->axisYRight(); }
54 Q_REVISION(2) void setAxisYRight(QAbstractAxis *axis) { m_axes->setAxisYRight(axis); }
48 qreal borderWidth() const;
55 qreal borderWidth() const;
49 void setBorderWidth(qreal borderWidth);
56 void setBorderWidth(qreal borderWidth);
50
57
51 Q_SIGNALS:
58 Q_SIGNALS:
52 Q_REVISION(1) void axisXChanged(QAbstractAxis *axis);
59 Q_REVISION(1) void axisXChanged(QAbstractAxis *axis);
53 Q_REVISION(1) void axisYChanged(QAbstractAxis *axis);
60 Q_REVISION(1) void axisYChanged(QAbstractAxis *axis);
54 Q_REVISION(1) void borderWidthChanged(qreal width);
61 Q_REVISION(1) void borderWidthChanged(qreal width);
62 Q_REVISION(2) void axisXTopChanged(QAbstractAxis *axis);
63 Q_REVISION(2) void axisYRightChanged(QAbstractAxis *axis);
55
64
56 private:
65 public:
57 QAbstractAxis *m_axisX;
66 DeclarativeAxes *m_axes;
58 QAbstractAxis *m_axisY;
59 };
67 };
60
68
61 QTCOMMERCIALCHART_END_NAMESPACE
69 QTCOMMERCIALCHART_END_NAMESPACE
62
70
63 #endif // DECLARATIVEAREASERIES_H
71 #endif // DECLARATIVEAREASERIES_H
@@ -1,433 +1,456
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 "declarativebarseries.h"
21 #include "declarativebarseries.h"
22 #include "qbarset.h"
22 #include "qbarset.h"
23 #include "qvbarmodelmapper.h"
23 #include "qvbarmodelmapper.h"
24 #include "qhbarmodelmapper.h"
24 #include "qhbarmodelmapper.h"
25
25
26 QTCOMMERCIALCHART_BEGIN_NAMESPACE
26 QTCOMMERCIALCHART_BEGIN_NAMESPACE
27
27
28 DeclarativeBarSet::DeclarativeBarSet(QObject *parent)
28 DeclarativeBarSet::DeclarativeBarSet(QObject *parent)
29 : QBarSet("", parent)
29 : QBarSet("", parent)
30 {
30 {
31 connect(this, SIGNAL(valuesAdded(int,int)), this, SLOT(handleCountChanged(int,int)));
31 connect(this, SIGNAL(valuesAdded(int,int)), this, SLOT(handleCountChanged(int,int)));
32 connect(this, SIGNAL(valuesRemoved(int,int)), this, SLOT(handleCountChanged(int,int)));
32 connect(this, SIGNAL(valuesRemoved(int,int)), this, SLOT(handleCountChanged(int,int)));
33 }
33 }
34
34
35 void DeclarativeBarSet::handleCountChanged(int index, int count)
35 void DeclarativeBarSet::handleCountChanged(int index, int count)
36 {
36 {
37 Q_UNUSED(index)
37 Q_UNUSED(index)
38 Q_UNUSED(count)
38 Q_UNUSED(count)
39 emit countChanged(QBarSet::count());
39 emit countChanged(QBarSet::count());
40 }
40 }
41
41
42 qreal DeclarativeBarSet::borderWidth() const
42 qreal DeclarativeBarSet::borderWidth() const
43 {
43 {
44 return pen().widthF();
44 return pen().widthF();
45 }
45 }
46
46
47 void DeclarativeBarSet::setBorderWidth(qreal width)
47 void DeclarativeBarSet::setBorderWidth(qreal width)
48 {
48 {
49 if (width != pen().widthF()) {
49 if (width != pen().widthF()) {
50 QPen p = pen();
50 QPen p = pen();
51 p.setWidthF(width);
51 p.setWidthF(width);
52 setPen(p);
52 setPen(p);
53 emit borderWidthChanged(width);
53 emit borderWidthChanged(width);
54 }
54 }
55 }
55 }
56
56
57 QVariantList DeclarativeBarSet::values()
57 QVariantList DeclarativeBarSet::values()
58 {
58 {
59 QVariantList values;
59 QVariantList values;
60 for (int i(0); i < count(); i++)
60 for (int i(0); i < count(); i++)
61 values.append(QVariant(QBarSet::at(i)));
61 values.append(QVariant(QBarSet::at(i)));
62 return values;
62 return values;
63 }
63 }
64
64
65 void DeclarativeBarSet::setValues(QVariantList values)
65 void DeclarativeBarSet::setValues(QVariantList values)
66 {
66 {
67 while (count())
67 while (count())
68 remove(count() - 1);
68 remove(count() - 1);
69
69
70 for (int i(0); i < values.count(); i++) {
70 for (int i(0); i < values.count(); i++) {
71 if (values.at(i).canConvert(QVariant::Double))
71 if (values.at(i).canConvert(QVariant::Double))
72 QBarSet::append(values[i].toDouble());
72 QBarSet::append(values[i].toDouble());
73 }
73 }
74 }
74 }
75
75
76 // Declarative bar series ======================================================================================
76 // Declarative bar series ======================================================================================
77 DeclarativeBarSeries::DeclarativeBarSeries(QDeclarativeItem *parent) :
77 DeclarativeBarSeries::DeclarativeBarSeries(QDeclarativeItem *parent) :
78 QBarSeries(parent),
78 QBarSeries(parent),
79 m_axisX(0),
79 m_axes(new DeclarativeAxes(this))
80 m_axisY(0)
81 {
80 {
81 connect(m_axes, SIGNAL(axisXChanged(QAbstractAxis*)), this, SIGNAL(axisXChanged(QAbstractAxis*)));
82 connect(m_axes, SIGNAL(axisYChanged(QAbstractAxis*)), this, SIGNAL(axisYChanged(QAbstractAxis*)));
83 connect(m_axes, SIGNAL(axisXTopChanged(QAbstractAxis*)), this, SIGNAL(axisXTopChanged(QAbstractAxis*)));
84 connect(m_axes, SIGNAL(axisYRightChanged(QAbstractAxis*)), this, SIGNAL(axisYRightChanged(QAbstractAxis*)));
82 }
85 }
83
86
84 void DeclarativeBarSeries::classBegin()
87 void DeclarativeBarSeries::classBegin()
85 {
88 {
86 }
89 }
87
90
88 void DeclarativeBarSeries::componentComplete()
91 void DeclarativeBarSeries::componentComplete()
89 {
92 {
90 foreach (QObject *child, children()) {
93 foreach (QObject *child, children()) {
91 if (qobject_cast<DeclarativeBarSet *>(child)) {
94 if (qobject_cast<DeclarativeBarSet *>(child)) {
92 QAbstractBarSeries::append(qobject_cast<DeclarativeBarSet *>(child));
95 QAbstractBarSeries::append(qobject_cast<DeclarativeBarSet *>(child));
93 } else if (qobject_cast<QVBarModelMapper *>(child)) {
96 } else if (qobject_cast<QVBarModelMapper *>(child)) {
94 QVBarModelMapper *mapper = qobject_cast<QVBarModelMapper *>(child);
97 QVBarModelMapper *mapper = qobject_cast<QVBarModelMapper *>(child);
95 mapper->setSeries(this);
98 mapper->setSeries(this);
96 } else if (qobject_cast<QHBarModelMapper *>(child)) {
99 } else if (qobject_cast<QHBarModelMapper *>(child)) {
97 QHBarModelMapper *mapper = qobject_cast<QHBarModelMapper *>(child);
100 QHBarModelMapper *mapper = qobject_cast<QHBarModelMapper *>(child);
98 mapper->setSeries(this);
101 mapper->setSeries(this);
99 }
102 }
100 }
103 }
101 }
104 }
102
105
103 QDeclarativeListProperty<QObject> DeclarativeBarSeries::seriesChildren()
106 QDeclarativeListProperty<QObject> DeclarativeBarSeries::seriesChildren()
104 {
107 {
105 return QDeclarativeListProperty<QObject>(this, 0, &DeclarativeBarSeries::appendSeriesChildren);
108 return QDeclarativeListProperty<QObject>(this, 0, &DeclarativeBarSeries::appendSeriesChildren);
106 }
109 }
107
110
108 void DeclarativeBarSeries::appendSeriesChildren(QDeclarativeListProperty<QObject> * list, QObject *element)
111 void DeclarativeBarSeries::appendSeriesChildren(QDeclarativeListProperty<QObject> * list, QObject *element)
109 {
112 {
110 // Empty implementation; the children are parsed in componentComplete instead
113 // Empty implementation; the children are parsed in componentComplete instead
111 Q_UNUSED(list);
114 Q_UNUSED(list);
112 Q_UNUSED(element);
115 Q_UNUSED(element);
113 }
116 }
114
117
115 DeclarativeBarSet *DeclarativeBarSeries::at(int index)
118 DeclarativeBarSet *DeclarativeBarSeries::at(int index)
116 {
119 {
117 QList<QBarSet *> setList = barSets();
120 QList<QBarSet *> setList = barSets();
118 if (index >= 0 && index < setList.count())
121 if (index >= 0 && index < setList.count())
119 return qobject_cast<DeclarativeBarSet *>(setList[index]);
122 return qobject_cast<DeclarativeBarSet *>(setList[index]);
120
123
121 return 0;
124 return 0;
122 }
125 }
123
126
124 DeclarativeBarSet *DeclarativeBarSeries::insert(int index, QString label, QVariantList values)
127 DeclarativeBarSet *DeclarativeBarSeries::insert(int index, QString label, QVariantList values)
125 {
128 {
126 DeclarativeBarSet *barset = new DeclarativeBarSet(this);
129 DeclarativeBarSet *barset = new DeclarativeBarSet(this);
127 barset->setLabel(label);
130 barset->setLabel(label);
128 barset->setValues(values);
131 barset->setValues(values);
129 if (QBarSeries::insert(index, barset))
132 if (QBarSeries::insert(index, barset))
130 return barset;
133 return barset;
131 delete barset;
134 delete barset;
132 return 0;
135 return 0;
133 }
136 }
134
137
135 // Declarative stacked bar series ==============================================================================
138 // Declarative stacked bar series ==============================================================================
136 DeclarativeStackedBarSeries::DeclarativeStackedBarSeries(QDeclarativeItem *parent) :
139 DeclarativeStackedBarSeries::DeclarativeStackedBarSeries(QDeclarativeItem *parent) :
137 QStackedBarSeries(parent),
140 QStackedBarSeries(parent),
138 m_axisX(0),
141 m_axes(0)
139 m_axisY(0)
140 {
142 {
143 m_axes = new DeclarativeAxes(this);
144 connect(m_axes, SIGNAL(axisXChanged(QAbstractAxis*)), this, SIGNAL(axisXChanged(QAbstractAxis*)));
145 connect(m_axes, SIGNAL(axisYChanged(QAbstractAxis*)), this, SIGNAL(axisYChanged(QAbstractAxis*)));
146 connect(m_axes, SIGNAL(axisXTopChanged(QAbstractAxis*)), this, SIGNAL(axisXTopChanged(QAbstractAxis*)));
147 connect(m_axes, SIGNAL(axisYRightChanged(QAbstractAxis*)), this, SIGNAL(axisYRightChanged(QAbstractAxis*)));
141 }
148 }
142
149
143 void DeclarativeStackedBarSeries::classBegin()
150 void DeclarativeStackedBarSeries::classBegin()
144 {
151 {
145 }
152 }
146
153
147 void DeclarativeStackedBarSeries::componentComplete()
154 void DeclarativeStackedBarSeries::componentComplete()
148 {
155 {
149 foreach (QObject *child, children()) {
156 foreach (QObject *child, children()) {
150 if (qobject_cast<DeclarativeBarSet *>(child)) {
157 if (qobject_cast<DeclarativeBarSet *>(child)) {
151 QAbstractBarSeries::append(qobject_cast<DeclarativeBarSet *>(child));
158 QAbstractBarSeries::append(qobject_cast<DeclarativeBarSet *>(child));
152 } else if (qobject_cast<QVBarModelMapper *>(child)) {
159 } else if (qobject_cast<QVBarModelMapper *>(child)) {
153 QVBarModelMapper *mapper = qobject_cast<QVBarModelMapper *>(child);
160 QVBarModelMapper *mapper = qobject_cast<QVBarModelMapper *>(child);
154 mapper->setSeries(this);
161 mapper->setSeries(this);
155 } else if (qobject_cast<QHBarModelMapper *>(child)) {
162 } else if (qobject_cast<QHBarModelMapper *>(child)) {
156 QHBarModelMapper *mapper = qobject_cast<QHBarModelMapper *>(child);
163 QHBarModelMapper *mapper = qobject_cast<QHBarModelMapper *>(child);
157 mapper->setSeries(this);
164 mapper->setSeries(this);
158 }
165 }
159 }
166 }
160 }
167 }
161
168
162
169
163 QDeclarativeListProperty<QObject> DeclarativeStackedBarSeries::seriesChildren()
170 QDeclarativeListProperty<QObject> DeclarativeStackedBarSeries::seriesChildren()
164 {
171 {
165 return QDeclarativeListProperty<QObject>(this, 0, &DeclarativeBarSeries::appendSeriesChildren);
172 return QDeclarativeListProperty<QObject>(this, 0, &DeclarativeBarSeries::appendSeriesChildren);
166 }
173 }
167
174
168 void DeclarativeStackedBarSeries::appendSeriesChildren(QDeclarativeListProperty<QObject> * list, QObject *element)
175 void DeclarativeStackedBarSeries::appendSeriesChildren(QDeclarativeListProperty<QObject> * list, QObject *element)
169 {
176 {
170 // Empty implementation; the children are parsed in componentComplete instead
177 // Empty implementation; the children are parsed in componentComplete instead
171 Q_UNUSED(list);
178 Q_UNUSED(list);
172 Q_UNUSED(element);
179 Q_UNUSED(element);
173 }
180 }
174
181
175 DeclarativeBarSet *DeclarativeStackedBarSeries::at(int index)
182 DeclarativeBarSet *DeclarativeStackedBarSeries::at(int index)
176 {
183 {
177 QList<QBarSet *> setList = barSets();
184 QList<QBarSet *> setList = barSets();
178 if (index >= 0 && index < setList.count())
185 if (index >= 0 && index < setList.count())
179 return qobject_cast<DeclarativeBarSet *>(setList[index]);
186 return qobject_cast<DeclarativeBarSet *>(setList[index]);
180
187
181 return 0;
188 return 0;
182 }
189 }
183
190
184 DeclarativeBarSet *DeclarativeStackedBarSeries::insert(int index, QString label, QVariantList values)
191 DeclarativeBarSet *DeclarativeStackedBarSeries::insert(int index, QString label, QVariantList values)
185 {
192 {
186 DeclarativeBarSet *barset = new DeclarativeBarSet(this);
193 DeclarativeBarSet *barset = new DeclarativeBarSet(this);
187 barset->setLabel(label);
194 barset->setLabel(label);
188 barset->setValues(values);
195 barset->setValues(values);
189 if (QStackedBarSeries::insert(index, barset))
196 if (QStackedBarSeries::insert(index, barset))
190 return barset;
197 return barset;
191 delete barset;
198 delete barset;
192 return 0;
199 return 0;
193 }
200 }
194
201
195 // Declarative percent bar series ==============================================================================
202 // Declarative percent bar series ==============================================================================
196 DeclarativePercentBarSeries::DeclarativePercentBarSeries(QDeclarativeItem *parent) :
203 DeclarativePercentBarSeries::DeclarativePercentBarSeries(QDeclarativeItem *parent) :
197 QPercentBarSeries(parent),
204 QPercentBarSeries(parent),
198 m_axisX(0),
205 m_axes(0)
199 m_axisY(0)
200 {
206 {
207 m_axes = new DeclarativeAxes(this);
208 connect(m_axes, SIGNAL(axisXChanged(QAbstractAxis*)), this, SIGNAL(axisXChanged(QAbstractAxis*)));
209 connect(m_axes, SIGNAL(axisYChanged(QAbstractAxis*)), this, SIGNAL(axisYChanged(QAbstractAxis*)));
210 connect(m_axes, SIGNAL(axisXTopChanged(QAbstractAxis*)), this, SIGNAL(axisXTopChanged(QAbstractAxis*)));
211 connect(m_axes, SIGNAL(axisYRightChanged(QAbstractAxis*)), this, SIGNAL(axisYRightChanged(QAbstractAxis*)));
201 }
212 }
202
213
203 void DeclarativePercentBarSeries::classBegin()
214 void DeclarativePercentBarSeries::classBegin()
204 {
215 {
205 }
216 }
206
217
207 void DeclarativePercentBarSeries::componentComplete()
218 void DeclarativePercentBarSeries::componentComplete()
208 {
219 {
209 foreach (QObject *child, children()) {
220 foreach (QObject *child, children()) {
210 if (qobject_cast<DeclarativeBarSet *>(child)) {
221 if (qobject_cast<DeclarativeBarSet *>(child)) {
211 QAbstractBarSeries::append(qobject_cast<DeclarativeBarSet *>(child));
222 QAbstractBarSeries::append(qobject_cast<DeclarativeBarSet *>(child));
212 } else if (qobject_cast<QVBarModelMapper *>(child)) {
223 } else if (qobject_cast<QVBarModelMapper *>(child)) {
213 QVBarModelMapper *mapper = qobject_cast<QVBarModelMapper *>(child);
224 QVBarModelMapper *mapper = qobject_cast<QVBarModelMapper *>(child);
214 mapper->setSeries(this);
225 mapper->setSeries(this);
215 } else if (qobject_cast<QHBarModelMapper *>(child)) {
226 } else if (qobject_cast<QHBarModelMapper *>(child)) {
216 QHBarModelMapper *mapper = qobject_cast<QHBarModelMapper *>(child);
227 QHBarModelMapper *mapper = qobject_cast<QHBarModelMapper *>(child);
217 mapper->setSeries(this);
228 mapper->setSeries(this);
218 }
229 }
219 }
230 }
220 }
231 }
221
232
222 QDeclarativeListProperty<QObject> DeclarativePercentBarSeries::seriesChildren()
233 QDeclarativeListProperty<QObject> DeclarativePercentBarSeries::seriesChildren()
223 {
234 {
224 return QDeclarativeListProperty<QObject>(this, 0, &DeclarativeBarSeries::appendSeriesChildren);
235 return QDeclarativeListProperty<QObject>(this, 0, &DeclarativeBarSeries::appendSeriesChildren);
225 }
236 }
226
237
227 void DeclarativePercentBarSeries::appendSeriesChildren(QDeclarativeListProperty<QObject> * list, QObject *element)
238 void DeclarativePercentBarSeries::appendSeriesChildren(QDeclarativeListProperty<QObject> * list, QObject *element)
228 {
239 {
229 // Empty implementation; the children are parsed in componentComplete instead
240 // Empty implementation; the children are parsed in componentComplete instead
230 Q_UNUSED(list);
241 Q_UNUSED(list);
231 Q_UNUSED(element);
242 Q_UNUSED(element);
232 }
243 }
233
244
234 DeclarativeBarSet *DeclarativePercentBarSeries::at(int index)
245 DeclarativeBarSet *DeclarativePercentBarSeries::at(int index)
235 {
246 {
236 QList<QBarSet *> setList = barSets();
247 QList<QBarSet *> setList = barSets();
237 if (index >= 0 && index < setList.count())
248 if (index >= 0 && index < setList.count())
238 return qobject_cast<DeclarativeBarSet *>(setList[index]);
249 return qobject_cast<DeclarativeBarSet *>(setList[index]);
239
250
240 return 0;
251 return 0;
241 }
252 }
242
253
243 DeclarativeBarSet *DeclarativePercentBarSeries::insert(int index, QString label, QVariantList values)
254 DeclarativeBarSet *DeclarativePercentBarSeries::insert(int index, QString label, QVariantList values)
244 {
255 {
245 DeclarativeBarSet *barset = new DeclarativeBarSet(this);
256 DeclarativeBarSet *barset = new DeclarativeBarSet(this);
246 barset->setLabel(label);
257 barset->setLabel(label);
247 barset->setValues(values);
258 barset->setValues(values);
248 if (QPercentBarSeries::insert(index, barset))
259 if (QPercentBarSeries::insert(index, barset))
249 return barset;
260 return barset;
250 delete barset;
261 delete barset;
251 return 0;
262 return 0;
252 }
263 }
253
264
254 // Declarative horizontal bar series ===========================================================================
265 // Declarative horizontal bar series ===========================================================================
255 DeclarativeHorizontalBarSeries::DeclarativeHorizontalBarSeries(QDeclarativeItem *parent) :
266 DeclarativeHorizontalBarSeries::DeclarativeHorizontalBarSeries(QDeclarativeItem *parent) :
256 QHorizontalBarSeries(parent),
267 QHorizontalBarSeries(parent),
257 m_axisX(0),
268 m_axes(0)
258 m_axisY(0)
259 {
269 {
270 m_axes = new DeclarativeAxes(this);
271 connect(m_axes, SIGNAL(axisXChanged(QAbstractAxis*)), this, SIGNAL(axisXChanged(QAbstractAxis*)));
272 connect(m_axes, SIGNAL(axisYChanged(QAbstractAxis*)), this, SIGNAL(axisYChanged(QAbstractAxis*)));
273 connect(m_axes, SIGNAL(axisXTopChanged(QAbstractAxis*)), this, SIGNAL(axisXTopChanged(QAbstractAxis*)));
274 connect(m_axes, SIGNAL(axisYRightChanged(QAbstractAxis*)), this, SIGNAL(axisYRightChanged(QAbstractAxis*)));
260 }
275 }
261
276
262 void DeclarativeHorizontalBarSeries::classBegin()
277 void DeclarativeHorizontalBarSeries::classBegin()
263 {
278 {
264 }
279 }
265
280
266 void DeclarativeHorizontalBarSeries::componentComplete()
281 void DeclarativeHorizontalBarSeries::componentComplete()
267 {
282 {
268 foreach (QObject *child, children()) {
283 foreach (QObject *child, children()) {
269 if (qobject_cast<DeclarativeBarSet *>(child)) {
284 if (qobject_cast<DeclarativeBarSet *>(child)) {
270 QAbstractBarSeries::append(qobject_cast<DeclarativeBarSet *>(child));
285 QAbstractBarSeries::append(qobject_cast<DeclarativeBarSet *>(child));
271 } else if (qobject_cast<QVBarModelMapper *>(child)) {
286 } else if (qobject_cast<QVBarModelMapper *>(child)) {
272 QVBarModelMapper *mapper = qobject_cast<QVBarModelMapper *>(child);
287 QVBarModelMapper *mapper = qobject_cast<QVBarModelMapper *>(child);
273 mapper->setSeries(this);
288 mapper->setSeries(this);
274 } else if (qobject_cast<QHBarModelMapper *>(child)) {
289 } else if (qobject_cast<QHBarModelMapper *>(child)) {
275 QHBarModelMapper *mapper = qobject_cast<QHBarModelMapper *>(child);
290 QHBarModelMapper *mapper = qobject_cast<QHBarModelMapper *>(child);
276 mapper->setSeries(this);
291 mapper->setSeries(this);
277 }
292 }
278 }
293 }
279 }
294 }
280
295
281 QDeclarativeListProperty<QObject> DeclarativeHorizontalBarSeries::seriesChildren()
296 QDeclarativeListProperty<QObject> DeclarativeHorizontalBarSeries::seriesChildren()
282 {
297 {
283 return QDeclarativeListProperty<QObject>(this, 0, &DeclarativeHorizontalBarSeries::appendSeriesChildren);
298 return QDeclarativeListProperty<QObject>(this, 0, &DeclarativeHorizontalBarSeries::appendSeriesChildren);
284 }
299 }
285
300
286 void DeclarativeHorizontalBarSeries::appendSeriesChildren(QDeclarativeListProperty<QObject> * list, QObject *element)
301 void DeclarativeHorizontalBarSeries::appendSeriesChildren(QDeclarativeListProperty<QObject> * list, QObject *element)
287 {
302 {
288 // Empty implementation; the children are parsed in componentComplete instead
303 // Empty implementation; the children are parsed in componentComplete instead
289 Q_UNUSED(list);
304 Q_UNUSED(list);
290 Q_UNUSED(element);
305 Q_UNUSED(element);
291 }
306 }
292
307
293 DeclarativeBarSet *DeclarativeHorizontalBarSeries::at(int index)
308 DeclarativeBarSet *DeclarativeHorizontalBarSeries::at(int index)
294 {
309 {
295 QList<QBarSet *> setList = barSets();
310 QList<QBarSet *> setList = barSets();
296 if (index >= 0 && index < setList.count())
311 if (index >= 0 && index < setList.count())
297 return qobject_cast<DeclarativeBarSet *>(setList[index]);
312 return qobject_cast<DeclarativeBarSet *>(setList[index]);
298
313
299 return 0;
314 return 0;
300 }
315 }
301
316
302 DeclarativeBarSet *DeclarativeHorizontalBarSeries::insert(int index, QString label, QVariantList values)
317 DeclarativeBarSet *DeclarativeHorizontalBarSeries::insert(int index, QString label, QVariantList values)
303 {
318 {
304 DeclarativeBarSet *barset = new DeclarativeBarSet(this);
319 DeclarativeBarSet *barset = new DeclarativeBarSet(this);
305 barset->setLabel(label);
320 barset->setLabel(label);
306 barset->setValues(values);
321 barset->setValues(values);
307 if (QHorizontalBarSeries::insert(index, barset))
322 if (QHorizontalBarSeries::insert(index, barset))
308 return barset;
323 return barset;
309 delete barset;
324 delete barset;
310 return 0;
325 return 0;
311 }
326 }
312
327
313 // Declarative horizontal stacked bar series ===================================================================
328 // Declarative horizontal stacked bar series ===================================================================
314 DeclarativeHorizontalStackedBarSeries::DeclarativeHorizontalStackedBarSeries(QDeclarativeItem *parent) :
329 DeclarativeHorizontalStackedBarSeries::DeclarativeHorizontalStackedBarSeries(QDeclarativeItem *parent) :
315 QHorizontalStackedBarSeries(parent),
330 QHorizontalStackedBarSeries(parent),
316 m_axisX(0),
331 m_axes(0)
317 m_axisY(0)
318 {
332 {
333 m_axes = new DeclarativeAxes(this);
334 connect(m_axes, SIGNAL(axisXChanged(QAbstractAxis*)), this, SIGNAL(axisXChanged(QAbstractAxis*)));
335 connect(m_axes, SIGNAL(axisYChanged(QAbstractAxis*)), this, SIGNAL(axisYChanged(QAbstractAxis*)));
336 connect(m_axes, SIGNAL(axisXTopChanged(QAbstractAxis*)), this, SIGNAL(axisXTopChanged(QAbstractAxis*)));
337 connect(m_axes, SIGNAL(axisYRightChanged(QAbstractAxis*)), this, SIGNAL(axisYRightChanged(QAbstractAxis*)));
319 }
338 }
320
339
321 void DeclarativeHorizontalStackedBarSeries::classBegin()
340 void DeclarativeHorizontalStackedBarSeries::classBegin()
322 {
341 {
323 }
342 }
324
343
325 void DeclarativeHorizontalStackedBarSeries::componentComplete()
344 void DeclarativeHorizontalStackedBarSeries::componentComplete()
326 {
345 {
327 foreach (QObject *child, children()) {
346 foreach (QObject *child, children()) {
328 if (qobject_cast<DeclarativeBarSet *>(child)) {
347 if (qobject_cast<DeclarativeBarSet *>(child)) {
329 QAbstractBarSeries::append(qobject_cast<DeclarativeBarSet *>(child));
348 QAbstractBarSeries::append(qobject_cast<DeclarativeBarSet *>(child));
330 } else if (qobject_cast<QVBarModelMapper *>(child)) {
349 } else if (qobject_cast<QVBarModelMapper *>(child)) {
331 QVBarModelMapper *mapper = qobject_cast<QVBarModelMapper *>(child);
350 QVBarModelMapper *mapper = qobject_cast<QVBarModelMapper *>(child);
332 mapper->setSeries(this);
351 mapper->setSeries(this);
333 } else if (qobject_cast<QHBarModelMapper *>(child)) {
352 } else if (qobject_cast<QHBarModelMapper *>(child)) {
334 QHBarModelMapper *mapper = qobject_cast<QHBarModelMapper *>(child);
353 QHBarModelMapper *mapper = qobject_cast<QHBarModelMapper *>(child);
335 mapper->setSeries(this);
354 mapper->setSeries(this);
336 }
355 }
337 }
356 }
338 }
357 }
339
358
340 QDeclarativeListProperty<QObject> DeclarativeHorizontalStackedBarSeries::seriesChildren()
359 QDeclarativeListProperty<QObject> DeclarativeHorizontalStackedBarSeries::seriesChildren()
341 {
360 {
342 return QDeclarativeListProperty<QObject>(this, 0, &DeclarativeHorizontalStackedBarSeries::appendSeriesChildren);
361 return QDeclarativeListProperty<QObject>(this, 0, &DeclarativeHorizontalStackedBarSeries::appendSeriesChildren);
343 }
362 }
344
363
345 void DeclarativeHorizontalStackedBarSeries::appendSeriesChildren(QDeclarativeListProperty<QObject> * list, QObject *element)
364 void DeclarativeHorizontalStackedBarSeries::appendSeriesChildren(QDeclarativeListProperty<QObject> * list, QObject *element)
346 {
365 {
347 // Empty implementation; the children are parsed in componentComplete instead
366 // Empty implementation; the children are parsed in componentComplete instead
348 Q_UNUSED(list);
367 Q_UNUSED(list);
349 Q_UNUSED(element);
368 Q_UNUSED(element);
350 }
369 }
351
370
352 DeclarativeBarSet *DeclarativeHorizontalStackedBarSeries::at(int index)
371 DeclarativeBarSet *DeclarativeHorizontalStackedBarSeries::at(int index)
353 {
372 {
354 QList<QBarSet *> setList = barSets();
373 QList<QBarSet *> setList = barSets();
355 if (index >= 0 && index < setList.count())
374 if (index >= 0 && index < setList.count())
356 return qobject_cast<DeclarativeBarSet *>(setList[index]);
375 return qobject_cast<DeclarativeBarSet *>(setList[index]);
357
376
358 return 0;
377 return 0;
359 }
378 }
360
379
361 DeclarativeBarSet *DeclarativeHorizontalStackedBarSeries::insert(int index, QString label, QVariantList values)
380 DeclarativeBarSet *DeclarativeHorizontalStackedBarSeries::insert(int index, QString label, QVariantList values)
362 {
381 {
363 DeclarativeBarSet *barset = new DeclarativeBarSet(this);
382 DeclarativeBarSet *barset = new DeclarativeBarSet(this);
364 barset->setLabel(label);
383 barset->setLabel(label);
365 barset->setValues(values);
384 barset->setValues(values);
366 if (QHorizontalStackedBarSeries::insert(index, barset))
385 if (QHorizontalStackedBarSeries::insert(index, barset))
367 return barset;
386 return barset;
368 delete barset;
387 delete barset;
369 return 0;
388 return 0;
370 }
389 }
371
390
372 // Declarative horizontal percent bar series ===================================================================
391 // Declarative horizontal percent bar series ===================================================================
373 DeclarativeHorizontalPercentBarSeries::DeclarativeHorizontalPercentBarSeries(QDeclarativeItem *parent) :
392 DeclarativeHorizontalPercentBarSeries::DeclarativeHorizontalPercentBarSeries(QDeclarativeItem *parent) :
374 QHorizontalPercentBarSeries(parent),
393 QHorizontalPercentBarSeries(parent),
375 m_axisX(0),
394 m_axes(0)
376 m_axisY(0)
377 {
395 {
396 m_axes = new DeclarativeAxes(this);
397 connect(m_axes, SIGNAL(axisXChanged(QAbstractAxis*)), this, SIGNAL(axisXChanged(QAbstractAxis*)));
398 connect(m_axes, SIGNAL(axisYChanged(QAbstractAxis*)), this, SIGNAL(axisYChanged(QAbstractAxis*)));
399 connect(m_axes, SIGNAL(axisXTopChanged(QAbstractAxis*)), this, SIGNAL(axisXTopChanged(QAbstractAxis*)));
400 connect(m_axes, SIGNAL(axisYRightChanged(QAbstractAxis*)), this, SIGNAL(axisYRightChanged(QAbstractAxis*)));
378 }
401 }
379
402
380 void DeclarativeHorizontalPercentBarSeries::classBegin()
403 void DeclarativeHorizontalPercentBarSeries::classBegin()
381 {
404 {
382 }
405 }
383
406
384 void DeclarativeHorizontalPercentBarSeries::componentComplete()
407 void DeclarativeHorizontalPercentBarSeries::componentComplete()
385 {
408 {
386 foreach (QObject *child, children()) {
409 foreach (QObject *child, children()) {
387 if (qobject_cast<DeclarativeBarSet *>(child)) {
410 if (qobject_cast<DeclarativeBarSet *>(child)) {
388 QAbstractBarSeries::append(qobject_cast<DeclarativeBarSet *>(child));
411 QAbstractBarSeries::append(qobject_cast<DeclarativeBarSet *>(child));
389 } else if (qobject_cast<QVBarModelMapper *>(child)) {
412 } else if (qobject_cast<QVBarModelMapper *>(child)) {
390 QVBarModelMapper *mapper = qobject_cast<QVBarModelMapper *>(child);
413 QVBarModelMapper *mapper = qobject_cast<QVBarModelMapper *>(child);
391 mapper->setSeries(this);
414 mapper->setSeries(this);
392 } else if (qobject_cast<QHBarModelMapper *>(child)) {
415 } else if (qobject_cast<QHBarModelMapper *>(child)) {
393 QHBarModelMapper *mapper = qobject_cast<QHBarModelMapper *>(child);
416 QHBarModelMapper *mapper = qobject_cast<QHBarModelMapper *>(child);
394 mapper->setSeries(this);
417 mapper->setSeries(this);
395 }
418 }
396 }
419 }
397 }
420 }
398
421
399 QDeclarativeListProperty<QObject> DeclarativeHorizontalPercentBarSeries::seriesChildren()
422 QDeclarativeListProperty<QObject> DeclarativeHorizontalPercentBarSeries::seriesChildren()
400 {
423 {
401 return QDeclarativeListProperty<QObject>(this, 0, &DeclarativeHorizontalPercentBarSeries::appendSeriesChildren);
424 return QDeclarativeListProperty<QObject>(this, 0, &DeclarativeHorizontalPercentBarSeries::appendSeriesChildren);
402 }
425 }
403
426
404 void DeclarativeHorizontalPercentBarSeries::appendSeriesChildren(QDeclarativeListProperty<QObject> * list, QObject *element)
427 void DeclarativeHorizontalPercentBarSeries::appendSeriesChildren(QDeclarativeListProperty<QObject> * list, QObject *element)
405 {
428 {
406 // Empty implementation; the children are parsed in componentComplete instead
429 // Empty implementation; the children are parsed in componentComplete instead
407 Q_UNUSED(list);
430 Q_UNUSED(list);
408 Q_UNUSED(element);
431 Q_UNUSED(element);
409 }
432 }
410
433
411 DeclarativeBarSet *DeclarativeHorizontalPercentBarSeries::at(int index)
434 DeclarativeBarSet *DeclarativeHorizontalPercentBarSeries::at(int index)
412 {
435 {
413 QList<QBarSet *> setList = barSets();
436 QList<QBarSet *> setList = barSets();
414 if (index >= 0 && index < setList.count())
437 if (index >= 0 && index < setList.count())
415 return qobject_cast<DeclarativeBarSet *>(setList[index]);
438 return qobject_cast<DeclarativeBarSet *>(setList[index]);
416
439
417 return 0;
440 return 0;
418 }
441 }
419
442
420 DeclarativeBarSet *DeclarativeHorizontalPercentBarSeries::insert(int index, QString label, QVariantList values)
443 DeclarativeBarSet *DeclarativeHorizontalPercentBarSeries::insert(int index, QString label, QVariantList values)
421 {
444 {
422 DeclarativeBarSet *barset = new DeclarativeBarSet(this);
445 DeclarativeBarSet *barset = new DeclarativeBarSet(this);
423 barset->setLabel(label);
446 barset->setLabel(label);
424 barset->setValues(values);
447 barset->setValues(values);
425 if (QHorizontalPercentBarSeries::insert(index, barset))
448 if (QHorizontalPercentBarSeries::insert(index, barset))
426 return barset;
449 return barset;
427 delete barset;
450 delete barset;
428 return 0;
451 return 0;
429 }
452 }
430
453
431 #include "moc_declarativebarseries.cpp"
454 #include "moc_declarativebarseries.cpp"
432
455
433 QTCOMMERCIALCHART_END_NAMESPACE
456 QTCOMMERCIALCHART_END_NAMESPACE
@@ -1,308 +1,351
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 DECLARATIVEBARSERIES_H
21 #ifndef DECLARATIVEBARSERIES_H
22 #define DECLARATIVEBARSERIES_H
22 #define DECLARATIVEBARSERIES_H
23
23
24 #include "qbarseries.h"
24 #include "qbarseries.h"
25 #include "qstackedbarseries.h"
25 #include "qstackedbarseries.h"
26 #include "qpercentbarseries.h"
26 #include "qpercentbarseries.h"
27 #include "qhorizontalbarseries.h"
27 #include "qhorizontalbarseries.h"
28 #include "qhorizontalstackedbarseries.h"
28 #include "qhorizontalstackedbarseries.h"
29 #include "qhorizontalpercentbarseries.h"
29 #include "qhorizontalpercentbarseries.h"
30 #include "qbarset.h"
30 #include "qbarset.h"
31 #include "declarativeaxes.h"
31 #include <QtDeclarative/QDeclarativeItem>
32 #include <QtDeclarative/QDeclarativeItem>
32 #include <QtDeclarative/QDeclarativeParserStatus>
33 #include <QtDeclarative/QDeclarativeParserStatus>
33
34
34 QTCOMMERCIALCHART_BEGIN_NAMESPACE
35 QTCOMMERCIALCHART_BEGIN_NAMESPACE
35
36
36 class QChart;
37 class QChart;
37
38
38 class DeclarativeBarSet : public QBarSet
39 class DeclarativeBarSet : public QBarSet
39 {
40 {
40 Q_OBJECT
41 Q_OBJECT
41 Q_PROPERTY(QVariantList values READ values WRITE setValues)
42 Q_PROPERTY(QVariantList values READ values WRITE setValues)
42 Q_PROPERTY(qreal borderWidth READ borderWidth WRITE setBorderWidth NOTIFY borderWidthChanged REVISION 1)
43 Q_PROPERTY(qreal borderWidth READ borderWidth WRITE setBorderWidth NOTIFY borderWidthChanged REVISION 1)
43 Q_PROPERTY(int count READ count NOTIFY countChanged)
44 Q_PROPERTY(int count READ count NOTIFY countChanged)
44
45
45 public:
46 public:
46 explicit DeclarativeBarSet(QObject *parent = 0);
47 explicit DeclarativeBarSet(QObject *parent = 0);
47 QVariantList values();
48 QVariantList values();
48 void setValues(QVariantList values);
49 void setValues(QVariantList values);
49 qreal borderWidth() const;
50 qreal borderWidth() const;
50 void setBorderWidth(qreal borderWidth);
51 void setBorderWidth(qreal borderWidth);
51
52
52 public: // From QBarSet
53 public: // From QBarSet
53 Q_INVOKABLE void append(qreal value) { QBarSet::append(value); }
54 Q_INVOKABLE void append(qreal value) { QBarSet::append(value); }
54 Q_INVOKABLE void remove(const int index, const int count = 1) { QBarSet::remove(index, count); }
55 Q_INVOKABLE void remove(const int index, const int count = 1) { QBarSet::remove(index, count); }
55 Q_INVOKABLE void replace(int index, qreal value) { QBarSet::replace(index, value); }
56 Q_INVOKABLE void replace(int index, qreal value) { QBarSet::replace(index, value); }
56 Q_INVOKABLE qreal at(int index) { return QBarSet::at(index); }
57 Q_INVOKABLE qreal at(int index) { return QBarSet::at(index); }
57
58
58 Q_SIGNALS:
59 Q_SIGNALS:
59 void countChanged(int count);
60 void countChanged(int count);
60 Q_REVISION(1) void borderWidthChanged(qreal width);
61 Q_REVISION(1) void borderWidthChanged(qreal width);
61
62
62 private Q_SLOTS:
63 private Q_SLOTS:
63 void handleCountChanged(int index, int count);
64 void handleCountChanged(int index, int count);
64 };
65 };
65
66
66 class DeclarativeBarSeries : public QBarSeries, public QDeclarativeParserStatus
67 class DeclarativeBarSeries : public QBarSeries, public QDeclarativeParserStatus
67 {
68 {
68 Q_OBJECT
69 Q_OBJECT
69 Q_INTERFACES(QDeclarativeParserStatus)
70 Q_INTERFACES(QDeclarativeParserStatus)
70 Q_PROPERTY(QAbstractAxis *axisX READ axisX WRITE setAxisX NOTIFY axisXChanged REVISION 1)
71 Q_PROPERTY(QAbstractAxis *axisX READ axisX WRITE setAxisX NOTIFY axisXChanged REVISION 1)
71 Q_PROPERTY(QAbstractAxis *axisY READ axisY WRITE setAxisY NOTIFY axisYChanged REVISION 1)
72 Q_PROPERTY(QAbstractAxis *axisY READ axisY WRITE setAxisY NOTIFY axisYChanged REVISION 1)
73 Q_PROPERTY(QAbstractAxis *axisXTop READ axisXTop WRITE setAxisXTop NOTIFY axisXTopChanged REVISION 2)
74 Q_PROPERTY(QAbstractAxis *axisYRight READ axisYRight WRITE setAxisYRight NOTIFY axisYRightChanged REVISION 2)
72 Q_PROPERTY(QDeclarativeListProperty<QObject> seriesChildren READ seriesChildren)
75 Q_PROPERTY(QDeclarativeListProperty<QObject> seriesChildren READ seriesChildren)
73 Q_CLASSINFO("DefaultProperty", "seriesChildren")
76 Q_CLASSINFO("DefaultProperty", "seriesChildren")
74
77
75 public:
78 public:
76 explicit DeclarativeBarSeries(QDeclarativeItem *parent = 0);
79 explicit DeclarativeBarSeries(QDeclarativeItem *parent = 0);
77 QAbstractAxis *axisX() { return m_axisX; }
80 QAbstractAxis *axisX() { return m_axes->axisX(); }
78 void setAxisX(QAbstractAxis *axis) { m_axisX = axis; emit axisXChanged(axis); }
81 void setAxisX(QAbstractAxis *axis) { m_axes->setAxisX(axis); }
79 QAbstractAxis *axisY() { return m_axisY; }
82 QAbstractAxis *axisY() { return m_axes->axisY(); }
80 void setAxisY(QAbstractAxis *axis) { m_axisY = axis; emit axisYChanged(axis); }
83 void setAxisY(QAbstractAxis *axis) { m_axes->setAxisY(axis); }
84 Q_REVISION(2) QAbstractAxis *axisXTop() { return m_axes->axisXTop(); }
85 Q_REVISION(2) void setAxisXTop(QAbstractAxis *axis) { m_axes->setAxisXTop(axis); }
86 Q_REVISION(2) QAbstractAxis *axisYRight() { return m_axes->axisYRight(); }
87 Q_REVISION(2) void setAxisYRight(QAbstractAxis *axis) { m_axes->setAxisYRight(axis); }
81 QDeclarativeListProperty<QObject> seriesChildren();
88 QDeclarativeListProperty<QObject> seriesChildren();
82
89
83 public:
90 public:
84 Q_INVOKABLE DeclarativeBarSet *at(int index);
91 Q_INVOKABLE DeclarativeBarSet *at(int index);
85 Q_INVOKABLE DeclarativeBarSet *append(QString label, QVariantList values) { return insert(count(), label, values); }
92 Q_INVOKABLE DeclarativeBarSet *append(QString label, QVariantList values) { return insert(count(), label, values); }
86 Q_INVOKABLE DeclarativeBarSet *insert(int index, QString label, QVariantList values);
93 Q_INVOKABLE DeclarativeBarSet *insert(int index, QString label, QVariantList values);
87 Q_INVOKABLE bool remove(QBarSet *barset) { return QBarSeries::remove(barset); }
94 Q_INVOKABLE bool remove(QBarSet *barset) { return QBarSeries::remove(barset); }
88 Q_INVOKABLE void clear() { return QBarSeries::clear(); }
95 Q_INVOKABLE void clear() { return QBarSeries::clear(); }
89
96
90 public: // from QDeclarativeParserStatus
97 public: // from QDeclarativeParserStatus
91 void classBegin();
98 void classBegin();
92 void componentComplete();
99 void componentComplete();
93
100
94 Q_SIGNALS:
101 Q_SIGNALS:
95 Q_REVISION(1) void axisXChanged(QAbstractAxis *axis);
102 Q_REVISION(1) void axisXChanged(QAbstractAxis *axis);
96 Q_REVISION(1) void axisYChanged(QAbstractAxis *axis);
103 Q_REVISION(1) void axisYChanged(QAbstractAxis *axis);
104 Q_REVISION(2) void axisXTopChanged(QAbstractAxis *axis);
105 Q_REVISION(2) void axisYRightChanged(QAbstractAxis *axis);
97
106
98 public Q_SLOTS:
107 public Q_SLOTS:
99 static void appendSeriesChildren(QDeclarativeListProperty<QObject> *list, QObject *element);
108 static void appendSeriesChildren(QDeclarativeListProperty<QObject> *list, QObject *element);
100
109
101 private:
110 public:
102 QAbstractAxis *m_axisX;
111 DeclarativeAxes *m_axes;
103 QAbstractAxis *m_axisY;
104 };
112 };
105
113
106 class DeclarativeStackedBarSeries : public QStackedBarSeries, public QDeclarativeParserStatus
114 class DeclarativeStackedBarSeries : public QStackedBarSeries, public QDeclarativeParserStatus
107 {
115 {
108 Q_OBJECT
116 Q_OBJECT
109 Q_INTERFACES(QDeclarativeParserStatus)
117 Q_INTERFACES(QDeclarativeParserStatus)
110 Q_PROPERTY(QAbstractAxis *axisX READ axisX WRITE setAxisX NOTIFY axisXChanged REVISION 1)
118 Q_PROPERTY(QAbstractAxis *axisX READ axisX WRITE setAxisX NOTIFY axisXChanged REVISION 1)
111 Q_PROPERTY(QAbstractAxis *axisY READ axisY WRITE setAxisY NOTIFY axisYChanged REVISION 1)
119 Q_PROPERTY(QAbstractAxis *axisY READ axisY WRITE setAxisY NOTIFY axisYChanged REVISION 1)
120 Q_PROPERTY(QAbstractAxis *axisXTop READ axisXTop WRITE setAxisXTop NOTIFY axisXTopChanged REVISION 2)
121 Q_PROPERTY(QAbstractAxis *axisYRight READ axisYRight WRITE setAxisYRight NOTIFY axisYRightChanged REVISION 2)
112 Q_PROPERTY(QDeclarativeListProperty<QObject> seriesChildren READ seriesChildren)
122 Q_PROPERTY(QDeclarativeListProperty<QObject> seriesChildren READ seriesChildren)
113 Q_CLASSINFO("DefaultProperty", "seriesChildren")
123 Q_CLASSINFO("DefaultProperty", "seriesChildren")
114
124
115 public:
125 public:
116 explicit DeclarativeStackedBarSeries(QDeclarativeItem *parent = 0);
126 explicit DeclarativeStackedBarSeries(QDeclarativeItem *parent = 0);
117 QAbstractAxis *axisX() { return m_axisX; }
127 QAbstractAxis *axisX() { return m_axes->axisX(); }
118 void setAxisX(QAbstractAxis *axis) { m_axisX = axis; emit axisXChanged(axis); }
128 void setAxisX(QAbstractAxis *axis) { m_axes->setAxisX(axis); }
119 QAbstractAxis *axisY() { return m_axisY; }
129 QAbstractAxis *axisY() { return m_axes->axisY(); }
120 void setAxisY(QAbstractAxis *axis) { m_axisY = axis; emit axisYChanged(axis); }
130 void setAxisY(QAbstractAxis *axis) { m_axes->setAxisY(axis); }
131 Q_REVISION(2) QAbstractAxis *axisXTop() { return m_axes->axisXTop(); }
132 Q_REVISION(2) void setAxisXTop(QAbstractAxis *axis) { m_axes->setAxisXTop(axis); }
133 Q_REVISION(2) QAbstractAxis *axisYRight() { return m_axes->axisYRight(); }
134 Q_REVISION(2) void setAxisYRight(QAbstractAxis *axis) { m_axes->setAxisYRight(axis); }
121 QDeclarativeListProperty<QObject> seriesChildren();
135 QDeclarativeListProperty<QObject> seriesChildren();
122
136
123 public:
137 public:
124 Q_INVOKABLE DeclarativeBarSet *at(int index);
138 Q_INVOKABLE DeclarativeBarSet *at(int index);
125 Q_INVOKABLE DeclarativeBarSet *append(QString label, QVariantList values) { return insert(count(), label, values); }
139 Q_INVOKABLE DeclarativeBarSet *append(QString label, QVariantList values) { return insert(count(), label, values); }
126 Q_INVOKABLE DeclarativeBarSet *insert(int index, QString label, QVariantList values);
140 Q_INVOKABLE DeclarativeBarSet *insert(int index, QString label, QVariantList values);
127 Q_INVOKABLE bool remove(QBarSet *barset) { return QStackedBarSeries::remove(barset); }
141 Q_INVOKABLE bool remove(QBarSet *barset) { return QStackedBarSeries::remove(barset); }
128 Q_INVOKABLE void clear() { return QStackedBarSeries::clear(); }
142 Q_INVOKABLE void clear() { return QStackedBarSeries::clear(); }
129
143
130 public: // from QDeclarativeParserStatus
144 public: // from QDeclarativeParserStatus
131 void classBegin();
145 void classBegin();
132 void componentComplete();
146 void componentComplete();
133
147
134 Q_SIGNALS:
148 Q_SIGNALS:
135 Q_REVISION(1) void axisXChanged(QAbstractAxis *axis);
149 Q_REVISION(1) void axisXChanged(QAbstractAxis *axis);
136 Q_REVISION(1) void axisYChanged(QAbstractAxis *axis);
150 Q_REVISION(1) void axisYChanged(QAbstractAxis *axis);
151 Q_REVISION(2) void axisXTopChanged(QAbstractAxis *axis);
152 Q_REVISION(2) void axisYRightChanged(QAbstractAxis *axis);
137
153
138 public Q_SLOTS:
154 public Q_SLOTS:
139 static void appendSeriesChildren(QDeclarativeListProperty<QObject> *list, QObject *element);
155 static void appendSeriesChildren(QDeclarativeListProperty<QObject> *list, QObject *element);
140
156
141 private:
157 public:
142 QAbstractAxis *m_axisX;
158 DeclarativeAxes *m_axes;
143 QAbstractAxis *m_axisY;
144 };
159 };
145
160
146 class DeclarativePercentBarSeries : public QPercentBarSeries, public QDeclarativeParserStatus
161 class DeclarativePercentBarSeries : public QPercentBarSeries, public QDeclarativeParserStatus
147 {
162 {
148 Q_OBJECT
163 Q_OBJECT
149 Q_INTERFACES(QDeclarativeParserStatus)
164 Q_INTERFACES(QDeclarativeParserStatus)
150 Q_PROPERTY(QAbstractAxis *axisX READ axisX WRITE setAxisX NOTIFY axisXChanged REVISION 1)
165 Q_PROPERTY(QAbstractAxis *axisX READ axisX WRITE setAxisX NOTIFY axisXChanged REVISION 1)
151 Q_PROPERTY(QAbstractAxis *axisY READ axisY WRITE setAxisY NOTIFY axisYChanged REVISION 1)
166 Q_PROPERTY(QAbstractAxis *axisY READ axisY WRITE setAxisY NOTIFY axisYChanged REVISION 1)
167 Q_PROPERTY(QAbstractAxis *axisXTop READ axisXTop WRITE setAxisXTop NOTIFY axisXTopChanged REVISION 2)
168 Q_PROPERTY(QAbstractAxis *axisYRight READ axisYRight WRITE setAxisYRight NOTIFY axisYRightChanged REVISION 2)
152 Q_PROPERTY(QDeclarativeListProperty<QObject> seriesChildren READ seriesChildren)
169 Q_PROPERTY(QDeclarativeListProperty<QObject> seriesChildren READ seriesChildren)
153 Q_CLASSINFO("DefaultProperty", "seriesChildren")
170 Q_CLASSINFO("DefaultProperty", "seriesChildren")
154
171
155 public:
172 public:
156 explicit DeclarativePercentBarSeries(QDeclarativeItem *parent = 0);
173 explicit DeclarativePercentBarSeries(QDeclarativeItem *parent = 0);
157 QAbstractAxis *axisX() { return m_axisX; }
174 QAbstractAxis *axisX() { return m_axes->axisX(); }
158 void setAxisX(QAbstractAxis *axis) { m_axisX = axis; emit axisXChanged(axis); }
175 void setAxisX(QAbstractAxis *axis) { m_axes->setAxisX(axis); }
159 QAbstractAxis *axisY() { return m_axisY; }
176 QAbstractAxis *axisY() { return m_axes->axisY(); }
160 void setAxisY(QAbstractAxis *axis) { m_axisY = axis; emit axisYChanged(axis); }
177 void setAxisY(QAbstractAxis *axis) { m_axes->setAxisY(axis); }
178 Q_REVISION(2) QAbstractAxis *axisXTop() { return m_axes->axisXTop(); }
179 Q_REVISION(2) void setAxisXTop(QAbstractAxis *axis) { m_axes->setAxisXTop(axis); }
180 Q_REVISION(2) QAbstractAxis *axisYRight() { return m_axes->axisYRight(); }
181 Q_REVISION(2) void setAxisYRight(QAbstractAxis *axis) { m_axes->setAxisYRight(axis); }
161 QDeclarativeListProperty<QObject> seriesChildren();
182 QDeclarativeListProperty<QObject> seriesChildren();
162
183
163 public:
184 public:
164 Q_INVOKABLE DeclarativeBarSet *at(int index);
185 Q_INVOKABLE DeclarativeBarSet *at(int index);
165 Q_INVOKABLE DeclarativeBarSet *append(QString label, QVariantList values) { return insert(count(), label, values); }
186 Q_INVOKABLE DeclarativeBarSet *append(QString label, QVariantList values) { return insert(count(), label, values); }
166 Q_INVOKABLE DeclarativeBarSet *insert(int index, QString label, QVariantList values);
187 Q_INVOKABLE DeclarativeBarSet *insert(int index, QString label, QVariantList values);
167 Q_INVOKABLE bool remove(QBarSet *barset) { return QPercentBarSeries::remove(barset); }
188 Q_INVOKABLE bool remove(QBarSet *barset) { return QPercentBarSeries::remove(barset); }
168 Q_INVOKABLE void clear() { return QPercentBarSeries::clear(); }
189 Q_INVOKABLE void clear() { return QPercentBarSeries::clear(); }
169
190
170 public: // from QDeclarativeParserStatus
191 public: // from QDeclarativeParserStatus
171 void classBegin();
192 void classBegin();
172 void componentComplete();
193 void componentComplete();
173
194
174 Q_SIGNALS:
195 Q_SIGNALS:
175 Q_REVISION(1) void axisXChanged(QAbstractAxis *axis);
196 Q_REVISION(1) void axisXChanged(QAbstractAxis *axis);
176 Q_REVISION(1) void axisYChanged(QAbstractAxis *axis);
197 Q_REVISION(1) void axisYChanged(QAbstractAxis *axis);
198 Q_REVISION(2) void axisXTopChanged(QAbstractAxis *axis);
199 Q_REVISION(2) void axisYRightChanged(QAbstractAxis *axis);
177
200
178 public Q_SLOTS:
201 public Q_SLOTS:
179 static void appendSeriesChildren(QDeclarativeListProperty<QObject> *list, QObject *element);
202 static void appendSeriesChildren(QDeclarativeListProperty<QObject> *list, QObject *element);
180
203
181 private:
204 public:
182 QAbstractAxis *m_axisX;
205 DeclarativeAxes *m_axes;
183 QAbstractAxis *m_axisY;
184 };
206 };
185
207
186 class DeclarativeHorizontalBarSeries : public QHorizontalBarSeries, public QDeclarativeParserStatus
208 class DeclarativeHorizontalBarSeries : public QHorizontalBarSeries, public QDeclarativeParserStatus
187 {
209 {
188 Q_OBJECT
210 Q_OBJECT
189 Q_INTERFACES(QDeclarativeParserStatus)
211 Q_INTERFACES(QDeclarativeParserStatus)
190 Q_PROPERTY(QAbstractAxis *axisX READ axisX WRITE setAxisX NOTIFY axisXChanged REVISION 1)
212 Q_PROPERTY(QAbstractAxis *axisX READ axisX WRITE setAxisX NOTIFY axisXChanged REVISION 1)
191 Q_PROPERTY(QAbstractAxis *axisY READ axisY WRITE setAxisY NOTIFY axisYChanged REVISION 1)
213 Q_PROPERTY(QAbstractAxis *axisY READ axisY WRITE setAxisY NOTIFY axisYChanged REVISION 1)
214 Q_PROPERTY(QAbstractAxis *axisXTop READ axisXTop WRITE setAxisXTop NOTIFY axisXTopChanged REVISION 2)
215 Q_PROPERTY(QAbstractAxis *axisYRight READ axisYRight WRITE setAxisYRight NOTIFY axisYRightChanged REVISION 2)
192 Q_PROPERTY(QDeclarativeListProperty<QObject> seriesChildren READ seriesChildren)
216 Q_PROPERTY(QDeclarativeListProperty<QObject> seriesChildren READ seriesChildren)
193 Q_CLASSINFO("DefaultProperty", "seriesChildren")
217 Q_CLASSINFO("DefaultProperty", "seriesChildren")
194
218
195 public:
219 public:
196 explicit DeclarativeHorizontalBarSeries(QDeclarativeItem *parent = 0);
220 explicit DeclarativeHorizontalBarSeries(QDeclarativeItem *parent = 0);
197 QAbstractAxis *axisX() { return m_axisX; }
221 QAbstractAxis *axisX() { return m_axes->axisX(); }
198 void setAxisX(QAbstractAxis *axis) { m_axisX = axis; emit axisXChanged(axis); }
222 void setAxisX(QAbstractAxis *axis) { m_axes->setAxisX(axis); }
199 QAbstractAxis *axisY() { return m_axisY; }
223 QAbstractAxis *axisY() { return m_axes->axisY(); }
200 void setAxisY(QAbstractAxis *axis) { m_axisY = axis; emit axisYChanged(axis); }
224 void setAxisY(QAbstractAxis *axis) { m_axes->setAxisY(axis); }
225 Q_REVISION(2) QAbstractAxis *axisXTop() { return m_axes->axisXTop(); }
226 Q_REVISION(2) void setAxisXTop(QAbstractAxis *axis) { m_axes->setAxisXTop(axis); }
227 Q_REVISION(2) QAbstractAxis *axisYRight() { return m_axes->axisYRight(); }
228 Q_REVISION(2) void setAxisYRight(QAbstractAxis *axis) { m_axes->setAxisYRight(axis); }
201 QDeclarativeListProperty<QObject> seriesChildren();
229 QDeclarativeListProperty<QObject> seriesChildren();
202
230
203 public:
231 public:
204 Q_INVOKABLE DeclarativeBarSet *at(int index);
232 Q_INVOKABLE DeclarativeBarSet *at(int index);
205 Q_INVOKABLE DeclarativeBarSet *append(QString label, QVariantList values) { return insert(count(), label, values); }
233 Q_INVOKABLE DeclarativeBarSet *append(QString label, QVariantList values) { return insert(count(), label, values); }
206 Q_INVOKABLE DeclarativeBarSet *insert(int index, QString label, QVariantList values);
234 Q_INVOKABLE DeclarativeBarSet *insert(int index, QString label, QVariantList values);
207 Q_INVOKABLE bool remove(QBarSet *barset) { return QHorizontalBarSeries::remove(barset); }
235 Q_INVOKABLE bool remove(QBarSet *barset) { return QHorizontalBarSeries::remove(barset); }
208 Q_INVOKABLE void clear() { return QHorizontalBarSeries::clear(); }
236 Q_INVOKABLE void clear() { return QHorizontalBarSeries::clear(); }
209
237
210 public: // from QDeclarativeParserStatus
238 public: // from QDeclarativeParserStatus
211 void classBegin();
239 void classBegin();
212 void componentComplete();
240 void componentComplete();
213
241
214 Q_SIGNALS:
242 Q_SIGNALS:
215 Q_REVISION(1) void axisXChanged(QAbstractAxis *axis);
243 Q_REVISION(1) void axisXChanged(QAbstractAxis *axis);
216 Q_REVISION(1) void axisYChanged(QAbstractAxis *axis);
244 Q_REVISION(1) void axisYChanged(QAbstractAxis *axis);
245 Q_REVISION(2) void axisXTopChanged(QAbstractAxis *axis);
246 Q_REVISION(2) void axisYRightChanged(QAbstractAxis *axis);
217
247
218 public Q_SLOTS:
248 public Q_SLOTS:
219 static void appendSeriesChildren(QDeclarativeListProperty<QObject> *list, QObject *element);
249 static void appendSeriesChildren(QDeclarativeListProperty<QObject> *list, QObject *element);
220
250
221 private:
251 public:
222 QAbstractAxis *m_axisX;
252 DeclarativeAxes *m_axes;
223 QAbstractAxis *m_axisY;
224 };
253 };
225
254
226 class DeclarativeHorizontalStackedBarSeries : public QHorizontalStackedBarSeries, public QDeclarativeParserStatus
255 class DeclarativeHorizontalStackedBarSeries : public QHorizontalStackedBarSeries, public QDeclarativeParserStatus
227 {
256 {
228 Q_OBJECT
257 Q_OBJECT
229 Q_INTERFACES(QDeclarativeParserStatus)
258 Q_INTERFACES(QDeclarativeParserStatus)
230 Q_PROPERTY(QAbstractAxis *axisX READ axisX WRITE setAxisX NOTIFY axisXChanged REVISION 1)
259 Q_PROPERTY(QAbstractAxis *axisX READ axisX WRITE setAxisX NOTIFY axisXChanged REVISION 1)
231 Q_PROPERTY(QAbstractAxis *axisY READ axisY WRITE setAxisY NOTIFY axisYChanged REVISION 1)
260 Q_PROPERTY(QAbstractAxis *axisY READ axisY WRITE setAxisY NOTIFY axisYChanged REVISION 1)
261 Q_PROPERTY(QAbstractAxis *axisXTop READ axisXTop WRITE setAxisXTop NOTIFY axisXTopChanged REVISION 2)
262 Q_PROPERTY(QAbstractAxis *axisYRight READ axisYRight WRITE setAxisYRight NOTIFY axisYRightChanged REVISION 2)
232 Q_PROPERTY(QDeclarativeListProperty<QObject> seriesChildren READ seriesChildren)
263 Q_PROPERTY(QDeclarativeListProperty<QObject> seriesChildren READ seriesChildren)
233 Q_CLASSINFO("DefaultProperty", "seriesChildren")
264 Q_CLASSINFO("DefaultProperty", "seriesChildren")
234
265
235 public:
266 public:
236 explicit DeclarativeHorizontalStackedBarSeries(QDeclarativeItem *parent = 0);
267 explicit DeclarativeHorizontalStackedBarSeries(QDeclarativeItem *parent = 0);
237 QAbstractAxis *axisX() { return m_axisX; }
268 QAbstractAxis *axisX() { return m_axes->axisX(); }
238 void setAxisX(QAbstractAxis *axis) { m_axisX = axis; emit axisXChanged(axis); }
269 void setAxisX(QAbstractAxis *axis) { m_axes->setAxisX(axis); }
239 QAbstractAxis *axisY() { return m_axisY; }
270 QAbstractAxis *axisY() { return m_axes->axisY(); }
240 void setAxisY(QAbstractAxis *axis) { m_axisY = axis; emit axisYChanged(axis); }
271 void setAxisY(QAbstractAxis *axis) { m_axes->setAxisY(axis); }
272 Q_REVISION(2) QAbstractAxis *axisXTop() { return m_axes->axisXTop(); }
273 Q_REVISION(2) void setAxisXTop(QAbstractAxis *axis) { m_axes->setAxisXTop(axis); }
274 Q_REVISION(2) QAbstractAxis *axisYRight() { return m_axes->axisYRight(); }
275 Q_REVISION(2) void setAxisYRight(QAbstractAxis *axis) { m_axes->setAxisYRight(axis); }
241 QDeclarativeListProperty<QObject> seriesChildren();
276 QDeclarativeListProperty<QObject> seriesChildren();
242
277
243 public:
278 public:
244 Q_INVOKABLE DeclarativeBarSet *at(int index);
279 Q_INVOKABLE DeclarativeBarSet *at(int index);
245 Q_INVOKABLE DeclarativeBarSet *append(QString label, QVariantList values) { return insert(count(), label, values); }
280 Q_INVOKABLE DeclarativeBarSet *append(QString label, QVariantList values) { return insert(count(), label, values); }
246 Q_INVOKABLE DeclarativeBarSet *insert(int index, QString label, QVariantList values);
281 Q_INVOKABLE DeclarativeBarSet *insert(int index, QString label, QVariantList values);
247 Q_INVOKABLE bool remove(QBarSet *barset) { return QHorizontalStackedBarSeries::remove(barset); }
282 Q_INVOKABLE bool remove(QBarSet *barset) { return QHorizontalStackedBarSeries::remove(barset); }
248 Q_INVOKABLE void clear() { return QHorizontalStackedBarSeries::clear(); }
283 Q_INVOKABLE void clear() { return QHorizontalStackedBarSeries::clear(); }
249
284
250 public: // from QDeclarativeParserStatus
285 public: // from QDeclarativeParserStatus
251 void classBegin();
286 void classBegin();
252 void componentComplete();
287 void componentComplete();
253
288
254 Q_SIGNALS:
289 Q_SIGNALS:
255 Q_REVISION(1) void axisXChanged(QAbstractAxis *axis);
290 Q_REVISION(1) void axisXChanged(QAbstractAxis *axis);
256 Q_REVISION(1) void axisYChanged(QAbstractAxis *axis);
291 Q_REVISION(1) void axisYChanged(QAbstractAxis *axis);
292 Q_REVISION(2) void axisXTopChanged(QAbstractAxis *axis);
293 Q_REVISION(2) void axisYRightChanged(QAbstractAxis *axis);
257
294
258 public Q_SLOTS:
295 public Q_SLOTS:
259 static void appendSeriesChildren(QDeclarativeListProperty<QObject> *list, QObject *element);
296 static void appendSeriesChildren(QDeclarativeListProperty<QObject> *list, QObject *element);
260
297
261 private:
298 public:
262 QAbstractAxis *m_axisX;
299 DeclarativeAxes *m_axes;
263 QAbstractAxis *m_axisY;
264 };
300 };
265
301
266 class DeclarativeHorizontalPercentBarSeries : public QHorizontalPercentBarSeries, public QDeclarativeParserStatus
302 class DeclarativeHorizontalPercentBarSeries : public QHorizontalPercentBarSeries, public QDeclarativeParserStatus
267 {
303 {
268 Q_OBJECT
304 Q_OBJECT
269 Q_INTERFACES(QDeclarativeParserStatus)
305 Q_INTERFACES(QDeclarativeParserStatus)
270 Q_PROPERTY(QAbstractAxis *axisX READ axisX WRITE setAxisX NOTIFY axisXChanged REVISION 1)
306 Q_PROPERTY(QAbstractAxis *axisX READ axisX WRITE setAxisX NOTIFY axisXChanged REVISION 1)
271 Q_PROPERTY(QAbstractAxis *axisY READ axisY WRITE setAxisY NOTIFY axisYChanged REVISION 1)
307 Q_PROPERTY(QAbstractAxis *axisY READ axisY WRITE setAxisY NOTIFY axisYChanged REVISION 1)
308 Q_PROPERTY(QAbstractAxis *axisXTop READ axisXTop WRITE setAxisXTop NOTIFY axisXTopChanged REVISION 2)
309 Q_PROPERTY(QAbstractAxis *axisYRight READ axisYRight WRITE setAxisYRight NOTIFY axisYRightChanged REVISION 2)
272 Q_PROPERTY(QDeclarativeListProperty<QObject> seriesChildren READ seriesChildren)
310 Q_PROPERTY(QDeclarativeListProperty<QObject> seriesChildren READ seriesChildren)
273 Q_CLASSINFO("DefaultProperty", "seriesChildren")
311 Q_CLASSINFO("DefaultProperty", "seriesChildren")
274
312
275 public:
313 public:
276 explicit DeclarativeHorizontalPercentBarSeries(QDeclarativeItem *parent = 0);
314 explicit DeclarativeHorizontalPercentBarSeries(QDeclarativeItem *parent = 0);
277 QAbstractAxis *axisX() { return m_axisX; }
315 QAbstractAxis *axisX() { return m_axes->axisX(); }
278 void setAxisX(QAbstractAxis *axis) { m_axisX = axis; emit axisXChanged(axis); }
316 void setAxisX(QAbstractAxis *axis) { m_axes->setAxisX(axis); }
279 QAbstractAxis *axisY() { return m_axisY; }
317 QAbstractAxis *axisY() { return m_axes->axisY(); }
280 void setAxisY(QAbstractAxis *axis) { m_axisY = axis; emit axisYChanged(axis); }
318 void setAxisY(QAbstractAxis *axis) { m_axes->setAxisY(axis); }
319 Q_REVISION(2) QAbstractAxis *axisXTop() { return m_axes->axisXTop(); }
320 Q_REVISION(2) void setAxisXTop(QAbstractAxis *axis) { m_axes->setAxisXTop(axis); }
321 Q_REVISION(2) QAbstractAxis *axisYRight() { return m_axes->axisYRight(); }
322 Q_REVISION(2) void setAxisYRight(QAbstractAxis *axis) { m_axes->setAxisYRight(axis); }
281 QDeclarativeListProperty<QObject> seriesChildren();
323 QDeclarativeListProperty<QObject> seriesChildren();
282
324
283 public:
325 public:
284 Q_INVOKABLE DeclarativeBarSet *at(int index);
326 Q_INVOKABLE DeclarativeBarSet *at(int index);
285 Q_INVOKABLE DeclarativeBarSet *append(QString label, QVariantList values) { return insert(count(), label, values); }
327 Q_INVOKABLE DeclarativeBarSet *append(QString label, QVariantList values) { return insert(count(), label, values); }
286 Q_INVOKABLE DeclarativeBarSet *insert(int index, QString label, QVariantList values);
328 Q_INVOKABLE DeclarativeBarSet *insert(int index, QString label, QVariantList values);
287 Q_INVOKABLE bool remove(QBarSet *barset) { return QHorizontalPercentBarSeries::remove(barset); }
329 Q_INVOKABLE bool remove(QBarSet *barset) { return QHorizontalPercentBarSeries::remove(barset); }
288 Q_INVOKABLE void clear() { return QHorizontalPercentBarSeries::clear(); }
330 Q_INVOKABLE void clear() { return QHorizontalPercentBarSeries::clear(); }
289
331
290 public: // from QDeclarativeParserStatus
332 public: // from QDeclarativeParserStatus
291 void classBegin();
333 void classBegin();
292 void componentComplete();
334 void componentComplete();
293
335
294 Q_SIGNALS:
336 Q_SIGNALS:
295 Q_REVISION(1) void axisXChanged(QAbstractAxis *axis);
337 Q_REVISION(1) void axisXChanged(QAbstractAxis *axis);
296 Q_REVISION(1) void axisYChanged(QAbstractAxis *axis);
338 Q_REVISION(1) void axisYChanged(QAbstractAxis *axis);
339 Q_REVISION(2) void axisXTopChanged(QAbstractAxis *axis);
340 Q_REVISION(2) void axisYRightChanged(QAbstractAxis *axis);
297
341
298 public Q_SLOTS:
342 public Q_SLOTS:
299 static void appendSeriesChildren(QDeclarativeListProperty<QObject> *list, QObject *element);
343 static void appendSeriesChildren(QDeclarativeListProperty<QObject> *list, QObject *element);
300
344
301 private:
345 public:
302 QAbstractAxis *m_axisX;
346 DeclarativeAxes *m_axes;
303 QAbstractAxis *m_axisY;
304 };
347 };
305
348
306 QTCOMMERCIALCHART_END_NAMESPACE
349 QTCOMMERCIALCHART_END_NAMESPACE
307
350
308 #endif // DECLARATIVEBARSERIES_H
351 #endif // DECLARATIVEBARSERIES_H
@@ -1,730 +1,769
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 "qchart_p.h"
37 #include "qchart_p.h"
37
38
38 #ifndef QT_ON_ARM
39 #ifndef QT_ON_ARM
39 #include "qdatetimeaxis.h"
40 #include "qdatetimeaxis.h"
40 #endif
41 #endif
41
42
42 QTCOMMERCIALCHART_BEGIN_NAMESPACE
43 QTCOMMERCIALCHART_BEGIN_NAMESPACE
43
44
44 /*!
45 /*!
45 \qmlclass ChartView DeclarativeChart
46 \qmlclass ChartView DeclarativeChart
46
47
47 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.
48
49
49 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:
50 \snippet ../examples/qmlpiechart/qml/qmlpiechart/main.qml 1
51 \snippet ../examples/qmlpiechart/qml/qmlpiechart/main.qml 1
51 \snippet ../examples/qmlpiechart/qml/qmlpiechart/main.qml 2
52 \snippet ../examples/qmlpiechart/qml/qmlpiechart/main.qml 2
52 \snippet ../examples/qmlpiechart/qml/qmlpiechart/main.qml 3
53 \snippet ../examples/qmlpiechart/qml/qmlpiechart/main.qml 3
53
54
54 \beginfloatleft
55 \beginfloatleft
55 \image examples_qmlpiechart.png
56 \image examples_qmlpiechart.png
56 \endfloat
57 \endfloat
57 \clearfloat
58 \clearfloat
58 */
59 */
59
60
60 /*!
61 /*!
61 \qmlproperty Theme ChartView::theme
62 \qmlproperty Theme ChartView::theme
62 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
63 widths and chart background.
64 widths and chart background.
64 */
65 */
65
66
66 /*!
67 /*!
67 \qmlproperty Animation ChartView::animationOptions
68 \qmlproperty Animation ChartView::animationOptions
68 Animation configuration of the chart. One of ChartView.NoAnimation, ChartView.GridAxisAnimations,
69 Animation configuration of the chart. One of ChartView.NoAnimation, ChartView.GridAxisAnimations,
69 ChartView.SeriesAnimations or ChartView.AllAnimations.
70 ChartView.SeriesAnimations or ChartView.AllAnimations.
70 */
71 */
71
72
72 /*!
73 /*!
73 \qmlproperty Font ChartView::titleFont
74 \qmlproperty Font ChartView::titleFont
74 The title font of the chart
75 The title font of the chart
75
76
76 See the \l {Font} {QML Font Element} for detailed documentation.
77 See the \l {Font} {QML Font Element} for detailed documentation.
77 */
78 */
78
79
79 /*!
80 /*!
80 \qmlproperty string ChartView::title
81 \qmlproperty string ChartView::title
81 The title of the chart, shown on top of the chart.
82 The title of the chart, shown on top of the chart.
82 \sa ChartView::titleColor
83 \sa ChartView::titleColor
83 */
84 */
84
85
85 /*!
86 /*!
86 \qmlproperty color ChartView::titleColor
87 \qmlproperty color ChartView::titleColor
87 The color of the title text.
88 The color of the title text.
88 */
89 */
89
90
90 /*!
91 /*!
91 \qmlproperty Legend ChartView::legend
92 \qmlproperty Legend ChartView::legend
92 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.
93 */
94 */
94
95
95 /*!
96 /*!
96 \qmlproperty int ChartView::count
97 \qmlproperty int ChartView::count
97 The count of series added to the chart.
98 The count of series added to the chart.
98 */
99 */
99
100
100 /*!
101 /*!
101 \qmlproperty color ChartView::backgroundColor
102 \qmlproperty color ChartView::backgroundColor
102 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.
103 \sa ChartView::theme
104 \sa ChartView::theme
104 */
105 */
105
106
106 /*!
107 /*!
107 \qmlproperty bool ChartView::dropShadowEnabled
108 \qmlproperty bool ChartView::dropShadowEnabled
108 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.
109 */
110 */
110
111
111 /*!
112 /*!
112 \qmlproperty real ChartView::topMargin
113 \qmlproperty real ChartView::topMargin
113 Deprecated. Use minimumMargins and plotArea instead.
114 Deprecated. Use minimumMargins and plotArea instead.
114 */
115 */
115
116
116 /*!
117 /*!
117 \qmlproperty real ChartView::bottomMargin
118 \qmlproperty real ChartView::bottomMargin
118 Deprecated. Use minimumMargins and plotArea instead.
119 Deprecated. Use minimumMargins and plotArea instead.
119 */
120 */
120
121
121 /*!
122 /*!
122 \qmlproperty real ChartView::leftMargin
123 \qmlproperty real ChartView::leftMargin
123 Deprecated. Use minimumMargins and plotArea instead.
124 Deprecated. Use minimumMargins and plotArea instead.
124 */
125 */
125
126
126 /*!
127 /*!
127 \qmlproperty real ChartView::rightMargin
128 \qmlproperty real ChartView::rightMargin
128 Deprecated. Use minimumMargins and plotArea instead.
129 Deprecated. Use minimumMargins and plotArea instead.
129 */
130 */
130
131
131 /*!
132 /*!
132 \qmlproperty Margins ChartView::minimumMargins
133 \qmlproperty Margins ChartView::minimumMargins
133 The minimum margins allowed between the outer bounds and the plotArea of the ChartView. Margins
134 The minimum margins allowed between the outer bounds and the plotArea of the ChartView. Margins
134 area of ChartView is used for drawing title, axes and legend. Please note that setting the
135 area of ChartView is used for drawing title, axes and legend. Please note that setting the
135 properties of minimumMargins may be bigger than the defined value, depending on other ChartView
136 properties of minimumMargins may be bigger than the defined value, depending on other ChartView
136 properties that affect it's layout. If you need to know the actual plotting area used at any
137 properties that affect it's layout. If you need to know the actual plotting area used at any
137 given time, you can check ChartView::plotArea instead.
138 given time, you can check ChartView::plotArea instead.
138 */
139 */
139
140
140 /*!
141 /*!
141 \qmlproperty rect ChartView::plotArea
142 \qmlproperty rect ChartView::plotArea
142 The area on the ChartView that is used for drawing series. This is the ChartView rect without the
143 The area on the ChartView that is used for drawing series. This is the ChartView rect without the
143 margins.
144 margins.
144 \sa ChartView::minimumMargins
145 \sa ChartView::minimumMargins
145 */
146 */
146
147
147 /*!
148 /*!
148 \qmlmethod AbstractSeries ChartView::series(int index)
149 \qmlmethod AbstractSeries ChartView::series(int index)
149 Returns the series with \a index on the chart. This allows you to loop through the series of a chart together with
150 Returns the series with \a index on the chart. This allows you to loop through the series of a chart together with
150 the count property of the chart.
151 the count property of the chart.
151 */
152 */
152
153
153 /*!
154 /*!
154 \qmlmethod AbstractSeries ChartView::series(string name)
155 \qmlmethod AbstractSeries ChartView::series(string name)
155 Returns the first series on the chart with \a name. If there is no series with that name, returns null.
156 Returns the first series on the chart with \a name. If there is no series with that name, returns null.
156 */
157 */
157
158
158 /*!
159 /*!
159 \qmlmethod AbstractSeries ChartView::createSeries(SeriesType type, string name, AbstractAxis axisX, AbstractAxis axisY)
160 \qmlmethod AbstractSeries ChartView::createSeries(SeriesType type, string name, AbstractAxis axisX, AbstractAxis axisY)
160 Creates a series object of \a type to the chart with name \a name, optional axis \a axisX and
161 Creates a series object of \a type to the chart with name \a name, optional axis \a axisX and
161 optional axis \a axisY. For example:
162 optional axis \a axisY. For example:
162 \code
163 \code
163 // lineSeries is a LineSeries object that has already been added to the ChartView; re-use it's axes
164 // lineSeries is a LineSeries object that has already been added to the ChartView; re-use it's axes
164 var myAxisX = chartView.axisX(lineSeries);
165 var myAxisX = chartView.axisX(lineSeries);
165 var myAxisY = chartView.axisY(lineSeries);
166 var myAxisY = chartView.axisY(lineSeries);
166 var scatter = chartView.createSeries(ChartView.SeriesTypeScatter, "scatter series", myAxisX, myAxisY);
167 var scatter = chartView.createSeries(ChartView.SeriesTypeScatter, "scatter series", myAxisX, myAxisY);
167 \endcode
168 \endcode
168 */
169 */
169
170
170 /*!
171 /*!
171 \qmlmethod ChartView::removeSeries(AbstractSeries series)
172 \qmlmethod ChartView::removeSeries(AbstractSeries series)
172 Removes the \a series from the chart. The series object is also destroyed.
173 Removes the \a series from the chart. The series object is also destroyed.
173 */
174 */
174
175
175 /*!
176 /*!
176 \qmlmethod ChartView::removeAllSeries()
177 \qmlmethod ChartView::removeAllSeries()
177 Removes all series from the chart. All the series objects are also destroyed.
178 Removes all series from the chart. All the series objects are also destroyed.
178 */
179 */
179
180
180 /*!
181 /*!
181 \qmlmethod Axis ChartView::axisX(AbstractSeries series)
182 \qmlmethod Axis ChartView::axisX(AbstractSeries series)
182 The x-axis of the series.
183 The x-axis of the series.
183 */
184 */
184
185
185 /*!
186 /*!
186 \qmlmethod Axis ChartView::axisY(AbstractSeries series)
187 \qmlmethod Axis ChartView::axisY(AbstractSeries series)
187 The y-axis of the series.
188 The y-axis of the series.
188 */
189 */
189
190
190 /*!
191 /*!
191 \qmlmethod ChartView::zoomY(real factor)
192 \qmlmethod ChartView::zoomY(real factor)
192 Zooms in by \a factor on the center of the chart.
193 Zooms in by \a factor on the center of the chart.
193 */
194 */
194
195
195 /*!
196 /*!
196 \qmlmethod ChartView::scrollLeft(real pixels)
197 \qmlmethod ChartView::scrollLeft(real pixels)
197 Scrolls to left by \a pixels. This is a convenience function that suits for example for key navigation.
198 Scrolls to left by \a pixels. This is a convenience function that suits for example for key navigation.
198 \sa ValueAxis::min, ValueAxis::max, BarCategoryAxis::min, BarCategoryAxis::max
199 \sa ValueAxis::min, ValueAxis::max, BarCategoryAxis::min, BarCategoryAxis::max
199 */
200 */
200
201
201 /*!
202 /*!
202 \qmlmethod ChartView::scrollRight(real pixels)
203 \qmlmethod ChartView::scrollRight(real pixels)
203 Scrolls to right by \a pixels. This is a convenience function that suits for example for key navigation.
204 Scrolls to right by \a pixels. This is a convenience function that suits for example for key navigation.
204 \sa ValueAxis::min, ValueAxis::max, BarCategoryAxis::min, BarCategoryAxis::max
205 \sa ValueAxis::min, ValueAxis::max, BarCategoryAxis::min, BarCategoryAxis::max
205 */
206 */
206
207
207 /*!
208 /*!
208 \qmlmethod ChartView::scrollUp(real pixels)
209 \qmlmethod ChartView::scrollUp(real pixels)
209 Scrolls up by \a pixels. This is a convenience function that suits for example for key navigation.
210 Scrolls up by \a pixels. This is a convenience function that suits for example for key navigation.
210 \sa ValueAxis::min, ValueAxis::max, BarCategoryAxis::min, BarCategoryAxis::max
211 \sa ValueAxis::min, ValueAxis::max, BarCategoryAxis::min, BarCategoryAxis::max
211 */
212 */
212
213
213 /*!
214 /*!
214 \qmlmethod ChartView::scrollDown(real pixels)
215 \qmlmethod ChartView::scrollDown(real pixels)
215 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.
216 \sa ValueAxis::min, ValueAxis::max, BarCategoryAxis::min, BarCategoryAxis::max
217 \sa ValueAxis::min, ValueAxis::max, BarCategoryAxis::min, BarCategoryAxis::max
217 */
218 */
218
219
219 /*!
220 /*!
220 \qmlsignal ChartView::onPlotAreaChanged(rect plotArea)
221 \qmlsignal ChartView::onPlotAreaChanged(rect plotArea)
221 The plot area of the chart has changed. This may happen for example, if you modify minimumMargins
222 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
223 or if you resize the chart, or if you modify font size related properties of the legend or chart
223 title.
224 title.
224 */
225 */
225
226
226 /*!
227 /*!
227 \qmlsignal ChartView::seriesAdded(AbstractSeries series)
228 \qmlsignal ChartView::seriesAdded(AbstractSeries series)
228 The \a series has been added to the chart.
229 The \a series has been added to the chart.
229 */
230 */
230
231
231 /*!
232 /*!
232 \qmlsignal ChartView::seriesRemoved(AbstractSeries series)
233 \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
234 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.
235 object after the signal handler has completed.
235 */
236 */
236
237
237 DeclarativeChart::DeclarativeChart(QDeclarativeItem *parent)
238 DeclarativeChart::DeclarativeChart(QDeclarativeItem *parent)
238 : QDeclarativeItem(parent),
239 : QDeclarativeItem(parent),
239 m_chart(new QChart(this))
240 m_chart(new QChart(this))
240 {
241 {
241 setFlag(QGraphicsItem::ItemHasNoContents, false);
242 setFlag(QGraphicsItem::ItemHasNoContents, false);
242 m_margins = new DeclarativeMargins(this);
243 m_margins = new DeclarativeMargins(this);
243 m_margins->setTop(m_chart->margins().top());
244 m_margins->setTop(m_chart->margins().top());
244 m_margins->setLeft(m_chart->margins().left());
245 m_margins->setLeft(m_chart->margins().left());
245 m_margins->setRight(m_chart->margins().right());
246 m_margins->setRight(m_chart->margins().right());
246 m_margins->setBottom(m_chart->margins().bottom());
247 m_margins->setBottom(m_chart->margins().bottom());
247 connect(m_margins, SIGNAL(topChanged(int,int,int,int)), this, SLOT(changeMinimumMargins(int,int,int,int)));
248 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)));
249 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)));
250 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)));
251 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*)));
252 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*)));
253 connect(m_chart->d_ptr->m_dataset, SIGNAL(seriesRemoved(QAbstractSeries*)), this, SIGNAL(seriesRemoved(QAbstractSeries*)));
253 }
254 }
254
255
255 void DeclarativeChart::handleSeriesAdded(QAbstractSeries *series)
256 void DeclarativeChart::handleSeriesAdded(QAbstractSeries *series)
256 {
257 {
257 emit seriesAdded(series);
258 emit seriesAdded(series);
258 }
259 }
259
260
260 void DeclarativeChart::changeMinimumMargins(int top, int bottom, int left, int right)
261 void DeclarativeChart::changeMinimumMargins(int top, int bottom, int left, int right)
261 {
262 {
262 m_chart->setMargins(QMargins(left, top, right, bottom));
263 m_chart->setMargins(QMargins(left, top, right, bottom));
263 emit minimumMarginsChanged();
264 emit minimumMarginsChanged();
264 emit plotAreaChanged(m_chart->plotArea());
265 emit plotAreaChanged(m_chart->plotArea());
265 }
266 }
266
267
267 DeclarativeChart::~DeclarativeChart()
268 DeclarativeChart::~DeclarativeChart()
268 {
269 {
269 delete m_chart;
270 delete m_chart;
270 }
271 }
271
272
272 void DeclarativeChart::childEvent(QChildEvent *event)
273 void DeclarativeChart::childEvent(QChildEvent *event)
273 {
274 {
274 if (event->type() == QEvent::ChildAdded) {
275 if (event->type() == QEvent::ChildAdded) {
275 if (qobject_cast<QAbstractSeries *>(event->child())) {
276 if (qobject_cast<QAbstractSeries *>(event->child())) {
276 m_chart->addSeries(qobject_cast<QAbstractSeries *>(event->child()));
277 m_chart->addSeries(qobject_cast<QAbstractSeries *>(event->child()));
277 }
278 }
278 }
279 }
279 }
280 }
280
281
281 void DeclarativeChart::componentComplete()
282 void DeclarativeChart::componentComplete()
282 {
283 {
283 foreach (QObject *child, children()) {
284 foreach (QObject *child, children()) {
284 if (qobject_cast<QAbstractSeries *>(child)) {
285 if (qobject_cast<QAbstractSeries *>(child)) {
285 // Add series to the chart
286 // Add series to the chart
286 QAbstractSeries *series = qobject_cast<QAbstractSeries *>(child);
287 QAbstractSeries *series = qobject_cast<QAbstractSeries *>(child);
287 m_chart->addSeries(series);
288 m_chart->addSeries(series);
288
289
289 // Set optional user defined axes for the series and connect axis related signals
290 // Connect to axis changed signals (unless this is a pie series)
290 if (qobject_cast<DeclarativeLineSeries *>(child)) {
291 if (!qobject_cast<DeclarativePieSeries *>(series)) {
291 DeclarativeLineSeries *s = qobject_cast<DeclarativeLineSeries *>(child);
292 connect(series, SIGNAL(axisXChanged(QAbstractAxis*)), this, SLOT(handleAxisXSet(QAbstractAxis*)));
292 connect(s, SIGNAL(axisXChanged(QAbstractAxis*)), this, SLOT(handleAxisXSet(QAbstractAxis*)));
293 connect(series, SIGNAL(axisXTopChanged(QAbstractAxis*)), this, SLOT(handleAxisXSet(QAbstractAxis*)));
293 connect(s, SIGNAL(axisYChanged(QAbstractAxis*)), this, SLOT(handleAxisYSet(QAbstractAxis*)));
294 connect(series, SIGNAL(axisYChanged(QAbstractAxis*)), this, SLOT(handleAxisYSet(QAbstractAxis*)));
294 setAxisX(s->axisX(), s);
295 connect(series, SIGNAL(axisYRightChanged(QAbstractAxis*)), this, SLOT(handleAxisYRightSet(QAbstractAxis*)));
295 setAxisY(s->axisY(), s);
296 } else if (qobject_cast<DeclarativeSplineSeries *>(child)) {
297 DeclarativeSplineSeries *s = qobject_cast<DeclarativeSplineSeries *>(child);
298 connect(s, SIGNAL(axisXChanged(QAbstractAxis*)), this, SLOT(handleAxisXSet(QAbstractAxis*)));
299 connect(s, SIGNAL(axisYChanged(QAbstractAxis*)), this, SLOT(handleAxisYSet(QAbstractAxis*)));
300 setAxisX(s->axisX(), s);
301 setAxisY(s->axisY(), s);
302 } else if (qobject_cast<DeclarativeScatterSeries *>(child)) {
303 DeclarativeScatterSeries *s = qobject_cast<DeclarativeScatterSeries *>(child);
304 connect(s, SIGNAL(axisXChanged(QAbstractAxis*)), this, SLOT(handleAxisXSet(QAbstractAxis*)));
305 connect(s, SIGNAL(axisYChanged(QAbstractAxis*)), this, SLOT(handleAxisYSet(QAbstractAxis*)));
306 setAxisX(s->axisX(), s);
307 setAxisY(s->axisY(), s);
308 } else if (qobject_cast<DeclarativeAreaSeries *>(child)) {
309 DeclarativeAreaSeries *s = qobject_cast<DeclarativeAreaSeries *>(child);
310 connect(s, SIGNAL(axisXChanged(QAbstractAxis*)), this, SLOT(handleAxisXSet(QAbstractAxis*)));
311 connect(s, SIGNAL(axisYChanged(QAbstractAxis*)), this, SLOT(handleAxisYSet(QAbstractAxis*)));
312 setAxisX(s->axisX(), s);
313 setAxisY(s->axisY(), s);
314 } else if (qobject_cast<DeclarativeBarSeries *>(child)) {
315 DeclarativeBarSeries *s = qobject_cast<DeclarativeBarSeries *>(child);
316 connect(s, SIGNAL(axisXChanged(QAbstractAxis*)), this, SLOT(handleAxisXSet(QAbstractAxis*)));
317 connect(s, SIGNAL(axisYChanged(QAbstractAxis*)), this, SLOT(handleAxisYSet(QAbstractAxis*)));
318 setAxisX(s->axisX(), s);
319 setAxisY(s->axisY(), s);
320 } else if (qobject_cast<DeclarativeStackedBarSeries *>(child)) {
321 DeclarativeStackedBarSeries *s = qobject_cast<DeclarativeStackedBarSeries *>(child);
322 connect(s, SIGNAL(axisXChanged(QAbstractAxis*)), this, SLOT(handleAxisXSet(QAbstractAxis*)));
323 connect(s, SIGNAL(axisYChanged(QAbstractAxis*)), this, SLOT(handleAxisYSet(QAbstractAxis*)));
324 setAxisX(s->axisX(), s);
325 setAxisY(s->axisY(), s);
326 } else if (qobject_cast<DeclarativePercentBarSeries *>(child)) {
327 DeclarativePercentBarSeries *s = qobject_cast<DeclarativePercentBarSeries *>(child);
328 connect(s, SIGNAL(axisXChanged(QAbstractAxis*)), this, SLOT(handleAxisXSet(QAbstractAxis*)));
329 connect(s, SIGNAL(axisYChanged(QAbstractAxis*)), this, SLOT(handleAxisYSet(QAbstractAxis*)));
330 setAxisX(s->axisX(), s);
331 setAxisY(s->axisY(), s);
332 } else if (qobject_cast<DeclarativeHorizontalBarSeries *>(child)) {
333 DeclarativeHorizontalBarSeries *s = qobject_cast<DeclarativeHorizontalBarSeries *>(child);
334 connect(s, SIGNAL(axisXChanged(QAbstractAxis*)), this, SLOT(handleAxisXSet(QAbstractAxis*)));
335 connect(s, SIGNAL(axisYChanged(QAbstractAxis*)), this, SLOT(handleAxisYSet(QAbstractAxis*)));
336 setAxisX(s->axisX(), s);
337 setAxisY(s->axisY(), s);
338 } else if (qobject_cast<DeclarativeHorizontalStackedBarSeries *>(child)) {
339 DeclarativeHorizontalStackedBarSeries *s = qobject_cast<DeclarativeHorizontalStackedBarSeries *>(child);
340 connect(s, SIGNAL(axisXChanged(QAbstractAxis*)), this, SLOT(handleAxisXSet(QAbstractAxis*)));
341 connect(s, SIGNAL(axisYChanged(QAbstractAxis*)), this, SLOT(handleAxisYSet(QAbstractAxis*)));
342 setAxisX(s->axisX(), s);
343 setAxisY(s->axisY(), s);
344 } else if (qobject_cast<DeclarativeHorizontalPercentBarSeries *>(child)) {
345 DeclarativeHorizontalPercentBarSeries *s = qobject_cast<DeclarativeHorizontalPercentBarSeries *>(child);
346 connect(s, SIGNAL(axisXChanged(QAbstractAxis*)), this, SLOT(handleAxisXSet(QAbstractAxis*)));
347 connect(s, SIGNAL(axisYChanged(QAbstractAxis*)), this, SLOT(handleAxisYSet(QAbstractAxis*)));
348 setAxisX(s->axisX(), s);
349 setAxisY(s->axisY(), s);
350 }
296 }
297
298 initializeAxes(series);
351 }
299 }
352 }
300 }
353
301
354 // Create the missing axes for the series that cannot be painted without axes
355 foreach (QAbstractSeries *chartSeries, m_chart->series())
356 createDefaultAxes(chartSeries);
357
358 QDeclarativeItem::componentComplete();
302 QDeclarativeItem::componentComplete();
359 }
303 }
360
304
361 void DeclarativeChart::handleAxisXSet(QAbstractAxis *axis)
305 void DeclarativeChart::handleAxisXSet(QAbstractAxis *axis)
362 {
306 {
363 // qDebug() << "DeclarativeChart::handleAxisXSet" << sender() << axis;
307 QAbstractSeries *s = qobject_cast<QAbstractSeries *>(sender());
364 if (axis && qobject_cast<QAbstractSeries *>(sender()))
308 if (axis && s) {
365 m_chart->setAxisX(axis, qobject_cast<QAbstractSeries *>(sender()));
309 if (!m_chart->axes(Qt::Horizontal).contains(axis))
366 else
310 m_chart->addAxis(axis, Qt::AlignBottom);
311 if (!s->attachedAxes().contains(axis))
312 s->attachAxis(axis);
313 } else {
367 qWarning() << "Trying to set axisX to null.";
314 qWarning() << "Trying to set axisX to null.";
315 }
316 }
317
318 void DeclarativeChart::handleAxisXTopSet(QAbstractAxis *axis)
319 {
320 QAbstractSeries *s = qobject_cast<QAbstractSeries *>(sender());
321 if (axis && s) {
322 if (!m_chart->axes(Qt::Horizontal).contains(axis))
323 m_chart->addAxis(axis, Qt::AlignTop);
324 if (!s->attachedAxes().contains(axis))
325 s->attachAxis(axis);
326 } else {
327 qWarning() << "Trying to set axisXTop to null.";
328 }
368 }
329 }
369
330
370 void DeclarativeChart::handleAxisYSet(QAbstractAxis *axis)
331 void DeclarativeChart::handleAxisYSet(QAbstractAxis *axis)
371 {
332 {
372 // qDebug() << "DeclarativeChart::handleAxisYSet" << sender() << axis;
333 QAbstractSeries *s = qobject_cast<QAbstractSeries *>(sender());
373 if (axis && qobject_cast<QAbstractSeries *>(sender()))
334 if (axis && s) {
374 m_chart->setAxisY(axis, qobject_cast<QAbstractSeries *>(sender()));
335 if (!m_chart->axes(Qt::Vertical).contains(axis))
375 else
336 m_chart->addAxis(axis, Qt::AlignLeft);
337 if (!s->attachedAxes().contains(axis))
338 s->attachAxis(axis);
339 } else {
376 qWarning() << "Trying to set axisY to null.";
340 qWarning() << "Trying to set axisY to null.";
341 }
342 }
343
344 void DeclarativeChart::handleAxisYRightSet(QAbstractAxis *axis)
345 {
346 QAbstractSeries *s = qobject_cast<QAbstractSeries *>(sender());
347 if (axis && s) {
348 if (!m_chart->axes(Qt::Vertical).contains(axis))
349 m_chart->addAxis(axis, Qt::AlignRight);
350 if (!s->attachedAxes().contains(axis))
351 s->attachAxis(axis);
352 } else {
353 qWarning() << "Trying to set axisYRight to null.";
354 }
377 }
355 }
378
356
379 void DeclarativeChart::geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry)
357 void DeclarativeChart::geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry)
380 {
358 {
381 // qDebug() << "DeclarativeChart::geometryChanged" << newGeometry.width() << newGeometry.height();
359 // qDebug() << "DeclarativeChart::geometryChanged" << newGeometry.width() << newGeometry.height();
382 if (newGeometry.isValid()) {
360 if (newGeometry.isValid()) {
383 if (newGeometry.width() > 0 && newGeometry.height() > 0) {
361 if (newGeometry.width() > 0 && newGeometry.height() > 0) {
384 m_chart->resize(newGeometry.width(), newGeometry.height());
362 m_chart->resize(newGeometry.width(), newGeometry.height());
385 }
363 }
386 }
364 }
387 QDeclarativeItem::geometryChanged(newGeometry, oldGeometry);
365 QDeclarativeItem::geometryChanged(newGeometry, oldGeometry);
388
366
389 // It would be better to trigger the plotAreaChanged signal from QChart::plotAreaChanged or
367 // It would be better to trigger the plotAreaChanged signal from QChart::plotAreaChanged or
390 // similar. Since that kind of a signal is not clearly needed in the C++ API the work-around is
368 // similar. Since that kind of a signal is not clearly needed in the C++ API the work-around is
391 // to implement it here for the QML API purposes.
369 // to implement it here for the QML API purposes.
392 emit plotAreaChanged(m_chart->plotArea());
370 emit plotAreaChanged(m_chart->plotArea());
393 }
371 }
394
372
395 void DeclarativeChart::setTheme(DeclarativeChart::Theme theme)
373 void DeclarativeChart::setTheme(DeclarativeChart::Theme theme)
396 {
374 {
397 QChart::ChartTheme chartTheme = (QChart::ChartTheme) theme;
375 QChart::ChartTheme chartTheme = (QChart::ChartTheme) theme;
398 if (chartTheme != m_chart->theme())
376 if (chartTheme != m_chart->theme())
399 m_chart->setTheme(chartTheme);
377 m_chart->setTheme(chartTheme);
400 }
378 }
401
379
402 DeclarativeChart::Theme DeclarativeChart::theme()
380 DeclarativeChart::Theme DeclarativeChart::theme()
403 {
381 {
404 return (DeclarativeChart::Theme) m_chart->theme();
382 return (DeclarativeChart::Theme) m_chart->theme();
405 }
383 }
406
384
407 void DeclarativeChart::setAnimationOptions(DeclarativeChart::Animation animations)
385 void DeclarativeChart::setAnimationOptions(DeclarativeChart::Animation animations)
408 {
386 {
409 QChart::AnimationOption animationOptions = (QChart::AnimationOption) animations;
387 QChart::AnimationOption animationOptions = (QChart::AnimationOption) animations;
410 if (animationOptions != m_chart->animationOptions())
388 if (animationOptions != m_chart->animationOptions())
411 m_chart->setAnimationOptions(animationOptions);
389 m_chart->setAnimationOptions(animationOptions);
412 }
390 }
413
391
414 DeclarativeChart::Animation DeclarativeChart::animationOptions()
392 DeclarativeChart::Animation DeclarativeChart::animationOptions()
415 {
393 {
416 if (m_chart->animationOptions().testFlag(QChart::AllAnimations))
394 if (m_chart->animationOptions().testFlag(QChart::AllAnimations))
417 return DeclarativeChart::AllAnimations;
395 return DeclarativeChart::AllAnimations;
418 else if (m_chart->animationOptions().testFlag(QChart::GridAxisAnimations))
396 else if (m_chart->animationOptions().testFlag(QChart::GridAxisAnimations))
419 return DeclarativeChart::GridAxisAnimations;
397 return DeclarativeChart::GridAxisAnimations;
420 else if (m_chart->animationOptions().testFlag(QChart::SeriesAnimations))
398 else if (m_chart->animationOptions().testFlag(QChart::SeriesAnimations))
421 return DeclarativeChart::SeriesAnimations;
399 return DeclarativeChart::SeriesAnimations;
422 else
400 else
423 return DeclarativeChart::NoAnimation;
401 return DeclarativeChart::NoAnimation;
424 }
402 }
425
403
426 void DeclarativeChart::setTitle(QString title)
404 void DeclarativeChart::setTitle(QString title)
427 {
405 {
428 if (title != m_chart->title())
406 if (title != m_chart->title())
429 m_chart->setTitle(title);
407 m_chart->setTitle(title);
430 }
408 }
431 QString DeclarativeChart::title()
409 QString DeclarativeChart::title()
432 {
410 {
433 return m_chart->title();
411 return m_chart->title();
434 }
412 }
435
413
436 QAbstractAxis *DeclarativeChart::axisX(QAbstractSeries *series)
414 QAbstractAxis *DeclarativeChart::axisX(QAbstractSeries *series)
437 {
415 {
438 return m_chart->axisX(series);
416 QList<QAbstractAxis *> axes = m_chart->axes(Qt::Horizontal, series);
417 if (axes.count())
418 return axes[0];
419 return 0;
439 }
420 }
440
421
441 QAbstractAxis *DeclarativeChart::axisY(QAbstractSeries *series)
422 QAbstractAxis *DeclarativeChart::axisY(QAbstractSeries *series)
442 {
423 {
443 return m_chart->axisY(series);
424 QList<QAbstractAxis *> axes = m_chart->axes(Qt::Vertical, series);
425 if (axes.count())
426 return axes[0];
427 return 0;
444 }
428 }
445
429
446 QLegend *DeclarativeChart::legend()
430 QLegend *DeclarativeChart::legend()
447 {
431 {
448 return m_chart->legend();
432 return m_chart->legend();
449 }
433 }
450
434
451 void DeclarativeChart::setTitleColor(QColor color)
435 void DeclarativeChart::setTitleColor(QColor color)
452 {
436 {
453 QBrush b = m_chart->titleBrush();
437 QBrush b = m_chart->titleBrush();
454 if (color != b.color()) {
438 if (color != b.color()) {
455 b.setColor(color);
439 b.setColor(color);
456 m_chart->setTitleBrush(b);
440 m_chart->setTitleBrush(b);
457 emit titleColorChanged(color);
441 emit titleColorChanged(color);
458 }
442 }
459 }
443 }
460
444
461 QFont DeclarativeChart::titleFont() const
445 QFont DeclarativeChart::titleFont() const
462 {
446 {
463 return m_chart->titleFont();
447 return m_chart->titleFont();
464 }
448 }
465
449
466 void DeclarativeChart::setTitleFont(const QFont &font)
450 void DeclarativeChart::setTitleFont(const QFont &font)
467 {
451 {
468 m_chart->setTitleFont(font);
452 m_chart->setTitleFont(font);
469 }
453 }
470
454
471 QColor DeclarativeChart::titleColor()
455 QColor DeclarativeChart::titleColor()
472 {
456 {
473 return m_chart->titleBrush().color();
457 return m_chart->titleBrush().color();
474 }
458 }
475
459
476 void DeclarativeChart::setBackgroundColor(QColor color)
460 void DeclarativeChart::setBackgroundColor(QColor color)
477 {
461 {
478 QBrush b = m_chart->backgroundBrush();
462 QBrush b = m_chart->backgroundBrush();
479 if (b.style() != Qt::SolidPattern || color != b.color()) {
463 if (b.style() != Qt::SolidPattern || color != b.color()) {
480 b.setStyle(Qt::SolidPattern);
464 b.setStyle(Qt::SolidPattern);
481 b.setColor(color);
465 b.setColor(color);
482 m_chart->setBackgroundBrush(b);
466 m_chart->setBackgroundBrush(b);
483 emit backgroundColorChanged();
467 emit backgroundColorChanged();
484 }
468 }
485 }
469 }
486
470
487 QColor DeclarativeChart::backgroundColor()
471 QColor DeclarativeChart::backgroundColor()
488 {
472 {
489 return m_chart->backgroundBrush().color();
473 return m_chart->backgroundBrush().color();
490 }
474 }
491
475
492 int DeclarativeChart::count()
476 int DeclarativeChart::count()
493 {
477 {
494 return m_chart->series().count();
478 return m_chart->series().count();
495 }
479 }
496
480
497 void DeclarativeChart::setDropShadowEnabled(bool enabled)
481 void DeclarativeChart::setDropShadowEnabled(bool enabled)
498 {
482 {
499 if (enabled != m_chart->isDropShadowEnabled()) {
483 if (enabled != m_chart->isDropShadowEnabled()) {
500 m_chart->setDropShadowEnabled(enabled);
484 m_chart->setDropShadowEnabled(enabled);
501 dropShadowEnabledChanged(enabled);
485 dropShadowEnabledChanged(enabled);
502 }
486 }
503 }
487 }
504
488
505 bool DeclarativeChart::dropShadowEnabled()
489 bool DeclarativeChart::dropShadowEnabled()
506 {
490 {
507 return m_chart->isDropShadowEnabled();
491 return m_chart->isDropShadowEnabled();
508 }
492 }
509
493
510 qreal DeclarativeChart::topMargin()
494 qreal DeclarativeChart::topMargin()
511 {
495 {
512 qWarning() << "ChartView.topMargin is deprecated. Use minimumMargins and plotArea instead.";
496 qWarning() << "ChartView.topMargin is deprecated. Use minimumMargins and plotArea instead.";
513 return m_chart->plotArea().top();
497 return m_chart->plotArea().top();
514 }
498 }
515
499
516 qreal DeclarativeChart::bottomMargin()
500 qreal DeclarativeChart::bottomMargin()
517 {
501 {
518
502
519 qWarning() << "ChartView.bottomMargin is deprecated. Use minimumMargins and plotArea instead.";
503 qWarning() << "ChartView.bottomMargin is deprecated. Use minimumMargins and plotArea instead.";
520 return m_chart->plotArea().bottom();
504 return m_chart->plotArea().bottom();
521 }
505 }
522
506
523 qreal DeclarativeChart::leftMargin()
507 qreal DeclarativeChart::leftMargin()
524 {
508 {
525 qWarning() << "ChartView.leftMargin is deprecated. Use minimumMargins and plotArea instead.";
509 qWarning() << "ChartView.leftMargin is deprecated. Use minimumMargins and plotArea instead.";
526 return m_chart->plotArea().left();
510 return m_chart->plotArea().left();
527 }
511 }
528
512
529 qreal DeclarativeChart::rightMargin()
513 qreal DeclarativeChart::rightMargin()
530 {
514 {
531 qWarning() << "ChartView.rightMargin is deprecated. Use minimumMargins and plotArea instead.";
515 qWarning() << "ChartView.rightMargin is deprecated. Use minimumMargins and plotArea instead.";
532 return m_chart->plotArea().right();
516 return m_chart->plotArea().right();
533 }
517 }
534
518
535 void DeclarativeChart::zoom(qreal factor)
519 void DeclarativeChart::zoom(qreal factor)
536 {
520 {
537 m_chart->zoom(factor);
521 m_chart->zoom(factor);
538 }
522 }
539
523
540 void DeclarativeChart::scrollLeft(qreal pixels)
524 void DeclarativeChart::scrollLeft(qreal pixels)
541 {
525 {
542 m_chart->scroll(-pixels, 0);
526 m_chart->scroll(-pixels, 0);
543 }
527 }
544
528
545 void DeclarativeChart::scrollRight(qreal pixels)
529 void DeclarativeChart::scrollRight(qreal pixels)
546 {
530 {
547 m_chart->scroll(pixels, 0);
531 m_chart->scroll(pixels, 0);
548 }
532 }
549
533
550 void DeclarativeChart::scrollUp(qreal pixels)
534 void DeclarativeChart::scrollUp(qreal pixels)
551 {
535 {
552 m_chart->scroll(0, pixels);
536 m_chart->scroll(0, pixels);
553 }
537 }
554
538
555 void DeclarativeChart::scrollDown(qreal pixels)
539 void DeclarativeChart::scrollDown(qreal pixels)
556 {
540 {
557 m_chart->scroll(0, -pixels);
541 m_chart->scroll(0, -pixels);
558 }
542 }
559
543
544 QDeclarativeListProperty<QAbstractAxis> DeclarativeChart::axes()
545 {
546 return QDeclarativeListProperty<QAbstractAxis>(this, 0,
547 &DeclarativeChart::axesAppendFunc,
548 &DeclarativeChart::axesCountFunc,
549 &DeclarativeChart::axesAtFunc);
550 }
551
552 void DeclarativeChart::axesAppendFunc(QDeclarativeListProperty<QAbstractAxis> *list, QAbstractAxis *element)
553 {
554 // Empty implementation
555 Q_UNUSED(list);
556 Q_UNUSED(element);
557 }
558
559 int DeclarativeChart::axesCountFunc(QDeclarativeListProperty<QAbstractAxis> *list)
560 {
561 if (qobject_cast<DeclarativeChart *>(list->object)) {
562 DeclarativeChart *chart = qobject_cast<DeclarativeChart *>(list->object);
563 return chart->m_chart->axes(Qt::Horizontal | Qt::Vertical, chart->m_chart->series()[0]).count();
564 }
565 return 0;
566 }
567
568 QAbstractAxis *DeclarativeChart::axesAtFunc(QDeclarativeListProperty<QAbstractAxis> *list, int index)
569 {
570 if (qobject_cast<DeclarativeChart *>(list->object)) {
571 DeclarativeChart *chart = qobject_cast<DeclarativeChart *>(list->object);
572 QList<QAbstractAxis *> axes = chart->m_chart->axes(Qt::Horizontal | Qt::Vertical, chart->m_chart->series()[0]);
573 return axes.at(index);
574 }
575 return 0;
576 }
577
560 QAbstractSeries *DeclarativeChart::series(int index)
578 QAbstractSeries *DeclarativeChart::series(int index)
561 {
579 {
562 if (index < m_chart->series().count()) {
580 if (index < m_chart->series().count()) {
563 return m_chart->series().at(index);
581 return m_chart->series().at(index);
564 }
582 }
565 return 0;
583 return 0;
566 }
584 }
567
585
568 QAbstractSeries *DeclarativeChart::series(QString seriesName)
586 QAbstractSeries *DeclarativeChart::series(QString seriesName)
569 {
587 {
570 foreach (QAbstractSeries *series, m_chart->series()) {
588 foreach (QAbstractSeries *series, m_chart->series()) {
571 if (series->name() == seriesName)
589 if (series->name() == seriesName)
572 return series;
590 return series;
573 }
591 }
574 return 0;
592 return 0;
575 }
593 }
576
594
577 QAbstractSeries *DeclarativeChart::createSeries(DeclarativeChart::SeriesType type, QString name)
595 QAbstractSeries *DeclarativeChart::createSeries(DeclarativeChart::SeriesType type, QString name)
578 {
596 {
579 return createSeries(type, name, 0, 0);
597 return createSeries(type, name, 0, 0);
580 }
598 }
581
599
582 QAbstractSeries *DeclarativeChart::createSeries(DeclarativeChart::SeriesType type, QString name, QAbstractAxis *axisX, QAbstractAxis *axisY)
600 QAbstractSeries *DeclarativeChart::createSeries(DeclarativeChart::SeriesType type, QString name, QAbstractAxis *axisX, QAbstractAxis *axisY)
583 {
601 {
584 QAbstractSeries *series = 0;
602 QAbstractSeries *series = 0;
585
603
586 switch (type) {
604 switch (type) {
587 case DeclarativeChart::SeriesTypeLine:
605 case DeclarativeChart::SeriesTypeLine:
588 series = new DeclarativeLineSeries();
606 series = new DeclarativeLineSeries();
589 break;
607 break;
590 case DeclarativeChart::SeriesTypeArea: {
608 case DeclarativeChart::SeriesTypeArea: {
591 DeclarativeAreaSeries *area = new DeclarativeAreaSeries();
609 DeclarativeAreaSeries *area = new DeclarativeAreaSeries();
592 area->setUpperSeries(new DeclarativeLineSeries());
610 area->setUpperSeries(new DeclarativeLineSeries());
593 series = area;
611 series = area;
594 break;
612 break;
595 }
613 }
596 case DeclarativeChart::SeriesTypeStackedBar:
614 case DeclarativeChart::SeriesTypeStackedBar:
597 series = new DeclarativeStackedBarSeries();
615 series = new DeclarativeStackedBarSeries();
598 break;
616 break;
599 case DeclarativeChart::SeriesTypePercentBar:
617 case DeclarativeChart::SeriesTypePercentBar:
600 series = new DeclarativePercentBarSeries();
618 series = new DeclarativePercentBarSeries();
601 break;
619 break;
602 case DeclarativeChart::SeriesTypeBar:
620 case DeclarativeChart::SeriesTypeBar:
603 series = new DeclarativeBarSeries();
621 series = new DeclarativeBarSeries();
604 break;
622 break;
605 case DeclarativeChart::SeriesTypeHorizontalBar:
623 case DeclarativeChart::SeriesTypeHorizontalBar:
606 series = new DeclarativeHorizontalBarSeries();
624 series = new DeclarativeHorizontalBarSeries();
607 break;
625 break;
608 case DeclarativeChart::SeriesTypeHorizontalPercentBar:
626 case DeclarativeChart::SeriesTypeHorizontalPercentBar:
609 series = new DeclarativeHorizontalPercentBarSeries();
627 series = new DeclarativeHorizontalPercentBarSeries();
610 break;
628 break;
611 case DeclarativeChart::SeriesTypeHorizontalStackedBar:
629 case DeclarativeChart::SeriesTypeHorizontalStackedBar:
612 series = new DeclarativeHorizontalStackedBarSeries();
630 series = new DeclarativeHorizontalStackedBarSeries();
613 break;
631 break;
614 case DeclarativeChart::SeriesTypePie:
632 case DeclarativeChart::SeriesTypePie:
615 series = new DeclarativePieSeries();
633 series = new DeclarativePieSeries();
616 break;
634 break;
617 case DeclarativeChart::SeriesTypeScatter:
635 case DeclarativeChart::SeriesTypeScatter:
618 series = new DeclarativeScatterSeries();
636 series = new DeclarativeScatterSeries();
619 break;
637 break;
620 case DeclarativeChart::SeriesTypeSpline:
638 case DeclarativeChart::SeriesTypeSpline:
621 series = new DeclarativeSplineSeries();
639 series = new DeclarativeSplineSeries();
622 break;
640 break;
623 default:
641 default:
624 qWarning() << "Illegal series type";
642 qWarning() << "Illegal series type";
625 }
643 }
626
644
627 if (series) {
645 if (series) {
646 // Connect to axis changed signals (unless this is a pie series)
647 if (!qobject_cast<DeclarativePieSeries *>(series)) {
648 connect(series, SIGNAL(axisXChanged(QAbstractAxis*)), this, SLOT(handleAxisXSet(QAbstractAxis*)));
649 connect(series, SIGNAL(axisXTopChanged(QAbstractAxis*)), this, SLOT(handleAxisXSet(QAbstractAxis*)));
650 connect(series, SIGNAL(axisYChanged(QAbstractAxis*)), this, SLOT(handleAxisYSet(QAbstractAxis*)));
651 connect(series, SIGNAL(axisYRightChanged(QAbstractAxis*)), this, SLOT(handleAxisYRightSet(QAbstractAxis*)));
652 }
653
628 series->setName(name);
654 series->setName(name);
629 m_chart->addSeries(series);
655 m_chart->addSeries(series);
630 // Set possible user defined axes
656
631 setAxisX(axisX, series);
657 if (axisX)
632 setAxisY(axisY, series);
658 setAxisX(axisX, series);
633 // Then create the missing axes
659 if (axisY)
634 createDefaultAxes(series);
660 setAxisY(axisY, series);
661
662 if (series->attachedAxes().count() < 2)
663 initializeAxes(series);
635 }
664 }
636
665
637 return series;
666 return series;
638 }
667 }
639
668
640 void DeclarativeChart::removeSeries(QAbstractSeries *series)
669 void DeclarativeChart::removeSeries(QAbstractSeries *series)
641 {
670 {
642 if (series)
671 if (series)
643 m_chart->removeSeries(series);
672 m_chart->removeSeries(series);
644 else
673 else
645 qWarning("removeSeries: cannot remove null");
674 qWarning("removeSeries: cannot remove null");
646 }
675 }
647
676
648 void DeclarativeChart::setAxisX(QAbstractAxis *axis, QAbstractSeries *series)
677 void DeclarativeChart::setAxisX(QAbstractAxis *axis, QAbstractSeries *series)
649 {
678 {
650 if (axis)
679 if (axis)
651 m_chart->setAxisX(axis, series);
680 m_chart->setAxisX(axis, series);
652 }
681 }
653
682
654 void DeclarativeChart::setAxisY(QAbstractAxis *axis, QAbstractSeries *series)
683 void DeclarativeChart::setAxisY(QAbstractAxis *axis, QAbstractSeries *series)
655 {
684 {
656 if (axis)
685 if (axis)
657 m_chart->setAxisY(axis, series);
686 m_chart->setAxisY(axis, series);
658 }
687 }
659
688
660 void DeclarativeChart::createDefaultAxes()
689 void DeclarativeChart::createDefaultAxes()
661 {
690 {
662 qWarning() << "ChartView.createDefaultAxes() is deprecated. Axes are created automatically.";
691 qWarning() << "ChartView.createDefaultAxes() is deprecated. Axes are created automatically.";
663 }
692 }
664
693
665 void DeclarativeChart::createDefaultAxes(QAbstractSeries *series)
694 QAbstractAxis *DeclarativeChart::defaultAxis(Qt::Orientation orientation, QAbstractSeries *series)
666 {
695 {
667 foreach (QAbstractSeries *s, m_chart->series()) {
696 if (!series) {
668 // If there is already an x axis of the correct type, re-use it
697 qWarning() << "No axis type defined for null series";
669 if (!m_chart->axisX(series) && s != series && m_chart->axisX(s)
698 return 0;
670 && m_chart->axisX(s)->type() == series->d_ptr->defaultAxisType(Qt::Horizontal))
671 m_chart->setAxisX(m_chart->axisX(s), series);
672
673 // If there is already a y axis of the correct type, re-use it
674 if (!m_chart->axisY(series) && s != series && m_chart->axisY(s)
675 && m_chart->axisY(s)->type() == series->d_ptr->defaultAxisType(Qt::Vertical))
676 m_chart->setAxisY(m_chart->axisY(s), series);
677 }
699 }
678
700
679 // If no x axis of correct type was found, create a new x axis based of default axis type
701 foreach (QAbstractAxis *existingAxis, m_chart->axes(orientation)) {
680 if (!m_chart->axisX(series)) {
702 if (existingAxis->type() == series->d_ptr->defaultAxisType(orientation))
681 switch (series->d_ptr->defaultAxisType(Qt::Horizontal)) {
703 return existingAxis;
682 case QAbstractAxis::AxisTypeValue:
683 m_chart->setAxisX(new QValueAxis(this), series);
684 break;
685 case QAbstractAxis::AxisTypeBarCategory:
686 m_chart->setAxisX(new QBarCategoryAxis(this), series);
687 break;
688 case QAbstractAxis::AxisTypeCategory:
689 m_chart->setAxisX(new QCategoryAxis(this), series);
690 break;
691 #ifndef QT_ON_ARM
692 case QAbstractAxis::AxisTypeDateTime:
693 m_chart->setAxisX(new QDateTimeAxis(this), series);
694 break;
695 #endif
696 default:
697 // Do nothing, assume AxisTypeNoAxis
698 break;
699 }
700 }
704 }
701
705
702 // If no y axis of correct type was found, create a new y axis based of default axis type
706 switch (series->d_ptr->defaultAxisType(orientation)) {
703 if (!m_chart->axisY(series)) {
707 case QAbstractAxis::AxisTypeValue:
704 switch (series->d_ptr->defaultAxisType(Qt::Vertical)) {
708 return new QValueAxis(this);
705 case QAbstractAxis::AxisTypeValue:
709 case QAbstractAxis::AxisTypeBarCategory:
706 m_chart->setAxisY(new QValueAxis(this), series);
710 return new QBarCategoryAxis(this);
707 break;
711 case QAbstractAxis::AxisTypeCategory:
708 case QAbstractAxis::AxisTypeBarCategory:
712 return new QCategoryAxis(this);
709 m_chart->setAxisY(new QBarCategoryAxis(this), series);
710 break;
711 case QAbstractAxis::AxisTypeCategory:
712 m_chart->setAxisY(new QCategoryAxis(this), series);
713 break;
714 #ifndef QT_ON_ARM
713 #ifndef QT_ON_ARM
715 case QAbstractAxis::AxisTypeDateTime:
714 case QAbstractAxis::AxisTypeDateTime:
716 m_chart->setAxisY(new QDateTimeAxis(this), series);
715 return new QDateTimeAxis(this);
717 break;
718 #endif
716 #endif
719 default:
717 default:
720 // Do nothing, assume AxisTypeNoAxis
718 // assume AxisTypeNoAxis
721 break;
719 return 0;
722 }
723 }
720 }
721 }
724
722
725 //qDebug() << "axis for series" << series << "x:" << m_chart->axisX(series) << "y:" << m_chart->axisY(series);
723 void DeclarativeChart::initializeAxes(QAbstractSeries *series)
724 {
725 if (qobject_cast<DeclarativeLineSeries *>(series))
726 doInitializeAxes(series, qobject_cast<DeclarativeLineSeries *>(series)->m_axes);
727 else if (qobject_cast<DeclarativeScatterSeries *>(series))
728 doInitializeAxes(series, qobject_cast<DeclarativeScatterSeries *>(series)->m_axes);
729 else if (qobject_cast<DeclarativeSplineSeries *>(series))
730 doInitializeAxes(series, qobject_cast<DeclarativeSplineSeries *>(series)->m_axes);
731 else if (qobject_cast<DeclarativeAreaSeries *>(series))
732 doInitializeAxes(series, qobject_cast<DeclarativeAreaSeries *>(series)->m_axes);
733 else if (qobject_cast<DeclarativeBarSeries *>(series))
734 doInitializeAxes(series, qobject_cast<DeclarativeBarSeries *>(series)->m_axes);
735 else if (qobject_cast<DeclarativeStackedBarSeries *>(series))
736 doInitializeAxes(series, qobject_cast<DeclarativeStackedBarSeries *>(series)->m_axes);
737 else if (qobject_cast<DeclarativePercentBarSeries *>(series))
738 doInitializeAxes(series, qobject_cast<DeclarativePercentBarSeries *>(series)->m_axes);
739 else if (qobject_cast<DeclarativeHorizontalBarSeries *>(series))
740 doInitializeAxes(series, qobject_cast<DeclarativeHorizontalBarSeries *>(series)->m_axes);
741 else if (qobject_cast<DeclarativeHorizontalStackedBarSeries *>(series))
742 doInitializeAxes(series, qobject_cast<DeclarativeHorizontalStackedBarSeries *>(series)->m_axes);
743 else if (qobject_cast<DeclarativeHorizontalPercentBarSeries *>(series))
744 doInitializeAxes(series, qobject_cast<DeclarativeHorizontalPercentBarSeries *>(series)->m_axes);
745 // else: do nothing
746 }
747
748 void DeclarativeChart::doInitializeAxes(QAbstractSeries *series, DeclarativeAxes *axes)
749 {
750 // Initialize axis X
751 if (axes->axisX())
752 axes->emitAxisXChanged();
753 else if (axes->axisXTop())
754 axes->emitAxisXTopChanged();
755 else
756 axes->setAxisX(defaultAxis(Qt::Horizontal, series));
757
758 // Initialize axis Y
759 if (axes->axisY())
760 axes->emitAxisYChanged();
761 else if (axes->axisYRight())
762 axes->emitAxisYRightChanged();
763 else
764 axes->setAxisY(defaultAxis(Qt::Vertical, series));
726 }
765 }
727
766
728 #include "moc_declarativechart.cpp"
767 #include "moc_declarativechart.cpp"
729
768
730 QTCOMMERCIALCHART_END_NAMESPACE
769 QTCOMMERCIALCHART_END_NAMESPACE
@@ -1,172 +1,184
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 AbstractDomain;
32 class Domain;
33 class DeclarativeAxes;
33
34
34 class DeclarativeChart : public QDeclarativeItem
35 class DeclarativeChart : public QDeclarativeItem
35 {
36 {
36 Q_OBJECT
37 Q_OBJECT
37 Q_PROPERTY(Theme theme READ theme WRITE setTheme)
38 Q_PROPERTY(Theme theme READ theme WRITE setTheme)
38 Q_PROPERTY(Animation animationOptions READ animationOptions WRITE setAnimationOptions)
39 Q_PROPERTY(Animation animationOptions READ animationOptions WRITE setAnimationOptions)
39 Q_PROPERTY(QString title READ title WRITE setTitle)
40 Q_PROPERTY(QString title READ title WRITE setTitle)
40 Q_PROPERTY(QFont titleFont READ titleFont WRITE setTitleFont)
41 Q_PROPERTY(QFont titleFont READ titleFont WRITE setTitleFont)
41 Q_PROPERTY(QColor titleColor READ titleColor WRITE setTitleColor NOTIFY titleColorChanged)
42 Q_PROPERTY(QColor titleColor READ titleColor WRITE setTitleColor NOTIFY titleColorChanged)
42 Q_PROPERTY(QLegend *legend READ legend)
43 Q_PROPERTY(QLegend *legend READ legend)
43 Q_PROPERTY(int count READ count)
44 Q_PROPERTY(int count READ count)
44 Q_PROPERTY(QColor backgroundColor READ backgroundColor WRITE setBackgroundColor NOTIFY backgroundColorChanged)
45 Q_PROPERTY(QColor backgroundColor READ backgroundColor WRITE setBackgroundColor NOTIFY backgroundColorChanged)
45 Q_PROPERTY(bool dropShadowEnabled READ dropShadowEnabled WRITE setDropShadowEnabled NOTIFY dropShadowEnabledChanged)
46 Q_PROPERTY(bool dropShadowEnabled READ dropShadowEnabled WRITE setDropShadowEnabled NOTIFY dropShadowEnabledChanged)
46 Q_PROPERTY(qreal topMargin READ topMargin)
47 Q_PROPERTY(qreal topMargin READ topMargin)
47 Q_PROPERTY(qreal bottomMargin READ bottomMargin)
48 Q_PROPERTY(qreal bottomMargin READ bottomMargin)
48 Q_PROPERTY(qreal leftMargin READ leftMargin)
49 Q_PROPERTY(qreal leftMargin READ leftMargin)
49 Q_PROPERTY(qreal rightMargin READ rightMargin)
50 Q_PROPERTY(qreal rightMargin READ rightMargin)
50 Q_PROPERTY(DeclarativeMargins *minimumMargins READ minimumMargins NOTIFY minimumMarginsChanged REVISION 1)
51 Q_PROPERTY(DeclarativeMargins *minimumMargins READ minimumMargins NOTIFY minimumMarginsChanged REVISION 1)
51 Q_PROPERTY(DeclarativeMargins *margins READ margins NOTIFY marginsChanged REVISION 2)
52 Q_PROPERTY(DeclarativeMargins *margins READ margins NOTIFY marginsChanged REVISION 2)
52 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)
53 Q_ENUMS(Animation)
55 Q_ENUMS(Animation)
54 Q_ENUMS(Theme)
56 Q_ENUMS(Theme)
55 Q_ENUMS(SeriesType)
57 Q_ENUMS(SeriesType)
56
58
57 public:
59 public:
58 // 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
59 enum Theme {
61 enum Theme {
60 ChartThemeLight = 0,
62 ChartThemeLight = 0,
61 ChartThemeBlueCerulean,
63 ChartThemeBlueCerulean,
62 ChartThemeDark,
64 ChartThemeDark,
63 ChartThemeBrownSand,
65 ChartThemeBrownSand,
64 ChartThemeBlueNcs,
66 ChartThemeBlueNcs,
65 ChartThemeHighContrast,
67 ChartThemeHighContrast,
66 ChartThemeBlueIcy
68 ChartThemeBlueIcy
67 };
69 };
68
70
69 enum Animation {
71 enum Animation {
70 NoAnimation = 0x0,
72 NoAnimation = 0x0,
71 GridAxisAnimations = 0x1,
73 GridAxisAnimations = 0x1,
72 SeriesAnimations = 0x2,
74 SeriesAnimations = 0x2,
73 AllAnimations = 0x3
75 AllAnimations = 0x3
74 };
76 };
75
77
76 enum SeriesType {
78 enum SeriesType {
77 SeriesTypeLine,
79 SeriesTypeLine,
78 SeriesTypeArea,
80 SeriesTypeArea,
79 SeriesTypeBar,
81 SeriesTypeBar,
80 SeriesTypeStackedBar,
82 SeriesTypeStackedBar,
81 SeriesTypePercentBar,
83 SeriesTypePercentBar,
82 SeriesTypePie,
84 SeriesTypePie,
83 SeriesTypeScatter,
85 SeriesTypeScatter,
84 SeriesTypeSpline,
86 SeriesTypeSpline,
85 SeriesTypeHorizontalBar,
87 SeriesTypeHorizontalBar,
86 SeriesTypeHorizontalStackedBar,
88 SeriesTypeHorizontalStackedBar,
87 SeriesTypeHorizontalPercentBar
89 SeriesTypeHorizontalPercentBar
88 };
90 };
89
91
90 public:
92 public:
91 DeclarativeChart(QDeclarativeItem *parent = 0);
93 DeclarativeChart(QDeclarativeItem *parent = 0);
92 ~DeclarativeChart();
94 ~DeclarativeChart();
93
95
94 public: // From QDeclarativeItem/QGraphicsItem
96 public: // From QDeclarativeItem/QGraphicsItem
95 void childEvent(QChildEvent *event);
97 void childEvent(QChildEvent *event);
96 void componentComplete();
98 void componentComplete();
97 void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry);
99 void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry);
98
100
99 public:
101 public:
100 void setTheme(DeclarativeChart::Theme theme);
102 void setTheme(DeclarativeChart::Theme theme);
101 DeclarativeChart::Theme theme();
103 DeclarativeChart::Theme theme();
102 void setAnimationOptions(DeclarativeChart::Animation animations);
104 void setAnimationOptions(DeclarativeChart::Animation animations);
103 DeclarativeChart::Animation animationOptions();
105 DeclarativeChart::Animation animationOptions();
104 void setTitle(QString title);
106 void setTitle(QString title);
105 QString title();
107 QString title();
106 QLegend *legend();
108 QLegend *legend();
107 QFont titleFont() const;
109 QFont titleFont() const;
108 void setTitleFont(const QFont &font);
110 void setTitleFont(const QFont &font);
109 void setTitleColor(QColor color);
111 void setTitleColor(QColor color);
110 QColor titleColor();
112 QColor titleColor();
111 void setBackgroundColor(QColor color);
113 void setBackgroundColor(QColor color);
112 QColor backgroundColor();
114 QColor backgroundColor();
113 int count();
115 int count();
114 void setDropShadowEnabled(bool enabled);
116 void setDropShadowEnabled(bool enabled);
115 bool dropShadowEnabled();
117 bool dropShadowEnabled();
116 qreal topMargin();
118 qreal topMargin();
117 qreal bottomMargin();
119 qreal bottomMargin();
118 qreal leftMargin();
120 qreal leftMargin();
119 qreal rightMargin();
121 qreal rightMargin();
120 void createDefaultAxes(QAbstractSeries *series);
122 QAbstractAxis *defaultAxis(Qt::Orientation orientation, QAbstractSeries *series);
123 void initializeAxes(QAbstractSeries *series);
124 void doInitializeAxes(QAbstractSeries *series, DeclarativeAxes *axes);
121 //TODO this is deprecated:
125 //TODO this is deprecated:
122 DeclarativeMargins *minimumMargins() { return m_margins; }
126 DeclarativeMargins *minimumMargins() { return m_margins; }
123
127
124 Q_REVISION(2) DeclarativeMargins *margins() { return m_margins; }
128 Q_REVISION(2) DeclarativeMargins *margins() { return m_margins; }
125 QRectF plotArea() { return m_chart->plotArea(); }
129 QRectF plotArea() { return m_chart->plotArea(); }
126
130
131 // Axis list property methods
132 QDeclarativeListProperty<QAbstractAxis> axes();
133 static void axesAppendFunc(QDeclarativeListProperty<QAbstractAxis> *list, QAbstractAxis *element);
134 static int axesCountFunc(QDeclarativeListProperty<QAbstractAxis> *list);
135 static QAbstractAxis *axesAtFunc(QDeclarativeListProperty<QAbstractAxis> *list, int index);
136
127 public:
137 public:
128 Q_INVOKABLE QAbstractSeries *series(int index);
138 Q_INVOKABLE QAbstractSeries *series(int index);
129 Q_INVOKABLE QAbstractSeries *series(QString seriesName);
139 Q_INVOKABLE QAbstractSeries *series(QString seriesName);
130 Q_INVOKABLE QAbstractSeries *createSeries(DeclarativeChart::SeriesType type, QString name = "");
140 Q_INVOKABLE QAbstractSeries *createSeries(DeclarativeChart::SeriesType type, QString name = "");
131 Q_INVOKABLE QAbstractSeries *createSeries(DeclarativeChart::SeriesType type, QString name, QAbstractAxis *axisX, QAbstractAxis *axisY);
141 Q_INVOKABLE QAbstractSeries *createSeries(DeclarativeChart::SeriesType type, QString name, QAbstractAxis *axisX, QAbstractAxis *axisY);
132 Q_INVOKABLE void removeSeries(QAbstractSeries *series);
142 Q_INVOKABLE void removeSeries(QAbstractSeries *series);
133 Q_INVOKABLE void removeAllSeries() { m_chart->removeAllSeries(); }
143 Q_INVOKABLE void removeAllSeries() { m_chart->removeAllSeries(); }
134 Q_INVOKABLE void setAxisX(QAbstractAxis *axis, QAbstractSeries *series = 0);
144 Q_INVOKABLE void setAxisX(QAbstractAxis *axis, QAbstractSeries *series = 0);
135 Q_INVOKABLE void setAxisY(QAbstractAxis *axis, QAbstractSeries *series = 0);
145 Q_INVOKABLE void setAxisY(QAbstractAxis *axis, QAbstractSeries *series = 0);
136 Q_INVOKABLE void createDefaultAxes();
146 Q_INVOKABLE void createDefaultAxes();
137 Q_INVOKABLE QAbstractAxis *axisX(QAbstractSeries *series = 0);
147 Q_INVOKABLE QAbstractAxis *axisX(QAbstractSeries *series = 0);
138 Q_INVOKABLE QAbstractAxis *axisY(QAbstractSeries *series = 0);
148 Q_INVOKABLE QAbstractAxis *axisY(QAbstractSeries *series = 0);
139 Q_INVOKABLE void zoom(qreal factor);
149 Q_INVOKABLE void zoom(qreal factor);
140 Q_INVOKABLE void scrollLeft(qreal pixels);
150 Q_INVOKABLE void scrollLeft(qreal pixels);
141 Q_INVOKABLE void scrollRight(qreal pixels);
151 Q_INVOKABLE void scrollRight(qreal pixels);
142 Q_INVOKABLE void scrollUp(qreal pixels);
152 Q_INVOKABLE void scrollUp(qreal pixels);
143 Q_INVOKABLE void scrollDown(qreal pixels);
153 Q_INVOKABLE void scrollDown(qreal pixels);
144
154
145 Q_SIGNALS:
155 Q_SIGNALS:
146 void axisLabelsChanged();
156 void axisLabelsChanged();
147 void titleColorChanged(QColor color);
157 void titleColorChanged(QColor color);
148 void backgroundColorChanged();
158 void backgroundColorChanged();
149 void dropShadowEnabledChanged(bool enabled);
159 void dropShadowEnabledChanged(bool enabled);
150 void minimumMarginsChanged();
160 void minimumMarginsChanged();
151 Q_REVISION(2) void marginsChanged();
161 Q_REVISION(2) void marginsChanged();
152 void plotAreaChanged(QRectF plotArea);
162 void plotAreaChanged(QRectF plotArea);
153 void seriesAdded(QAbstractSeries *series);
163 void seriesAdded(QAbstractSeries *series);
154 void seriesRemoved(QAbstractSeries *series);
164 void seriesRemoved(QAbstractSeries *series);
155
165
156 public Q_SLOTS:
166 private Q_SLOTS:
157 void changeMinimumMargins(int top, int bottom, int left, int right);
167 void changeMinimumMargins(int top, int bottom, int left, int right);
158 void handleAxisXSet(QAbstractAxis *axis);
168 void handleAxisXSet(QAbstractAxis *axis);
159 void handleAxisYSet(QAbstractAxis *axis);
169 void handleAxisYSet(QAbstractAxis *axis);
170 void handleAxisXTopSet(QAbstractAxis *axis);
171 void handleAxisYRightSet(QAbstractAxis *axis);
160 void handleSeriesAdded(QAbstractSeries *series);
172 void handleSeriesAdded(QAbstractSeries *series);
161
173
162 private:
174 private:
163 // Extending QChart with DeclarativeChart is not possible because QObject does not support
175 // Extending QChart with DeclarativeChart is not possible because QObject does not support
164 // multi inheritance, so we now have a QChart as a member instead
176 // multi inheritance, so we now have a QChart as a member instead
165 QChart *m_chart;
177 QChart *m_chart;
166 //QMargins m_chartMargins;
178 //QMargins m_chartMargins;
167 DeclarativeMargins *m_margins;
179 DeclarativeMargins *m_margins;
168 };
180 };
169
181
170 QTCOMMERCIALCHART_END_NAMESPACE
182 QTCOMMERCIALCHART_END_NAMESPACE
171
183
172 #endif // DECLARATIVECHART_H
184 #endif // DECLARATIVECHART_H
@@ -1,99 +1,102
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 "declarativelineseries.h"
21 #include "declarativelineseries.h"
22
22
23 QTCOMMERCIALCHART_BEGIN_NAMESPACE
23 QTCOMMERCIALCHART_BEGIN_NAMESPACE
24
24
25 DeclarativeLineSeries::DeclarativeLineSeries(QObject *parent) :
25 DeclarativeLineSeries::DeclarativeLineSeries(QObject *parent) :
26 QLineSeries(parent),
26 QLineSeries(parent),
27 m_axisX(0),
27 m_axes(new DeclarativeAxes(this))
28 m_axisY(0)
29 {
28 {
29 connect(m_axes, SIGNAL(axisXChanged(QAbstractAxis*)), this, SIGNAL(axisXChanged(QAbstractAxis*)));
30 connect(m_axes, SIGNAL(axisYChanged(QAbstractAxis*)), this, SIGNAL(axisYChanged(QAbstractAxis*)));
31 connect(m_axes, SIGNAL(axisXTopChanged(QAbstractAxis*)), this, SIGNAL(axisXTopChanged(QAbstractAxis*)));
32 connect(m_axes, SIGNAL(axisYRightChanged(QAbstractAxis*)), this, SIGNAL(axisYRightChanged(QAbstractAxis*)));
30 connect(this, SIGNAL(pointAdded(int)), this, SLOT(handleCountChanged(int)));
33 connect(this, SIGNAL(pointAdded(int)), this, SLOT(handleCountChanged(int)));
31 connect(this, SIGNAL(pointRemoved(int)), this, SLOT(handleCountChanged(int)));
34 connect(this, SIGNAL(pointRemoved(int)), this, SLOT(handleCountChanged(int)));
32 }
35 }
33
36
34 void DeclarativeLineSeries::handleCountChanged(int index)
37 void DeclarativeLineSeries::handleCountChanged(int index)
35 {
38 {
36 Q_UNUSED(index)
39 Q_UNUSED(index)
37 emit countChanged(points().count());
40 emit countChanged(points().count());
38 }
41 }
39
42
40 qreal DeclarativeLineSeries::width() const
43 qreal DeclarativeLineSeries::width() const
41 {
44 {
42 return pen().widthF();
45 return pen().widthF();
43 }
46 }
44
47
45 void DeclarativeLineSeries::setWidth(qreal width)
48 void DeclarativeLineSeries::setWidth(qreal width)
46 {
49 {
47 if (width != pen().widthF()) {
50 if (width != pen().widthF()) {
48 QPen p = pen();
51 QPen p = pen();
49 p.setWidthF(width);
52 p.setWidthF(width);
50 setPen(p);
53 setPen(p);
51 emit widthChanged(width);
54 emit widthChanged(width);
52 }
55 }
53 }
56 }
54
57
55 Qt::PenStyle DeclarativeLineSeries::style() const
58 Qt::PenStyle DeclarativeLineSeries::style() const
56 {
59 {
57 return pen().style();
60 return pen().style();
58 }
61 }
59
62
60 void DeclarativeLineSeries::setStyle(Qt::PenStyle style)
63 void DeclarativeLineSeries::setStyle(Qt::PenStyle style)
61 {
64 {
62 if (style != pen().style()) {
65 if (style != pen().style()) {
63 QPen p = pen();
66 QPen p = pen();
64 p.setStyle(style);
67 p.setStyle(style);
65 setPen(p);
68 setPen(p);
66 emit styleChanged(style);
69 emit styleChanged(style);
67 }
70 }
68 }
71 }
69
72
70 Qt::PenCapStyle DeclarativeLineSeries::capStyle() const
73 Qt::PenCapStyle DeclarativeLineSeries::capStyle() const
71 {
74 {
72 return pen().capStyle();
75 return pen().capStyle();
73 }
76 }
74
77
75 void DeclarativeLineSeries::setCapStyle(Qt::PenCapStyle capStyle)
78 void DeclarativeLineSeries::setCapStyle(Qt::PenCapStyle capStyle)
76 {
79 {
77 if (capStyle != pen().capStyle()) {
80 if (capStyle != pen().capStyle()) {
78 QPen p = pen();
81 QPen p = pen();
79 p.setCapStyle(capStyle);
82 p.setCapStyle(capStyle);
80 setPen(p);
83 setPen(p);
81 emit capStyleChanged(capStyle);
84 emit capStyleChanged(capStyle);
82 }
85 }
83 }
86 }
84
87
85 QDeclarativeListProperty<QObject> DeclarativeLineSeries::declarativeChildren()
88 QDeclarativeListProperty<QObject> DeclarativeLineSeries::declarativeChildren()
86 {
89 {
87 return QDeclarativeListProperty<QObject>(this, 0, &appendDeclarativeChildren);
90 return QDeclarativeListProperty<QObject>(this, 0, &appendDeclarativeChildren);
88 }
91 }
89
92
90 void DeclarativeLineSeries::appendDeclarativeChildren(QDeclarativeListProperty<QObject> *list, QObject *element)
93 void DeclarativeLineSeries::appendDeclarativeChildren(QDeclarativeListProperty<QObject> *list, QObject *element)
91 {
94 {
92 Q_UNUSED(list)
95 Q_UNUSED(list)
93 Q_UNUSED(element)
96 Q_UNUSED(element)
94 // Empty implementation, children are parsed in componentComplete
97 // Empty implementation, children are parsed in componentComplete
95 }
98 }
96
99
97 #include "moc_declarativelineseries.cpp"
100 #include "moc_declarativelineseries.cpp"
98
101
99 QTCOMMERCIALCHART_END_NAMESPACE
102 QTCOMMERCIALCHART_END_NAMESPACE
@@ -1,90 +1,98
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 DECLARATIVELINESERIES_H
21 #ifndef DECLARATIVELINESERIES_H
22 #define DECLARATIVELINESERIES_H
22 #define DECLARATIVELINESERIES_H
23
23
24 #include "qlineseries.h"
24 #include "qlineseries.h"
25 #include "declarativexyseries.h"
25 #include "declarativexyseries.h"
26 #include "declarativeaxes.h"
26 #include <QtDeclarative/QDeclarativeListProperty>
27 #include <QtDeclarative/QDeclarativeListProperty>
27 #include <QtDeclarative/QDeclarativeParserStatus>
28 #include <QtDeclarative/QDeclarativeParserStatus>
28
29
29 QTCOMMERCIALCHART_BEGIN_NAMESPACE
30 QTCOMMERCIALCHART_BEGIN_NAMESPACE
30
31
31 class DeclarativeLineSeries : public QLineSeries, public DeclarativeXySeries, public QDeclarativeParserStatus
32 class DeclarativeLineSeries : public QLineSeries, public DeclarativeXySeries, public QDeclarativeParserStatus
32 {
33 {
33 Q_OBJECT
34 Q_OBJECT
34 Q_INTERFACES(QDeclarativeParserStatus)
35 Q_INTERFACES(QDeclarativeParserStatus)
35 Q_PROPERTY(int count READ count NOTIFY countChanged)
36 Q_PROPERTY(int count READ count NOTIFY countChanged)
36 Q_PROPERTY(QAbstractAxis *axisX READ axisX WRITE setAxisX NOTIFY axisXChanged REVISION 1)
37 Q_PROPERTY(QAbstractAxis *axisX READ axisX WRITE setAxisX NOTIFY axisXChanged REVISION 1)
37 Q_PROPERTY(QAbstractAxis *axisY READ axisY WRITE setAxisY NOTIFY axisYChanged REVISION 1)
38 Q_PROPERTY(QAbstractAxis *axisY READ axisY WRITE setAxisY NOTIFY axisYChanged REVISION 1)
39 Q_PROPERTY(QAbstractAxis *axisXTop READ axisXTop WRITE setAxisXTop NOTIFY axisXTopChanged REVISION 2)
40 Q_PROPERTY(QAbstractAxis *axisYRight READ axisYRight WRITE setAxisYRight NOTIFY axisYRightChanged REVISION 2)
38 Q_PROPERTY(qreal width READ width WRITE setWidth NOTIFY widthChanged REVISION 1)
41 Q_PROPERTY(qreal width READ width WRITE setWidth NOTIFY widthChanged REVISION 1)
39 Q_PROPERTY(Qt::PenStyle style READ style WRITE setStyle NOTIFY styleChanged REVISION 1)
42 Q_PROPERTY(Qt::PenStyle style READ style WRITE setStyle NOTIFY styleChanged REVISION 1)
40 Q_PROPERTY(Qt::PenCapStyle capStyle READ capStyle WRITE setCapStyle NOTIFY capStyleChanged REVISION 1)
43 Q_PROPERTY(Qt::PenCapStyle capStyle READ capStyle WRITE setCapStyle NOTIFY capStyleChanged REVISION 1)
41 Q_PROPERTY(QDeclarativeListProperty<QObject> declarativeChildren READ declarativeChildren)
44 Q_PROPERTY(QDeclarativeListProperty<QObject> declarativeChildren READ declarativeChildren)
42 Q_CLASSINFO("DefaultProperty", "declarativeChildren")
45 Q_CLASSINFO("DefaultProperty", "declarativeChildren")
43
46
44 public:
47 public:
45 explicit DeclarativeLineSeries(QObject *parent = 0);
48 explicit DeclarativeLineSeries(QObject *parent = 0);
46 QXYSeries *xySeries() { return this; }
49 QXYSeries *xySeries() { return this; }
47 QAbstractAxis *axisX() { return m_axisX; }
50 QAbstractAxis *axisX() { return m_axes->axisX(); }
48 void setAxisX(QAbstractAxis *axis) { m_axisX = axis; emit axisXChanged(axis); }
51 void setAxisX(QAbstractAxis *axis) { m_axes->setAxisX(axis); }
49 QAbstractAxis *axisY() { return m_axisY; }
52 QAbstractAxis *axisY() { return m_axes->axisY(); }
50 void setAxisY(QAbstractAxis *axis) { m_axisY = axis; emit axisYChanged(axis); }
53 void setAxisY(QAbstractAxis *axis) { m_axes->setAxisY(axis); }
54 Q_REVISION(2) QAbstractAxis *axisXTop() { return m_axes->axisXTop(); }
55 Q_REVISION(2) void setAxisXTop(QAbstractAxis *axis) { m_axes->setAxisXTop(axis); }
56 Q_REVISION(2) QAbstractAxis *axisYRight() { return m_axes->axisYRight(); }
57 Q_REVISION(2) void setAxisYRight(QAbstractAxis *axis) { m_axes->setAxisYRight(axis); }
51 qreal width() const;
58 qreal width() const;
52 void setWidth(qreal width);
59 void setWidth(qreal width);
53 Qt::PenStyle style() const;
60 Qt::PenStyle style() const;
54 void setStyle(Qt::PenStyle style);
61 void setStyle(Qt::PenStyle style);
55 Qt::PenCapStyle capStyle() const;
62 Qt::PenCapStyle capStyle() const;
56 void setCapStyle(Qt::PenCapStyle capStyle);
63 void setCapStyle(Qt::PenCapStyle capStyle);
57 QDeclarativeListProperty<QObject> declarativeChildren();
64 QDeclarativeListProperty<QObject> declarativeChildren();
58
65
59 public: // from QDeclarativeParserStatus
66 public: // from QDeclarativeParserStatus
60 void classBegin() { DeclarativeXySeries::classBegin(); }
67 void classBegin() { DeclarativeXySeries::classBegin(); }
61 void componentComplete() { DeclarativeXySeries::componentComplete(); }
68 void componentComplete() { DeclarativeXySeries::componentComplete(); }
62
69
63 public:
70 public:
64 Q_INVOKABLE void append(qreal x, qreal y) { DeclarativeXySeries::append(x, y); }
71 Q_INVOKABLE void append(qreal x, qreal y) { DeclarativeXySeries::append(x, y); }
65 Q_INVOKABLE void replace(qreal oldX, qreal oldY, qreal newX, qreal newY) { DeclarativeXySeries::replace(oldX, oldY, newX, newY); }
72 Q_INVOKABLE void replace(qreal oldX, qreal oldY, qreal newX, qreal newY) { DeclarativeXySeries::replace(oldX, oldY, newX, newY); }
66 Q_INVOKABLE void remove(qreal x, qreal y) { DeclarativeXySeries::remove(x, y); }
73 Q_INVOKABLE void remove(qreal x, qreal y) { DeclarativeXySeries::remove(x, y); }
67 Q_INVOKABLE void insert(int index, qreal x, qreal y) { DeclarativeXySeries::insert(index, x, y); }
74 Q_INVOKABLE void insert(int index, qreal x, qreal y) { DeclarativeXySeries::insert(index, x, y); }
68 Q_INVOKABLE void clear() { DeclarativeXySeries::clear(); }
75 Q_INVOKABLE void clear() { DeclarativeXySeries::clear(); }
69 Q_INVOKABLE QPointF at(int index) { return DeclarativeXySeries::at(index); }
76 Q_INVOKABLE QPointF at(int index) { return DeclarativeXySeries::at(index); }
70
77
71 Q_SIGNALS:
78 Q_SIGNALS:
72 void countChanged(int count);
79 void countChanged(int count);
73 Q_REVISION(1) void axisXChanged(QAbstractAxis *axis);
80 Q_REVISION(1) void axisXChanged(QAbstractAxis *axis);
74 Q_REVISION(1) void axisYChanged(QAbstractAxis *axis);
81 Q_REVISION(1) void axisYChanged(QAbstractAxis *axis);
82 Q_REVISION(2) void axisXTopChanged(QAbstractAxis *axis);
83 Q_REVISION(2) void axisYRightChanged(QAbstractAxis *axis);
75 Q_REVISION(1) void widthChanged(qreal width);
84 Q_REVISION(1) void widthChanged(qreal width);
76 Q_REVISION(1) void styleChanged(Qt::PenStyle style);
85 Q_REVISION(1) void styleChanged(Qt::PenStyle style);
77 Q_REVISION(1) void capStyleChanged(Qt::PenCapStyle capStyle);
86 Q_REVISION(1) void capStyleChanged(Qt::PenCapStyle capStyle);
78
87
79 public Q_SLOTS:
88 public Q_SLOTS:
80 static void appendDeclarativeChildren(QDeclarativeListProperty<QObject> *list, QObject *element);
89 static void appendDeclarativeChildren(QDeclarativeListProperty<QObject> *list, QObject *element);
81 void handleCountChanged(int index);
90 void handleCountChanged(int index);
82
91
83 private:
92 public:
84 QAbstractAxis *m_axisX;
93 DeclarativeAxes *m_axes;
85 QAbstractAxis *m_axisY;
86 };
94 };
87
95
88 QTCOMMERCIALCHART_END_NAMESPACE
96 QTCOMMERCIALCHART_END_NAMESPACE
89
97
90 #endif // DECLARATIVELINESERIES_H
98 #endif // DECLARATIVELINESERIES_H
@@ -1,69 +1,72
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 "declarativescatterseries.h"
21 #include "declarativescatterseries.h"
22
22
23 QTCOMMERCIALCHART_BEGIN_NAMESPACE
23 QTCOMMERCIALCHART_BEGIN_NAMESPACE
24
24
25 DeclarativeScatterSeries::DeclarativeScatterSeries(QObject *parent) :
25 DeclarativeScatterSeries::DeclarativeScatterSeries(QObject *parent) :
26 QScatterSeries(parent),
26 QScatterSeries(parent),
27 m_axisX(0),
27 m_axes(new DeclarativeAxes(this))
28 m_axisY(0)
29 {
28 {
29 connect(m_axes, SIGNAL(axisXChanged(QAbstractAxis*)), this, SIGNAL(axisXChanged(QAbstractAxis*)));
30 connect(m_axes, SIGNAL(axisYChanged(QAbstractAxis*)), this, SIGNAL(axisYChanged(QAbstractAxis*)));
31 connect(m_axes, SIGNAL(axisXTopChanged(QAbstractAxis*)), this, SIGNAL(axisXTopChanged(QAbstractAxis*)));
32 connect(m_axes, SIGNAL(axisYRightChanged(QAbstractAxis*)), this, SIGNAL(axisYRightChanged(QAbstractAxis*)));
30 connect(this, SIGNAL(pointAdded(int)), this, SLOT(handleCountChanged(int)));
33 connect(this, SIGNAL(pointAdded(int)), this, SLOT(handleCountChanged(int)));
31 connect(this, SIGNAL(pointRemoved(int)), this, SLOT(handleCountChanged(int)));
34 connect(this, SIGNAL(pointRemoved(int)), this, SLOT(handleCountChanged(int)));
32 }
35 }
33
36
34 void DeclarativeScatterSeries::handleCountChanged(int index)
37 void DeclarativeScatterSeries::handleCountChanged(int index)
35 {
38 {
36 Q_UNUSED(index)
39 Q_UNUSED(index)
37 emit countChanged(QScatterSeries::count());
40 emit countChanged(QScatterSeries::count());
38 }
41 }
39
42
40 qreal DeclarativeScatterSeries::borderWidth() const
43 qreal DeclarativeScatterSeries::borderWidth() const
41 {
44 {
42 return pen().widthF();
45 return pen().widthF();
43 }
46 }
44
47
45 void DeclarativeScatterSeries::setBorderWidth(qreal width)
48 void DeclarativeScatterSeries::setBorderWidth(qreal width)
46 {
49 {
47 if (width != pen().widthF()) {
50 if (width != pen().widthF()) {
48 QPen p = pen();
51 QPen p = pen();
49 p.setWidthF(width);
52 p.setWidthF(width);
50 setPen(p);
53 setPen(p);
51 emit borderWidthChanged(width);
54 emit borderWidthChanged(width);
52 }
55 }
53 }
56 }
54
57
55 QDeclarativeListProperty<QObject> DeclarativeScatterSeries::declarativeChildren()
58 QDeclarativeListProperty<QObject> DeclarativeScatterSeries::declarativeChildren()
56 {
59 {
57 return QDeclarativeListProperty<QObject>(this, 0, &appendDeclarativeChildren);
60 return QDeclarativeListProperty<QObject>(this, 0, &appendDeclarativeChildren);
58 }
61 }
59
62
60 void DeclarativeScatterSeries::appendDeclarativeChildren(QDeclarativeListProperty<QObject> *list, QObject *element)
63 void DeclarativeScatterSeries::appendDeclarativeChildren(QDeclarativeListProperty<QObject> *list, QObject *element)
61 {
64 {
62 Q_UNUSED(list)
65 Q_UNUSED(list)
63 Q_UNUSED(element)
66 Q_UNUSED(element)
64 // Empty implementation, children are parsed in componentComplete
67 // Empty implementation, children are parsed in componentComplete
65 }
68 }
66
69
67 #include "moc_declarativescatterseries.cpp"
70 #include "moc_declarativescatterseries.cpp"
68
71
69 QTCOMMERCIALCHART_END_NAMESPACE
72 QTCOMMERCIALCHART_END_NAMESPACE
@@ -1,82 +1,90
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 DECLARATIVESCATTERSERIES_H
21 #ifndef DECLARATIVESCATTERSERIES_H
22 #define DECLARATIVESCATTERSERIES_H
22 #define DECLARATIVESCATTERSERIES_H
23
23
24 #include "qscatterseries.h"
24 #include "qscatterseries.h"
25 #include "declarativexyseries.h"
25 #include "declarativexyseries.h"
26 #include "declarativeaxes.h"
26 #include <QtDeclarative/QDeclarativeListProperty>
27 #include <QtDeclarative/QDeclarativeListProperty>
27 #include <QtDeclarative/QDeclarativeParserStatus>
28 #include <QtDeclarative/QDeclarativeParserStatus>
28
29
29 QTCOMMERCIALCHART_BEGIN_NAMESPACE
30 QTCOMMERCIALCHART_BEGIN_NAMESPACE
30
31
31 class DeclarativeScatterSeries : public QScatterSeries, public DeclarativeXySeries, public QDeclarativeParserStatus
32 class DeclarativeScatterSeries : public QScatterSeries, public DeclarativeXySeries, public QDeclarativeParserStatus
32 {
33 {
33 Q_OBJECT
34 Q_OBJECT
34 Q_INTERFACES(QDeclarativeParserStatus)
35 Q_INTERFACES(QDeclarativeParserStatus)
35 Q_PROPERTY(int count READ count NOTIFY countChanged)
36 Q_PROPERTY(int count READ count NOTIFY countChanged)
36 Q_PROPERTY(QAbstractAxis *axisX READ axisX WRITE setAxisX NOTIFY axisXChanged REVISION 1)
37 Q_PROPERTY(QAbstractAxis *axisX READ axisX WRITE setAxisX NOTIFY axisXChanged REVISION 1)
37 Q_PROPERTY(QAbstractAxis *axisY READ axisY WRITE setAxisY NOTIFY axisYChanged REVISION 1)
38 Q_PROPERTY(QAbstractAxis *axisY READ axisY WRITE setAxisY NOTIFY axisYChanged REVISION 1)
39 Q_PROPERTY(QAbstractAxis *axisXTop READ axisXTop WRITE setAxisXTop NOTIFY axisXTopChanged REVISION 2)
40 Q_PROPERTY(QAbstractAxis *axisYRight READ axisYRight WRITE setAxisYRight NOTIFY axisYRightChanged REVISION 2)
38 Q_PROPERTY(qreal borderWidth READ borderWidth WRITE setBorderWidth NOTIFY borderWidthChanged REVISION 1)
41 Q_PROPERTY(qreal borderWidth READ borderWidth WRITE setBorderWidth NOTIFY borderWidthChanged REVISION 1)
39 Q_PROPERTY(QDeclarativeListProperty<QObject> declarativeChildren READ declarativeChildren)
42 Q_PROPERTY(QDeclarativeListProperty<QObject> declarativeChildren READ declarativeChildren)
40 Q_CLASSINFO("DefaultProperty", "declarativeChildren")
43 Q_CLASSINFO("DefaultProperty", "declarativeChildren")
41
44
42 public:
45 public:
43 explicit DeclarativeScatterSeries(QObject *parent = 0);
46 explicit DeclarativeScatterSeries(QObject *parent = 0);
44 QXYSeries *xySeries() { return this; }
47 QXYSeries *xySeries() { return this; }
45 QAbstractAxis *axisX() { return m_axisX; }
48 QAbstractAxis *axisX() { return m_axes->axisX(); }
46 void setAxisX(QAbstractAxis *axis) { m_axisX = axis; emit axisXChanged(axis); }
49 void setAxisX(QAbstractAxis *axis) { m_axes->setAxisX(axis); }
47 QAbstractAxis *axisY() { return m_axisY; }
50 QAbstractAxis *axisY() { return m_axes->axisY(); }
48 void setAxisY(QAbstractAxis *axis) { m_axisY = axis; emit axisYChanged(axis); }
51 void setAxisY(QAbstractAxis *axis) { m_axes->setAxisY(axis); }
52 Q_REVISION(2) QAbstractAxis *axisXTop() { return m_axes->axisXTop(); }
53 Q_REVISION(2) void setAxisXTop(QAbstractAxis *axis) { m_axes->setAxisXTop(axis); }
54 Q_REVISION(2) QAbstractAxis *axisYRight() { return m_axes->axisYRight(); }
55 Q_REVISION(2) void setAxisYRight(QAbstractAxis *axis) { m_axes->setAxisYRight(axis); }
49 qreal borderWidth() const;
56 qreal borderWidth() const;
50 void setBorderWidth(qreal borderWidth);
57 void setBorderWidth(qreal borderWidth);
51 QDeclarativeListProperty<QObject> declarativeChildren();
58 QDeclarativeListProperty<QObject> declarativeChildren();
52
59
53 public: // from QDeclarativeParserStatus
60 public: // from QDeclarativeParserStatus
54 void classBegin() { DeclarativeXySeries::classBegin(); }
61 void classBegin() { DeclarativeXySeries::classBegin(); }
55 void componentComplete() { DeclarativeXySeries::componentComplete(); }
62 void componentComplete() { DeclarativeXySeries::componentComplete(); }
56
63
57 public:
64 public:
58 Q_INVOKABLE void append(qreal x, qreal y) { DeclarativeXySeries::append(x, y); }
65 Q_INVOKABLE void append(qreal x, qreal y) { DeclarativeXySeries::append(x, y); }
59 Q_INVOKABLE void replace(qreal oldX, qreal oldY, qreal newX, qreal newY) { DeclarativeXySeries::replace(oldX, oldY, newX, newY); }
66 Q_INVOKABLE void replace(qreal oldX, qreal oldY, qreal newX, qreal newY) { DeclarativeXySeries::replace(oldX, oldY, newX, newY); }
60 Q_INVOKABLE void remove(qreal x, qreal y) { DeclarativeXySeries::remove(x, y); }
67 Q_INVOKABLE void remove(qreal x, qreal y) { DeclarativeXySeries::remove(x, y); }
61 Q_INVOKABLE void insert(int index, qreal x, qreal y) { DeclarativeXySeries::insert(index, x, y); }
68 Q_INVOKABLE void insert(int index, qreal x, qreal y) { DeclarativeXySeries::insert(index, x, y); }
62 Q_INVOKABLE void clear() { DeclarativeXySeries::clear(); }
69 Q_INVOKABLE void clear() { DeclarativeXySeries::clear(); }
63 Q_INVOKABLE QPointF at(int index) { return DeclarativeXySeries::at(index); }
70 Q_INVOKABLE QPointF at(int index) { return DeclarativeXySeries::at(index); }
64
71
65 Q_SIGNALS:
72 Q_SIGNALS:
66 void countChanged(int count);
73 void countChanged(int count);
67 Q_REVISION(1) void axisXChanged(QAbstractAxis *axis);
74 Q_REVISION(1) void axisXChanged(QAbstractAxis *axis);
68 Q_REVISION(1) void axisYChanged(QAbstractAxis *axis);
75 Q_REVISION(1) void axisYChanged(QAbstractAxis *axis);
69 Q_REVISION(1) void borderWidthChanged(qreal width);
76 Q_REVISION(1) void borderWidthChanged(qreal width);
77 Q_REVISION(2) void axisXTopChanged(QAbstractAxis *axis);
78 Q_REVISION(2) void axisYRightChanged(QAbstractAxis *axis);
70
79
71 public Q_SLOTS:
80 public Q_SLOTS:
72 static void appendDeclarativeChildren(QDeclarativeListProperty<QObject> *list, QObject *element);
81 static void appendDeclarativeChildren(QDeclarativeListProperty<QObject> *list, QObject *element);
73 void handleCountChanged(int index);
82 void handleCountChanged(int index);
74
83
75 private:
84 public:
76 QAbstractAxis *m_axisX;
85 DeclarativeAxes *m_axes;
77 QAbstractAxis *m_axisY;
78 };
86 };
79
87
80 QTCOMMERCIALCHART_END_NAMESPACE
88 QTCOMMERCIALCHART_END_NAMESPACE
81
89
82 #endif // DECLARATIVESCATTERSERIES_H
90 #endif // DECLARATIVESCATTERSERIES_H
@@ -1,99 +1,102
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 "declarativesplineseries.h"
21 #include "declarativesplineseries.h"
22
22
23 QTCOMMERCIALCHART_BEGIN_NAMESPACE
23 QTCOMMERCIALCHART_BEGIN_NAMESPACE
24
24
25 DeclarativeSplineSeries::DeclarativeSplineSeries(QObject *parent) :
25 DeclarativeSplineSeries::DeclarativeSplineSeries(QObject *parent) :
26 QSplineSeries(parent),
26 QSplineSeries(parent),
27 m_axisX(0),
27 m_axes(new DeclarativeAxes(this))
28 m_axisY(0)
29 {
28 {
29 connect(m_axes, SIGNAL(axisXChanged(QAbstractAxis*)), this, SIGNAL(axisXChanged(QAbstractAxis*)));
30 connect(m_axes, SIGNAL(axisYChanged(QAbstractAxis*)), this, SIGNAL(axisYChanged(QAbstractAxis*)));
31 connect(m_axes, SIGNAL(axisXTopChanged(QAbstractAxis*)), this, SIGNAL(axisXTopChanged(QAbstractAxis*)));
32 connect(m_axes, SIGNAL(axisYRightChanged(QAbstractAxis*)), this, SIGNAL(axisYRightChanged(QAbstractAxis*)));
30 connect(this, SIGNAL(pointAdded(int)), this, SLOT(handleCountChanged(int)));
33 connect(this, SIGNAL(pointAdded(int)), this, SLOT(handleCountChanged(int)));
31 connect(this, SIGNAL(pointRemoved(int)), this, SLOT(handleCountChanged(int)));
34 connect(this, SIGNAL(pointRemoved(int)), this, SLOT(handleCountChanged(int)));
32 }
35 }
33
36
34 void DeclarativeSplineSeries::handleCountChanged(int index)
37 void DeclarativeSplineSeries::handleCountChanged(int index)
35 {
38 {
36 Q_UNUSED(index)
39 Q_UNUSED(index)
37 emit countChanged(points().count());
40 emit countChanged(points().count());
38 }
41 }
39
42
40 qreal DeclarativeSplineSeries::width() const
43 qreal DeclarativeSplineSeries::width() const
41 {
44 {
42 return pen().widthF();
45 return pen().widthF();
43 }
46 }
44
47
45 void DeclarativeSplineSeries::setWidth(qreal width)
48 void DeclarativeSplineSeries::setWidth(qreal width)
46 {
49 {
47 if (width != pen().widthF()) {
50 if (width != pen().widthF()) {
48 QPen p = pen();
51 QPen p = pen();
49 p.setWidthF(width);
52 p.setWidthF(width);
50 setPen(p);
53 setPen(p);
51 emit widthChanged(width);
54 emit widthChanged(width);
52 }
55 }
53 }
56 }
54
57
55 Qt::PenStyle DeclarativeSplineSeries::style() const
58 Qt::PenStyle DeclarativeSplineSeries::style() const
56 {
59 {
57 return pen().style();
60 return pen().style();
58 }
61 }
59
62
60 void DeclarativeSplineSeries::setStyle(Qt::PenStyle style)
63 void DeclarativeSplineSeries::setStyle(Qt::PenStyle style)
61 {
64 {
62 if (style != pen().style()) {
65 if (style != pen().style()) {
63 QPen p = pen();
66 QPen p = pen();
64 p.setStyle(style);
67 p.setStyle(style);
65 setPen(p);
68 setPen(p);
66 emit styleChanged(style);
69 emit styleChanged(style);
67 }
70 }
68 }
71 }
69
72
70 Qt::PenCapStyle DeclarativeSplineSeries::capStyle() const
73 Qt::PenCapStyle DeclarativeSplineSeries::capStyle() const
71 {
74 {
72 return pen().capStyle();
75 return pen().capStyle();
73 }
76 }
74
77
75 void DeclarativeSplineSeries::setCapStyle(Qt::PenCapStyle capStyle)
78 void DeclarativeSplineSeries::setCapStyle(Qt::PenCapStyle capStyle)
76 {
79 {
77 if (capStyle != pen().capStyle()) {
80 if (capStyle != pen().capStyle()) {
78 QPen p = pen();
81 QPen p = pen();
79 p.setCapStyle(capStyle);
82 p.setCapStyle(capStyle);
80 setPen(p);
83 setPen(p);
81 emit capStyleChanged(capStyle);
84 emit capStyleChanged(capStyle);
82 }
85 }
83 }
86 }
84
87
85 QDeclarativeListProperty<QObject> DeclarativeSplineSeries::declarativeChildren()
88 QDeclarativeListProperty<QObject> DeclarativeSplineSeries::declarativeChildren()
86 {
89 {
87 return QDeclarativeListProperty<QObject>(this, 0, &appendDeclarativeChildren);
90 return QDeclarativeListProperty<QObject>(this, 0, &appendDeclarativeChildren);
88 }
91 }
89
92
90 void DeclarativeSplineSeries::appendDeclarativeChildren(QDeclarativeListProperty<QObject> *list, QObject *element)
93 void DeclarativeSplineSeries::appendDeclarativeChildren(QDeclarativeListProperty<QObject> *list, QObject *element)
91 {
94 {
92 Q_UNUSED(list)
95 Q_UNUSED(list)
93 Q_UNUSED(element)
96 Q_UNUSED(element)
94 // Empty implementation, children are parsed in componentComplete
97 // Empty implementation, children are parsed in componentComplete
95 }
98 }
96
99
97 #include "moc_declarativesplineseries.cpp"
100 #include "moc_declarativesplineseries.cpp"
98
101
99 QTCOMMERCIALCHART_END_NAMESPACE
102 QTCOMMERCIALCHART_END_NAMESPACE
@@ -1,90 +1,98
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 DECLARATIVESPLINESERIES_H
21 #ifndef DECLARATIVESPLINESERIES_H
22 #define DECLARATIVESPLINESERIES_H
22 #define DECLARATIVESPLINESERIES_H
23
23
24 #include "qsplineseries.h"
24 #include "qsplineseries.h"
25 #include "declarativexyseries.h"
25 #include "declarativexyseries.h"
26 #include "declarativeaxes.h"
26 #include <QtDeclarative/QDeclarativeListProperty>
27 #include <QtDeclarative/QDeclarativeListProperty>
27 #include <QtDeclarative/QDeclarativeParserStatus>
28 #include <QtDeclarative/QDeclarativeParserStatus>
28
29
29 QTCOMMERCIALCHART_BEGIN_NAMESPACE
30 QTCOMMERCIALCHART_BEGIN_NAMESPACE
30
31
31 class DeclarativeSplineSeries : public QSplineSeries, public DeclarativeXySeries, public QDeclarativeParserStatus
32 class DeclarativeSplineSeries : public QSplineSeries, public DeclarativeXySeries, public QDeclarativeParserStatus
32 {
33 {
33 Q_OBJECT
34 Q_OBJECT
34 Q_INTERFACES(QDeclarativeParserStatus)
35 Q_INTERFACES(QDeclarativeParserStatus)
35 Q_PROPERTY(int count READ count NOTIFY countChanged)
36 Q_PROPERTY(int count READ count NOTIFY countChanged)
36 Q_PROPERTY(QAbstractAxis *axisX READ axisX WRITE setAxisX NOTIFY axisXChanged REVISION 1)
37 Q_PROPERTY(QAbstractAxis *axisX READ axisX WRITE setAxisX NOTIFY axisXChanged REVISION 1)
37 Q_PROPERTY(QAbstractAxis *axisY READ axisY WRITE setAxisY NOTIFY axisYChanged REVISION 1)
38 Q_PROPERTY(QAbstractAxis *axisY READ axisY WRITE setAxisY NOTIFY axisYChanged REVISION 1)
39 Q_PROPERTY(QAbstractAxis *axisXTop READ axisXTop WRITE setAxisXTop NOTIFY axisXTopChanged REVISION 2)
40 Q_PROPERTY(QAbstractAxis *axisYRight READ axisYRight WRITE setAxisYRight NOTIFY axisYRightChanged REVISION 2)
38 Q_PROPERTY(qreal width READ width WRITE setWidth NOTIFY widthChanged REVISION 1)
41 Q_PROPERTY(qreal width READ width WRITE setWidth NOTIFY widthChanged REVISION 1)
39 Q_PROPERTY(Qt::PenStyle style READ style WRITE setStyle NOTIFY styleChanged REVISION 1)
42 Q_PROPERTY(Qt::PenStyle style READ style WRITE setStyle NOTIFY styleChanged REVISION 1)
40 Q_PROPERTY(Qt::PenCapStyle capStyle READ capStyle WRITE setCapStyle NOTIFY capStyleChanged REVISION 1)
43 Q_PROPERTY(Qt::PenCapStyle capStyle READ capStyle WRITE setCapStyle NOTIFY capStyleChanged REVISION 1)
41 Q_PROPERTY(QDeclarativeListProperty<QObject> declarativeChildren READ declarativeChildren)
44 Q_PROPERTY(QDeclarativeListProperty<QObject> declarativeChildren READ declarativeChildren)
42 Q_CLASSINFO("DefaultProperty", "declarativeChildren")
45 Q_CLASSINFO("DefaultProperty", "declarativeChildren")
43
46
44 public:
47 public:
45 explicit DeclarativeSplineSeries(QObject *parent = 0);
48 explicit DeclarativeSplineSeries(QObject *parent = 0);
46 QXYSeries *xySeries() { return this; }
49 QXYSeries *xySeries() { return this; }
47 QAbstractAxis *axisX() { return m_axisX; }
50 QAbstractAxis *axisX() { return m_axes->axisX(); }
48 void setAxisX(QAbstractAxis *axis) { m_axisX = axis; emit axisXChanged(axis); }
51 void setAxisX(QAbstractAxis *axis) { m_axes->setAxisX(axis); }
49 QAbstractAxis *axisY() { return m_axisY; }
52 QAbstractAxis *axisY() { return m_axes->axisY(); }
50 void setAxisY(QAbstractAxis *axis) { m_axisY = axis; emit axisYChanged(axis); }
53 void setAxisY(QAbstractAxis *axis) { m_axes->setAxisY(axis); }
54 Q_REVISION(2) QAbstractAxis *axisXTop() { return m_axes->axisXTop(); }
55 Q_REVISION(2) void setAxisXTop(QAbstractAxis *axis) { m_axes->setAxisXTop(axis); }
56 Q_REVISION(2) QAbstractAxis *axisYRight() { return m_axes->axisYRight(); }
57 Q_REVISION(2) void setAxisYRight(QAbstractAxis *axis) { m_axes->setAxisYRight(axis); }
51 qreal width() const;
58 qreal width() const;
52 void setWidth(qreal width);
59 void setWidth(qreal width);
53 Qt::PenStyle style() const;
60 Qt::PenStyle style() const;
54 void setStyle(Qt::PenStyle style);
61 void setStyle(Qt::PenStyle style);
55 Qt::PenCapStyle capStyle() const;
62 Qt::PenCapStyle capStyle() const;
56 void setCapStyle(Qt::PenCapStyle capStyle);
63 void setCapStyle(Qt::PenCapStyle capStyle);
57 QDeclarativeListProperty<QObject> declarativeChildren();
64 QDeclarativeListProperty<QObject> declarativeChildren();
58
65
59 public: // from QDeclarativeParserStatus
66 public: // from QDeclarativeParserStatus
60 void classBegin() { DeclarativeXySeries::classBegin(); }
67 void classBegin() { DeclarativeXySeries::classBegin(); }
61 void componentComplete() { DeclarativeXySeries::componentComplete(); }
68 void componentComplete() { DeclarativeXySeries::componentComplete(); }
62
69
63 public:
70 public:
64 Q_INVOKABLE void append(qreal x, qreal y) { DeclarativeXySeries::append(x, y); }
71 Q_INVOKABLE void append(qreal x, qreal y) { DeclarativeXySeries::append(x, y); }
65 Q_INVOKABLE void replace(qreal oldX, qreal oldY, qreal newX, qreal newY) { DeclarativeXySeries::replace(oldX, oldY, newX, newY); }
72 Q_INVOKABLE void replace(qreal oldX, qreal oldY, qreal newX, qreal newY) { DeclarativeXySeries::replace(oldX, oldY, newX, newY); }
66 Q_INVOKABLE void remove(qreal x, qreal y) { DeclarativeXySeries::remove(x, y); }
73 Q_INVOKABLE void remove(qreal x, qreal y) { DeclarativeXySeries::remove(x, y); }
67 Q_INVOKABLE void insert(int index, qreal x, qreal y) { DeclarativeXySeries::insert(index, x, y); }
74 Q_INVOKABLE void insert(int index, qreal x, qreal y) { DeclarativeXySeries::insert(index, x, y); }
68 Q_INVOKABLE void clear() { DeclarativeXySeries::clear(); }
75 Q_INVOKABLE void clear() { DeclarativeXySeries::clear(); }
69 Q_INVOKABLE QPointF at(int index) { return DeclarativeXySeries::at(index); }
76 Q_INVOKABLE QPointF at(int index) { return DeclarativeXySeries::at(index); }
70
77
71 Q_SIGNALS:
78 Q_SIGNALS:
72 void countChanged(int count);
79 void countChanged(int count);
73 Q_REVISION(1) void axisXChanged(QAbstractAxis *axis);
80 Q_REVISION(1) void axisXChanged(QAbstractAxis *axis);
74 Q_REVISION(1) void axisYChanged(QAbstractAxis *axis);
81 Q_REVISION(1) void axisYChanged(QAbstractAxis *axis);
82 Q_REVISION(2) void axisXTopChanged(QAbstractAxis *axis);
83 Q_REVISION(2) void axisYRightChanged(QAbstractAxis *axis);
75 Q_REVISION(1) void widthChanged(qreal width);
84 Q_REVISION(1) void widthChanged(qreal width);
76 Q_REVISION(1) void styleChanged(Qt::PenStyle style);
85 Q_REVISION(1) void styleChanged(Qt::PenStyle style);
77 Q_REVISION(1) void capStyleChanged(Qt::PenCapStyle capStyle);
86 Q_REVISION(1) void capStyleChanged(Qt::PenCapStyle capStyle);
78
87
79 public Q_SLOTS:
88 public Q_SLOTS:
80 static void appendDeclarativeChildren(QDeclarativeListProperty<QObject> *list, QObject *element);
89 static void appendDeclarativeChildren(QDeclarativeListProperty<QObject> *list, QObject *element);
81 void handleCountChanged(int index);
90 void handleCountChanged(int index);
82
91
83 public:
92 public:
84 QAbstractAxis *m_axisX;
93 DeclarativeAxes *m_axes;
85 QAbstractAxis *m_axisY;
86 };
94 };
87
95
88 QTCOMMERCIALCHART_END_NAMESPACE
96 QTCOMMERCIALCHART_END_NAMESPACE
89
97
90 #endif // DECLARATIVESPLINESERIES_H
98 #endif // DECLARATIVESPLINESERIES_H
@@ -1,215 +1,230
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 "qvxymodelmapper.h"
35 #include "qvxymodelmapper.h"
35 #include "qhxymodelmapper.h"
36 #include "qhxymodelmapper.h"
36 #include "qhpiemodelmapper.h"
37 #include "qhpiemodelmapper.h"
37 #include "qvpiemodelmapper.h"
38 #include "qvpiemodelmapper.h"
38 #include "qhbarmodelmapper.h"
39 #include "qhbarmodelmapper.h"
39 #include "qvbarmodelmapper.h"
40 #include "qvbarmodelmapper.h"
40 #include "declarativemargins.h"
41 #include "declarativemargins.h"
41 #include "qarealegendmarker.h"
42 #include "qarealegendmarker.h"
42 #include "qbarlegendmarker.h"
43 #include "qbarlegendmarker.h"
43 #include "qpielegendmarker.h"
44 #include "qpielegendmarker.h"
44 #include "qxylegendmarker.h"
45 #include "qxylegendmarker.h"
45 #ifndef QT_ON_ARM
46 #ifndef QT_ON_ARM
46 #include "qdatetimeaxis.h"
47 #include "qdatetimeaxis.h"
47 #endif
48 #endif
48 #include <QAbstractItemModel>
49 #include <QAbstractItemModel>
49 #include <QtDeclarative/qdeclarativeextensionplugin.h>
50 #include <QtDeclarative/qdeclarativeextensionplugin.h>
50 #include <QtDeclarative/qdeclarative.h>
51 #include <QtDeclarative/qdeclarative.h>
51
52
52 QTCOMMERCIALCHART_USE_NAMESPACE
53 QTCOMMERCIALCHART_USE_NAMESPACE
53
54
54 Q_DECLARE_METATYPE(QList<QPieSlice *>)
55 Q_DECLARE_METATYPE(QList<QPieSlice *>)
55 Q_DECLARE_METATYPE(QList<QBarSet *>)
56 Q_DECLARE_METATYPE(QList<QBarSet *>)
57 Q_DECLARE_METATYPE(QList<QAbstractAxis *>)
56
58
57 #if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
59 #if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
58
60
59 // NOTE: Hackish fixes for Qt5 (beta2).
61 // NOTE: Hackish fixes for Qt5 (beta2).
60 // 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.
61
63
62 Q_DECLARE_METATYPE(DeclarativeChart::SeriesType)
64 Q_DECLARE_METATYPE(DeclarativeChart::SeriesType)
63 Q_DECLARE_METATYPE(DeclarativeMargins *)
65 Q_DECLARE_METATYPE(DeclarativeMargins *)
64 Q_DECLARE_METATYPE(DeclarativeAreaSeries *)
66 Q_DECLARE_METATYPE(DeclarativeAreaSeries *)
65 Q_DECLARE_METATYPE(DeclarativeBarSeries *)
67 Q_DECLARE_METATYPE(DeclarativeBarSeries *)
66 Q_DECLARE_METATYPE(DeclarativeLineSeries *)
68 Q_DECLARE_METATYPE(DeclarativeLineSeries *)
67 Q_DECLARE_METATYPE(DeclarativePieSeries *)
69 Q_DECLARE_METATYPE(DeclarativePieSeries *)
68 Q_DECLARE_METATYPE(DeclarativeScatterSeries *)
70 Q_DECLARE_METATYPE(DeclarativeScatterSeries *)
69 Q_DECLARE_METATYPE(DeclarativeSplineSeries *)
71 Q_DECLARE_METATYPE(DeclarativeSplineSeries *)
70
72
71 Q_DECLARE_METATYPE(QAbstractAxis *)
73 Q_DECLARE_METATYPE(QAbstractAxis *)
72 Q_DECLARE_METATYPE(QValueAxis *)
74 Q_DECLARE_METATYPE(QValueAxis *)
73 Q_DECLARE_METATYPE(QBarCategoryAxis *)
75 Q_DECLARE_METATYPE(QBarCategoryAxis *)
74 Q_DECLARE_METATYPE(QCategoryAxis *)
76 Q_DECLARE_METATYPE(QCategoryAxis *)
75 Q_DECLARE_METATYPE(QDateTimeAxis *)
77 Q_DECLARE_METATYPE(QDateTimeAxis *)
76
78
77 Q_DECLARE_METATYPE(QLegend *)
79 Q_DECLARE_METATYPE(QLegend *)
78 Q_DECLARE_METATYPE(QLegendMarker *)
80 Q_DECLARE_METATYPE(QLegendMarker *)
79 Q_DECLARE_METATYPE(QAreaLegendMarker *)
81 Q_DECLARE_METATYPE(QAreaLegendMarker *)
80 Q_DECLARE_METATYPE(QBarLegendMarker *)
82 Q_DECLARE_METATYPE(QBarLegendMarker *)
81 Q_DECLARE_METATYPE(QPieLegendMarker *)
83 Q_DECLARE_METATYPE(QPieLegendMarker *)
82
84
83 Q_DECLARE_METATYPE(QHPieModelMapper *)
85 Q_DECLARE_METATYPE(QHPieModelMapper *)
84 Q_DECLARE_METATYPE(QHXYModelMapper *)
86 Q_DECLARE_METATYPE(QHXYModelMapper *)
85 Q_DECLARE_METATYPE(QPieModelMapper *)
87 Q_DECLARE_METATYPE(QPieModelMapper *)
86 Q_DECLARE_METATYPE(QHBarModelMapper *)
88 Q_DECLARE_METATYPE(QHBarModelMapper *)
87 Q_DECLARE_METATYPE(QBarModelMapper *)
89 Q_DECLARE_METATYPE(QBarModelMapper *)
88 Q_DECLARE_METATYPE(QVBarModelMapper *)
90 Q_DECLARE_METATYPE(QVBarModelMapper *)
89 Q_DECLARE_METATYPE(QVPieModelMapper *)
91 Q_DECLARE_METATYPE(QVPieModelMapper *)
90 Q_DECLARE_METATYPE(QVXYModelMapper *)
92 Q_DECLARE_METATYPE(QVXYModelMapper *)
91 Q_DECLARE_METATYPE(QXYLegendMarker *)
93 Q_DECLARE_METATYPE(QXYLegendMarker *)
92 Q_DECLARE_METATYPE(QXYModelMapper *)
94 Q_DECLARE_METATYPE(QXYModelMapper *)
93
95
94 Q_DECLARE_METATYPE(QAbstractSeries *)
96 Q_DECLARE_METATYPE(QAbstractSeries *)
95 Q_DECLARE_METATYPE(QXYSeries *)
97 Q_DECLARE_METATYPE(QXYSeries *)
96 Q_DECLARE_METATYPE(QAbstractBarSeries *)
98 Q_DECLARE_METATYPE(QAbstractBarSeries *)
97 Q_DECLARE_METATYPE(QBarSeries *)
99 Q_DECLARE_METATYPE(QBarSeries *)
98 Q_DECLARE_METATYPE(QBarSet *)
100 Q_DECLARE_METATYPE(QBarSet *)
99 Q_DECLARE_METATYPE(QAreaSeries *)
101 Q_DECLARE_METATYPE(QAreaSeries *)
100 Q_DECLARE_METATYPE(QHorizontalBarSeries *)
102 Q_DECLARE_METATYPE(QHorizontalBarSeries *)
101 Q_DECLARE_METATYPE(QHorizontalPercentBarSeries *)
103 Q_DECLARE_METATYPE(QHorizontalPercentBarSeries *)
102 Q_DECLARE_METATYPE(QHorizontalStackedBarSeries *)
104 Q_DECLARE_METATYPE(QHorizontalStackedBarSeries *)
103 Q_DECLARE_METATYPE(QLineSeries *)
105 Q_DECLARE_METATYPE(QLineSeries *)
104 Q_DECLARE_METATYPE(QPercentBarSeries *)
106 Q_DECLARE_METATYPE(QPercentBarSeries *)
105 Q_DECLARE_METATYPE(QPieSeries *)
107 Q_DECLARE_METATYPE(QPieSeries *)
106 Q_DECLARE_METATYPE(QPieSlice *)
108 Q_DECLARE_METATYPE(QPieSlice *)
107 Q_DECLARE_METATYPE(QScatterSeries *)
109 Q_DECLARE_METATYPE(QScatterSeries *)
108 Q_DECLARE_METATYPE(QSplineSeries *)
110 Q_DECLARE_METATYPE(QSplineSeries *)
109 Q_DECLARE_METATYPE(QStackedBarSeries *)
111 Q_DECLARE_METATYPE(QStackedBarSeries *)
110
112
111 #endif
113 #endif
112
114
113 QTCOMMERCIALCHART_BEGIN_NAMESPACE
115 QTCOMMERCIALCHART_BEGIN_NAMESPACE
114
116
115 class ChartQmlPlugin : public QDeclarativeExtensionPlugin
117 class ChartQmlPlugin : public QDeclarativeExtensionPlugin
116 {
118 {
117 Q_OBJECT
119 Q_OBJECT
118
120
119 #if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
121 #if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
120 Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QDeclarativeExtensionInterface")
122 Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QDeclarativeExtensionInterface")
121 #endif
123 #endif
122
124
123 public:
125 public:
124 virtual void registerTypes(const char *uri)
126 virtual void registerTypes(const char *uri)
125 {
127 {
126 Q_ASSERT(QLatin1String(uri) == QLatin1String("QtCommercial.Chart"));
128 Q_ASSERT(QLatin1String(uri) == QLatin1String("QtCommercial.Chart"));
127
129
128 qRegisterMetaType<QList<QPieSlice *> >();
130 qRegisterMetaType<QList<QPieSlice *> >();
129 qRegisterMetaType<QList<QBarSet *> >();
131 qRegisterMetaType<QList<QBarSet *> >();
132 qRegisterMetaType<QList<QAbstractAxis *> >();
130 #if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
133 #if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
131 qRegisterMetaType<DeclarativeChart::SeriesType>();
134 qRegisterMetaType<DeclarativeChart::SeriesType>();
132 #endif
135 #endif
133
136
134 // QtCommercial.Chart 1.0
137 // QtCommercial.Chart 1.0
135 qmlRegisterType<DeclarativeChart>(uri, 1, 0, "ChartView");
138 qmlRegisterType<DeclarativeChart>(uri, 1, 0, "ChartView");
136 qmlRegisterType<DeclarativeXYPoint>(uri, 1, 0, "XYPoint");
139 qmlRegisterType<DeclarativeXYPoint>(uri, 1, 0, "XYPoint");
137 qmlRegisterType<DeclarativeScatterSeries>(uri, 1, 0, "ScatterSeries");
140 qmlRegisterType<DeclarativeScatterSeries>(uri, 1, 0, "ScatterSeries");
138 qmlRegisterType<DeclarativeLineSeries>(uri, 1, 0, "LineSeries");
141 qmlRegisterType<DeclarativeLineSeries>(uri, 1, 0, "LineSeries");
139 qmlRegisterType<DeclarativeSplineSeries>(uri, 1, 0, "SplineSeries");
142 qmlRegisterType<DeclarativeSplineSeries>(uri, 1, 0, "SplineSeries");
140 qmlRegisterType<DeclarativeAreaSeries>(uri, 1, 0, "AreaSeries");
143 qmlRegisterType<DeclarativeAreaSeries>(uri, 1, 0, "AreaSeries");
141 qmlRegisterType<DeclarativeBarSeries>(uri, 1, 0, "BarSeries");
144 qmlRegisterType<DeclarativeBarSeries>(uri, 1, 0, "BarSeries");
142 qmlRegisterType<DeclarativeStackedBarSeries>(uri, 1, 0, "StackedBarSeries");
145 qmlRegisterType<DeclarativeStackedBarSeries>(uri, 1, 0, "StackedBarSeries");
143 qmlRegisterType<DeclarativePercentBarSeries>(uri, 1, 0, "PercentBarSeries");
146 qmlRegisterType<DeclarativePercentBarSeries>(uri, 1, 0, "PercentBarSeries");
144 qmlRegisterType<DeclarativePieSeries>(uri, 1, 0, "PieSeries");
147 qmlRegisterType<DeclarativePieSeries>(uri, 1, 0, "PieSeries");
145 qmlRegisterType<QPieSlice>(uri, 1, 0, "PieSlice");
148 qmlRegisterType<QPieSlice>(uri, 1, 0, "PieSlice");
146 qmlRegisterType<DeclarativeBarSet>(uri, 1, 0, "BarSet");
149 qmlRegisterType<DeclarativeBarSet>(uri, 1, 0, "BarSet");
147 qmlRegisterType<QHXYModelMapper>(uri, 1, 0, "HXYModelMapper");
150 qmlRegisterType<QHXYModelMapper>(uri, 1, 0, "HXYModelMapper");
148 qmlRegisterType<QVXYModelMapper>(uri, 1, 0, "VXYModelMapper");
151 qmlRegisterType<QVXYModelMapper>(uri, 1, 0, "VXYModelMapper");
149 qmlRegisterType<QHPieModelMapper>(uri, 1, 0, "HPieModelMapper");
152 qmlRegisterType<QHPieModelMapper>(uri, 1, 0, "HPieModelMapper");
150 qmlRegisterType<QVPieModelMapper>(uri, 1, 0, "VPieModelMapper");
153 qmlRegisterType<QVPieModelMapper>(uri, 1, 0, "VPieModelMapper");
151 qmlRegisterType<QHBarModelMapper>(uri, 1, 0, "HBarModelMapper");
154 qmlRegisterType<QHBarModelMapper>(uri, 1, 0, "HBarModelMapper");
152 qmlRegisterType<QVBarModelMapper>(uri, 1, 0, "VBarModelMapper");
155 qmlRegisterType<QVBarModelMapper>(uri, 1, 0, "VBarModelMapper");
153 qmlRegisterType<QValueAxis>(uri, 1, 0, "ValuesAxis");
156 qmlRegisterType<QValueAxis>(uri, 1, 0, "ValuesAxis");
154 qmlRegisterType<QBarCategoryAxis>(uri, 1, 0, "BarCategoriesAxis");
157 qmlRegisterType<QBarCategoryAxis>(uri, 1, 0, "BarCategoriesAxis");
155 qmlRegisterUncreatableType<QLegend>(uri, 1, 0, "Legend",
158 qmlRegisterUncreatableType<QLegend>(uri, 1, 0, "Legend",
156 QLatin1String("Trying to create uncreatable: Legend."));
159 QLatin1String("Trying to create uncreatable: Legend."));
157 qmlRegisterUncreatableType<QXYSeries>(uri, 1, 0, "XYSeries",
160 qmlRegisterUncreatableType<QXYSeries>(uri, 1, 0, "XYSeries",
158 QLatin1String("Trying to create uncreatable: XYSeries."));
161 QLatin1String("Trying to create uncreatable: XYSeries."));
159 qmlRegisterUncreatableType<QAbstractItemModel>(uri, 1, 0, "AbstractItemModel",
162 qmlRegisterUncreatableType<QAbstractItemModel>(uri, 1, 0, "AbstractItemModel",
160 QLatin1String("Trying to create uncreatable: AbstractItemModel."));
163 QLatin1String("Trying to create uncreatable: AbstractItemModel."));
161 qmlRegisterUncreatableType<QXYModelMapper>(uri, 1, 0, "XYModelMapper",
164 qmlRegisterUncreatableType<QXYModelMapper>(uri, 1, 0, "XYModelMapper",
162 QLatin1String("Trying to create uncreatable: XYModelMapper."));
165 QLatin1String("Trying to create uncreatable: XYModelMapper."));
163 qmlRegisterUncreatableType<QPieModelMapper>(uri, 1, 0, "PieModelMapper",
166 qmlRegisterUncreatableType<QPieModelMapper>(uri, 1, 0, "PieModelMapper",
164 QLatin1String("Trying to create uncreatable: PieModelMapper."));
167 QLatin1String("Trying to create uncreatable: PieModelMapper."));
165 qmlRegisterUncreatableType<QBarModelMapper>(uri, 1, 0, "BarModelMapper",
168 qmlRegisterUncreatableType<QBarModelMapper>(uri, 1, 0, "BarModelMapper",
166 QLatin1String("Trying to create uncreatable: BarModelMapper."));
169 QLatin1String("Trying to create uncreatable: BarModelMapper."));
167 qmlRegisterUncreatableType<QAbstractSeries>(uri, 1, 0, "AbstractSeries",
170 qmlRegisterUncreatableType<QAbstractSeries>(uri, 1, 0, "AbstractSeries",
168 QLatin1String("Trying to create uncreatable: AbstractSeries."));
171 QLatin1String("Trying to create uncreatable: AbstractSeries."));
169 qmlRegisterUncreatableType<QAbstractBarSeries>(uri, 1, 0, "AbstractBarSeries",
172 qmlRegisterUncreatableType<QAbstractBarSeries>(uri, 1, 0, "AbstractBarSeries",
170 QLatin1String("Trying to create uncreatable: AbstractBarSeries."));
173 QLatin1String("Trying to create uncreatable: AbstractBarSeries."));
171 qmlRegisterUncreatableType<QAbstractAxis>(uri, 1, 0, "AbstractAxis",
174 qmlRegisterUncreatableType<QAbstractAxis>(uri, 1, 0, "AbstractAxis",
172 QLatin1String("Trying to create uncreatable: AbstractAxis. Use specific types of axis instead."));
175 QLatin1String("Trying to create uncreatable: AbstractAxis. Use specific types of axis instead."));
173 qmlRegisterUncreatableType<QBarSet>(uri, 1, 0, "BarSetBase",
176 qmlRegisterUncreatableType<QBarSet>(uri, 1, 0, "BarSetBase",
174 QLatin1String("Trying to create uncreatable: BarsetBase."));
177 QLatin1String("Trying to create uncreatable: BarsetBase."));
175 qmlRegisterUncreatableType<QPieSeries>(uri, 1, 0, "QPieSeries",
178 qmlRegisterUncreatableType<QPieSeries>(uri, 1, 0, "QPieSeries",
176 QLatin1String("Trying to create uncreatable: QPieSeries. Use PieSeries instead."));
179 QLatin1String("Trying to create uncreatable: QPieSeries. Use PieSeries instead."));
180 qmlRegisterUncreatableType<DeclarativeAxes>(uri, 1, 0, "DeclarativeAxes",
181 QLatin1String("Trying to create uncreatable: DeclarativeAxes."));
177
182
178 // QtCommercial.Chart 1.1
183 // QtCommercial.Chart 1.1
179 qmlRegisterType<DeclarativeChart, 1>(uri, 1, 1, "ChartView");
184 qmlRegisterType<DeclarativeChart, 1>(uri, 1, 1, "ChartView");
180 qmlRegisterType<DeclarativeScatterSeries, 1>(uri, 1, 1, "ScatterSeries");
185 qmlRegisterType<DeclarativeScatterSeries, 1>(uri, 1, 1, "ScatterSeries");
181 qmlRegisterType<DeclarativeLineSeries, 1>(uri, 1, 1, "LineSeries");
186 qmlRegisterType<DeclarativeLineSeries, 1>(uri, 1, 1, "LineSeries");
182 qmlRegisterType<DeclarativeSplineSeries, 1>(uri, 1, 1, "SplineSeries");
187 qmlRegisterType<DeclarativeSplineSeries, 1>(uri, 1, 1, "SplineSeries");
183 qmlRegisterType<DeclarativeAreaSeries, 1>(uri, 1, 1, "AreaSeries");
188 qmlRegisterType<DeclarativeAreaSeries, 1>(uri, 1, 1, "AreaSeries");
184 qmlRegisterType<DeclarativeBarSeries, 1>(uri, 1, 1, "BarSeries");
189 qmlRegisterType<DeclarativeBarSeries, 1>(uri, 1, 1, "BarSeries");
185 qmlRegisterType<DeclarativeStackedBarSeries, 1>(uri, 1, 1, "StackedBarSeries");
190 qmlRegisterType<DeclarativeStackedBarSeries, 1>(uri, 1, 1, "StackedBarSeries");
186 qmlRegisterType<DeclarativePercentBarSeries, 1>(uri, 1, 1, "PercentBarSeries");
191 qmlRegisterType<DeclarativePercentBarSeries, 1>(uri, 1, 1, "PercentBarSeries");
187 qmlRegisterType<DeclarativeHorizontalBarSeries, 1>(uri, 1, 1, "HorizontalBarSeries");
192 qmlRegisterType<DeclarativeHorizontalBarSeries, 1>(uri, 1, 1, "HorizontalBarSeries");
188 qmlRegisterType<DeclarativeHorizontalStackedBarSeries, 1>(uri, 1, 1, "HorizontalStackedBarSeries");
193 qmlRegisterType<DeclarativeHorizontalStackedBarSeries, 1>(uri, 1, 1, "HorizontalStackedBarSeries");
189 qmlRegisterType<DeclarativeHorizontalPercentBarSeries, 1>(uri, 1, 1, "HorizontalPercentBarSeries");
194 qmlRegisterType<DeclarativeHorizontalPercentBarSeries, 1>(uri, 1, 1, "HorizontalPercentBarSeries");
190 qmlRegisterType<DeclarativePieSeries>(uri, 1, 1, "PieSeries");
195 qmlRegisterType<DeclarativePieSeries>(uri, 1, 1, "PieSeries");
191 qmlRegisterType<DeclarativeBarSet>(uri, 1, 1, "BarSet");
196 qmlRegisterType<DeclarativeBarSet>(uri, 1, 1, "BarSet");
192 qmlRegisterType<QValueAxis>(uri, 1, 1, "ValueAxis");
197 qmlRegisterType<QValueAxis>(uri, 1, 1, "ValueAxis");
193 #ifndef QT_ON_ARM
198 #ifndef QT_ON_ARM
194 qmlRegisterType<QDateTimeAxis>(uri, 1, 1, "DateTimeAxis");
199 qmlRegisterType<QDateTimeAxis>(uri, 1, 1, "DateTimeAxis");
195 #endif
200 #endif
196 qmlRegisterType<DeclarativeCategoryAxis>(uri, 1, 1, "CategoryAxis");
201 qmlRegisterType<DeclarativeCategoryAxis>(uri, 1, 1, "CategoryAxis");
197 qmlRegisterType<DeclarativeCategoryRange>(uri, 1, 1, "CategoryRange");
202 qmlRegisterType<DeclarativeCategoryRange>(uri, 1, 1, "CategoryRange");
198 qmlRegisterType<QBarCategoryAxis>(uri, 1, 1, "BarCategoryAxis");
203 qmlRegisterType<QBarCategoryAxis>(uri, 1, 1, "BarCategoryAxis");
199 qmlRegisterUncreatableType<DeclarativeMargins>(uri, 1, 1, "Margins",
204 qmlRegisterUncreatableType<DeclarativeMargins>(uri, 1, 1, "Margins",
200 QLatin1String("Trying to create uncreatable: Margins."));
205 QLatin1String("Trying to create uncreatable: Margins."));
201
206
202 // QtCommercial.Chart 1.2
207 // QtCommercial.Chart 1.2
203 qmlRegisterType<DeclarativeChart, 2>(uri, 1, 2, "ChartView");
208 qmlRegisterType<DeclarativeChart, 2>(uri, 1, 2, "ChartView");
209 qmlRegisterType<DeclarativeScatterSeries, 2>(uri, 1, 2, "ScatterSeries");
210 qmlRegisterType<DeclarativeLineSeries, 2>(uri, 1, 2, "LineSeries");
211 qmlRegisterType<DeclarativeSplineSeries, 2>(uri, 1, 2, "SplineSeries");
212 qmlRegisterType<DeclarativeAreaSeries, 2>(uri, 1, 2, "AreaSeries");
213 qmlRegisterType<DeclarativeBarSeries, 2>(uri, 1, 2, "BarSeries");
214 qmlRegisterType<DeclarativeStackedBarSeries, 2>(uri, 1, 2, "StackedBarSeries");
215 qmlRegisterType<DeclarativePercentBarSeries, 2>(uri, 1, 2, "PercentBarSeries");
216 qmlRegisterType<DeclarativeHorizontalBarSeries, 2>(uri, 1, 2, "HorizontalBarSeries");
217 qmlRegisterType<DeclarativeHorizontalStackedBarSeries, 2>(uri, 1, 2, "HorizontalStackedBarSeries");
218 qmlRegisterType<DeclarativeHorizontalPercentBarSeries, 2>(uri, 1, 2, "HorizontalPercentBarSeries");
204 }
219 }
205 };
220 };
206
221
207 #include "plugin.moc"
222 #include "plugin.moc"
208
223
209 QTCOMMERCIALCHART_END_NAMESPACE
224 QTCOMMERCIALCHART_END_NAMESPACE
210
225
211 QTCOMMERCIALCHART_USE_NAMESPACE
226 QTCOMMERCIALCHART_USE_NAMESPACE
212
227
213 #if (QT_VERSION < QT_VERSION_CHECK(5, 0, 0))
228 #if (QT_VERSION < QT_VERSION_CHECK(5, 0, 0))
214 Q_EXPORT_PLUGIN2(qtcommercialchartqml, QT_PREPEND_NAMESPACE(ChartQmlPlugin))
229 Q_EXPORT_PLUGIN2(qtcommercialchartqml, QT_PREPEND_NAMESPACE(ChartQmlPlugin))
215 #endif
230 #endif
@@ -1,657 +1,665
1 /****************************************************************************
1 /****************************************************************************
2 **
2 **
3 ** Copyright (C) 2012 Digia Plc
3 ** Copyright (C) 2012 Digia Plc
4 ** All rights reserved.
4 ** All rights reserved.
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 **
6 **
7 ** This file is part of the Qt Commercial Charts Add-on.
7 ** This file is part of the Qt Commercial Charts Add-on.
8 **
8 **
9 ** $QT_BEGIN_LICENSE$
9 ** $QT_BEGIN_LICENSE$
10 ** Licensees holding valid Qt Commercial licenses may use this file in
10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 ** accordance with the Qt Commercial License Agreement provided with the
11 ** accordance with the Qt Commercial License Agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia.
13 ** a written agreement between you and Digia.
14 **
14 **
15 ** If you have questions regarding the use of this file, please use
15 ** If you have questions regarding the use of this file, please use
16 ** contact form at http://qt.digia.com
16 ** contact form at http://qt.digia.com
17 ** $QT_END_LICENSE$
17 ** $QT_END_LICENSE$
18 **
18 **
19 ****************************************************************************/
19 ****************************************************************************/
20
20
21 #include "qchart.h"
21 #include "qchart.h"
22 #include "qchart_p.h"
22 #include "qchart_p.h"
23 #include "legendscroller_p.h"
23 #include "legendscroller_p.h"
24 #include "qlegend_p.h"
24 #include "qlegend_p.h"
25 #include "chartbackground_p.h"
25 #include "chartbackground_p.h"
26 #include "qabstractaxis.h"
26 #include "qabstractaxis.h"
27 #include "chartlayout_p.h"
27 #include "chartlayout_p.h"
28 #include "charttheme_p.h"
28 #include "charttheme_p.h"
29 #include "chartpresenter_p.h"
29 #include "chartpresenter_p.h"
30 #include "chartdataset_p.h"
30 #include "chartdataset_p.h"
31 #include <QGraphicsScene>
31 #include <QGraphicsScene>
32 #include <QGraphicsSceneResizeEvent>
32 #include <QGraphicsSceneResizeEvent>
33
33
34 QTCOMMERCIALCHART_BEGIN_NAMESPACE
34 QTCOMMERCIALCHART_BEGIN_NAMESPACE
35
35
36 /*!
36 /*!
37 \enum QChart::ChartTheme
37 \enum QChart::ChartTheme
38
38
39 This enum describes the theme used by the chart.
39 This enum describes the theme used by the chart.
40
40
41 \value ChartThemeLight The default theme
41 \value ChartThemeLight The default theme
42 \value ChartThemeBlueCerulean
42 \value ChartThemeBlueCerulean
43 \value ChartThemeDark
43 \value ChartThemeDark
44 \value ChartThemeBrownSand
44 \value ChartThemeBrownSand
45 \value ChartThemeBlueNcs
45 \value ChartThemeBlueNcs
46 \value ChartThemeHighContrast
46 \value ChartThemeHighContrast
47 \value ChartThemeBlueIcy
47 \value ChartThemeBlueIcy
48 */
48 */
49
49
50 /*!
50 /*!
51 \enum QChart::AnimationOption
51 \enum QChart::AnimationOption
52
52
53 For enabling/disabling animations. Defaults to NoAnimation.
53 For enabling/disabling animations. Defaults to NoAnimation.
54
54
55 \value NoAnimation
55 \value NoAnimation
56 \value GridAxisAnimations
56 \value GridAxisAnimations
57 \value SeriesAnimations
57 \value SeriesAnimations
58 \value AllAnimations
58 \value AllAnimations
59 */
59 */
60
60
61 /*!
61 /*!
62 \class QChart
62 \class QChart
63 \brief QtCommercial chart API.
63 \brief QtCommercial chart API.
64
64
65 QChart is a QGraphicsWidget that you can show in a QGraphicsScene. It manages the graphical
65 QChart is a QGraphicsWidget that you can show in a QGraphicsScene. It manages the graphical
66 representation of different types of series and other chart related objects like
66 representation of different types of series and other chart related objects like
67 QAxis and QLegend. If you simply want to show a chart in a layout, you can use the
67 QAxis and QLegend. If you simply want to show a chart in a layout, you can use the
68 convenience class QChartView instead of QChart.
68 convenience class QChartView instead of QChart.
69 \sa QChartView
69 \sa QChartView
70 */
70 */
71
71
72 /*!
72 /*!
73 \property QChart::animationOptions
73 \property QChart::animationOptions
74 The animation \a options for the chart. Animations are enabled/disabled based on this setting.
74 The animation \a options for the chart. Animations are enabled/disabled based on this setting.
75 */
75 */
76
76
77 /*!
77 /*!
78 \property QChart::backgroundVisible
78 \property QChart::backgroundVisible
79 Whether the chart background is visible or not.
79 Whether the chart background is visible or not.
80 \sa setBackgroundBrush(), setBackgroundPen()
80 \sa setBackgroundBrush(), setBackgroundPen()
81 */
81 */
82
82
83 /*!
83 /*!
84 \property QChart::dropShadowEnabled
84 \property QChart::dropShadowEnabled
85 If set to true, the background drop shadow effect is enabled. If set to false, it is disabled. Note that the drop
85 If set to true, the background drop shadow effect is enabled. If set to false, it is disabled. Note that the drop
86 shadow effect depends on theme, which means the setting may be changed if you switch to another theme.
86 shadow effect depends on theme, which means the setting may be changed if you switch to another theme.
87 */
87 */
88
88
89 /*!
89 /*!
90 \property QChart::minimumMargins
90 \property QChart::minimumMargins
91 Minimum margins between the plot area (axes) and the edge of the chart widget.
91 Minimum margins between the plot area (axes) and the edge of the chart widget.
92 */
92 */
93
93
94 /*!
94 /*!
95 \property QChart::theme
95 \property QChart::theme
96 Theme is a built-in collection of UI style related settings applied for all visual elements of a chart, like colors,
96 Theme is a built-in collection of UI style related settings applied for all visual elements of a chart, like colors,
97 pens, brushes and fonts of series, axes, title and legend. \l {Chart themes demo} shows an example with a few
97 pens, brushes and fonts of series, axes, title and legend. \l {Chart themes demo} shows an example with a few
98 different themes.
98 different themes.
99 Note: changing the theme will overwrite all customizations previously applied to the series.
99 Note: changing the theme will overwrite all customizations previously applied to the series.
100 */
100 */
101
101
102 /*!
102 /*!
103 \property QChart::title
103 \property QChart::title
104 Title is the name (label) of a chart. It is shown as a headline on top of the chart.
104 Title is the name (label) of a chart. It is shown as a headline on top of the chart.
105 */
105 */
106
106
107 /*!
107 /*!
108 Constructs a chart object which is a child of a\a parent. Parameter \a wFlags is passed to the QGraphicsWidget constructor.
108 Constructs a chart object which is a child of a\a parent. Parameter \a wFlags is passed to the QGraphicsWidget constructor.
109 */
109 */
110 QChart::QChart(QGraphicsItem *parent, Qt::WindowFlags wFlags)
110 QChart::QChart(QGraphicsItem *parent, Qt::WindowFlags wFlags)
111 : QGraphicsWidget(parent, wFlags),
111 : QGraphicsWidget(parent, wFlags),
112 d_ptr(new QChartPrivate(this))
112 d_ptr(new QChartPrivate(this))
113 {
113 {
114 d_ptr->m_legend = new LegendScroller(this);
114 d_ptr->m_legend = new LegendScroller(this);
115 setTheme(QChart::ChartThemeLight);
115 setTheme(QChart::ChartThemeLight);
116 //TODO: what is that ?
116 //TODO: what is that ?
117 //connect(d_ptr->m_presenter, SIGNAL(marginsChanged(QRectF)), this, SIGNAL(marginsChanged(QRectF)));
117 //connect(d_ptr->m_presenter, SIGNAL(marginsChanged(QRectF)), this, SIGNAL(marginsChanged(QRectF)));
118 setLayout(d_ptr->m_presenter->layout());
118 setLayout(d_ptr->m_presenter->layout());
119 }
119 }
120
120
121 /*!
121 /*!
122 Destroys the object and it's children, like series and axis objects added to it.
122 Destroys the object and it's children, like series and axis objects added to it.
123 */
123 */
124 QChart::~QChart()
124 QChart::~QChart()
125 {
125 {
126 //start by deleting dataset, it will remove all series and axes
126 //start by deleting dataset, it will remove all series and axes
127 delete d_ptr->m_dataset;
127 delete d_ptr->m_dataset;
128 d_ptr->m_dataset = 0;
128 d_ptr->m_dataset = 0;
129 }
129 }
130
130
131 /*!
131 /*!
132 Adds the \a series onto the chart and takes the ownership of the object.
132 Adds the \a series onto the chart and takes the ownership of the object.
133 If auto scaling is enabled, re-scales the axes the series is bound to (both the x axis and
133 If auto scaling is enabled, re-scales the axes the series is bound to (both the x axis and
134 the y axis).
134 the y axis).
135
135
136 \sa removeSeries(), removeAllSeries()
136 \sa removeSeries(), removeAllSeries()
137 */
137 */
138 void QChart::addSeries(QAbstractSeries *series)
138 void QChart::addSeries(QAbstractSeries *series)
139 {
139 {
140 Q_ASSERT(series);
140 Q_ASSERT(series);
141 d_ptr->m_dataset->addSeries(series);
141 d_ptr->m_dataset->addSeries(series);
142 }
142 }
143
143
144 /*!
144 /*!
145 Removes the \a series specified in a perameter from the QChartView.
145 Removes the \a series specified in a perameter from the QChartView.
146 It releses its ownership of the specified QChartSeries object.
146 It releses its ownership of the specified QChartSeries object.
147 It does not delete the pointed QChartSeries data object
147 It does not delete the pointed QChartSeries data object
148 \sa addSeries(), removeAllSeries()
148 \sa addSeries(), removeAllSeries()
149 */
149 */
150 void QChart::removeSeries(QAbstractSeries *series)
150 void QChart::removeSeries(QAbstractSeries *series)
151 {
151 {
152 Q_ASSERT(series);
152 Q_ASSERT(series);
153 d_ptr->m_dataset->removeSeries(series);
153 d_ptr->m_dataset->removeSeries(series);
154 }
154 }
155
155
156 /*!
156 /*!
157 Removes all the QChartSeries that have been added to the QChartView
157 Removes all the QChartSeries that have been added to the QChartView
158 It also deletes the pointed QChartSeries data objects
158 It also deletes the pointed QChartSeries data objects
159 \sa addSeries(), removeSeries()
159 \sa addSeries(), removeSeries()
160 */
160 */
161 void QChart::removeAllSeries()
161 void QChart::removeAllSeries()
162 {
162 {
163 foreach (QAbstractSeries *s , d_ptr->m_dataset->series()){
163 foreach (QAbstractSeries *s , d_ptr->m_dataset->series()){
164 removeSeries(s);
164 removeSeries(s);
165 delete s;
165 delete s;
166 }
166 }
167 }
167 }
168
168
169 /*!
169 /*!
170 Sets the \a brush that is used for painting the background of the chart area.
170 Sets the \a brush that is used for painting the background of the chart area.
171 */
171 */
172 void QChart::setBackgroundBrush(const QBrush &brush)
172 void QChart::setBackgroundBrush(const QBrush &brush)
173 {
173 {
174 d_ptr->m_presenter->setBackgroundBrush(brush);
174 d_ptr->m_presenter->setBackgroundBrush(brush);
175 }
175 }
176
176
177 /*!
177 /*!
178 Gets the brush that is used for painting the background of the chart area.
178 Gets the brush that is used for painting the background of the chart area.
179 */
179 */
180 QBrush QChart::backgroundBrush() const
180 QBrush QChart::backgroundBrush() const
181 {
181 {
182 return d_ptr->m_presenter->backgroundBrush();
182 return d_ptr->m_presenter->backgroundBrush();
183 }
183 }
184
184
185 /*!
185 /*!
186 Sets the \a pen that is used for painting the background of the chart area.
186 Sets the \a pen that is used for painting the background of the chart area.
187 */
187 */
188 void QChart::setBackgroundPen(const QPen &pen)
188 void QChart::setBackgroundPen(const QPen &pen)
189 {
189 {
190 d_ptr->m_presenter->setBackgroundPen(pen);
190 d_ptr->m_presenter->setBackgroundPen(pen);
191 }
191 }
192
192
193 /*!
193 /*!
194 Gets the pen that is used for painting the background of the chart area.
194 Gets the pen that is used for painting the background of the chart area.
195 */
195 */
196 QPen QChart::backgroundPen() const
196 QPen QChart::backgroundPen() const
197 {
197 {
198 return d_ptr->m_presenter->backgroundPen();
198 return d_ptr->m_presenter->backgroundPen();
199 }
199 }
200
200
201 /*!
201 /*!
202 Sets the chart \a title. The description text that is drawn above the chart.
202 Sets the chart \a title. The description text that is drawn above the chart.
203 */
203 */
204 void QChart::setTitle(const QString &title)
204 void QChart::setTitle(const QString &title)
205 {
205 {
206 d_ptr->m_presenter->setTitle(title);
206 d_ptr->m_presenter->setTitle(title);
207 }
207 }
208
208
209 /*!
209 /*!
210 Returns the chart title. The description text that is drawn above the chart.
210 Returns the chart title. The description text that is drawn above the chart.
211 */
211 */
212 QString QChart::title() const
212 QString QChart::title() const
213 {
213 {
214 return d_ptr->m_presenter->title();
214 return d_ptr->m_presenter->title();
215 }
215 }
216
216
217 /*!
217 /*!
218 Sets the \a font that is used for drawing the chart description text that is rendered above the chart.
218 Sets the \a font that is used for drawing the chart description text that is rendered above the chart.
219 */
219 */
220 void QChart::setTitleFont(const QFont &font)
220 void QChart::setTitleFont(const QFont &font)
221 {
221 {
222 d_ptr->m_presenter->setTitleFont(font);
222 d_ptr->m_presenter->setTitleFont(font);
223 }
223 }
224
224
225 /*!
225 /*!
226 Gets the font that is used for drawing the chart description text that is rendered above the chart.
226 Gets the font that is used for drawing the chart description text that is rendered above the chart.
227 */
227 */
228 QFont QChart::titleFont() const
228 QFont QChart::titleFont() const
229 {
229 {
230 return d_ptr->m_presenter->titleFont();
230 return d_ptr->m_presenter->titleFont();
231 }
231 }
232
232
233 /*!
233 /*!
234 Sets the \a brush used for rendering the title text.
234 Sets the \a brush used for rendering the title text.
235 */
235 */
236 void QChart::setTitleBrush(const QBrush &brush)
236 void QChart::setTitleBrush(const QBrush &brush)
237 {
237 {
238 d_ptr->m_presenter->setTitleBrush(brush);
238 d_ptr->m_presenter->setTitleBrush(brush);
239 }
239 }
240
240
241 /*!
241 /*!
242 Returns the brush used for rendering the title text.
242 Returns the brush used for rendering the title text.
243 */
243 */
244 QBrush QChart::titleBrush() const
244 QBrush QChart::titleBrush() const
245 {
245 {
246 return d_ptr->m_presenter->titleBrush();
246 return d_ptr->m_presenter->titleBrush();
247 }
247 }
248
248
249 void QChart::setTheme(QChart::ChartTheme theme)
249 void QChart::setTheme(QChart::ChartTheme theme)
250 {
250 {
251 d_ptr->m_themeManager->setTheme(theme);
251 d_ptr->m_themeManager->setTheme(theme);
252 }
252 }
253
253
254 QChart::ChartTheme QChart::theme() const
254 QChart::ChartTheme QChart::theme() const
255 {
255 {
256 return d_ptr->m_themeManager->theme()->id();
256 return d_ptr->m_themeManager->theme()->id();
257 }
257 }
258
258
259 /*!
259 /*!
260 Zooms in the view by a factor of 2
260 Zooms in the view by a factor of 2
261 */
261 */
262 void QChart::zoomIn()
262 void QChart::zoomIn()
263 {
263 {
264 d_ptr->zoomIn(2.0);
264 d_ptr->zoomIn(2.0);
265 }
265 }
266
266
267 /*!
267 /*!
268 Zooms in the view to a maximum level at which \a rect is still fully visible.
268 Zooms in the view to a maximum level at which \a rect is still fully visible.
269 */
269 */
270 void QChart::zoomIn(const QRectF &rect)
270 void QChart::zoomIn(const QRectF &rect)
271 {
271 {
272 d_ptr->zoomIn(rect);
272 d_ptr->zoomIn(rect);
273 }
273 }
274
274
275 /*!
275 /*!
276 Restores the view zoom level to the previous one.
276 Restores the view zoom level to the previous one.
277 */
277 */
278 void QChart::zoomOut()
278 void QChart::zoomOut()
279 {
279 {
280 d_ptr->zoomOut(2.0);
280 d_ptr->zoomOut(2.0);
281 }
281 }
282
282
283 /*!
283 /*!
284 Zooms in the view by a \a factor.
284 Zooms in the view by a \a factor.
285
285
286 A factor over 1.0 zooms the view in and factor between 0.0 and 1.0 zooms out.
286 A factor over 1.0 zooms the view in and factor between 0.0 and 1.0 zooms out.
287 */
287 */
288 void QChart::zoom(qreal factor)
288 void QChart::zoom(qreal factor)
289 {
289 {
290 if (qFuzzyCompare(factor, 0))
290 if (qFuzzyCompare(factor, 0))
291 return;
291 return;
292
292
293 if (qFuzzyCompare(factor, (qreal)1.0))
293 if (qFuzzyCompare(factor, (qreal)1.0))
294 return;
294 return;
295
295
296 if (factor < 0)
296 if (factor < 0)
297 return;
297 return;
298
298
299 if (factor > 1.0)
299 if (factor > 1.0)
300 d_ptr->zoomIn(factor);
300 d_ptr->zoomIn(factor);
301 else
301 else
302 d_ptr->zoomOut(1.0 / factor);
302 d_ptr->zoomOut(1.0 / factor);
303 }
303 }
304
304
305 /*!
305 /*!
306 Returns the pointer to the x axis object of the chart asociated with the specified \a series
306 Returns the pointer to the x axis object of the chart asociated with the specified \a series
307 If no series is provided then pointer to currently visible axis is provided
307 If no series is provided then pointer to currently visible axis is provided
308 */
308 */
309 QAbstractAxis *QChart::axisX(QAbstractSeries *series) const
309 QAbstractAxis *QChart::axisX(QAbstractSeries *series) const
310 {
310 {
311 if(!series && d_ptr->m_dataset->series().size()>0){
311 if(!series && d_ptr->m_dataset->series().size()>0){
312 series = d_ptr->m_dataset->series().first();
312 series = d_ptr->m_dataset->series().first();
313 }
313 }
314
314
315 QList<QAbstractAxis*> axes = series->attachedAxes();
315 QList<QAbstractAxis*> axes = series->attachedAxes();
316 QAbstractAxis* bottom=0;
316 QAbstractAxis* bottom=0;
317 QAbstractAxis* top=0;
317 QAbstractAxis* top=0;
318
318
319 foreach(QAbstractAxis* axis, axes){
319 foreach(QAbstractAxis* axis, axes){
320
320
321 if(axis->alignment()==Qt::AlignTop){
321 if(axis->alignment()==Qt::AlignTop){
322 top=axis;
322 top=axis;
323 }
323 }
324
324
325 if(axis->alignment()==Qt::AlignBottom){
325 if(axis->alignment()==Qt::AlignBottom){
326 bottom=axis;
326 bottom=axis;
327 }
327 }
328 }
328 }
329 return bottom?bottom:top;
329 return bottom?bottom:top;
330 }
330 }
331
331
332 /*!
332 /*!
333 Returns the pointer to the y axis object of the chart asociated with the specified \a series
333 Returns the pointer to the y axis object of the chart asociated with the specified \a series
334 If no series is provided then pointer to currently visible axis is provided
334 If no series is provided then pointer to currently visible axis is provided
335 */
335 */
336 QAbstractAxis *QChart::axisY(QAbstractSeries *series) const
336 QAbstractAxis *QChart::axisY(QAbstractSeries *series) const
337 {
337 {
338 if(!series && d_ptr->m_dataset->series().size()>0) {
338 if(!series && d_ptr->m_dataset->series().size()>0) {
339 series = d_ptr->m_dataset->series().first();
339 series = d_ptr->m_dataset->series().first();
340 }
340 }
341
341
342 QList<QAbstractAxis*> axes = series->attachedAxes();
342 QList<QAbstractAxis*> axes = series->attachedAxes();
343
343
344 QAbstractAxis* left=0;
344 QAbstractAxis* left=0;
345 QAbstractAxis* right=0;
345 QAbstractAxis* right=0;
346
346
347 foreach(QAbstractAxis* axis, axes){
347 foreach(QAbstractAxis* axis, axes){
348
348
349 if(axis->alignment()==Qt::AlignLeft){
349 if(axis->alignment()==Qt::AlignLeft){
350 left=axis;
350 left=axis;
351 }
351 }
352
352
353 if(axis->alignment()==Qt::AlignRight){
353 if(axis->alignment()==Qt::AlignRight){
354 right=axis;
354 right=axis;
355 }
355 }
356 }
356 }
357
357
358 return left?left:right;
358 return left?left:right;
359 }
359 }
360
360
361
362 QList<QAbstractAxis *> QChart::axes(Qt::Orientations orientation, QAbstractSeries *series) const
361 QList<QAbstractAxis *> QChart::axes(Qt::Orientations orientation, QAbstractSeries *series) const
363 {
362 {
364 QList<QAbstractAxis *> result ;
363 QList<QAbstractAxis *> result ;
365
364
366 foreach(QAbstractAxis* axis,series->attachedAxes()){
365 if (series) {
367 if(orientation.testFlag(axis->orientation()))
366 foreach (QAbstractAxis *axis, series->attachedAxes()){
368 result << axis;
367 if (orientation.testFlag(axis->orientation()))
368 result << axis;
369 }
370 } else {
371 foreach (QAbstractSeries *s, QChart::series()) {
372 foreach (QAbstractAxis *axis, s->attachedAxes()){
373 if (orientation.testFlag(axis->orientation()))
374 result << axis;
375 }
376 }
369 }
377 }
370
378
371 return result;
379 return result;
372 }
380 }
373
381
374 /*!
382 /*!
375 NOTICE: This function has to be called after series has been added to the chart if no customized axes are set to the chart. Otherwise axisX(), axisY() calls return NULL.
383 NOTICE: This function has to be called after series has been added to the chart if no customized axes are set to the chart. Otherwise axisX(), axisY() calls return NULL.
376
384
377 Creates the axes for the chart based on the series that has already been added to the chart.
385 Creates the axes for the chart based on the series that has already been added to the chart.
378
386
379 \table
387 \table
380 \header
388 \header
381 \o Series type
389 \o Series type
382 \o X-axis
390 \o X-axis
383 \o Y-axis
391 \o Y-axis
384 \row
392 \row
385 \o QXYSeries
393 \o QXYSeries
386 \o QValueAxis
394 \o QValueAxis
387 \o QValueAxis
395 \o QValueAxis
388 \row
396 \row
389 \o QBarSeries
397 \o QBarSeries
390 \o QBarCategoryAxis
398 \o QBarCategoryAxis
391 \o QValueAxis
399 \o QValueAxis
392 \row
400 \row
393 \o QPieSeries
401 \o QPieSeries
394 \o None
402 \o None
395 \o None
403 \o None
396 \endtable
404 \endtable
397
405
398 If there are several QXYSeries derived series added to the chart and no other series type has been added then only one pair of axes is created.
406 If there are several QXYSeries derived series added to the chart and no other series type has been added then only one pair of axes is created.
399 If there are sevaral series added of different types then each series gets its own axes pair.
407 If there are sevaral series added of different types then each series gets its own axes pair.
400
408
401 NOTICE: if there is more than one x and y axes created then no axis is drawn by default and one needs to choose explicitly which axis should be shown.
409 NOTICE: if there is more than one x and y axes created then no axis is drawn by default and one needs to choose explicitly which axis should be shown.
402
410
403 Axis specifix to the series can be later obtained from the chart by providing the series as the parameter of axisX(), axisY() function calls.
411 Axis specifix to the series can be later obtained from the chart by providing the series as the parameter of axisX(), axisY() function calls.
404 QPieSeries does not create any axes.
412 QPieSeries does not create any axes.
405
413
406 \sa axisX(), axisY(), setAxisX(), setAxisY()
414 \sa axisX(), axisY(), setAxisX(), setAxisY()
407 */
415 */
408 void QChart::createDefaultAxes()
416 void QChart::createDefaultAxes()
409 {
417 {
410 d_ptr->m_dataset->createDefaultAxes();
418 d_ptr->m_dataset->createDefaultAxes();
411 }
419 }
412
420
413 /*!
421 /*!
414 Returns the legend object of the chart. Ownership stays in chart.
422 Returns the legend object of the chart. Ownership stays in chart.
415 */
423 */
416 QLegend *QChart::legend() const
424 QLegend *QChart::legend() const
417 {
425 {
418 return d_ptr->m_legend;
426 return d_ptr->m_legend;
419 }
427 }
420
428
421 /*!
429 /*!
422 Sets the minimum \a margins between the plot area (axes) and the edge of the chart widget.
430 Sets the minimum \a margins between the plot area (axes) and the edge of the chart widget.
423 Deprecated. Use setMargins().
431 Deprecated. Use setMargins().
424 */
432 */
425 void QChart::setMinimumMargins(const QMargins &margins)
433 void QChart::setMinimumMargins(const QMargins &margins)
426 {
434 {
427 qWarning() << "QChart::setMinimumMargins is deprecated. Use QChart::setMargins instead.";
435 qWarning() << "QChart::setMinimumMargins is deprecated. Use QChart::setMargins instead.";
428 d_ptr->m_presenter->layout()->setMargins(margins);
436 d_ptr->m_presenter->layout()->setMargins(margins);
429 }
437 }
430
438
431 /*!
439 /*!
432 Returns the rect that contains information about margins (distance between chart widget edge and axes).
440 Returns the rect that contains information about margins (distance between chart widget edge and axes).
433 Individual margins can be obtained by calling left, top, right, bottom on the returned rect.
441 Individual margins can be obtained by calling left, top, right, bottom on the returned rect.
434 Deprecated. Use margins().
442 Deprecated. Use margins().
435 */
443 */
436 QMargins QChart::minimumMargins() const
444 QMargins QChart::minimumMargins() const
437 {
445 {
438 qWarning() << "QChart::minimumMargins is deprecated. Use QChart::margins instead.";
446 qWarning() << "QChart::minimumMargins is deprecated. Use QChart::margins instead.";
439 return d_ptr->m_presenter->layout()->margins();
447 return d_ptr->m_presenter->layout()->margins();
440 }
448 }
441
449
442 /*!
450 /*!
443 Sets the minimum \a margins between the plot area (axes) and the edge of the chart widget.
451 Sets the minimum \a margins between the plot area (axes) and the edge of the chart widget.
444 */
452 */
445 void QChart::setMargins(const QMargins &margins)
453 void QChart::setMargins(const QMargins &margins)
446 {
454 {
447 d_ptr->m_presenter->layout()->setMargins(margins);
455 d_ptr->m_presenter->layout()->setMargins(margins);
448 }
456 }
449
457
450 /*!
458 /*!
451 Returns the rect that contains information about margins (distance between chart widget edge and axes).
459 Returns the rect that contains information about margins (distance between chart widget edge and axes).
452 Individual margins can be obtained by calling left, top, right, bottom on the returned rect.
460 Individual margins can be obtained by calling left, top, right, bottom on the returned rect.
453 */
461 */
454 QMargins QChart::margins() const
462 QMargins QChart::margins() const
455 {
463 {
456 return d_ptr->m_presenter->layout()->margins();
464 return d_ptr->m_presenter->layout()->margins();
457 }
465 }
458
466
459 /*!
467 /*!
460 Returns the the rect within which the drawing of the chart is done.
468 Returns the the rect within which the drawing of the chart is done.
461 It does not include the area defines by margins.
469 It does not include the area defines by margins.
462 */
470 */
463 QRectF QChart::plotArea() const
471 QRectF QChart::plotArea() const
464 {
472 {
465 return d_ptr->m_presenter->geometry();
473 return d_ptr->m_presenter->geometry();
466 }
474 }
467
475
468 ///*!
476 ///*!
469 // TODO: Dummy.
477 // TODO: Dummy.
470 // Adjest the ranges of the axes so that all the data of the specified \a series is visible
478 // Adjest the ranges of the axes so that all the data of the specified \a series is visible
471 // */
479 // */
472 //void QChart::adjustViewToSeries(QAbstractSeries* series)
480 //void QChart::adjustViewToSeries(QAbstractSeries* series)
473 //{
481 //{
474 // //
482 // //
475 //}
483 //}
476
484
477 /*!
485 /*!
478 Sets animation \a options for the chart
486 Sets animation \a options for the chart
479 */
487 */
480 void QChart::setAnimationOptions(AnimationOptions options)
488 void QChart::setAnimationOptions(AnimationOptions options)
481 {
489 {
482 d_ptr->m_presenter->setAnimationOptions(options);
490 d_ptr->m_presenter->setAnimationOptions(options);
483 }
491 }
484
492
485 QChart::AnimationOptions QChart::animationOptions() const
493 QChart::AnimationOptions QChart::animationOptions() const
486 {
494 {
487 return d_ptr->m_presenter->animationOptions();
495 return d_ptr->m_presenter->animationOptions();
488 }
496 }
489
497
490 /*!
498 /*!
491 Scrolls the visible area of the chart by the distance defined in the \a dx and \a dy.
499 Scrolls the visible area of the chart by the distance defined in the \a dx and \a dy.
492 */
500 */
493 void QChart::scroll(qreal dx, qreal dy)
501 void QChart::scroll(qreal dx, qreal dy)
494 {
502 {
495 d_ptr->scroll(dx,dy);
503 d_ptr->scroll(dx,dy);
496 }
504 }
497
505
498 void QChart::setBackgroundVisible(bool visible)
506 void QChart::setBackgroundVisible(bool visible)
499 {
507 {
500 d_ptr->m_presenter->setBackgroundVisible(visible);
508 d_ptr->m_presenter->setBackgroundVisible(visible);
501 }
509 }
502
510
503 bool QChart::isBackgroundVisible() const
511 bool QChart::isBackgroundVisible() const
504 {
512 {
505 return d_ptr->m_presenter->isBackgroundVisible();
513 return d_ptr->m_presenter->isBackgroundVisible();
506 }
514 }
507
515
508 void QChart::setDropShadowEnabled(bool enabled)
516 void QChart::setDropShadowEnabled(bool enabled)
509 {
517 {
510 d_ptr->m_presenter->setBackgroundDropShadowEnabled(enabled);
518 d_ptr->m_presenter->setBackgroundDropShadowEnabled(enabled);
511 }
519 }
512
520
513 bool QChart::isDropShadowEnabled() const
521 bool QChart::isDropShadowEnabled() const
514 {
522 {
515 return d_ptr->m_presenter->isBackgroundDropShadowEnabled();
523 return d_ptr->m_presenter->isBackgroundDropShadowEnabled();
516 }
524 }
517
525
518 /*!
526 /*!
519 Returns all the series that are added to the chart.
527 Returns all the series that are added to the chart.
520
528
521 \sa addSeries(), removeSeries(), removeAllSeries()
529 \sa addSeries(), removeSeries(), removeAllSeries()
522 */
530 */
523 QList<QAbstractSeries *> QChart::series() const
531 QList<QAbstractSeries *> QChart::series() const
524 {
532 {
525 return d_ptr->m_dataset->series();
533 return d_ptr->m_dataset->series();
526 }
534 }
527
535
528 /*!
536 /*!
529 Sets \a axis to the chart, which will control the presentation of the \a series
537 Sets \a axis to the chart, which will control the presentation of the \a series
530
538
531 \sa axisX(), axisY(), setAxisY(), createDefaultAxes()
539 \sa axisX(), axisY(), setAxisY(), createDefaultAxes()
532 */
540 */
533 void QChart::setAxisX(QAbstractAxis *axis , QAbstractSeries *series)
541 void QChart::setAxisX(QAbstractAxis *axis , QAbstractSeries *series)
534 {
542 {
535 QList<QAbstractAxis*> list = axes(Qt::Horizontal,series);
543 QList<QAbstractAxis*> list = axes(Qt::Horizontal,series);
536
544
537 foreach(QAbstractAxis* a, list){
545 foreach(QAbstractAxis* a, list){
538 d_ptr->m_dataset->removeAxis(a);
546 d_ptr->m_dataset->removeAxis(a);
539 delete a;
547 delete a;
540 }
548 }
541
549
542 if(!d_ptr->m_dataset->axes().contains(axis))
550 if(!d_ptr->m_dataset->axes().contains(axis))
543 d_ptr->m_dataset->addAxis(axis,Qt::AlignBottom);
551 d_ptr->m_dataset->addAxis(axis,Qt::AlignBottom);
544 d_ptr->m_dataset->attachAxis(series,axis);
552 d_ptr->m_dataset->attachAxis(series,axis);
545 }
553 }
546
554
547 /*!
555 /*!
548 Sets \a axis to the chart, which will control the presentation of the \a series
556 Sets \a axis to the chart, which will control the presentation of the \a series
549
557
550 \sa axisX(), axisY(), setAxisX(), createDefaultAxes()
558 \sa axisX(), axisY(), setAxisX(), createDefaultAxes()
551 */
559 */
552 void QChart::setAxisY(QAbstractAxis *axis , QAbstractSeries *series)
560 void QChart::setAxisY(QAbstractAxis *axis , QAbstractSeries *series)
553 {
561 {
554 QList<QAbstractAxis*> list = axes(Qt::Vertical,series);
562 QList<QAbstractAxis*> list = axes(Qt::Vertical,series);
555
563
556 foreach(QAbstractAxis* a, list) {
564 foreach(QAbstractAxis* a, list) {
557 d_ptr->m_dataset->removeAxis(a);
565 d_ptr->m_dataset->removeAxis(a);
558 delete a;
566 delete a;
559 }
567 }
560
568
561 if(!d_ptr->m_dataset->axes().contains(axis))
569 if(!d_ptr->m_dataset->axes().contains(axis))
562 d_ptr->m_dataset->addAxis(axis,Qt::AlignLeft);
570 d_ptr->m_dataset->addAxis(axis,Qt::AlignLeft);
563 d_ptr->m_dataset->attachAxis(series,axis);
571 d_ptr->m_dataset->attachAxis(series,axis);
564 }
572 }
565
573
566 void QChart::addAxis(QAbstractAxis *axis,Qt::Alignment aligment)
574 void QChart::addAxis(QAbstractAxis *axis,Qt::Alignment aligment)
567 {
575 {
568 d_ptr->m_dataset->addAxis(axis,aligment);
576 d_ptr->m_dataset->addAxis(axis,aligment);
569 }
577 }
570
578
571 void QChart::removeAxis(QAbstractAxis *axis)
579 void QChart::removeAxis(QAbstractAxis *axis)
572 {
580 {
573 d_ptr->m_dataset->removeAxis(axis);
581 d_ptr->m_dataset->removeAxis(axis);
574 }
582 }
575
583
576 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
584 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
577
585
578 QChartPrivate::QChartPrivate(QChart *q):
586 QChartPrivate::QChartPrivate(QChart *q):
579 q_ptr(q),
587 q_ptr(q),
580 m_legend(0),
588 m_legend(0),
581 m_dataset(new ChartDataSet(q)),
589 m_dataset(new ChartDataSet(q)),
582 m_presenter(new ChartPresenter(q)),
590 m_presenter(new ChartPresenter(q)),
583 m_themeManager(new ChartThemeManager(q))
591 m_themeManager(new ChartThemeManager(q))
584 {
592 {
585 QObject::connect(m_dataset, SIGNAL(seriesAdded(QAbstractSeries*)), m_presenter, SLOT(handleSeriesAdded(QAbstractSeries*)));
593 QObject::connect(m_dataset, SIGNAL(seriesAdded(QAbstractSeries*)), m_presenter, SLOT(handleSeriesAdded(QAbstractSeries*)));
586 QObject::connect(m_dataset, SIGNAL(seriesRemoved(QAbstractSeries*)), m_presenter, SLOT(handleSeriesRemoved(QAbstractSeries*)));
594 QObject::connect(m_dataset, SIGNAL(seriesRemoved(QAbstractSeries*)), m_presenter, SLOT(handleSeriesRemoved(QAbstractSeries*)));
587 QObject::connect(m_dataset, SIGNAL(axisAdded(QAbstractAxis*)), m_presenter, SLOT(handleAxisAdded(QAbstractAxis*)));
595 QObject::connect(m_dataset, SIGNAL(axisAdded(QAbstractAxis*)), m_presenter, SLOT(handleAxisAdded(QAbstractAxis*)));
588 QObject::connect(m_dataset, SIGNAL(axisRemoved(QAbstractAxis*)), m_presenter, SLOT(handleAxisRemoved(QAbstractAxis*)));
596 QObject::connect(m_dataset, SIGNAL(axisRemoved(QAbstractAxis*)), m_presenter, SLOT(handleAxisRemoved(QAbstractAxis*)));
589 QObject::connect(m_dataset, SIGNAL(seriesAdded(QAbstractSeries*)), m_themeManager, SLOT(handleSeriesAdded(QAbstractSeries*)));
597 QObject::connect(m_dataset, SIGNAL(seriesAdded(QAbstractSeries*)), m_themeManager, SLOT(handleSeriesAdded(QAbstractSeries*)));
590 QObject::connect(m_dataset, SIGNAL(seriesRemoved(QAbstractSeries*)), m_themeManager, SLOT(handleSeriesRemoved(QAbstractSeries*)));
598 QObject::connect(m_dataset, SIGNAL(seriesRemoved(QAbstractSeries*)), m_themeManager, SLOT(handleSeriesRemoved(QAbstractSeries*)));
591 QObject::connect(m_dataset, SIGNAL(axisAdded(QAbstractAxis*)), m_themeManager, SLOT(handleAxisAdded(QAbstractAxis*)));
599 QObject::connect(m_dataset, SIGNAL(axisAdded(QAbstractAxis*)), m_themeManager, SLOT(handleAxisAdded(QAbstractAxis*)));
592 QObject::connect(m_dataset, SIGNAL(axisRemoved(QAbstractAxis*)), m_themeManager, SLOT(handleAxisRemoved(QAbstractAxis*)));
600 QObject::connect(m_dataset, SIGNAL(axisRemoved(QAbstractAxis*)), m_themeManager, SLOT(handleAxisRemoved(QAbstractAxis*)));
593 }
601 }
594
602
595 QChartPrivate::~QChartPrivate()
603 QChartPrivate::~QChartPrivate()
596 {
604 {
597
605
598 }
606 }
599
607
600 void QChartPrivate::zoomIn(qreal factor)
608 void QChartPrivate::zoomIn(qreal factor)
601 {
609 {
602 QRectF rect = m_presenter->geometry();
610 QRectF rect = m_presenter->geometry();
603 rect.setWidth(rect.width() / factor);
611 rect.setWidth(rect.width() / factor);
604 rect.setHeight(rect.height() / factor);
612 rect.setHeight(rect.height() / factor);
605 rect.moveCenter(m_presenter->geometry().center());
613 rect.moveCenter(m_presenter->geometry().center());
606 zoomIn(rect);
614 zoomIn(rect);
607 }
615 }
608
616
609 void QChartPrivate::zoomIn(const QRectF &rect)
617 void QChartPrivate::zoomIn(const QRectF &rect)
610 {
618 {
611 if (!rect.isValid())
619 if (!rect.isValid())
612 return;
620 return;
613
621
614 QRectF r = rect.normalized();
622 QRectF r = rect.normalized();
615 const QRectF geometry = m_presenter->geometry();
623 const QRectF geometry = m_presenter->geometry();
616 r.translate(-geometry.topLeft());
624 r.translate(-geometry.topLeft());
617
625
618 if (!r.isValid())
626 if (!r.isValid())
619 return;
627 return;
620
628
621 QPointF zoomPoint(r.center().x() / geometry.width(), r.center().y() / geometry.height());
629 QPointF zoomPoint(r.center().x() / geometry.width(), r.center().y() / geometry.height());
622 m_presenter->setState(ChartPresenter::ZoomInState,zoomPoint);
630 m_presenter->setState(ChartPresenter::ZoomInState,zoomPoint);
623 m_dataset->zoomInDomain(r);
631 m_dataset->zoomInDomain(r);
624 m_presenter->setState(ChartPresenter::ShowState,QPointF());
632 m_presenter->setState(ChartPresenter::ShowState,QPointF());
625
633
626 }
634 }
627
635
628 void QChartPrivate::zoomOut(qreal factor)
636 void QChartPrivate::zoomOut(qreal factor)
629 {
637 {
630 const QRectF geometry = m_presenter->geometry();
638 const QRectF geometry = m_presenter->geometry();
631
639
632 QRectF r;
640 QRectF r;
633 r.setSize(geometry.size() / factor);
641 r.setSize(geometry.size() / factor);
634 r.moveCenter(QPointF(geometry.size().width()/2 ,geometry.size().height()/2));
642 r.moveCenter(QPointF(geometry.size().width()/2 ,geometry.size().height()/2));
635 if (!r.isValid())
643 if (!r.isValid())
636 return;
644 return;
637
645
638 QPointF zoomPoint(r.center().x() / geometry.width(), r.center().y() / geometry.height());
646 QPointF zoomPoint(r.center().x() / geometry.width(), r.center().y() / geometry.height());
639 m_presenter->setState(ChartPresenter::ZoomOutState,zoomPoint);
647 m_presenter->setState(ChartPresenter::ZoomOutState,zoomPoint);
640 m_dataset->zoomOutDomain(r);
648 m_dataset->zoomOutDomain(r);
641 m_presenter->setState(ChartPresenter::ShowState,QPointF());
649 m_presenter->setState(ChartPresenter::ShowState,QPointF());
642 }
650 }
643
651
644 void QChartPrivate::scroll(qreal dx, qreal dy)
652 void QChartPrivate::scroll(qreal dx, qreal dy)
645 {
653 {
646 if (dx < 0) m_presenter->setState(ChartPresenter::ScrollLeftState,QPointF());
654 if (dx < 0) m_presenter->setState(ChartPresenter::ScrollLeftState,QPointF());
647 if (dx > 0) m_presenter->setState(ChartPresenter::ScrollRightState,QPointF());
655 if (dx > 0) m_presenter->setState(ChartPresenter::ScrollRightState,QPointF());
648 if (dy < 0) m_presenter->setState(ChartPresenter::ScrollUpState,QPointF());
656 if (dy < 0) m_presenter->setState(ChartPresenter::ScrollUpState,QPointF());
649 if (dy > 0) m_presenter->setState(ChartPresenter::ScrollDownState,QPointF());
657 if (dy > 0) m_presenter->setState(ChartPresenter::ScrollDownState,QPointF());
650
658
651 m_dataset->scrollDomain(dx, dy);
659 m_dataset->scrollDomain(dx, dy);
652 m_presenter->setState(ChartPresenter::ShowState,QPointF());
660 m_presenter->setState(ChartPresenter::ShowState,QPointF());
653 }
661 }
654
662
655 #include "moc_qchart.cpp"
663 #include "moc_qchart.cpp"
656
664
657 QTCOMMERCIALCHART_END_NAMESPACE
665 QTCOMMERCIALCHART_END_NAMESPACE
@@ -1,177 +1,177
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 // W A R N I N G
21 // W A R N I N G
22 // -------------
22 // -------------
23 //
23 //
24 // This file is not part of the QtCommercial Chart API. It exists purely as an
24 // This file is not part of the QtCommercial Chart API. It exists purely as an
25 // implementation detail. This header file may change from version to
25 // implementation detail. This header file may change from version to
26 // version without notice, or even be removed.
26 // version without notice, or even be removed.
27 //
27 //
28 // We mean it.
28 // We mean it.
29
29
30 #ifndef CHARTTHEMESYSTEM_P_H
30 #ifndef CHARTTHEMESYSTEM_P_H
31 #define CHARTTHEMESYSTEM_P_H
31 #define CHARTTHEMESYSTEM_P_H
32
32
33 #include "charttheme_p.h"
33 #include "charttheme_p.h"
34 #ifdef Q_OS_WIN
34 #ifdef Q_OS_WIN
35 #include <windows.h>
35 #include <windows.h>
36 #include <stdio.h>
36 #include <stdio.h>
37 #endif
37 #endif
38
38
39 QTCOMMERCIALCHART_BEGIN_NAMESPACE
39 QTCOMMERCIALCHART_BEGIN_NAMESPACE
40
40
41 class ChartThemeSystem: public ChartTheme
41 class ChartThemeSystem: public ChartTheme
42 {
42 {
43 public:
43 public:
44 // System theme not used at the moment (the user is not able to select this theme)
44 // System theme not used at the moment (the user is not able to select this theme)
45 ChartThemeSystem() : ChartTheme(QChart::ChartThemeLight /*QChart::ChartThemeSystem*/)
45 ChartThemeSystem() : ChartTheme(QChart::ChartThemeLight /*QChart::ChartThemeSystem*/)
46 {
46 {
47 #ifdef Q_OS_WIN
47 #ifdef Q_OS_WIN
48 // We could also use theme specific window frame color as a series base color (it would give more
48 // We could also use theme specific window frame color as a series base color (it would give more
49 // variation to the base colors in addition to the blue and black used now)
49 // variation to the base colors in addition to the blue and black used now)
50
50
51 // First series base color from COLOR_HIGHLIGHT
51 // First series base color from COLOR_HIGHLIGHT
52 DWORD colorHighlight;
52 DWORD colorHighlight;
53 colorHighlight = GetSysColor(COLOR_HIGHLIGHT);
53 colorHighlight = GetSysColor(COLOR_HIGHLIGHT);
54 m_seriesColors.append(QColor(GetRValue(colorHighlight),
54 m_seriesColors.append(QColor(GetRValue(colorHighlight),
55 GetGValue(colorHighlight),
55 GetGValue(colorHighlight),
56 GetBValue(colorHighlight)));
56 GetBValue(colorHighlight)));
57
57
58 // Second series base color from COLOR_WINDOWFRAME
58 // Second series base color from COLOR_WINDOWFRAME
59 DWORD colorWindowFrame;
59 DWORD colorWindowFrame;
60 colorWindowFrame = GetSysColor(COLOR_WINDOWFRAME);
60 colorWindowFrame = GetSysColor(COLOR_WINDOWFRAME);
61 m_seriesColors.append(QColor(GetRValue(colorWindowFrame),
61 m_seriesColors.append(QColor(GetRValue(colorWindowFrame),
62 GetGValue(colorWindowFrame),
62 GetGValue(colorWindowFrame),
63 GetBValue(colorWindowFrame)));
63 GetBValue(colorWindowFrame)));
64
64
65 // Third series base color from the middle of the COLOR_ACTIVECAPTION /
65 // Third series base color from the middle of the COLOR_ACTIVECAPTION /
66 // COLOR_GRADIENTACTIVECAPTION gradient
66 // COLOR_GRADIENTACTIVECAPTION gradient
67 DWORD colorGradientActiveCaptionLeft;
67 DWORD colorGradientActiveCaptionLeft;
68 colorGradientActiveCaptionLeft = GetSysColor(COLOR_ACTIVECAPTION);
68 colorGradientActiveCaptionLeft = GetSysColor(COLOR_ACTIVECAPTION);
69 DWORD colorGradientActiveCaptionRight;
69 DWORD colorGradientActiveCaptionRight;
70 colorGradientActiveCaptionRight = GetSysColor(COLOR_GRADIENTACTIVECAPTION);
70 colorGradientActiveCaptionRight = GetSysColor(COLOR_GRADIENTACTIVECAPTION);
71 QLinearGradient g;
71 QLinearGradient g;
72 QColor start = QColor(GetRValue(colorGradientActiveCaptionLeft),
72 QColor start = QColor(GetRValue(colorGradientActiveCaptionLeft),
73 GetGValue(colorGradientActiveCaptionLeft),
73 GetGValue(colorGradientActiveCaptionLeft),
74 GetBValue(colorGradientActiveCaptionLeft));
74 GetBValue(colorGradientActiveCaptionLeft));
75 g.setColorAt(0.0, start);
75 g.setColorAt(0.0, start);
76 QColor end = QColor(GetRValue(colorGradientActiveCaptionRight),
76 QColor end = QColor(GetRValue(colorGradientActiveCaptionRight),
77 GetGValue(colorGradientActiveCaptionRight),
77 GetGValue(colorGradientActiveCaptionRight),
78 GetBValue(colorGradientActiveCaptionRight));
78 GetBValue(colorGradientActiveCaptionRight));
79 g.setColorAt(1.0, end);
79 g.setColorAt(1.0, end);
80 m_seriesColors.append(ChartThemeManager::colorAt(g, 0.5));
80 m_seriesColors.append(ChartThemeManager::colorAt(g, 0.5));
81
81
82 // Generate gradients from the base colors
82 // Generate gradients from the base colors
83 ChartThemeManager::generateSeriesGradients(m_seriesColors);
83 m_seriesGradients = ChartThemeManager::generateSeriesGradients(m_seriesColors);
84
84
85 // Background fill color from COLOR_WINDOW
85 // Background fill color from COLOR_WINDOW
86 QLinearGradient backgroundGradient;
86 QLinearGradient backgroundGradient;
87 DWORD colorWindow;
87 DWORD colorWindow;
88 colorWindow = GetSysColor(COLOR_WINDOW);
88 colorWindow = GetSysColor(COLOR_WINDOW);
89 backgroundGradient.setColorAt(0.0, QColor(GetRValue(colorWindow),
89 backgroundGradient.setColorAt(0.0, QColor(GetRValue(colorWindow),
90 GetGValue(colorWindow),
90 GetGValue(colorWindow),
91 GetBValue(colorWindow)));
91 GetBValue(colorWindow)));
92 backgroundGradient.setColorAt(1.0, QColor(GetRValue(colorWindow),
92 backgroundGradient.setColorAt(1.0, QColor(GetRValue(colorWindow),
93 GetGValue(colorWindow),
93 GetGValue(colorWindow),
94 GetBValue(colorWindow)));
94 GetBValue(colorWindow)));
95 // Axes and other
95 // Axes and other
96 m_axisLinePen = QPen(0xd6d6d6);
96 m_axisLinePen = QPen(0xd6d6d6);
97 m_axisLinePen.setWidth(1);
97 m_axisLinePen.setWidth(1);
98 m_labelBrush = QBrush(QRgb(0x404044));
98 m_labelBrush = QBrush(QRgb(0x404044));
99 m_gridLinePen = QPen(QRgb(0xe2e2e2));
99 m_gridLinePen = QPen(QRgb(0xe2e2e2));
100 m_gridLinePen.setWidth(1);
100 m_gridLinePen.setWidth(1);
101 m_backgroundShades = BackgroundShadesNone;
101 m_backgroundShades = BackgroundShadesNone;
102
102
103 #elif defined(Q_OS_LINUX)
103 #elif defined(Q_OS_LINUX)
104 // Using a hard coded theme for Linux system theme
104 // Using a hard coded theme for Linux system theme
105 m_seriesColors << QRgb(0x60a6e6);
105 m_seriesColors << QRgb(0x60a6e6);
106 m_seriesColors << QRgb(0x92ca66);
106 m_seriesColors << QRgb(0x92ca66);
107 m_seriesColors << QRgb(0xeba85f);
107 m_seriesColors << QRgb(0xeba85f);
108 m_seriesColors << QRgb(0xfc5751);
108 m_seriesColors << QRgb(0xfc5751);
109 m_seriesGradients = ChartThemeManager::generateSeriesGradients(m_seriesColors);
109 m_seriesGradients = ChartThemeManager::generateSeriesGradients(m_seriesColors);
110
110
111 // Background
111 // Background
112 QLinearGradient backgroundGradient;
112 QLinearGradient backgroundGradient;
113 backgroundGradient.setColorAt(0.0, QRgb(0xffffff));
113 backgroundGradient.setColorAt(0.0, QRgb(0xffffff));
114 backgroundGradient.setColorAt(1.0, QRgb(0xffffff));
114 backgroundGradient.setColorAt(1.0, QRgb(0xffffff));
115 backgroundGradient.setCoordinateMode(QGradient::ObjectBoundingMode);
115 backgroundGradient.setCoordinateMode(QGradient::ObjectBoundingMode);
116 m_chartBackgroundGradient = backgroundGradient;
116 m_chartBackgroundGradient = backgroundGradient;
117
117
118 // Axes and other
118 // Axes and other
119 m_axisLinePen = QPen(0xd6d6d6);
119 m_axisLinePen = QPen(0xd6d6d6);
120 m_axisLinePen.setWidth(1);
120 m_axisLinePen.setWidth(1);
121 m_labelBrush = QBrush(QRgb(0x404044));
121 m_labelBrush = QBrush(QRgb(0x404044));
122 m_gridLinePen = QPen(QRgb(0xe2e2e2));
122 m_gridLinePen = QPen(QRgb(0xe2e2e2));
123 m_gridLinePen.setWidth(1);
123 m_gridLinePen.setWidth(1);
124 m_backgroundShades = BackgroundShadesNone;
124 m_backgroundShades = BackgroundShadesNone;
125
125
126 #elif defined(Q_OS_MAC)
126 #elif defined(Q_OS_MAC)
127 // Using a hard coded theme for OSX system theme; the colors match the OSX 10.7 colors
127 // Using a hard coded theme for OSX system theme; the colors match the OSX 10.7 colors
128 m_seriesColors << QRgb(0x60a6e6);
128 m_seriesColors << QRgb(0x60a6e6);
129 m_seriesColors << QRgb(0x92ca66);
129 m_seriesColors << QRgb(0x92ca66);
130 m_seriesColors << QRgb(0xeba85f);
130 m_seriesColors << QRgb(0xeba85f);
131 m_seriesColors << QRgb(0xfc5751);
131 m_seriesColors << QRgb(0xfc5751);
132 generateSeriesGradients();
132 m_seriesGradients = ChartThemeManager::generateSeriesGradients(m_seriesColors);
133
133
134 // Background
134 // Background
135 QLinearGradient backgroundGradient;
135 QLinearGradient backgroundGradient;
136 backgroundGradient.setColorAt(0.0, QRgb(0xffffff));
136 backgroundGradient.setColorAt(0.0, QRgb(0xffffff));
137 backgroundGradient.setColorAt(1.0, QRgb(0xffffff));
137 backgroundGradient.setColorAt(1.0, QRgb(0xffffff));
138 backgroundGradient.setCoordinateMode(QGradient::ObjectBoundingMode);
138 backgroundGradient.setCoordinateMode(QGradient::ObjectBoundingMode);
139 m_chartBackgroundGradient = backgroundGradient;
139 m_chartBackgroundGradient = backgroundGradient;
140
140
141 // Axes and other
141 // Axes and other
142 m_axisLinePen = QPen(0xd6d6d6);
142 m_axisLinePen = QPen(0xd6d6d6);
143 m_axisLinePen.setWidth(1);
143 m_axisLinePen.setWidth(1);
144 m_labelBrush = QBrush(QRgb(0x404044));
144 m_labelBrush = QBrush(QRgb(0x404044));
145 m_gridLinePen = QPen(QRgb(0xe2e2e2));
145 m_gridLinePen = QPen(QRgb(0xe2e2e2));
146 m_gridLinePen.setWidth(1);
146 m_gridLinePen.setWidth(1);
147 m_backgroundShades = BackgroundShadesNone;
147 m_backgroundShades = BackgroundShadesNone;
148
148
149 #else
149 #else
150 // Hard coded theme
150 // Hard coded theme
151 m_seriesColors << QRgb(0x60a6e6);
151 m_seriesColors << QRgb(0x60a6e6);
152 m_seriesColors << QRgb(0x92ca66);
152 m_seriesColors << QRgb(0x92ca66);
153 m_seriesColors << QRgb(0xeba85f);
153 m_seriesColors << QRgb(0xeba85f);
154 m_seriesColors << QRgb(0xfc5751);
154 m_seriesColors << QRgb(0xfc5751);
155 m_seriesGradients = ChartThemeManager::generateSeriesGradients(m_seriesColors);
155 m_seriesGradients = ChartThemeManager::generateSeriesGradients(m_seriesColors);
156
156
157 // Background
157 // Background
158 QLinearGradient backgroundGradient;
158 QLinearGradient backgroundGradient;
159 backgroundGradient.setColorAt(0.0, QRgb(0xffffff));
159 backgroundGradient.setColorAt(0.0, QRgb(0xffffff));
160 backgroundGradient.setColorAt(1.0, QRgb(0xffffff));
160 backgroundGradient.setColorAt(1.0, QRgb(0xffffff));
161 backgroundGradient.setCoordinateMode(QGradient::ObjectBoundingMode);
161 backgroundGradient.setCoordinateMode(QGradient::ObjectBoundingMode);
162 m_chartBackgroundGradient = backgroundGradient;
162 m_chartBackgroundGradient = backgroundGradient;
163
163
164 // Axes and other
164 // Axes and other
165 m_axisLinePen = QPen(0xd6d6d6);
165 m_axisLinePen = QPen(0xd6d6d6);
166 m_axisLinePen.setWidth(1);
166 m_axisLinePen.setWidth(1);
167 m_labelBrush = QBrush(QRgb(0x404044));
167 m_labelBrush = QBrush(QRgb(0x404044));
168 m_gridLinePen = QPen(QRgb(0xe2e2e2));
168 m_gridLinePen = QPen(QRgb(0xe2e2e2));
169 m_gridLinePen.setWidth(1);
169 m_gridLinePen.setWidth(1);
170 m_backgroundShades = BackgroundShadesNone;
170 m_backgroundShades = BackgroundShadesNone;
171 #endif
171 #endif
172 }
172 }
173 };
173 };
174
174
175 QTCOMMERCIALCHART_END_NAMESPACE
175 QTCOMMERCIALCHART_END_NAMESPACE
176
176
177 #endif // CHARTTHEMESYSTEM_P_H
177 #endif // CHARTTHEMESYSTEM_P_H
@@ -1,125 +1,147
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 QtQuickTest 1.0
22 import QtQuickTest 1.0
23 import QtCommercial.Chart 1.2
23 import QtCommercial.Chart 1.2
24
24
25 Rectangle {
25 Rectangle {
26 width: 400
26 width: 400
27 height: 300
27 height: 300
28
28
29 TestCase {
29 TestCase {
30 id: tc1
30 id: tc1
31 name: "tst_qml-qtquicktest BarSeries"
31 name: "tst_qml-qtquicktest BarSeries"
32 when: windowShown
32 when: windowShown
33
33
34 function test_properties() {
34 function test_properties() {
35 compare(barSeries.barWidth, 0.5);
35 compare(barSeries.barWidth, 0.5);
36 compare(barSeries.labelsVisible, false);
36 compare(barSeries.labelsVisible, false);
37 }
37 }
38
38
39 function test_axes() {
40 compare(chartView.axes.length, 2);
41 verify(chartView.axes[0] == barSeries.axisX || chartView.axes[1] == barSeries.axisX);
42 verify(chartView.axes[0] == barSeries.axisY || chartView.axes[1] == barSeries.axisY);
43
44 compare(barSeries.axisX, stackedBarSeries.axisX);
45 compare(barSeries.axisY, stackedBarSeries.axisY);
46
47 compare(barSeries.axisX, percentBarSeries.axisX);
48 compare(barSeries.axisY, percentBarSeries.axisY);
49 }
50
39 function test_append() {
51 function test_append() {
40 var setCount = 5;
52 var setCount = 5;
41 var valueCount = 50;
53 var valueCount = 50;
42 addedSpy.clear();
54 addedSpy.clear();
43 append(setCount, valueCount);
55 append(setCount, valueCount);
44
56
45 compare(barSeries.count, setCount);
57 compare(barSeries.count, setCount);
46 for (var k = 0; k < setCount; k++) {
58 for (var k = 0; k < setCount; k++) {
47 compare(barSeries.at(k).count, valueCount);
59 compare(barSeries.at(k).count, valueCount);
48 compare(barSeries.at(k).label, "barset" + k);
60 compare(barSeries.at(k).label, "barset" + k);
49 }
61 }
50 compare(addedSpy.count, setCount);
62 compare(addedSpy.count, setCount);
51
63
52 barSeries.clear();
64 barSeries.clear();
53 compare(barSeries.count, 0);
65 compare(barSeries.count, 0);
54 }
66 }
55
67
56 function test_insert() {
68 function test_insert() {
57 var setCount = 5;
69 var setCount = 5;
58 var valueCount = 50;
70 var valueCount = 50;
59 addedSpy.clear();
71 addedSpy.clear();
60 append(setCount, valueCount);
72 append(setCount, valueCount);
61
73
62 for (var i = 0; i < setCount; i++) {
74 for (var i = 0; i < setCount; i++) {
63 var values = [];
75 var values = [];
64 for (var j = 0; j < valueCount; j++)
76 for (var j = 0; j < valueCount; j++)
65 values[j] = Math.random() * 10;
77 values[j] = Math.random() * 10;
66 var set = barSeries.insert(i, "barset" + i, values);
78 var set = barSeries.insert(i, "barset" + i, values);
67 compare(set.label, "barset" + i);
79 compare(set.label, "barset" + i);
68 }
80 }
69
81
70 compare(barSeries.count, setCount * 2);
82 compare(barSeries.count, setCount * 2);
71 for (var k = 0; k < setCount * 2; k++)
83 for (var k = 0; k < setCount * 2; k++)
72 compare(barSeries.at(k).count, valueCount);
84 compare(barSeries.at(k).count, valueCount);
73 compare(addedSpy.count, 2 * setCount);
85 compare(addedSpy.count, 2 * setCount);
74
86
75 barSeries.clear();
87 barSeries.clear();
76 compare(barSeries.count, 0);
88 compare(barSeries.count, 0);
77 }
89 }
78
90
79 function test_remove() {
91 function test_remove() {
80 var setCount = 5;
92 var setCount = 5;
81 var valueCount = 50;
93 var valueCount = 50;
82 removedSpy.clear();
94 removedSpy.clear();
83 append(setCount, valueCount);
95 append(setCount, valueCount);
84
96
85 for (var k = 0; k < setCount; k++)
97 for (var k = 0; k < setCount; k++)
86 barSeries.remove(barSeries.at(0));
98 barSeries.remove(barSeries.at(0));
87
99
88 compare(barSeries.count, 0);
100 compare(barSeries.count, 0);
89 compare(removedSpy.count, setCount);
101 compare(removedSpy.count, setCount);
90 }
102 }
91
103
92 // Not a test function, used by one or more test functions
104 // Not a test function, used by one or more test functions
93 function append(setCount, valueCount) {
105 function append(setCount, valueCount) {
94 for (var i = 0; i < setCount; i++) {
106 for (var i = 0; i < setCount; i++) {
95 var values = [];
107 var values = [];
96 for (var j = 0; j < valueCount; j++)
108 for (var j = 0; j < valueCount; j++)
97 values[j] = Math.random() * 10;
109 values[j] = Math.random() * 10;
98 barSeries.append("barset" + i, values);
110 barSeries.append("barset" + i, values);
99 }
111 }
100 }
112 }
101 }
113 }
102
114
103 ChartView {
115 ChartView {
104 id: chartView
116 id: chartView
105 anchors.fill: parent
117 anchors.fill: parent
106
118
107 BarSeries {
119 BarSeries {
108 axisX: BarCategoriesAxis {}
109 axisY: ValuesAxis { min: 0; max: 10 }
110 id: barSeries
120 id: barSeries
111 name: "bar"
121 name: "bar"
122 axisX: BarCategoryAxis {}
123 axisY: ValueAxis { min: 0; max: 10 }
112
124
113 SignalSpy {
125 SignalSpy {
114 id: addedSpy
126 id: addedSpy
115 target: barSeries
127 target: barSeries
116 signalName: "barsetsAdded"
128 signalName: "barsetsAdded"
117 }
129 }
118 SignalSpy {
130 SignalSpy {
119 id: removedSpy
131 id: removedSpy
120 target: barSeries
132 target: barSeries
121 signalName: "barsetsRemoved"
133 signalName: "barsetsRemoved"
122 }
134 }
123 }
135 }
136
137 StackedBarSeries {
138 id: stackedBarSeries
139 name: "stackedBar"
140 }
141
142 PercentBarSeries {
143 id: percentBarSeries
144 name: "percentBar"
145 }
124 }
146 }
125 }
147 }
@@ -1,259 +1,264
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 QtQuickTest 1.0
22 import QtQuickTest 1.0
23 import QtCommercial.Chart 1.2
23 import QtCommercial.Chart 1.2
24
24
25 Rectangle {
25 Rectangle {
26 width: 400
26 width: 400
27 height: 300
27 height: 300
28
28
29 TestCase {
29 TestCase {
30 id: tc1
30 id: tc1
31 name: "tst_qml-qtquicktest XY Series"
31 name: "tst_qml-qtquicktest XY Series"
32 when: windowShown
32 when: windowShown
33
33
34 function test_properties() {
34 function test_properties() {
35 verify(lineSeries.color != undefined);
35 verify(lineSeries.color != undefined);
36 compare(lineSeries.pointsVisible, false);
36 compare(lineSeries.pointsVisible, false);
37 // TODO: Should the properties be set or not?
38 // verify(lineSeries.axisX != null);
39 // verify(lineSeries.axisY != null);
40 compare(lineSeries.capStyle, Qt.SquareCap);
37 compare(lineSeries.capStyle, Qt.SquareCap);
41 compare(lineSeries.style, Qt.SolidLine);
38 compare(lineSeries.style, Qt.SolidLine);
42 compare(lineSeries.width, 2.0);
39 compare(lineSeries.width, 2.0);
43
40
44 verify(splineSeries.color != undefined);
41 verify(splineSeries.color != undefined);
45 compare(splineSeries.pointsVisible, false);
42 compare(splineSeries.pointsVisible, false);
46 // TODO: Should the properties be set or not?
47 // verify(splineSeries.axisX != null);
48 // verify(splineSeries.axisY != null);
49 compare(splineSeries.capStyle, Qt.SquareCap);
43 compare(splineSeries.capStyle, Qt.SquareCap);
50 compare(splineSeries.style, Qt.SolidLine);
44 compare(splineSeries.style, Qt.SolidLine);
51 compare(splineSeries.width, 2.0);
45 compare(splineSeries.width, 2.0);
52
46
53 verify(scatterSeries.color != undefined);
47 verify(scatterSeries.color != undefined);
54 // TODO: Should the properties be set or not?
55 // verify(scatterSeries.axisX != null);
56 // verify(scatterSeries.axisY != null);
57 verify(scatterSeries.borderColor != undefined);
48 verify(scatterSeries.borderColor != undefined);
58 compare(scatterSeries.borderWidth, 2.0);
49 compare(scatterSeries.borderWidth, 2.0);
59 compare(scatterSeries.markerShape, ScatterSeries.MarkerShapeCircle);
50 compare(scatterSeries.markerShape, ScatterSeries.MarkerShapeCircle);
60 compare(scatterSeries.markerSize, 15.0);
51 compare(scatterSeries.markerSize, 15.0);
61
52
62 verify(areaSeries.color != undefined);
53 verify(areaSeries.color != undefined);
63 verify(areaSeries.borderColor != undefined);
54 verify(areaSeries.borderColor != undefined);
64 compare(areaSeries.borderWidth, 2.0);
55 compare(areaSeries.borderWidth, 2.0);
65 }
56 }
66
57
58 function test_axes() {
59 compare(chartView.axes.length, 2);
60 console.log("chart.axes[0] " + chartView.axes[0]);
61 console.log("chart.axes[1] " + chartView.axes[1]);
62 console.log("lineSeries.axisX " + lineSeries.axisX);
63 console.log("lineSeries.axisY " + lineSeries.axisY);
64 verify(chartView.axes[0] == lineSeries.axisX || chartView.axes[1] == lineSeries.axisX);
65 verify(chartView.axes[0] == lineSeries.axisY || chartView.axes[1] == lineSeries.axisY);
66 verify(lineSeries.axisX == splineSeries.axisX);
67 verify(lineSeries.axisY == splineSeries.axisY);
68 verify(lineSeries.axisX == areaSeries.axisX);
69 verify(lineSeries.axisY == areaSeries.axisY);
70 }
71
67 function test_append() {
72 function test_append() {
68 lineSeriesPointAddedSpy.clear();
73 lineSeriesPointAddedSpy.clear();
69 splineSeriesPointAddedSpy.clear();
74 splineSeriesPointAddedSpy.clear();
70 scatterSeriesPointAddedSpy.clear();
75 scatterSeriesPointAddedSpy.clear();
71 var count = append();
76 var count = append();
72 compare(lineSeries.count, count);
77 compare(lineSeries.count, count);
73 compare(splineSeries.count, count);
78 compare(splineSeries.count, count);
74 compare(scatterSeries.count, count);
79 compare(scatterSeries.count, count);
75 tryCompare(lineSeriesPointAddedSpy.count, count);
80 tryCompare(lineSeriesPointAddedSpy.count, count);
76 tryCompare(splineSeriesPointAddedSpy.count, count);
81 tryCompare(splineSeriesPointAddedSpy.count, count);
77 tryCompare(scatterSeriesPointAddedSpy.count, count);
82 tryCompare(scatterSeriesPointAddedSpy.count, count);
78 clear();
83 clear();
79 compare(lineSeries.count, 0);
84 compare(lineSeries.count, 0);
80 compare(splineSeries.count, 0);
85 compare(splineSeries.count, 0);
81 compare(scatterSeries.count, 0);
86 compare(scatterSeries.count, 0);
82 }
87 }
83
88
84 function test_replace() {
89 function test_replace() {
85 var count = append();
90 var count = append();
86 for (var i = 0; i < count; i++) {
91 for (var i = 0; i < count; i++) {
87 lineSeries.replace(lineSeries.at(i).x, lineSeries.at(i).y, i, Math.random());
92 lineSeries.replace(lineSeries.at(i).x, lineSeries.at(i).y, i, Math.random());
88 splineSeries.replace(splineSeries.at(i).x, splineSeries.at(i).y, i, Math.random());
93 splineSeries.replace(splineSeries.at(i).x, splineSeries.at(i).y, i, Math.random());
89 scatterSeries.replace(scatterSeries.at(i).x, scatterSeries.at(i).y, i, Math.random());
94 scatterSeries.replace(scatterSeries.at(i).x, scatterSeries.at(i).y, i, Math.random());
90 }
95 }
91 compare(lineSeries.count, count);
96 compare(lineSeries.count, count);
92 compare(splineSeries.count, count);
97 compare(splineSeries.count, count);
93 compare(scatterSeries.count, count);
98 compare(scatterSeries.count, count);
94 tryCompare(lineSeriesPointReplacedSpy.count, count);
99 tryCompare(lineSeriesPointReplacedSpy.count, count);
95 tryCompare(splineSeriesPointReplacedSpy.count, count);
100 tryCompare(splineSeriesPointReplacedSpy.count, count);
96 tryCompare(scatterSeriesPointReplacedSpy.count, count);
101 tryCompare(scatterSeriesPointReplacedSpy.count, count);
97 clear();
102 clear();
98 }
103 }
99
104
100 function test_insert() {
105 function test_insert() {
101 var count = append();
106 var count = append();
102 lineSeriesPointAddedSpy.clear();
107 lineSeriesPointAddedSpy.clear();
103 splineSeriesPointAddedSpy.clear();
108 splineSeriesPointAddedSpy.clear();
104 scatterSeriesPointAddedSpy.clear();
109 scatterSeriesPointAddedSpy.clear();
105 for (var i = 0; i < count; i++) {
110 for (var i = 0; i < count; i++) {
106 lineSeries.insert(i * 2, i, Math.random());
111 lineSeries.insert(i * 2, i, Math.random());
107 splineSeries.insert(i * 2, i, Math.random());
112 splineSeries.insert(i * 2, i, Math.random());
108 scatterSeries.insert(i * 2, i, Math.random());
113 scatterSeries.insert(i * 2, i, Math.random());
109 }
114 }
110 compare(lineSeries.count, count * 2);
115 compare(lineSeries.count, count * 2);
111 compare(splineSeries.count, count * 2);
116 compare(splineSeries.count, count * 2);
112 compare(scatterSeries.count, count * 2);
117 compare(scatterSeries.count, count * 2);
113 tryCompare(lineSeriesPointAddedSpy.count, count);
118 tryCompare(lineSeriesPointAddedSpy.count, count);
114 tryCompare(splineSeriesPointAddedSpy.count, count);
119 tryCompare(splineSeriesPointAddedSpy.count, count);
115 tryCompare(scatterSeriesPointAddedSpy.count, count);
120 tryCompare(scatterSeriesPointAddedSpy.count, count);
116 clear();
121 clear();
117 }
122 }
118
123
119 function test_remove() {
124 function test_remove() {
120 lineSeriesPointRemovedSpy.clear();
125 lineSeriesPointRemovedSpy.clear();
121 splineSeriesPointRemovedSpy.clear();
126 splineSeriesPointRemovedSpy.clear();
122 scatterSeriesPointRemovedSpy.clear();
127 scatterSeriesPointRemovedSpy.clear();
123 var count = append();
128 var count = append();
124 for (var i = 0; i < count; i++) {
129 for (var i = 0; i < count; i++) {
125 lineSeries.remove(lineSeries.at(0).x, lineSeries.at(0).y);
130 lineSeries.remove(lineSeries.at(0).x, lineSeries.at(0).y);
126 splineSeries.remove(splineSeries.at(0).x, splineSeries.at(0).y);
131 splineSeries.remove(splineSeries.at(0).x, splineSeries.at(0).y);
127 scatterSeries.remove(scatterSeries.at(0).x, scatterSeries.at(0).y);
132 scatterSeries.remove(scatterSeries.at(0).x, scatterSeries.at(0).y);
128 }
133 }
129 compare(lineSeries.count, 0);
134 compare(lineSeries.count, 0);
130 compare(splineSeries.count, 0);
135 compare(splineSeries.count, 0);
131 compare(scatterSeries.count, 0);
136 compare(scatterSeries.count, 0);
132 tryCompare(lineSeriesPointRemovedSpy.count, count);
137 tryCompare(lineSeriesPointRemovedSpy.count, count);
133 tryCompare(splineSeriesPointRemovedSpy.count, count);
138 tryCompare(splineSeriesPointRemovedSpy.count, count);
134 tryCompare(scatterSeriesPointRemovedSpy.count, count);
139 tryCompare(scatterSeriesPointRemovedSpy.count, count);
135 }
140 }
136
141
137 // Not a test function, called from test functions
142 // Not a test function, called from test functions
138 function append() {
143 function append() {
139 var count = 100;
144 var count = 100;
140 chartView.axisX().min = 0;
145 chartView.axisX().min = 0;
141 chartView.axisX().max = 100;
146 chartView.axisX().max = 100;
142 chartView.axisY().min = 0;
147 chartView.axisY().min = 0;
143 chartView.axisY().max = 1;
148 chartView.axisY().max = 1;
144
149
145 for (var i = 0; i < count; i++) {
150 for (var i = 0; i < count; i++) {
146 lineSeries.append(i, Math.random());
151 lineSeries.append(i, Math.random());
147 splineSeries.append(i, Math.random());
152 splineSeries.append(i, Math.random());
148 scatterSeries.append(i, Math.random());
153 scatterSeries.append(i, Math.random());
149 }
154 }
150
155
151 return count;
156 return count;
152 }
157 }
153
158
154 // Not a test function, called from test functions
159 // Not a test function, called from test functions
155 function clear() {
160 function clear() {
156 lineSeries.clear();
161 lineSeries.clear();
157 splineSeries.clear();
162 splineSeries.clear();
158 scatterSeries.clear();
163 scatterSeries.clear();
159 }
164 }
160 }
165 }
161
166
162 ChartView {
167 ChartView {
163 id: chartView
168 id: chartView
164 anchors.fill: parent
169 anchors.fill: parent
165
170
166 LineSeries {
171 LineSeries {
167 id: lineSeries
172 id: lineSeries
168 name: "line"
173 name: "line"
169
174
170 SignalSpy {
175 SignalSpy {
171 id: lineSeriesPointAddedSpy
176 id: lineSeriesPointAddedSpy
172 target: lineSeries
177 target: lineSeries
173 signalName: "pointAdded"
178 signalName: "pointAdded"
174 }
179 }
175
180
176 SignalSpy {
181 SignalSpy {
177 id: lineSeriesPointReplacedSpy
182 id: lineSeriesPointReplacedSpy
178 target: lineSeries
183 target: lineSeries
179 signalName: "pointReplaced"
184 signalName: "pointReplaced"
180 }
185 }
181
186
182 SignalSpy {
187 SignalSpy {
183 id: lineSeriesPointsReplacedSpy
188 id: lineSeriesPointsReplacedSpy
184 target: lineSeries
189 target: lineSeries
185 signalName: "pointsReplaced"
190 signalName: "pointsReplaced"
186 }
191 }
187
192
188 SignalSpy {
193 SignalSpy {
189 id: lineSeriesPointRemovedSpy
194 id: lineSeriesPointRemovedSpy
190 target: lineSeries
195 target: lineSeries
191 signalName: "pointRemoved"
196 signalName: "pointRemoved"
192 }
197 }
193 }
198 }
194
199
195 AreaSeries {
200 AreaSeries {
196 id: areaSeries
201 id: areaSeries
197 name: "area"
202 name: "area"
198 upperSeries: lineSeries
203 upperSeries: lineSeries
199 }
204 }
200
205
201 SplineSeries {
206 SplineSeries {
202 id: splineSeries
207 id: splineSeries
203 name: "spline"
208 name: "spline"
204
209
205 SignalSpy {
210 SignalSpy {
206 id: splineSeriesPointAddedSpy
211 id: splineSeriesPointAddedSpy
207 target: splineSeries
212 target: splineSeries
208 signalName: "pointAdded"
213 signalName: "pointAdded"
209 }
214 }
210
215
211 SignalSpy {
216 SignalSpy {
212 id: splineSeriesPointReplacedSpy
217 id: splineSeriesPointReplacedSpy
213 target: splineSeries
218 target: splineSeries
214 signalName: "pointReplaced"
219 signalName: "pointReplaced"
215 }
220 }
216
221
217 SignalSpy {
222 SignalSpy {
218 id: splineSeriesPointsReplacedSpy
223 id: splineSeriesPointsReplacedSpy
219 target: splineSeries
224 target: splineSeries
220 signalName: "pointsReplaced"
225 signalName: "pointsReplaced"
221 }
226 }
222
227
223 SignalSpy {
228 SignalSpy {
224 id: splineSeriesPointRemovedSpy
229 id: splineSeriesPointRemovedSpy
225 target: splineSeries
230 target: splineSeries
226 signalName: "pointRemoved"
231 signalName: "pointRemoved"
227 }
232 }
228 }
233 }
229
234
230 ScatterSeries {
235 ScatterSeries {
231 id: scatterSeries
236 id: scatterSeries
232 name: "scatter"
237 name: "scatter"
233
238
234 SignalSpy {
239 SignalSpy {
235 id: scatterSeriesPointAddedSpy
240 id: scatterSeriesPointAddedSpy
236 target: scatterSeries
241 target: scatterSeries
237 signalName: "pointAdded"
242 signalName: "pointAdded"
238 }
243 }
239
244
240 SignalSpy {
245 SignalSpy {
241 id: scatterSeriesPointReplacedSpy
246 id: scatterSeriesPointReplacedSpy
242 target: scatterSeries
247 target: scatterSeries
243 signalName: "pointReplaced"
248 signalName: "pointReplaced"
244 }
249 }
245
250
246 SignalSpy {
251 SignalSpy {
247 id: scatterSeriesPointsReplacedSpy
252 id: scatterSeriesPointsReplacedSpy
248 target: scatterSeries
253 target: scatterSeries
249 signalName: "pointsReplaced"
254 signalName: "pointsReplaced"
250 }
255 }
251
256
252 SignalSpy {
257 SignalSpy {
253 id: scatterSeriesPointRemovedSpy
258 id: scatterSeriesPointRemovedSpy
254 target: scatterSeries
259 target: scatterSeries
255 signalName: "pointRemoved"
260 signalName: "pointRemoved"
256 }
261 }
257 }
262 }
258 }
263 }
259 }
264 }
@@ -1,74 +1,74
1 /****************************************************************************
1 /****************************************************************************
2 **
2 **
3 ** Copyright (C) 2012 Digia Plc
3 ** Copyright (C) 2012 Digia Plc
4 ** All rights reserved.
4 ** All rights reserved.
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 **
6 **
7 ** This file is part of the Qt Commercial Charts Add-on.
7 ** This file is part of the Qt Commercial Charts Add-on.
8 **
8 **
9 ** $QT_BEGIN_LICENSE$
9 ** $QT_BEGIN_LICENSE$
10 ** Licensees holding valid Qt Commercial licenses may use this file in
10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 ** accordance with the Qt Commercial License Agreement provided with the
11 ** accordance with the Qt Commercial License Agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia.
13 ** a written agreement between you and Digia.
14 **
14 **
15 ** If you have questions regarding the use of this file, please use
15 ** If you have questions regarding the use of this file, please use
16 ** contact form at http://qt.digia.com
16 ** contact form at http://qt.digia.com
17 ** $QT_END_LICENSE$
17 ** $QT_END_LICENSE$
18 **
18 **
19 ****************************************************************************/
19 ****************************************************************************/
20
20
21 import QtQuick 1.0
21 import QtQuick 1.0
22 import QtCommercial.Chart 1.1
22 import QtCommercial.Chart 1.1
23
23
24 ChartView {
24 ChartView {
25 title: "configuring dynamically"
25 title: "configuring dynamically"
26 id: chartView
26 id: chartView
27 property int index: 0
27 property int index: 0
28
28
29 Timer {
29 Timer {
30 interval: 1000
30 interval: 1000
31 repeat: true
31 repeat: true
32 running: true
32 running: true
33 onTriggered: {
33 onTriggered: {
34 switch (index) {
34 switch (index) {
35 case 0:
35 case 0:
36 chartView.axisX(lineSeries).max = 6;
36 lineSeries.axisX.max = 6;
37 chartView.axisY(lineSeries).max = 6;
37 lineSeries.axisY.max = 6;
38 break;
38 break;
39 case 1:
39 case 1:
40 chartView.axisX(scatterSeries).max = 10;
40 scatterSeries.axisX.max = 10;
41 chartView.axisY(scatterSeries).max = 10;
41 scatterSeries.axisY.max = 10;
42 break;
42 break;
43 default:
43 default:
44 chartView.axisX().max = 4;
44 chartView.axisX().max = 4;
45 chartView.axisY().max = 4;
45 chartView.axisY().max = 4;
46 }
46 }
47 index = (index + 1) % 3;
47 index = (index + 1) % 3;
48 }
48 }
49 }
49 }
50
50
51 LineSeries {
51 LineSeries {
52 id: lineSeries
52 id: lineSeries
53 name: "line series"
53 name: "line series"
54 XYPoint { x: 0; y: 0 }
54 XYPoint { x: 0; y: 0 }
55 XYPoint { x: 1; y: 1 }
55 XYPoint { x: 1; y: 1 }
56 XYPoint { x: 2; y: 2 }
56 XYPoint { x: 2; y: 2 }
57 XYPoint { x: 3; y: 3 }
57 XYPoint { x: 3; y: 3 }
58 XYPoint { x: 4; y: 4 }
58 XYPoint { x: 4; y: 4 }
59 }
59 }
60
60
61 ScatterSeries {
61 ScatterSeries {
62 id: scatterSeries
62 id: scatterSeries
63 name: "scatter series"
63 name: "scatter series"
64 XYPoint { x: 0; y: 0 }
64 XYPoint { x: 0; y: 0 }
65 XYPoint { x: 0.5; y: 1 }
65 XYPoint { x: 0.5; y: 1 }
66 XYPoint { x: 1; y: 2 }
66 XYPoint { x: 1; y: 2 }
67 XYPoint { x: 1.5; y: 3 }
67 XYPoint { x: 1.5; y: 3 }
68 XYPoint { x: 2; y: 4 }
68 XYPoint { x: 2; y: 4 }
69 XYPoint { x: 1; y: 1 }
69 XYPoint { x: 1; y: 1 }
70 XYPoint { x: 2; y: 2 }
70 XYPoint { x: 2; y: 2 }
71 XYPoint { x: 3; y: 3 }
71 XYPoint { x: 3; y: 3 }
72 XYPoint { x: 4; y: 4 }
72 XYPoint { x: 4; y: 4 }
73 }
73 }
74 }
74 }
General Comments 0
You need to be logged in to leave comments. Login now