##// END OF EJS Templates
Renamed XyPoint to XYPoint
Tero Ahola -
r1532:d1f7bd98a717
parent child
Show More
@@ -1,44 +1,44
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.0
22 import QtCommercial.Chart 1.0
23
23
24 Rectangle {
24 Rectangle {
25 anchors.fill: parent
25 anchors.fill: parent
26
26
27 //![1]
27 //![1]
28 ChartView {
28 ChartView {
29 title: "Line"
29 title: "Line"
30 anchors.fill: parent
30 anchors.fill: parent
31
31
32 LineSeries {
32 LineSeries {
33 name: "LineSeries"
33 name: "LineSeries"
34 XyPoint { x: 0; y: 0 }
34 XYPoint { x: 0; y: 0 }
35 XyPoint { x: 1.1; y: 2.1 }
35 XYPoint { x: 1.1; y: 2.1 }
36 XyPoint { x: 1.9; y: 3.3 }
36 XYPoint { x: 1.9; y: 3.3 }
37 XyPoint { x: 2.1; y: 2.1 }
37 XYPoint { x: 2.1; y: 2.1 }
38 XyPoint { x: 2.9; y: 4.9 }
38 XYPoint { x: 2.9; y: 4.9 }
39 XyPoint { x: 3.4; y: 3.0 }
39 XYPoint { x: 3.4; y: 3.0 }
40 XyPoint { x: 4.1; y: 3.3 }
40 XYPoint { x: 4.1; y: 3.3 }
41 }
41 }
42 }
42 }
43 //![1]
43 //![1]
44 }
44 }
@@ -1,44 +1,44
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.0
22 import QtCommercial.Chart 1.0
23
23
24 Rectangle {
24 Rectangle {
25 anchors.fill: parent
25 anchors.fill: parent
26
26
27 //![1]
27 //![1]
28 ChartView {
28 ChartView {
29 title: "Spline"
29 title: "Spline"
30 anchors.fill: parent
30 anchors.fill: parent
31
31
32 SplineSeries {
32 SplineSeries {
33 name: "SplineSeries"
33 name: "SplineSeries"
34 XyPoint { x: 0; y: 0.3 }
34 XYPoint { x: 0; y: 0.3 }
35 XyPoint { x: 1.1; y: 3.2 }
35 XYPoint { x: 1.1; y: 3.2 }
36 XyPoint { x: 1.9; y: 2.4 }
36 XYPoint { x: 1.9; y: 2.4 }
37 XyPoint { x: 2.1; y: 2.1 }
37 XYPoint { x: 2.1; y: 2.1 }
38 XyPoint { x: 2.9; y: 2.6 }
38 XYPoint { x: 2.9; y: 2.6 }
39 XyPoint { x: 3.4; y: 2.3 }
39 XYPoint { x: 3.4; y: 2.3 }
40 XyPoint { x: 4.1; y: 3.1 }
40 XYPoint { x: 4.1; y: 3.1 }
41 }
41 }
42 }
42 }
43 //![1]
43 //![1]
44 }
44 }
@@ -1,141 +1,141
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.0
22 import QtCommercial.Chart 1.0
23
23
24 Rectangle {
24 Rectangle {
25 anchors.fill: parent
25 anchors.fill: parent
26
26
27 //![1]
27 //![1]
28 ChartView {
28 ChartView {
29 title: "NHL All-Star Team Players"
29 title: "NHL All-Star Team Players"
30 anchors.fill: parent
30 anchors.fill: parent
31 axisXLabels: ["0", "2000", "1", "2001", "2", "2002", "3", "2003", "4", "2004", "5", "2005",
31 axisXLabels: ["0", "2000", "1", "2001", "2", "2002", "3", "2003", "4", "2004", "5", "2005",
32 "6", "2006", "7", "2007", "8", "2008", "9", "2009", "10", "2010", "11", "2011"]
32 "6", "2006", "7", "2007", "8", "2008", "9", "2009", "10", "2010", "11", "2011"]
33
33
34 AreaSeries {
34 AreaSeries {
35 name: "Russian"
35 name: "Russian"
36 upperSeries: LineSeries {
36 upperSeries: LineSeries {
37 XyPoint { x: 0; y: 1 }
37 XYPoint { x: 0; y: 1 }
38 XyPoint { x: 1; y: 1 }
38 XYPoint { x: 1; y: 1 }
39 XyPoint { x: 2; y: 1 }
39 XYPoint { x: 2; y: 1 }
40 XyPoint { x: 3; y: 1 }
40 XYPoint { x: 3; y: 1 }
41 XyPoint { x: 4; y: 1 }
41 XYPoint { x: 4; y: 1 }
42 XyPoint { x: 5; y: 0 }
42 XYPoint { x: 5; y: 0 }
43 XyPoint { x: 6; y: 1 }
43 XYPoint { x: 6; y: 1 }
44 XyPoint { x: 7; y: 1 }
44 XYPoint { x: 7; y: 1 }
45 XyPoint { x: 8; y: 4 }
45 XYPoint { x: 8; y: 4 }
46 XyPoint { x: 9; y: 3 }
46 XYPoint { x: 9; y: 3 }
47 XyPoint { x: 10; y: 2 }
47 XYPoint { x: 10; y: 2 }
48 XyPoint { x: 11; y: 1 }
48 XYPoint { x: 11; y: 1 }
49 }
49 }
50 lowerSeries: LineSeries {
50 lowerSeries: LineSeries {
51 XyPoint { x: 0; y: 0 }
51 XYPoint { x: 0; y: 0 }
52 XyPoint { x: 1; y: 0 }
52 XYPoint { x: 1; y: 0 }
53 XyPoint { x: 2; y: 0 }
53 XYPoint { x: 2; y: 0 }
54 XyPoint { x: 3; y: 0 }
54 XYPoint { x: 3; y: 0 }
55 XyPoint { x: 4; y: 0 }
55 XYPoint { x: 4; y: 0 }
56 XyPoint { x: 5; y: 0 }
56 XYPoint { x: 5; y: 0 }
57 XyPoint { x: 6; y: 0 }
57 XYPoint { x: 6; y: 0 }
58 XyPoint { x: 7; y: 0 }
58 XYPoint { x: 7; y: 0 }
59 XyPoint { x: 8; y: 0 }
59 XYPoint { x: 8; y: 0 }
60 XyPoint { x: 9; y: 0 }
60 XYPoint { x: 9; y: 0 }
61 XyPoint { x: 10; y: 0 }
61 XYPoint { x: 10; y: 0 }
62 XyPoint { x: 11; y: 0 }
62 XYPoint { x: 11; y: 0 }
63 }
63 }
64 }
64 }
65 // ...
65 // ...
66 //![1]
66 //![1]
67
67
68 AreaSeries {
68 AreaSeries {
69 id: swedish
69 id: swedish
70 name: "Swedish"
70 name: "Swedish"
71 upperSeries: LineSeries {
71 upperSeries: LineSeries {
72 XyPoint { x: 0; y: 1 }
72 XYPoint { x: 0; y: 1 }
73 XyPoint { x: 1; y: 1 }
73 XYPoint { x: 1; y: 1 }
74 XyPoint { x: 2; y: 3 }
74 XYPoint { x: 2; y: 3 }
75 XyPoint { x: 3; y: 3 }
75 XYPoint { x: 3; y: 3 }
76 XyPoint { x: 4; y: 2 }
76 XYPoint { x: 4; y: 2 }
77 XyPoint { x: 5; y: 0 }
77 XYPoint { x: 5; y: 0 }
78 XyPoint { x: 6; y: 2 }
78 XYPoint { x: 6; y: 2 }
79 XyPoint { x: 7; y: 1 }
79 XYPoint { x: 7; y: 1 }
80 XyPoint { x: 8; y: 2 }
80 XYPoint { x: 8; y: 2 }
81 XyPoint { x: 9; y: 1 }
81 XYPoint { x: 9; y: 1 }
82 XyPoint { x: 10; y: 3 }
82 XYPoint { x: 10; y: 3 }
83 XyPoint { x: 11; y: 3 }
83 XYPoint { x: 11; y: 3 }
84 }
84 }
85 lowerSeries: LineSeries {
85 lowerSeries: LineSeries {
86 XyPoint { x: 0; y: 0 }
86 XYPoint { x: 0; y: 0 }
87 XyPoint { x: 1; y: 0 }
87 XYPoint { x: 1; y: 0 }
88 XyPoint { x: 2; y: 0 }
88 XYPoint { x: 2; y: 0 }
89 XyPoint { x: 3; y: 0 }
89 XYPoint { x: 3; y: 0 }
90 XyPoint { x: 4; y: 0 }
90 XYPoint { x: 4; y: 0 }
91 XyPoint { x: 5; y: 0 }
91 XYPoint { x: 5; y: 0 }
92 XyPoint { x: 6; y: 0 }
92 XYPoint { x: 6; y: 0 }
93 XyPoint { x: 7; y: 0 }
93 XYPoint { x: 7; y: 0 }
94 XyPoint { x: 8; y: 0 }
94 XYPoint { x: 8; y: 0 }
95 XyPoint { x: 9; y: 0 }
95 XYPoint { x: 9; y: 0 }
96 XyPoint { x: 10; y: 0 }
96 XYPoint { x: 10; y: 0 }
97 XyPoint { x: 11; y: 0 }
97 XYPoint { x: 11; y: 0 }
98 }
98 }
99 onClicked: {
99 onClicked: {
100 color = "yellow";
100 color = "yellow";
101 borderColor = "blue";
101 borderColor = "blue";
102 }
102 }
103 }
103 }
104
104
105 AreaSeries {
105 AreaSeries {
106 name: "Finnish"
106 name: "Finnish"
107 upperSeries: LineSeries {
107 upperSeries: LineSeries {
108 XyPoint { x: 0; y: 0 }
108 XYPoint { x: 0; y: 0 }
109 XyPoint { x: 1; y: 0 }
109 XYPoint { x: 1; y: 0 }
110 XyPoint { x: 2; y: 0 }
110 XYPoint { x: 2; y: 0 }
111 XyPoint { x: 3; y: 0 }
111 XYPoint { x: 3; y: 0 }
112 XyPoint { x: 4; y: 0 }
112 XYPoint { x: 4; y: 0 }
113 XyPoint { x: 5; y: 0 }
113 XYPoint { x: 5; y: 0 }
114 XyPoint { x: 6; y: 1 }
114 XYPoint { x: 6; y: 1 }
115 XyPoint { x: 7; y: 0 }
115 XYPoint { x: 7; y: 0 }
116 XyPoint { x: 8; y: 0 }
116 XYPoint { x: 8; y: 0 }
117 XyPoint { x: 9; y: 0 }
117 XYPoint { x: 9; y: 0 }
118 XyPoint { x: 10; y: 0 }
118 XYPoint { x: 10; y: 0 }
119 XyPoint { x: 11; y: 1 }
119 XYPoint { x: 11; y: 1 }
120 }
120 }
121 lowerSeries: LineSeries {
121 lowerSeries: LineSeries {
122 XyPoint { x: 0; y: 0 }
122 XYPoint { x: 0; y: 0 }
123 XyPoint { x: 1; y: 0 }
123 XYPoint { x: 1; y: 0 }
124 XyPoint { x: 2; y: 0 }
124 XYPoint { x: 2; y: 0 }
125 XyPoint { x: 3; y: 0 }
125 XYPoint { x: 3; y: 0 }
126 XyPoint { x: 4; y: 0 }
126 XYPoint { x: 4; y: 0 }
127 XyPoint { x: 5; y: 0 }
127 XYPoint { x: 5; y: 0 }
128 XyPoint { x: 6; y: 0 }
128 XYPoint { x: 6; y: 0 }
129 XyPoint { x: 7; y: 0 }
129 XYPoint { x: 7; y: 0 }
130 XyPoint { x: 8; y: 0 }
130 XYPoint { x: 8; y: 0 }
131 XyPoint { x: 9; y: 0 }
131 XYPoint { x: 9; y: 0 }
132 XyPoint { x: 10; y: 0 }
132 XYPoint { x: 10; y: 0 }
133 XyPoint { x: 11; y: 0 }
133 XYPoint { x: 11; y: 0 }
134 }
134 }
135 onClicked: {
135 onClicked: {
136 color = "white";
136 color = "white";
137 borderColor = "blue";
137 borderColor = "blue";
138 }
138 }
139 }
139 }
140 }
140 }
141 }
141 }
@@ -1,58 +1,58
1 /****************************************************************************
1 /****************************************************************************
2 **
2 **
3 ** Copyright (C) 2012 Digia Plc
3 ** Copyright (C) 2012 Digia Plc
4 ** All rights reserved.
4 ** All rights reserved.
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 **
6 **
7 ** This file is part of the Qt Commercial Charts Add-on.
7 ** This file is part of the Qt Commercial Charts Add-on.
8 **
8 **
9 ** $QT_BEGIN_LICENSE$
9 ** $QT_BEGIN_LICENSE$
10 ** Licensees holding valid Qt Commercial licenses may use this file in
10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 ** accordance with the Qt Commercial License Agreement provided with the
11 ** accordance with the Qt Commercial License Agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia.
13 ** a written agreement between you and Digia.
14 **
14 **
15 ** If you have questions regarding the use of this file, please use
15 ** If you have questions regarding the use of this file, please use
16 ** contact form at http://qt.digia.com
16 ** contact form at http://qt.digia.com
17 ** $QT_END_LICENSE$
17 ** $QT_END_LICENSE$
18 **
18 **
19 ****************************************************************************/
19 ****************************************************************************/
20
20
21 import QtQuick 1.0
21 import QtQuick 1.0
22 import QtCommercial.Chart 1.0
22 import QtCommercial.Chart 1.0
23
23
24 Rectangle {
24 Rectangle {
25 anchors.fill: parent
25 anchors.fill: parent
26
26
27 //![1]
27 //![1]
28 ChartView {
28 ChartView {
29 title: "Scatters"
29 title: "Scatters"
30 anchors.fill: parent
30 anchors.fill: parent
31
31
32 ScatterSeries {
32 ScatterSeries {
33 id: scatter1
33 id: scatter1
34 name: "Scatter1"
34 name: "Scatter1"
35 XyPoint { x: 1.5; y: 1.5 }
35 XYPoint { x: 1.5; y: 1.5 }
36 XyPoint { x: 1.5; y: 1.6 }
36 XYPoint { x: 1.5; y: 1.6 }
37 XyPoint { x: 1.57; y: 1.55 }
37 XYPoint { x: 1.57; y: 1.55 }
38 XyPoint { x: 1.8; y: 1.8 }
38 XYPoint { x: 1.8; y: 1.8 }
39 XyPoint { x: 1.9; y: 1.6 }
39 XYPoint { x: 1.9; y: 1.6 }
40 XyPoint { x: 2.1; y: 1.3 }
40 XYPoint { x: 2.1; y: 1.3 }
41 XyPoint { x: 2.5; y: 2.1 }
41 XYPoint { x: 2.5; y: 2.1 }
42 }
42 }
43
43
44 ScatterSeries {
44 ScatterSeries {
45 name: "Scatter2"
45 name: "Scatter2"
46 // ...
46 // ...
47 //![1]
47 //![1]
48 XyPoint { x: 2.0; y: 2.0 }
48 XYPoint { x: 2.0; y: 2.0 }
49 XyPoint { x: 2.0; y: 2.1 }
49 XYPoint { x: 2.0; y: 2.1 }
50 XyPoint { x: 2.07; y: 2.05 }
50 XYPoint { x: 2.07; y: 2.05 }
51 XyPoint { x: 2.2; y: 2.9 }
51 XYPoint { x: 2.2; y: 2.9 }
52 XyPoint { x: 2.4; y: 2.7 }
52 XYPoint { x: 2.4; y: 2.7 }
53 XyPoint { x: 2.67; y: 2.65 }
53 XYPoint { x: 2.67; y: 2.65 }
54 //![2]
54 //![2]
55 }
55 }
56 }
56 }
57 //![2]
57 //![2]
58 }
58 }
@@ -1,79 +1,79
1 /*!
1 /*!
2 \page qml.html
2 \page qml.html
3 \title QtCommercial Charts QML API
3 \title QtCommercial Charts QML API
4 \keyword Charts QML API
4 \keyword Charts QML API
5
5
6 QtCommercial Charts QML API is an intuitive and simple way to show charts in your QML
6 QtCommercial Charts QML API is an intuitive and simple way to show charts in your QML
7 applications. The following QML shows you to create a simple pie chart:
7 applications. The following QML shows you to create a simple pie chart:
8 \snippet ../examples/qmlpiechart/qml/qmlpiechart/main.qml 1
8 \snippet ../examples/qmlpiechart/qml/qmlpiechart/main.qml 1
9 \snippet ../examples/qmlpiechart/qml/qmlpiechart/main.qml 2
9 \snippet ../examples/qmlpiechart/qml/qmlpiechart/main.qml 2
10 \snippet ../examples/qmlpiechart/qml/qmlpiechart/main.qml 3
10 \snippet ../examples/qmlpiechart/qml/qmlpiechart/main.qml 3
11
11
12 \raw HTML
12 \raw HTML
13 <table cellpadding="2" cellspacing="1" border="0" width="95%" class="indextable">
13 <table cellpadding="2" cellspacing="1" border="0" width="95%" class="indextable">
14 <tr>
14 <tr>
15 <th class="titleheader" width="25%"> ChartView and it's properties </th>
15 <th class="titleheader" width="25%"> ChartView and it's properties </th>
16 </tr>
16 </tr>
17 <tr>
17 <tr>
18 <td valign="top">
18 <td valign="top">
19 <ul>
19 <ul>
20 <li><a href="qml-chartview.html">ChartView</a></li>
20 <li><a href="qml-chartview.html">ChartView</a></li>
21 <li><a href="qml-axis.html">Axis</a></li>
21 <li><a href="qml-axis.html">Axis</a></li>
22 <li><a href="qml-legend.html">Legend</a></li>
22 <li><a href="qml-legend.html">Legend</a></li>
23 <li><a href="qml-abstractseries.html">AbstractSeries</a></li>
23 <li><a href="qml-abstractseries.html">AbstractSeries</a></li>
24 </ul>
24 </ul>
25 </td>
25 </td>
26 </tr>
26 </tr>
27 </table>
27 </table>
28 <table cellpadding="2" cellspacing="1" border="0" width="95%" class="indextable">
28 <table cellpadding="2" cellspacing="1" border="0" width="95%" class="indextable">
29 <tr>
29 <tr>
30 <th class="titleheader" width="25%"> XY chart </th>
30 <th class="titleheader" width="25%"> XY chart </th>
31 </tr>
31 </tr>
32 <tr>
32 <tr>
33 <td valign="top">
33 <td valign="top">
34 <ul>
34 <ul>
35 <li><a href="qml-xyseries.html">XYSeries</a></li>
35 <li><a href="qml-xyseries.html">XYSeries</a></li>
36 <li><a href="qml-lineseries.html">LineSeries</a></li>
36 <li><a href="qml-lineseries.html">LineSeries</a></li>
37 <li><a href="qml-areaseries.html">AreaSeries</a></li>
37 <li><a href="qml-areaseries.html">AreaSeries</a></li>
38 <li><a href="qml-scatterseries.html">ScatterSeries</a></li>
38 <li><a href="qml-scatterseries.html">ScatterSeries</a></li>
39 <li><a href="qml-splineseries.html">SplineSeries</a></li>
39 <li><a href="qml-splineseries.html">SplineSeries</a></li>
40 <li><a href="qml-xypoint.html">XyPoint</a></li>
40 <li><a href="qml-xypoint.html">XYPoint</a></li>
41 <li><a href="qml-hxymodelmapper.html">HXYModelMapper</a></li>
41 <li><a href="qml-hxymodelmapper.html">HXYModelMapper</a></li>
42 <li><a href="qml-vxymodelmapper.html">VXYModelMapper</a></li>
42 <li><a href="qml-vxymodelmapper.html">VXYModelMapper</a></li>
43 </ul>
43 </ul>
44 </td>
44 </td>
45 </tr>
45 </tr>
46 </table>
46 </table>
47 <table cellpadding="2" cellspacing="1" border="0" width="95%" class="indextable">
47 <table cellpadding="2" cellspacing="1" border="0" width="95%" class="indextable">
48 <tr>
48 <tr>
49 <th class="titleheader" width="25%"> Pie chart </th>
49 <th class="titleheader" width="25%"> Pie chart </th>
50 <tr>
50 <tr>
51 <td valign="top">
51 <td valign="top">
52 <ul>
52 <ul>
53 <li><a href="qml-pieseries.html">PieSeries</a></li>
53 <li><a href="qml-pieseries.html">PieSeries</a></li>
54 <li><a href="qml-pieslice.html">PieSlice</a></li>
54 <li><a href="qml-pieslice.html">PieSlice</a></li>
55 <li><a href="qml-hpiemodelmapper.html">HPieModelMapper</a></li>
55 <li><a href="qml-hpiemodelmapper.html">HPieModelMapper</a></li>
56 <li><a href="qml-vpiemodelmapper.html">VPieModelMapper</a></li>
56 <li><a href="qml-vpiemodelmapper.html">VPieModelMapper</a></li>
57 </ul>
57 </ul>
58 </td>
58 </td>
59 </tr>
59 </tr>
60 </table>
60 </table>
61 <table cellpadding="2" cellspacing="1" border="0" width="95%" class="indextable">
61 <table cellpadding="2" cellspacing="1" border="0" width="95%" class="indextable">
62 <tr>
62 <tr>
63 <th class="titleheader" width="25%"> Bar chart </th>
63 <th class="titleheader" width="25%"> Bar chart </th>
64 <tr>
64 <tr>
65 <td valign="top">
65 <td valign="top">
66 <ul>
66 <ul>
67 <li><a href="qml-barseries.html">BarSeries</a></li>
67 <li><a href="qml-barseries.html">BarSeries</a></li>
68 <li><a href="qml-groupedbarseries.html">GroupedBarSeries</a></li>
68 <li><a href="qml-groupedbarseries.html">GroupedBarSeries</a></li>
69 <li><a href="qml-stackedbarseries.html">StackedBarSeries</a></li>
69 <li><a href="qml-stackedbarseries.html">StackedBarSeries</a></li>
70 <li><a href="qml-percentbarseries.html">PercentBarSeries</a></li>
70 <li><a href="qml-percentbarseries.html">PercentBarSeries</a></li>
71 <li><a href="qml-barset.html">BarSet</a></li>
71 <li><a href="qml-barset.html">BarSet</a></li>
72 <li><a href="qml-hbarmodelmapper.html">HBarModelMapper</a></li>
72 <li><a href="qml-hbarmodelmapper.html">HBarModelMapper</a></li>
73 <li><a href="qml-vbarmodelmapper.html">VBarModelMapper</a></li>
73 <li><a href="qml-vbarmodelmapper.html">VBarModelMapper</a></li>
74 </ul>
74 </ul>
75 </td>
75 </td>
76 </tr>
76 </tr>
77 </table>
77 </table>
78 \endraw
78 \endraw
79 */
79 */
@@ -1,51 +1,51
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 "declarativexypoint.h"
21 #include "declarativexypoint.h"
22
22
23 QTCOMMERCIALCHART_BEGIN_NAMESPACE
23 QTCOMMERCIALCHART_BEGIN_NAMESPACE
24
24
25 /*!
25 /*!
26 \qmlclass XyPoint QPointF
26 \qmlclass XYPoint QPointF
27 XyPoint is a convenience element for initializing XY-series with static coordinate data. To
27 XYPoint is a convenience element for initializing XY-series with static coordinate data. To
28 manipulate an XY-series dynamically, use it's data manipulation functions instead.
28 manipulate an XY-series dynamically, use it's data manipulation functions instead.
29 \sa LineSeries, AreaSeries, ScatterSeries, SplineSeries
29 \sa LineSeries, AreaSeries, ScatterSeries, SplineSeries
30 */
30 */
31
31
32 /*!
32 /*!
33 \qmlproperty real XyPoint::x
33 \qmlproperty real XYPoint::x
34 The x-coordinate of the point.
34 The x-coordinate of the point.
35 */
35 */
36
36
37 /*!
37 /*!
38 \qmlproperty real XyPoint::y
38 \qmlproperty real XYPoint::y
39 The y-coordinate of the point.
39 The y-coordinate of the point.
40 */
40 */
41
41
42 DeclarativeXyPoint::DeclarativeXyPoint(QObject *parent) :
42 DeclarativeXYPoint::DeclarativeXYPoint(QObject *parent) :
43 QObject(parent)
43 QObject(parent)
44 {
44 {
45 setX(0.0);
45 setX(0.0);
46 setY(0.0);
46 setY(0.0);
47 }
47 }
48
48
49 #include "moc_declarativexypoint.cpp"
49 #include "moc_declarativexypoint.cpp"
50
50
51 QTCOMMERCIALCHART_END_NAMESPACE
51 QTCOMMERCIALCHART_END_NAMESPACE
@@ -1,44 +1,44
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 DECLARATIVE_XY_POINT_H
21 #ifndef DECLARATIVE_XY_POINT_H
22 #define DECLARATIVE_XY_POINT_H
22 #define DECLARATIVE_XY_POINT_H
23
23
24 #include "qchartglobal.h"
24 #include "qchartglobal.h"
25 #include <QObject>
25 #include <QObject>
26 #include <QPointF>
26 #include <QPointF>
27 #include <QDataStream>
27 #include <QDataStream>
28
28
29 QTCOMMERCIALCHART_BEGIN_NAMESPACE
29 QTCOMMERCIALCHART_BEGIN_NAMESPACE
30
30
31 class DeclarativeXyPoint : public QObject, public QPointF
31 class DeclarativeXYPoint : public QObject, public QPointF
32 {
32 {
33 Q_OBJECT
33 Q_OBJECT
34 // TODO: make the setters change the value, if parented by a series
34 // TODO: make the setters change the value, if parented by a series
35 Q_PROPERTY(qreal x READ x WRITE setX /*NOTIFY dataXChanged*/)
35 Q_PROPERTY(qreal x READ x WRITE setX /*NOTIFY dataXChanged*/)
36 Q_PROPERTY(qreal y READ y WRITE setY /*NOTIFY dataYChanged*/)
36 Q_PROPERTY(qreal y READ y WRITE setY /*NOTIFY dataYChanged*/)
37
37
38 public:
38 public:
39 explicit DeclarativeXyPoint(QObject *parent = 0);
39 explicit DeclarativeXYPoint(QObject *parent = 0);
40 };
40 };
41
41
42 QTCOMMERCIALCHART_END_NAMESPACE
42 QTCOMMERCIALCHART_END_NAMESPACE
43
43
44 #endif // DECLARATIVE_XY_POINT_H
44 #endif // DECLARATIVE_XY_POINT_H
@@ -1,106 +1,106
1 /****************************************************************************
1 /****************************************************************************
2 **
2 **
3 ** Copyright (C) 2012 Digia Plc
3 ** Copyright (C) 2012 Digia Plc
4 ** All rights reserved.
4 ** All rights reserved.
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 **
6 **
7 ** This file is part of the Qt Commercial Charts Add-on.
7 ** This file is part of the Qt Commercial Charts Add-on.
8 **
8 **
9 ** $QT_BEGIN_LICENSE$
9 ** $QT_BEGIN_LICENSE$
10 ** Licensees holding valid Qt Commercial licenses may use this file in
10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 ** accordance with the Qt Commercial License Agreement provided with the
11 ** accordance with the Qt Commercial License Agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia.
13 ** a written agreement between you and Digia.
14 **
14 **
15 ** If you have questions regarding the use of this file, please use
15 ** If you have questions regarding the use of this file, please use
16 ** contact form at http://qt.digia.com
16 ** contact form at http://qt.digia.com
17 ** $QT_END_LICENSE$
17 ** $QT_END_LICENSE$
18 **
18 **
19 ****************************************************************************/
19 ****************************************************************************/
20
20
21 //#include "DeclarativeXySeries.h"
21 //#include "DeclarativeXySeries.h"
22 #include "declarativexyseries.h"
22 #include "declarativexyseries.h"
23 #include "declarativechart.h"
23 #include "declarativechart.h"
24 #include <QXYSeries>
24 #include <QXYSeries>
25 #include <QVXYModelMapper>
25 #include <QVXYModelMapper>
26 #include <QHXYModelMapper>
26 #include <QHXYModelMapper>
27 #include <QDeclarativeListProperty>
27 #include <QDeclarativeListProperty>
28
28
29 QTCOMMERCIALCHART_BEGIN_NAMESPACE
29 QTCOMMERCIALCHART_BEGIN_NAMESPACE
30
30
31 DeclarativeXySeries::DeclarativeXySeries()
31 DeclarativeXySeries::DeclarativeXySeries()
32 {
32 {
33 }
33 }
34
34
35 DeclarativeXySeries::~DeclarativeXySeries()
35 DeclarativeXySeries::~DeclarativeXySeries()
36 {
36 {
37 }
37 }
38
38
39 void DeclarativeXySeries::classBegin()
39 void DeclarativeXySeries::classBegin()
40 {
40 {
41 }
41 }
42
42
43 void DeclarativeXySeries::componentComplete()
43 void DeclarativeXySeries::componentComplete()
44 {
44 {
45 QXYSeries *series = qobject_cast<QXYSeries *>(xySeries());
45 QXYSeries *series = qobject_cast<QXYSeries *>(xySeries());
46 Q_ASSERT(series);
46 Q_ASSERT(series);
47
47
48 foreach(QObject *child, series->children()) {
48 foreach(QObject *child, series->children()) {
49 if (qobject_cast<DeclarativeXyPoint *>(child)) {
49 if (qobject_cast<DeclarativeXYPoint *>(child)) {
50 DeclarativeXyPoint *point = qobject_cast<DeclarativeXyPoint *>(child);
50 DeclarativeXYPoint *point = qobject_cast<DeclarativeXYPoint *>(child);
51 series->append(point->x(), point->y());
51 series->append(point->x(), point->y());
52 } else if(qobject_cast<QVXYModelMapper *>(child)) {
52 } else if(qobject_cast<QVXYModelMapper *>(child)) {
53 QVXYModelMapper *mapper = qobject_cast<QVXYModelMapper *>(child);
53 QVXYModelMapper *mapper = qobject_cast<QVXYModelMapper *>(child);
54 mapper->setSeries(series);
54 mapper->setSeries(series);
55 } else if(qobject_cast<QHXYModelMapper *>(child)) {
55 } else if(qobject_cast<QHXYModelMapper *>(child)) {
56 QHXYModelMapper *mapper = qobject_cast<QHXYModelMapper *>(child);
56 QHXYModelMapper *mapper = qobject_cast<QHXYModelMapper *>(child);
57 mapper->setSeries(series);
57 mapper->setSeries(series);
58 }
58 }
59 }
59 }
60 }
60 }
61
61
62 void DeclarativeXySeries::append(qreal x, qreal y)
62 void DeclarativeXySeries::append(qreal x, qreal y)
63 {
63 {
64 QXYSeries *series = qobject_cast<QXYSeries *>(xySeries());
64 QXYSeries *series = qobject_cast<QXYSeries *>(xySeries());
65 Q_ASSERT(series);
65 Q_ASSERT(series);
66 series->append(x, y);
66 series->append(x, y);
67 }
67 }
68
68
69 void DeclarativeXySeries::replace(qreal oldX, qreal oldY, qreal newX, qreal newY)
69 void DeclarativeXySeries::replace(qreal oldX, qreal oldY, qreal newX, qreal newY)
70 {
70 {
71 QXYSeries *series = qobject_cast<QXYSeries *>(xySeries());
71 QXYSeries *series = qobject_cast<QXYSeries *>(xySeries());
72 Q_ASSERT(series);
72 Q_ASSERT(series);
73 series->replace(oldX, oldY, newX, newY);
73 series->replace(oldX, oldY, newX, newY);
74 }
74 }
75
75
76 void DeclarativeXySeries::remove(qreal x, qreal y)
76 void DeclarativeXySeries::remove(qreal x, qreal y)
77 {
77 {
78 QXYSeries *series = qobject_cast<QXYSeries *>(xySeries());
78 QXYSeries *series = qobject_cast<QXYSeries *>(xySeries());
79 Q_ASSERT(series);
79 Q_ASSERT(series);
80 series->remove(x, y);
80 series->remove(x, y);
81 }
81 }
82
82
83 void DeclarativeXySeries::insert(int index, qreal x, qreal y)
83 void DeclarativeXySeries::insert(int index, qreal x, qreal y)
84 {
84 {
85 QXYSeries *series = qobject_cast<QXYSeries *>(xySeries());
85 QXYSeries *series = qobject_cast<QXYSeries *>(xySeries());
86 Q_ASSERT(series);
86 Q_ASSERT(series);
87 series->insert(index, QPointF(x, y));
87 series->insert(index, QPointF(x, y));
88 }
88 }
89
89
90 void DeclarativeXySeries::clear()
90 void DeclarativeXySeries::clear()
91 {
91 {
92 QXYSeries *series = qobject_cast<QXYSeries *>(xySeries());
92 QXYSeries *series = qobject_cast<QXYSeries *>(xySeries());
93 Q_ASSERT(series);
93 Q_ASSERT(series);
94 series->clear();
94 series->clear();
95 }
95 }
96
96
97 QPointF DeclarativeXySeries::at(int index)
97 QPointF DeclarativeXySeries::at(int index)
98 {
98 {
99 QXYSeries *series = qobject_cast<QXYSeries *>(xySeries());
99 QXYSeries *series = qobject_cast<QXYSeries *>(xySeries());
100 Q_ASSERT(series);
100 Q_ASSERT(series);
101 if (index >= 0 || index < series->count())
101 if (index >= 0 || index < series->count())
102 return series->points().at(index);
102 return series->points().at(index);
103 return QPointF(0, 0);
103 return QPointF(0, 0);
104 }
104 }
105
105
106 QTCOMMERCIALCHART_END_NAMESPACE
106 QTCOMMERCIALCHART_END_NAMESPACE
@@ -1,105 +1,105
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 <QtDeclarative/qdeclarativeextensionplugin.h>
21 #include <QtDeclarative/qdeclarativeextensionplugin.h>
22 #include <QtDeclarative/qdeclarative.h>
22 #include <QtDeclarative/qdeclarative.h>
23 #include "qchart.h"
23 #include "qchart.h"
24 #include "qaxiscategories.h"
24 #include "qaxiscategories.h"
25 #include "declarativechart.h"
25 #include "declarativechart.h"
26 #include "declarativexypoint.h"
26 #include "declarativexypoint.h"
27 #include "declarativelineseries.h"
27 #include "declarativelineseries.h"
28 #include "declarativesplineseries.h"
28 #include "declarativesplineseries.h"
29 #include "declarativeareaseries.h"
29 #include "declarativeareaseries.h"
30 #include "declarativescatterseries.h"
30 #include "declarativescatterseries.h"
31 #include "declarativebarseries.h"
31 #include "declarativebarseries.h"
32 #include "declarativepieseries.h"
32 #include "declarativepieseries.h"
33 #include <QVXYModelMapper>
33 #include <QVXYModelMapper>
34 #include <QHXYModelMapper>
34 #include <QHXYModelMapper>
35 #include <QHPieModelMapper>
35 #include <QHPieModelMapper>
36 #include <QVPieModelMapper>
36 #include <QVPieModelMapper>
37 #include <QHBarModelMapper>
37 #include <QHBarModelMapper>
38 #include <QVBarModelMapper>
38 #include <QVBarModelMapper>
39
39
40 QTCOMMERCIALCHART_BEGIN_NAMESPACE
40 QTCOMMERCIALCHART_BEGIN_NAMESPACE
41
41
42 class ChartQmlPlugin : public QDeclarativeExtensionPlugin
42 class ChartQmlPlugin : public QDeclarativeExtensionPlugin
43 {
43 {
44 Q_OBJECT
44 Q_OBJECT
45 public:
45 public:
46 virtual void registerTypes(const char *uri)
46 virtual void registerTypes(const char *uri)
47 {
47 {
48 Q_ASSERT(QLatin1String(uri) == QLatin1String("QtCommercial.Chart"));
48 Q_ASSERT(QLatin1String(uri) == QLatin1String("QtCommercial.Chart"));
49
49
50 qmlRegisterType<DeclarativeChart>(uri, 1, 0, "ChartView");
50 qmlRegisterType<DeclarativeChart>(uri, 1, 0, "ChartView");
51 qmlRegisterType<DeclarativeXyPoint>(uri, 1, 0, "XyPoint");
51 qmlRegisterType<DeclarativeXYPoint>(uri, 1, 0, "XYPoint");
52 qmlRegisterType<DeclarativeScatterSeries>(uri, 1, 0, "ScatterSeries");
52 qmlRegisterType<DeclarativeScatterSeries>(uri, 1, 0, "ScatterSeries");
53 qmlRegisterType<DeclarativeLineSeries>(uri, 1, 0, "LineSeries");
53 qmlRegisterType<DeclarativeLineSeries>(uri, 1, 0, "LineSeries");
54 qmlRegisterType<DeclarativeSplineSeries>(uri, 1, 0, "SplineSeries");
54 qmlRegisterType<DeclarativeSplineSeries>(uri, 1, 0, "SplineSeries");
55 qmlRegisterType<DeclarativeAreaSeries>(uri, 1, 0, "AreaSeries");
55 qmlRegisterType<DeclarativeAreaSeries>(uri, 1, 0, "AreaSeries");
56 qmlRegisterType<DeclarativeBarSeries>(uri, 1, 0, "BarSeries");
56 qmlRegisterType<DeclarativeBarSeries>(uri, 1, 0, "BarSeries");
57 qmlRegisterType<DeclarativeGroupedBarSeries>(uri, 1, 0, "GroupedBarSeries");
57 qmlRegisterType<DeclarativeGroupedBarSeries>(uri, 1, 0, "GroupedBarSeries");
58 qmlRegisterType<DeclarativeStackedBarSeries>(uri, 1, 0, "StackedBarSeries");
58 qmlRegisterType<DeclarativeStackedBarSeries>(uri, 1, 0, "StackedBarSeries");
59 qmlRegisterType<DeclarativePercentBarSeries>(uri, 1, 0, "PercentBarSeries");
59 qmlRegisterType<DeclarativePercentBarSeries>(uri, 1, 0, "PercentBarSeries");
60 qmlRegisterType<DeclarativePieSeries>(uri, 1, 0, "PieSeries");
60 qmlRegisterType<DeclarativePieSeries>(uri, 1, 0, "PieSeries");
61 qmlRegisterType<QPieSlice>(uri, 1, 0, "PieSlice");
61 qmlRegisterType<QPieSlice>(uri, 1, 0, "PieSlice");
62 qmlRegisterType<DeclarativeBarSet>(uri, 1, 0, "BarSet");
62 qmlRegisterType<DeclarativeBarSet>(uri, 1, 0, "BarSet");
63 qmlRegisterType<QHXYModelMapper>(uri, 1, 0, "HXYModelMapper");
63 qmlRegisterType<QHXYModelMapper>(uri, 1, 0, "HXYModelMapper");
64 qmlRegisterType<QVXYModelMapper>(uri, 1, 0, "VXYModelMapper");
64 qmlRegisterType<QVXYModelMapper>(uri, 1, 0, "VXYModelMapper");
65 qmlRegisterType<QHPieModelMapper>(uri, 1, 0, "HPieModelMapper");
65 qmlRegisterType<QHPieModelMapper>(uri, 1, 0, "HPieModelMapper");
66 qmlRegisterType<QVPieModelMapper>(uri, 1, 0, "VPieModelMapper");
66 qmlRegisterType<QVPieModelMapper>(uri, 1, 0, "VPieModelMapper");
67 qmlRegisterType<QHBarModelMapper>(uri, 1, 0, "HBarModelMapper");
67 qmlRegisterType<QHBarModelMapper>(uri, 1, 0, "HBarModelMapper");
68 qmlRegisterType<QVBarModelMapper>(uri, 1, 0, "VBarModelMapper");
68 qmlRegisterType<QVBarModelMapper>(uri, 1, 0, "VBarModelMapper");
69
69
70 qmlRegisterUncreatableType<QLegend>(uri, 1, 0, "Legend",
70 qmlRegisterUncreatableType<QLegend>(uri, 1, 0, "Legend",
71 QLatin1String("Trying to create uncreatable: Legend."));
71 QLatin1String("Trying to create uncreatable: Legend."));
72 qmlRegisterUncreatableType<QXYSeries>(uri, 1, 0, "XYSeries",
72 qmlRegisterUncreatableType<QXYSeries>(uri, 1, 0, "XYSeries",
73 QLatin1String("Trying to create uncreatable: XYSeries."));
73 QLatin1String("Trying to create uncreatable: XYSeries."));
74 qmlRegisterUncreatableType<QScatterSeries>(uri, 1, 0, "QScatterSeries",
74 qmlRegisterUncreatableType<QScatterSeries>(uri, 1, 0, "QScatterSeries",
75 QLatin1String("Trying to create uncreatable: QScatterSeries."));
75 QLatin1String("Trying to create uncreatable: QScatterSeries."));
76 qmlRegisterUncreatableType<QPieSeries>(uri, 1, 0, "QPieSeries",
76 qmlRegisterUncreatableType<QPieSeries>(uri, 1, 0, "QPieSeries",
77 QLatin1String("Trying to create uncreatable: QPieSeries."));
77 QLatin1String("Trying to create uncreatable: QPieSeries."));
78 qmlRegisterUncreatableType<QBarSet>(uri, 1, 0, "QBarSet",
78 qmlRegisterUncreatableType<QBarSet>(uri, 1, 0, "QBarSet",
79 QLatin1String("Trying to create uncreatable: QBarSet."));
79 QLatin1String("Trying to create uncreatable: QBarSet."));
80 qmlRegisterUncreatableType<QAbstractItemModel>(uri, 1, 0, "AbstractItemModel",
80 qmlRegisterUncreatableType<QAbstractItemModel>(uri, 1, 0, "AbstractItemModel",
81 QLatin1String("Trying to create uncreatable: AbstractItemModel."));
81 QLatin1String("Trying to create uncreatable: AbstractItemModel."));
82 qmlRegisterUncreatableType<QXYModelMapper>(uri, 1, 0, "XYModelMapper",
82 qmlRegisterUncreatableType<QXYModelMapper>(uri, 1, 0, "XYModelMapper",
83 QLatin1String("Trying to create uncreatable: XYModelMapper."));
83 QLatin1String("Trying to create uncreatable: XYModelMapper."));
84 qmlRegisterUncreatableType<QPieModelMapper>(uri, 1, 0, "PieModelMapper",
84 qmlRegisterUncreatableType<QPieModelMapper>(uri, 1, 0, "PieModelMapper",
85 QLatin1String("Trying to create uncreatable: PieModelMapper."));
85 QLatin1String("Trying to create uncreatable: PieModelMapper."));
86 qmlRegisterUncreatableType<QBarModelMapper>(uri, 1, 0, "BarModelMapper",
86 qmlRegisterUncreatableType<QBarModelMapper>(uri, 1, 0, "BarModelMapper",
87 QLatin1String("Trying to create uncreatable: BarModelMapper."));
87 QLatin1String("Trying to create uncreatable: BarModelMapper."));
88 qmlRegisterUncreatableType<QAbstractSeries>(uri, 1, 0, "AbstractSeries",
88 qmlRegisterUncreatableType<QAbstractSeries>(uri, 1, 0, "AbstractSeries",
89 QLatin1String("Trying to create uncreatable: AbstractSeries."));
89 QLatin1String("Trying to create uncreatable: AbstractSeries."));
90 qmlRegisterUncreatableType<QAxis>(uri, 1, 0, "Axis",
90 qmlRegisterUncreatableType<QAxis>(uri, 1, 0, "Axis",
91 QLatin1String("Trying to create uncreatable: Axis."));
91 QLatin1String("Trying to create uncreatable: Axis."));
92 qmlRegisterUncreatableType<QPieModelMapper>(uri, 1, 0, "PieModelMapper",
92 qmlRegisterUncreatableType<QPieModelMapper>(uri, 1, 0, "PieModelMapper",
93 QLatin1String("Trying to create uncreatable: PieModelMapper."));
93 QLatin1String("Trying to create uncreatable: PieModelMapper."));
94 qmlRegisterUncreatableType<QXYModelMapper>(uri, 1, 0, "XYModelMapper",
94 qmlRegisterUncreatableType<QXYModelMapper>(uri, 1, 0, "XYModelMapper",
95 QLatin1String("Trying to create uncreatable: XYModelMapper."));
95 QLatin1String("Trying to create uncreatable: XYModelMapper."));
96 }
96 }
97 };
97 };
98
98
99 #include "plugin.moc"
99 #include "plugin.moc"
100
100
101 QTCOMMERCIALCHART_END_NAMESPACE
101 QTCOMMERCIALCHART_END_NAMESPACE
102
102
103 QTCOMMERCIALCHART_USE_NAMESPACE
103 QTCOMMERCIALCHART_USE_NAMESPACE
104
104
105 Q_EXPORT_PLUGIN2(qtcommercialchartqml, QT_PREPEND_NAMESPACE(ChartQmlPlugin))
105 Q_EXPORT_PLUGIN2(qtcommercialchartqml, QT_PREPEND_NAMESPACE(ChartQmlPlugin))
@@ -1,720 +1,720
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 "qbarseries.h"
21 #include "qbarseries.h"
22 #include "qbarseries_p.h"
22 #include "qbarseries_p.h"
23 #include "qbarset.h"
23 #include "qbarset.h"
24 #include "qbarset_p.h"
24 #include "qbarset_p.h"
25 #include "domain_p.h"
25 #include "domain_p.h"
26 #include "legendmarker_p.h"
26 #include "legendmarker_p.h"
27 #include "chartdataset_p.h"
27 #include "chartdataset_p.h"
28 #include "charttheme_p.h"
28 #include "charttheme_p.h"
29 #include "chartanimator_p.h"
29 #include "chartanimator_p.h"
30
30
31 QTCOMMERCIALCHART_BEGIN_NAMESPACE
31 QTCOMMERCIALCHART_BEGIN_NAMESPACE
32
32
33 /*!
33 /*!
34 \class QBarSeries
34 \class QBarSeries
35 \brief Series for creating a bar chart
35 \brief Series for creating a bar chart
36 \mainclass
36 \mainclass
37
37
38 QBarSeries represents a series of data shown as bars. The purpose of this class is to draw bars to
38 QBarSeries represents a series of data shown as bars. The purpose of this class is to draw bars to
39 the position defined by data. Single bar is defined by QPointF, where x value is the x-coordinate of the bar
39 the position defined by data. Single bar is defined by QPointF, where x value is the x-coordinate of the bar
40 and y-value is the height of the bar. The category names are ignored with this series and x-axis
40 and y-value is the height of the bar. The category names are ignored with this series and x-axis
41 shows the x-values.
41 shows the x-values.
42
42
43 See the \l {BarChart Example} {bar chart example} to learn how to create a simple bar chart.
43 See the \l {BarChart Example} {bar chart example} to learn how to create a simple bar chart.
44 \image examples_barchart.png
44 \image examples_barchart.png
45
45
46 \sa QBarSet, QStackedBarSeries, QPercentBarSeries
46 \sa QBarSet, QStackedBarSeries, QPercentBarSeries
47 */
47 */
48 /*!
48 /*!
49 \qmlclass BarSeries QBarSeries
49 \qmlclass BarSeries QBarSeries
50 \inherits AbstractSeries
50 \inherits AbstractSeries
51
51
52 The following QML shows how to create a simple bar chart:
52 The following QML shows how to create a simple bar chart:
53 \snippet ../demos/qmlchart/qml/qmlchart/View6.qml 1
53 \snippet ../demos/qmlchart/qml/qmlchart/View6.qml 1
54
54
55 \beginfloatleft
55 \beginfloatleft
56 \image demos_qmlchart6.png
56 \image demos_qmlchart6.png
57 \endfloat
57 \endfloat
58 \clearfloat
58 \clearfloat
59 */
59 */
60
60
61 /*!
61 /*!
62 \property QBarSeries::barWidth
62 \property QBarSeries::barWidth
63 The width of the bars of the series. The unit of \a width is the unit of x-axis. The minimum width for bars
63 The width of the bars of the series. The unit of \a width is the unit of x-axis. The minimum width for bars
64 is zero and negative values are treated as zero. Setting the width to zero means that width of the bar on screen
64 is zero and negative values are treated as zero. Setting the width to zero means that width of the bar on screen
65 is one pixel no matter what the scale of x-axis is. Bars wider than zero are scaled with x-axis.
65 is one pixel no matter what the scale of x-axis is. Bars wider than zero are scaled with x-axis.
66 Note that with QGroupedBarSeries this value means the width of one group of bars instead of just one bar.
66 Note that with QGroupedBarSeries this value means the width of one group of bars instead of just one bar.
67 \sa QGroupedBarSeries
67 \sa QGroupedBarSeries
68 */
68 */
69 /*!
69 /*!
70 \qmlproperty real BarSeries::barWidth
70 \qmlproperty real BarSeries::barWidth
71 The width of the bars of the series. The unit of width is the unit of x-axis. The minimum width for bars
71 The width of the bars of the series. The unit of width is the unit of x-axis. The minimum width for bars
72 is zero and negative values are treated as zero. Setting the width to zero means that width of the bar on screen
72 is zero and negative values are treated as zero. Setting the width to zero means that width of the bar on screen
73 is one pixel no matter what the scale of x-axis is. Bars wider than zero are scaled with x-axis.
73 is one pixel no matter what the scale of x-axis is. Bars wider than zero are scaled with x-axis.
74 Note that with QGroupedBarSeries this value means the width of one group of bars instead of just one bar.
74 Note that with QGroupedBarSeries this value means the width of one group of bars instead of just one bar.
75 */
75 */
76
76
77 /*!
77 /*!
78 \property QBarSeries::count
78 \property QBarSeries::count
79 Holds the number of sets in series.
79 Holds the number of sets in series.
80 */
80 */
81 /*!
81 /*!
82 \qmlproperty int BarSeries::count
82 \qmlproperty int BarSeries::count
83 Holds the number of sets in series.
83 Holds the number of sets in series.
84 */
84 */
85
85
86 /*!
86 /*!
87 \property QBarSeries::labelsVisible
87 \property QBarSeries::labelsVisible
88 Defines the visibility of the labels in series
88 Defines the visibility of the labels in series
89 */
89 */
90 /*!
90 /*!
91 \qmlproperty bool BarSeries::labelsVisible
91 \qmlproperty bool BarSeries::labelsVisible
92 Defines the visibility of the labels in series
92 Defines the visibility of the labels in series
93 */
93 */
94
94
95 /*!
95 /*!
96 \fn void QBarSeries::clicked(QBarSet *barset, int index)
96 \fn void QBarSeries::clicked(QBarSet *barset, int index)
97 The signal is emitted if the user clicks with a mouse on top of QBarSet \a barset.
97 The signal is emitted if the user clicks with a mouse on top of QBarSet \a barset.
98 Clicked bar inside set is indexed by \a index
98 Clicked bar inside set is indexed by \a index
99 */
99 */
100 /*!
100 /*!
101 \qmlsignal BarSeries::onClicked(BarSet barset, int index)
101 \qmlsignal BarSeries::onClicked(BarSet barset, int index)
102 The signal is emitted if the user clicks with a mouse on top of BarSet.
102 The signal is emitted if the user clicks with a mouse on top of BarSet.
103 Clicked bar inside set is indexed by \a index
103 Clicked bar inside set is indexed by \a index
104 */
104 */
105
105
106 /*!
106 /*!
107 \fn void QBarSeries::hovered(QBarSet* barset, bool status)
107 \fn void QBarSeries::hovered(QBarSet* barset, bool status)
108
108
109 The signal is emitted if mouse is hovered on top of series.
109 The signal is emitted if mouse is hovered on top of series.
110 Parameter \a barset is the pointer of barset, where hover happened.
110 Parameter \a barset is the pointer of barset, where hover happened.
111 Parameter \a status is true, if mouse entered on top of series, false if mouse left from top of series.
111 Parameter \a status is true, if mouse entered on top of series, false if mouse left from top of series.
112 */
112 */
113 /*!
113 /*!
114 \qmlsignal BarSeries::onHovered(BarSet barset, bool status)
114 \qmlsignal BarSeries::onHovered(BarSet barset, bool status)
115
115
116 The signal is emitted if mouse is hovered on top of series.
116 The signal is emitted if mouse is hovered on top of series.
117 Parameter \a barset is the pointer of barset, where hover happened.
117 Parameter \a barset is the pointer of barset, where hover happened.
118 Parameter \a status is true, if mouse entered on top of series, false if mouse left from top of series.
118 Parameter \a status is true, if mouse entered on top of series, false if mouse left from top of series.
119 */
119 */
120
120
121 /*!
121 /*!
122 \fn void QBarSeries::countChanged()
122 \fn void QBarSeries::countChanged()
123 This signal is emitted when barset count has been changed, for example by append or remove.
123 This signal is emitted when barset count has been changed, for example by append or remove.
124 */
124 */
125 /*!
125 /*!
126 \qmlsignal BarSeries::onCountChanged()
126 \qmlsignal BarSeries::onCountChanged()
127 This signal is emitted when barset count has been changed, for example by append or remove.
127 This signal is emitted when barset count has been changed, for example by append or remove.
128 */
128 */
129
129
130 /*!
130 /*!
131 \fn void QBarSeries::labelsVisibleChanged()
131 \fn void QBarSeries::labelsVisibleChanged()
132 This signal is emitted when labels visibility have changed.
132 This signal is emitted when labels visibility have changed.
133 \sa isLabelsVisible(), setLabelsVisible()
133 \sa isLabelsVisible(), setLabelsVisible()
134 */
134 */
135
135
136 /*!
136 /*!
137 \fn void QBarSeries::barsetsAdded(QList<QBarSet*> sets)
137 \fn void QBarSeries::barsetsAdded(QList<QBarSet*> sets)
138 This signal is emitted when \a sets have been added to the series.
138 This signal is emitted when \a sets have been added to the series.
139 \sa append(), insert()
139 \sa append(), insert()
140 */
140 */
141 /*!
141 /*!
142 \qmlsignal BarSeries::onAdded(BarSet barset)
142 \qmlsignal BarSeries::onAdded(BarSet barset)
143 Emitted when \a barset has been added to the series.
143 Emitted when \a barset has been added to the series.
144 */
144 */
145
145
146 /*!
146 /*!
147 \fn void QBarSeries::barsetsRemoved(QList<QBarSet*> sets)
147 \fn void QBarSeries::barsetsRemoved(QList<QBarSet*> sets)
148 This signal is emitted when \a sets have been removed from the series.
148 This signal is emitted when \a sets have been removed from the series.
149 \sa remove()
149 \sa remove()
150 */
150 */
151 /*!
151 /*!
152 \qmlsignal BarSeries::onRemoved(BarSet barset)
152 \qmlsignal BarSeries::onRemoved(BarSet barset)
153 Emitted when \a barset has been removed from the series.
153 Emitted when \a barset has been removed from the series.
154 */
154 */
155
155
156 /*!
156 /*!
157 \qmlmethod BarSet BarSeries::at(int index)
157 \qmlmethod BarSet BarSeries::at(int index)
158 Returns bar set at \a index. Returns null if the index is not valid.
158 Returns bar set at \a index. Returns null if the index is not valid.
159 */
159 */
160
160
161 /*!
161 /*!
162 \qmlmethod BarSet BarSeries::append(string label, VariantList values)
162 \qmlmethod BarSet BarSeries::append(string label, VariantList values)
163 Adds a new bar set with \a label and \a values to \a index. Values can be a list of reals or a list of XyPoints.
163 Adds a new bar set with \a label and \a values to \a index. Values can be a list of reals or a list of XYPoints.
164 For example:
164 For example:
165 \code
165 \code
166 myBarSeries.append("set 1", [0, 0.2, 0.2, 0.5, 0.4, 1.5, 0.9]);
166 myBarSeries.append("set 1", [0, 0.2, 0.2, 0.5, 0.4, 1.5, 0.9]);
167 myBarSeries.append("set 2", [Qt.point(0, 1), Qt.point(2, 2.5), Qt.point(3.5, 2.2)]);
167 myBarSeries.append("set 2", [Qt.point(0, 1), Qt.point(2, 2.5), Qt.point(3.5, 2.2)]);
168 \endcode
168 \endcode
169 */
169 */
170
170
171 /*!
171 /*!
172 \qmlmethod BarSet BarSeries::insert(int index, string label, VariantList values)
172 \qmlmethod BarSet BarSeries::insert(int index, string label, VariantList values)
173 Inserts a new bar set with \a label and \a values to \a index. Values can be a list of reals or a list of XyPoints.
173 Inserts a new bar set with \a label and \a values to \a index. Values can be a list of reals or a list of XYPoints.
174 If index is zero or smaller, the new barset is prepended. If the index is count or bigger, the new barset is
174 If index is zero or smaller, the new barset is prepended. If the index is count or bigger, the new barset is
175 appended.
175 appended.
176 \sa BarSeries::append()
176 \sa BarSeries::append()
177 */
177 */
178
178
179 /*!
179 /*!
180 \qmlmethod bool BarSeries::remove(BarSet barset)
180 \qmlmethod bool BarSeries::remove(BarSet barset)
181 Removes the barset from the series. Returns true if successfull, false otherwise.
181 Removes the barset from the series. Returns true if successfull, false otherwise.
182 */
182 */
183
183
184 /*!
184 /*!
185 \qmlmethod BarSeries::clear()
185 \qmlmethod BarSeries::clear()
186 Removes all barsets from the series.
186 Removes all barsets from the series.
187 */
187 */
188
188
189 /*!
189 /*!
190 Constructs empty QBarSeries.
190 Constructs empty QBarSeries.
191 QBarSeries is QObject which is a child of a \a parent.
191 QBarSeries is QObject which is a child of a \a parent.
192 */
192 */
193 QBarSeries::QBarSeries(QObject *parent) :
193 QBarSeries::QBarSeries(QObject *parent) :
194 QAbstractSeries(*new QBarSeriesPrivate(this),parent)
194 QAbstractSeries(*new QBarSeriesPrivate(this),parent)
195 {
195 {
196 }
196 }
197
197
198 /*!
198 /*!
199 Destructs barseries and owned barsets.
199 Destructs barseries and owned barsets.
200 */
200 */
201 QBarSeries::~QBarSeries()
201 QBarSeries::~QBarSeries()
202 {
202 {
203 Q_D(QBarSeries);
203 Q_D(QBarSeries);
204 if(d->m_dataset){
204 if(d->m_dataset){
205 d->m_dataset->removeSeries(this);
205 d->m_dataset->removeSeries(this);
206 }
206 }
207 }
207 }
208
208
209 /*!
209 /*!
210 \internal
210 \internal
211 */
211 */
212 QBarSeries::QBarSeries(QBarSeriesPrivate &d, QObject *parent) :
212 QBarSeries::QBarSeries(QBarSeriesPrivate &d, QObject *parent) :
213 QAbstractSeries(d,parent)
213 QAbstractSeries(d,parent)
214 {
214 {
215 }
215 }
216
216
217 /*!
217 /*!
218 Returns the type of series. Derived classes override this.
218 Returns the type of series. Derived classes override this.
219 */
219 */
220 QAbstractSeries::SeriesType QBarSeries::type() const
220 QAbstractSeries::SeriesType QBarSeries::type() const
221 {
221 {
222 return QAbstractSeries::SeriesTypeBar;
222 return QAbstractSeries::SeriesTypeBar;
223 }
223 }
224
224
225 /*!
225 /*!
226 Sets the width of the bars of the series. The unit of \a width is the unit of x-axis. The minimum width for bars
226 Sets the width of the bars of the series. The unit of \a width is the unit of x-axis. The minimum width for bars
227 is zero and negative values are treated as zero. Setting the width to zero means that width of the bar on screen
227 is zero and negative values are treated as zero. Setting the width to zero means that width of the bar on screen
228 is one pixel no matter what the scale of x-axis is. Bars wider than zero are scaled with x-axis.
228 is one pixel no matter what the scale of x-axis is. Bars wider than zero are scaled with x-axis.
229 Note that with \link QGroupedBarSeries \endlink this value means the width of one group of bars instead of just one bar.
229 Note that with \link QGroupedBarSeries \endlink this value means the width of one group of bars instead of just one bar.
230 */
230 */
231 void QBarSeries::setBarWidth(qreal width)
231 void QBarSeries::setBarWidth(qreal width)
232 {
232 {
233 Q_D(QBarSeries);
233 Q_D(QBarSeries);
234 d->setBarWidth(width);
234 d->setBarWidth(width);
235 }
235 }
236
236
237 /*!
237 /*!
238 Returns the width of the bars of the series.
238 Returns the width of the bars of the series.
239 \sa setBarWidth()
239 \sa setBarWidth()
240 */
240 */
241 qreal QBarSeries::barWidth() const
241 qreal QBarSeries::barWidth() const
242 {
242 {
243 Q_D(const QBarSeries);
243 Q_D(const QBarSeries);
244 return d->barWidth();
244 return d->barWidth();
245 }
245 }
246
246
247 /*!
247 /*!
248 Adds a set of bars to series. Takes ownership of \a set. If the set is null or is already in series, it won't be appended.
248 Adds a set of bars to series. Takes ownership of \a set. If the set is null or is already in series, it won't be appended.
249 Returns true, if appending succeeded.
249 Returns true, if appending succeeded.
250 */
250 */
251 bool QBarSeries::append(QBarSet *set)
251 bool QBarSeries::append(QBarSet *set)
252 {
252 {
253 Q_D(QBarSeries);
253 Q_D(QBarSeries);
254 bool success = d->append(set);
254 bool success = d->append(set);
255 if (success) {
255 if (success) {
256 QList<QBarSet*> sets;
256 QList<QBarSet*> sets;
257 sets.append(set);
257 sets.append(set);
258 emit barsetsAdded(sets);
258 emit barsetsAdded(sets);
259 emit countChanged();
259 emit countChanged();
260 }
260 }
261 return success;
261 return success;
262 }
262 }
263
263
264 /*!
264 /*!
265 Removes a set of bars from series. Releases ownership of \a set. Doesn't delete \a set.
265 Removes a set of bars from series. Releases ownership of \a set. Doesn't delete \a set.
266 Returns true, if set was removed.
266 Returns true, if set was removed.
267 */
267 */
268 bool QBarSeries::remove(QBarSet *set)
268 bool QBarSeries::remove(QBarSet *set)
269 {
269 {
270 Q_D(QBarSeries);
270 Q_D(QBarSeries);
271 bool success = d->remove(set);
271 bool success = d->remove(set);
272 if (success) {
272 if (success) {
273 QList<QBarSet*> sets;
273 QList<QBarSet*> sets;
274 sets.append(set);
274 sets.append(set);
275 emit barsetsRemoved(sets);
275 emit barsetsRemoved(sets);
276 emit countChanged();
276 emit countChanged();
277 }
277 }
278 return success;
278 return success;
279 }
279 }
280
280
281 /*!
281 /*!
282 Adds a list of barsets to series. Takes ownership of \a sets.
282 Adds a list of barsets to series. Takes ownership of \a sets.
283 Returns true, if all sets were appended succesfully. If any of the sets is null or is already appended to series,
283 Returns true, if all sets were appended succesfully. If any of the sets is null or is already appended to series,
284 nothing is appended and function returns false. If any of the sets is in list more than once, nothing is appended
284 nothing is appended and function returns false. If any of the sets is in list more than once, nothing is appended
285 and function returns false.
285 and function returns false.
286 */
286 */
287 bool QBarSeries::append(QList<QBarSet* > sets)
287 bool QBarSeries::append(QList<QBarSet* > sets)
288 {
288 {
289 Q_D(QBarSeries);
289 Q_D(QBarSeries);
290 bool success = d->append(sets);
290 bool success = d->append(sets);
291 if (success) {
291 if (success) {
292 emit barsetsAdded(sets);
292 emit barsetsAdded(sets);
293 emit countChanged();
293 emit countChanged();
294 }
294 }
295 return success;
295 return success;
296 }
296 }
297
297
298 /*!
298 /*!
299 Insert a set of bars to series at \a index postion. Takes ownership of \a set. If the set is null or is already in series, it won't be appended.
299 Insert a set of bars to series at \a index postion. Takes ownership of \a set. If the set is null or is already in series, it won't be appended.
300 Returns true, if inserting succeeded.
300 Returns true, if inserting succeeded.
301
301
302 */
302 */
303 bool QBarSeries::insert(int index, QBarSet *set)
303 bool QBarSeries::insert(int index, QBarSet *set)
304 {
304 {
305 Q_D(QBarSeries);
305 Q_D(QBarSeries);
306 bool success = d->insert(index, set);
306 bool success = d->insert(index, set);
307 if (success) {
307 if (success) {
308 QList<QBarSet*> sets;
308 QList<QBarSet*> sets;
309 sets.append(set);
309 sets.append(set);
310 emit barsetsAdded(sets);
310 emit barsetsAdded(sets);
311 emit countChanged();
311 emit countChanged();
312 }
312 }
313 return success;
313 return success;
314 }
314 }
315
315
316 /*!
316 /*!
317 Removes all of the bar sets from the series
317 Removes all of the bar sets from the series
318 */
318 */
319 void QBarSeries::clear()
319 void QBarSeries::clear()
320 {
320 {
321 Q_D(QBarSeries);
321 Q_D(QBarSeries);
322 QList<QBarSet *> sets = barSets();
322 QList<QBarSet *> sets = barSets();
323 bool success = d->remove(sets);
323 bool success = d->remove(sets);
324 if (success) {
324 if (success) {
325 emit barsetsRemoved(sets);
325 emit barsetsRemoved(sets);
326 emit countChanged();
326 emit countChanged();
327 }
327 }
328 }
328 }
329
329
330 /*!
330 /*!
331 Returns number of sets in series.
331 Returns number of sets in series.
332 */
332 */
333 int QBarSeries::count() const
333 int QBarSeries::count() const
334 {
334 {
335 Q_D(const QBarSeries);
335 Q_D(const QBarSeries);
336 return d->m_barSets.count();
336 return d->m_barSets.count();
337 }
337 }
338
338
339 /*!
339 /*!
340 Returns a list of sets in series. Keeps ownership of sets.
340 Returns a list of sets in series. Keeps ownership of sets.
341 */
341 */
342 QList<QBarSet*> QBarSeries::barSets() const
342 QList<QBarSet*> QBarSeries::barSets() const
343 {
343 {
344 Q_D(const QBarSeries);
344 Q_D(const QBarSeries);
345 return d->m_barSets;
345 return d->m_barSets;
346 }
346 }
347
347
348 /*!
348 /*!
349 Sets the visibility of labels in series to \a visible
349 Sets the visibility of labels in series to \a visible
350 */
350 */
351 void QBarSeries::setLabelsVisible(bool visible)
351 void QBarSeries::setLabelsVisible(bool visible)
352 {
352 {
353 Q_D(QBarSeries);
353 Q_D(QBarSeries);
354 if (d->m_labelsVisible != visible) {
354 if (d->m_labelsVisible != visible) {
355 d->setLabelsVisible(visible);
355 d->setLabelsVisible(visible);
356 emit labelsVisibleChanged();
356 emit labelsVisibleChanged();
357 }
357 }
358 }
358 }
359
359
360 /*!
360 /*!
361 Returns the visibility of labels
361 Returns the visibility of labels
362 */
362 */
363 bool QBarSeries::isLabelsVisible() const
363 bool QBarSeries::isLabelsVisible() const
364 {
364 {
365 Q_D(const QBarSeries);
365 Q_D(const QBarSeries);
366 return d->m_labelsVisible;
366 return d->m_labelsVisible;
367 }
367 }
368
368
369 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
369 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
370
370
371 QBarSeriesPrivate::QBarSeriesPrivate(QBarSeries *q) :
371 QBarSeriesPrivate::QBarSeriesPrivate(QBarSeries *q) :
372 QAbstractSeriesPrivate(q),
372 QAbstractSeriesPrivate(q),
373 m_barWidth(0.5), // Default value is 50% of category width
373 m_barWidth(0.5), // Default value is 50% of category width
374 m_labelsVisible(false),
374 m_labelsVisible(false),
375 m_visible(true)
375 m_visible(true)
376 {
376 {
377 }
377 }
378
378
379 int QBarSeriesPrivate::categoryCount() const
379 int QBarSeriesPrivate::categoryCount() const
380 {
380 {
381 // No categories defined. return count of longest set.
381 // No categories defined. return count of longest set.
382 int count = 0;
382 int count = 0;
383 for (int i=0; i<m_barSets.count(); i++) {
383 for (int i=0; i<m_barSets.count(); i++) {
384 if (m_barSets.at(i)->count() > count) {
384 if (m_barSets.at(i)->count() > count) {
385 count = m_barSets.at(i)->count();
385 count = m_barSets.at(i)->count();
386 }
386 }
387 }
387 }
388
388
389 return count;
389 return count;
390 }
390 }
391
391
392 void QBarSeriesPrivate::setBarWidth(qreal width)
392 void QBarSeriesPrivate::setBarWidth(qreal width)
393 {
393 {
394 if (width < 0.0) {
394 if (width < 0.0) {
395 width = 0.0;
395 width = 0.0;
396 }
396 }
397 m_barWidth = width;
397 m_barWidth = width;
398 emit updatedBars();
398 emit updatedBars();
399 }
399 }
400
400
401 qreal QBarSeriesPrivate::barWidth() const
401 qreal QBarSeriesPrivate::barWidth() const
402 {
402 {
403 return m_barWidth;
403 return m_barWidth;
404 }
404 }
405
405
406 QBarSet* QBarSeriesPrivate::barsetAt(int index)
406 QBarSet* QBarSeriesPrivate::barsetAt(int index)
407 {
407 {
408 return m_barSets.at(index);
408 return m_barSets.at(index);
409 }
409 }
410
410
411 void QBarSeriesPrivate::setVisible(bool visible)
411 void QBarSeriesPrivate::setVisible(bool visible)
412 {
412 {
413 m_visible = visible;
413 m_visible = visible;
414 emit updatedBars();
414 emit updatedBars();
415 }
415 }
416
416
417 void QBarSeriesPrivate::setLabelsVisible(bool visible)
417 void QBarSeriesPrivate::setLabelsVisible(bool visible)
418 {
418 {
419 m_labelsVisible = visible;
419 m_labelsVisible = visible;
420 emit labelsVisibleChanged(visible);
420 emit labelsVisibleChanged(visible);
421 }
421 }
422
422
423 qreal QBarSeriesPrivate::min()
423 qreal QBarSeriesPrivate::min()
424 {
424 {
425 if (m_barSets.count() <= 0) {
425 if (m_barSets.count() <= 0) {
426 return 0;
426 return 0;
427 }
427 }
428 qreal min = INT_MAX;
428 qreal min = INT_MAX;
429
429
430 for (int i = 0; i < m_barSets.count(); i++) {
430 for (int i = 0; i < m_barSets.count(); i++) {
431 int categoryCount = m_barSets.at(i)->count();
431 int categoryCount = m_barSets.at(i)->count();
432 for (int j = 0; j < categoryCount; j++) {
432 for (int j = 0; j < categoryCount; j++) {
433 qreal temp = m_barSets.at(i)->at(j).y();
433 qreal temp = m_barSets.at(i)->at(j).y();
434 if (temp < min)
434 if (temp < min)
435 min = temp;
435 min = temp;
436 }
436 }
437 }
437 }
438 return min;
438 return min;
439 }
439 }
440
440
441 qreal QBarSeriesPrivate::max()
441 qreal QBarSeriesPrivate::max()
442 {
442 {
443 if (m_barSets.count() <= 0) {
443 if (m_barSets.count() <= 0) {
444 return 0;
444 return 0;
445 }
445 }
446 qreal max = INT_MIN;
446 qreal max = INT_MIN;
447
447
448 for (int i = 0; i < m_barSets.count(); i++) {
448 for (int i = 0; i < m_barSets.count(); i++) {
449 int categoryCount = m_barSets.at(i)->count();
449 int categoryCount = m_barSets.at(i)->count();
450 for (int j = 0; j < categoryCount; j++) {
450 for (int j = 0; j < categoryCount; j++) {
451 qreal temp = m_barSets.at(i)->at(j).y();
451 qreal temp = m_barSets.at(i)->at(j).y();
452 if (temp > max)
452 if (temp > max)
453 max = temp;
453 max = temp;
454 }
454 }
455 }
455 }
456
456
457 return max;
457 return max;
458 }
458 }
459
459
460 qreal QBarSeriesPrivate::valueAt(int set, int category)
460 qreal QBarSeriesPrivate::valueAt(int set, int category)
461 {
461 {
462 if ((set < 0) || (set >= m_barSets.count())) {
462 if ((set < 0) || (set >= m_barSets.count())) {
463 // No set, no value.
463 // No set, no value.
464 return 0;
464 return 0;
465 } else if ((category < 0) || (category >= m_barSets.at(set)->count())) {
465 } else if ((category < 0) || (category >= m_barSets.at(set)->count())) {
466 // No category, no value.
466 // No category, no value.
467 return 0;
467 return 0;
468 }
468 }
469
469
470 return m_barSets.at(set)->at(category).y();
470 return m_barSets.at(set)->at(category).y();
471 }
471 }
472
472
473 qreal QBarSeriesPrivate::percentageAt(int set, int category)
473 qreal QBarSeriesPrivate::percentageAt(int set, int category)
474 {
474 {
475 if ((set < 0) || (set >= m_barSets.count())) {
475 if ((set < 0) || (set >= m_barSets.count())) {
476 // No set, no value.
476 // No set, no value.
477 return 0;
477 return 0;
478 } else if ((category < 0) || (category >= m_barSets.at(set)->count())) {
478 } else if ((category < 0) || (category >= m_barSets.at(set)->count())) {
479 // No category, no value.
479 // No category, no value.
480 return 0;
480 return 0;
481 }
481 }
482
482
483 qreal value = m_barSets.at(set)->at(category).y();
483 qreal value = m_barSets.at(set)->at(category).y();
484 qreal sum = categorySum(category);
484 qreal sum = categorySum(category);
485 if ( qFuzzyIsNull(sum) ) {
485 if ( qFuzzyIsNull(sum) ) {
486 return 0;
486 return 0;
487 }
487 }
488
488
489 return value / sum;
489 return value / sum;
490 }
490 }
491
491
492 qreal QBarSeriesPrivate::categorySum(int category)
492 qreal QBarSeriesPrivate::categorySum(int category)
493 {
493 {
494 qreal sum(0);
494 qreal sum(0);
495 int count = m_barSets.count(); // Count sets
495 int count = m_barSets.count(); // Count sets
496 for (int set = 0; set < count; set++) {
496 for (int set = 0; set < count; set++) {
497 if (category < m_barSets.at(set)->count())
497 if (category < m_barSets.at(set)->count())
498 sum += m_barSets.at(set)->at(category).y();
498 sum += m_barSets.at(set)->at(category).y();
499 }
499 }
500 return sum;
500 return sum;
501 }
501 }
502
502
503 qreal QBarSeriesPrivate::absoluteCategorySum(int category)
503 qreal QBarSeriesPrivate::absoluteCategorySum(int category)
504 {
504 {
505 qreal sum(0);
505 qreal sum(0);
506 int count = m_barSets.count(); // Count sets
506 int count = m_barSets.count(); // Count sets
507 for (int set = 0; set < count; set++) {
507 for (int set = 0; set < count; set++) {
508 if (category < m_barSets.at(set)->count())
508 if (category < m_barSets.at(set)->count())
509 sum += qAbs(m_barSets.at(set)->at(category).y());
509 sum += qAbs(m_barSets.at(set)->at(category).y());
510 }
510 }
511 return sum;
511 return sum;
512 }
512 }
513
513
514 qreal QBarSeriesPrivate::maxCategorySum()
514 qreal QBarSeriesPrivate::maxCategorySum()
515 {
515 {
516 qreal max = INT_MIN;
516 qreal max = INT_MIN;
517 int count = categoryCount();
517 int count = categoryCount();
518 for (int i = 0; i < count; i++) {
518 for (int i = 0; i < count; i++) {
519 qreal sum = categorySum(i);
519 qreal sum = categorySum(i);
520 if (sum > max)
520 if (sum > max)
521 max = sum;
521 max = sum;
522 }
522 }
523 return max;
523 return max;
524 }
524 }
525
525
526 qreal QBarSeriesPrivate::minX()
526 qreal QBarSeriesPrivate::minX()
527 {
527 {
528 if (m_barSets.count() <= 0) {
528 if (m_barSets.count() <= 0) {
529 return 0;
529 return 0;
530 }
530 }
531 qreal min = INT_MAX;
531 qreal min = INT_MAX;
532
532
533 for (int i = 0; i < m_barSets.count(); i++) {
533 for (int i = 0; i < m_barSets.count(); i++) {
534 int categoryCount = m_barSets.at(i)->count();
534 int categoryCount = m_barSets.at(i)->count();
535 for (int j = 0; j < categoryCount; j++) {
535 for (int j = 0; j < categoryCount; j++) {
536 qreal temp = m_barSets.at(i)->at(j).x();
536 qreal temp = m_barSets.at(i)->at(j).x();
537 if (temp < min)
537 if (temp < min)
538 min = temp;
538 min = temp;
539 }
539 }
540 }
540 }
541 return min;
541 return min;
542 }
542 }
543
543
544 qreal QBarSeriesPrivate::maxX()
544 qreal QBarSeriesPrivate::maxX()
545 {
545 {
546 if (m_barSets.count() <= 0) {
546 if (m_barSets.count() <= 0) {
547 return 0;
547 return 0;
548 }
548 }
549 qreal max = INT_MIN;
549 qreal max = INT_MIN;
550
550
551 for (int i = 0; i < m_barSets.count(); i++) {
551 for (int i = 0; i < m_barSets.count(); i++) {
552 int categoryCount = m_barSets.at(i)->count();
552 int categoryCount = m_barSets.at(i)->count();
553 for (int j = 0; j < categoryCount; j++) {
553 for (int j = 0; j < categoryCount; j++) {
554 qreal temp = m_barSets.at(i)->at(j).x();
554 qreal temp = m_barSets.at(i)->at(j).x();
555 if (temp > max)
555 if (temp > max)
556 max = temp;
556 max = temp;
557 }
557 }
558 }
558 }
559
559
560 return max;
560 return max;
561 }
561 }
562
562
563
563
564 void QBarSeriesPrivate::scaleDomain(Domain& domain)
564 void QBarSeriesPrivate::scaleDomain(Domain& domain)
565 {
565 {
566 qreal minX(domain.minX());
566 qreal minX(domain.minX());
567 qreal minY(domain.minY());
567 qreal minY(domain.minY());
568 qreal maxX(domain.maxX());
568 qreal maxX(domain.maxX());
569 qreal maxY(domain.maxY());
569 qreal maxY(domain.maxY());
570 int tickXCount(domain.tickXCount());
570 int tickXCount(domain.tickXCount());
571 int tickYCount(domain.tickYCount());
571 int tickYCount(domain.tickYCount());
572
572
573 qreal seriesMinX = this->minX();
573 qreal seriesMinX = this->minX();
574 qreal seriesMaxX = this->maxX();
574 qreal seriesMaxX = this->maxX();
575 qreal y = max();
575 qreal y = max();
576 minX = qMin(minX, seriesMinX - 0.5);
576 minX = qMin(minX, seriesMinX - 0.5);
577 minY = qMin(minY, y);
577 minY = qMin(minY, y);
578 maxX = qMax(maxX, seriesMaxX + 0.5);
578 maxX = qMax(maxX, seriesMaxX + 0.5);
579 maxY = qMax(maxY, y);
579 maxY = qMax(maxY, y);
580 tickXCount = categoryCount()+1;
580 tickXCount = categoryCount()+1;
581
581
582 domain.setRange(minX,maxX,minY,maxY,tickXCount,tickYCount);
582 domain.setRange(minX,maxX,minY,maxY,tickXCount,tickYCount);
583 }
583 }
584
584
585 Chart* QBarSeriesPrivate::createGraphics(ChartPresenter* presenter)
585 Chart* QBarSeriesPrivate::createGraphics(ChartPresenter* presenter)
586 {
586 {
587 Q_Q(QBarSeries);
587 Q_Q(QBarSeries);
588
588
589 BarChartItem* bar = new BarChartItem(q,presenter);
589 BarChartItem* bar = new BarChartItem(q,presenter);
590 if(presenter->animationOptions().testFlag(QChart::SeriesAnimations)) {
590 if(presenter->animationOptions().testFlag(QChart::SeriesAnimations)) {
591 presenter->animator()->addAnimation(bar);
591 presenter->animator()->addAnimation(bar);
592 }
592 }
593 presenter->chartTheme()->decorate(q, presenter->dataSet()->seriesIndex(q));
593 presenter->chartTheme()->decorate(q, presenter->dataSet()->seriesIndex(q));
594 return bar;
594 return bar;
595
595
596 }
596 }
597
597
598 QList<LegendMarker*> QBarSeriesPrivate::createLegendMarker(QLegend* legend)
598 QList<LegendMarker*> QBarSeriesPrivate::createLegendMarker(QLegend* legend)
599 {
599 {
600 Q_Q(QBarSeries);
600 Q_Q(QBarSeries);
601 QList<LegendMarker*> markers;
601 QList<LegendMarker*> markers;
602 foreach(QBarSet* set, q->barSets()) {
602 foreach(QBarSet* set, q->barSets()) {
603 BarLegendMarker* marker = new BarLegendMarker(q,set,legend);
603 BarLegendMarker* marker = new BarLegendMarker(q,set,legend);
604 markers << marker;
604 markers << marker;
605 }
605 }
606
606
607 return markers;
607 return markers;
608 }
608 }
609
609
610 bool QBarSeriesPrivate::append(QBarSet *set)
610 bool QBarSeriesPrivate::append(QBarSet *set)
611 {
611 {
612 Q_Q(QBarSeries);
612 Q_Q(QBarSeries);
613 if ((m_barSets.contains(set)) || (set == 0)) {
613 if ((m_barSets.contains(set)) || (set == 0)) {
614 // Fail if set is already in list or set is null.
614 // Fail if set is already in list or set is null.
615 return false;
615 return false;
616 }
616 }
617 m_barSets.append(set);
617 m_barSets.append(set);
618 QObject::connect(set->d_ptr.data(), SIGNAL(updatedBars()), this, SIGNAL(updatedBars()));
618 QObject::connect(set->d_ptr.data(), SIGNAL(updatedBars()), this, SIGNAL(updatedBars()));
619 QObject::connect(set->d_ptr.data(), SIGNAL(restructuredBars()), this, SIGNAL(restructuredBars()));
619 QObject::connect(set->d_ptr.data(), SIGNAL(restructuredBars()), this, SIGNAL(restructuredBars()));
620 emit restructuredBars(); // this notifies barchartitem
620 emit restructuredBars(); // this notifies barchartitem
621 if (m_dataset) {
621 if (m_dataset) {
622 m_dataset->updateSeries(q); // this notifies legend
622 m_dataset->updateSeries(q); // this notifies legend
623 }
623 }
624 return true;
624 return true;
625 }
625 }
626
626
627 bool QBarSeriesPrivate::remove(QBarSet *set)
627 bool QBarSeriesPrivate::remove(QBarSet *set)
628 {
628 {
629 Q_Q(QBarSeries);
629 Q_Q(QBarSeries);
630 if (!m_barSets.contains(set)) {
630 if (!m_barSets.contains(set)) {
631 // Fail if set is not in list
631 // Fail if set is not in list
632 return false;
632 return false;
633 }
633 }
634 m_barSets.removeOne(set);
634 m_barSets.removeOne(set);
635 QObject::disconnect(set->d_ptr.data(), SIGNAL(updatedBars()), this, SIGNAL(updatedBars()));
635 QObject::disconnect(set->d_ptr.data(), SIGNAL(updatedBars()), this, SIGNAL(updatedBars()));
636 QObject::disconnect(set->d_ptr.data(), SIGNAL(restructuredBars()), this, SIGNAL(restructuredBars()));
636 QObject::disconnect(set->d_ptr.data(), SIGNAL(restructuredBars()), this, SIGNAL(restructuredBars()));
637 emit restructuredBars(); // this notifies barchartitem
637 emit restructuredBars(); // this notifies barchartitem
638 if (m_dataset) {
638 if (m_dataset) {
639 m_dataset->updateSeries(q); // this notifies legend
639 m_dataset->updateSeries(q); // this notifies legend
640 }
640 }
641 return true;
641 return true;
642 }
642 }
643
643
644 bool QBarSeriesPrivate::append(QList<QBarSet* > sets)
644 bool QBarSeriesPrivate::append(QList<QBarSet* > sets)
645 {
645 {
646 Q_Q(QBarSeries);
646 Q_Q(QBarSeries);
647 foreach (QBarSet* set, sets) {
647 foreach (QBarSet* set, sets) {
648 if ((set == 0) || (m_barSets.contains(set))) {
648 if ((set == 0) || (m_barSets.contains(set))) {
649 // Fail if any of the sets is null or is already appended.
649 // Fail if any of the sets is null or is already appended.
650 return false;
650 return false;
651 }
651 }
652 if (sets.count(set) != 1) {
652 if (sets.count(set) != 1) {
653 // Also fail if same set is more than once in given list.
653 // Also fail if same set is more than once in given list.
654 return false;
654 return false;
655 }
655 }
656 }
656 }
657
657
658 foreach (QBarSet* set, sets) {
658 foreach (QBarSet* set, sets) {
659 m_barSets.append(set);
659 m_barSets.append(set);
660 QObject::connect(set->d_ptr.data(), SIGNAL(updatedBars()), this, SIGNAL(updatedBars()));
660 QObject::connect(set->d_ptr.data(), SIGNAL(updatedBars()), this, SIGNAL(updatedBars()));
661 QObject::connect(set->d_ptr.data(), SIGNAL(restructuredBars()), this, SIGNAL(restructuredBars()));
661 QObject::connect(set->d_ptr.data(), SIGNAL(restructuredBars()), this, SIGNAL(restructuredBars()));
662 }
662 }
663 emit restructuredBars(); // this notifies barchartitem
663 emit restructuredBars(); // this notifies barchartitem
664 if (m_dataset) {
664 if (m_dataset) {
665 m_dataset->updateSeries(q); // this notifies legend
665 m_dataset->updateSeries(q); // this notifies legend
666 }
666 }
667 return true;
667 return true;
668 }
668 }
669
669
670 bool QBarSeriesPrivate::remove(QList<QBarSet* > sets)
670 bool QBarSeriesPrivate::remove(QList<QBarSet* > sets)
671 {
671 {
672 Q_Q(QBarSeries);
672 Q_Q(QBarSeries);
673 if (sets.count() == 0) {
673 if (sets.count() == 0) {
674 return false;
674 return false;
675 }
675 }
676 foreach (QBarSet* set, sets) {
676 foreach (QBarSet* set, sets) {
677 if ((set == 0) || (!m_barSets.contains(set))) {
677 if ((set == 0) || (!m_barSets.contains(set))) {
678 // Fail if any of the sets is null or is not in series
678 // Fail if any of the sets is null or is not in series
679 return false;
679 return false;
680 }
680 }
681 if (sets.count(set) != 1) {
681 if (sets.count(set) != 1) {
682 // Also fail if same set is more than once in given list.
682 // Also fail if same set is more than once in given list.
683 return false;
683 return false;
684 }
684 }
685 }
685 }
686
686
687 foreach (QBarSet* set, sets) {
687 foreach (QBarSet* set, sets) {
688 m_barSets.removeOne(set);
688 m_barSets.removeOne(set);
689 QObject::disconnect(set->d_ptr.data(), SIGNAL(updatedBars()), this, SIGNAL(updatedBars()));
689 QObject::disconnect(set->d_ptr.data(), SIGNAL(updatedBars()), this, SIGNAL(updatedBars()));
690 QObject::disconnect(set->d_ptr.data(), SIGNAL(restructuredBars()), this, SIGNAL(restructuredBars()));
690 QObject::disconnect(set->d_ptr.data(), SIGNAL(restructuredBars()), this, SIGNAL(restructuredBars()));
691 }
691 }
692
692
693 emit restructuredBars(); // this notifies barchartitem
693 emit restructuredBars(); // this notifies barchartitem
694 if (m_dataset) {
694 if (m_dataset) {
695 m_dataset->updateSeries(q); // this notifies legend
695 m_dataset->updateSeries(q); // this notifies legend
696 }
696 }
697 return true;
697 return true;
698 }
698 }
699
699
700 bool QBarSeriesPrivate::insert(int index, QBarSet *set)
700 bool QBarSeriesPrivate::insert(int index, QBarSet *set)
701 {
701 {
702 Q_Q(QBarSeries);
702 Q_Q(QBarSeries);
703 if ((m_barSets.contains(set)) || (set == 0)) {
703 if ((m_barSets.contains(set)) || (set == 0)) {
704 // Fail if set is already in list or set is null.
704 // Fail if set is already in list or set is null.
705 return false;
705 return false;
706 }
706 }
707 m_barSets.insert(index, set);
707 m_barSets.insert(index, set);
708 QObject::connect(set->d_ptr.data(), SIGNAL(updatedBars()), this, SIGNAL(updatedBars()));
708 QObject::connect(set->d_ptr.data(), SIGNAL(updatedBars()), this, SIGNAL(updatedBars()));
709 QObject::connect(set->d_ptr.data(), SIGNAL(restructuredBars()), this, SIGNAL(restructuredBars()));
709 QObject::connect(set->d_ptr.data(), SIGNAL(restructuredBars()), this, SIGNAL(restructuredBars()));
710 emit restructuredBars(); // this notifies barchartitem
710 emit restructuredBars(); // this notifies barchartitem
711 if (m_dataset) {
711 if (m_dataset) {
712 m_dataset->updateSeries(q); // this notifies legend
712 m_dataset->updateSeries(q); // this notifies legend
713 }
713 }
714 return true;
714 return true;
715 }
715 }
716
716
717 #include "moc_qbarseries.cpp"
717 #include "moc_qbarseries.cpp"
718 #include "moc_qbarseries_p.cpp"
718 #include "moc_qbarseries_p.cpp"
719
719
720 QTCOMMERCIALCHART_END_NAMESPACE
720 QTCOMMERCIALCHART_END_NAMESPACE
@@ -1,439 +1,439
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 "qxyseries.h"
21 #include "qxyseries.h"
22 #include "qxyseries_p.h"
22 #include "qxyseries_p.h"
23 #include "domain_p.h"
23 #include "domain_p.h"
24 #include "legendmarker_p.h"
24 #include "legendmarker_p.h"
25
25
26 QTCOMMERCIALCHART_BEGIN_NAMESPACE
26 QTCOMMERCIALCHART_BEGIN_NAMESPACE
27
27
28 /*!
28 /*!
29 \class QXYSeries
29 \class QXYSeries
30 \brief The QXYSeries class is a base class for line, spline and scatter series.
30 \brief The QXYSeries class is a base class for line, spline and scatter series.
31 */
31 */
32 /*!
32 /*!
33 \qmlclass XYSeries
33 \qmlclass XYSeries
34 \inherits AbstractSeries
34 \inherits AbstractSeries
35 The XYSeries class is a base class for line, spline and scatter series.
35 The XYSeries class is a base class for line, spline and scatter series.
36
36
37 The class cannot be instantiated directly.
37 The class cannot be instantiated directly.
38 */
38 */
39
39
40 /*!
40 /*!
41 \property QXYSeries::pointsVisible
41 \property QXYSeries::pointsVisible
42 Controls if the data points are visible and should be drawn.
42 Controls if the data points are visible and should be drawn.
43 */
43 */
44 /*!
44 /*!
45 \qmlproperty bool XYSeries::pointsVisible
45 \qmlproperty bool XYSeries::pointsVisible
46 Controls if the data points are visible and should be drawn.
46 Controls if the data points are visible and should be drawn.
47 */
47 */
48
48
49 /*!
49 /*!
50 \fn QPen QXYSeries::pen() const
50 \fn QPen QXYSeries::pen() const
51 \brief Returns pen used to draw points for series.
51 \brief Returns pen used to draw points for series.
52 \sa setPen()
52 \sa setPen()
53 */
53 */
54
54
55 /*!
55 /*!
56 \fn QBrush QXYSeries::brush() const
56 \fn QBrush QXYSeries::brush() const
57 \brief Returns brush used to draw points for series.
57 \brief Returns brush used to draw points for series.
58 \sa setBrush()
58 \sa setBrush()
59 */
59 */
60
60
61 /*!
61 /*!
62 \property QXYSeries::color
62 \property QXYSeries::color
63 The color of the series. This is line (pen) color in case of QLineSeries or QSplineSeries and
63 The color of the series. This is line (pen) color in case of QLineSeries or QSplineSeries and
64 fill (brush) color in case of QScatterSeries or QAreaSeries.
64 fill (brush) color in case of QScatterSeries or QAreaSeries.
65 \sa QXYSeries::pen(), QXYSeries::brush()
65 \sa QXYSeries::pen(), QXYSeries::brush()
66 */
66 */
67 /*!
67 /*!
68 \qmlproperty color XYSeries::color
68 \qmlproperty color XYSeries::color
69 The color of the series. This is line (pen) color in case of LineSeries or SplineSeries and
69 The color of the series. This is line (pen) color in case of LineSeries or SplineSeries and
70 fill (brush) color in case of ScatterSeries or AreaSeries.
70 fill (brush) color in case of ScatterSeries or AreaSeries.
71 */
71 */
72
72
73 /*!
73 /*!
74 \fn void QXYSeries::clicked(const QPointF& point)
74 \fn void QXYSeries::clicked(const QPointF& point)
75 \brief Signal is emitted when user clicks the \a point on chart.
75 \brief Signal is emitted when user clicks the \a point on chart.
76 */
76 */
77 /*!
77 /*!
78 \qmlsignal XYSeries::onClicked(QPointF point)
78 \qmlsignal XYSeries::onClicked(QPointF point)
79 Signal is emitted when user clicks the \a point on chart. For example:
79 Signal is emitted when user clicks the \a point on chart. For example:
80 \code
80 \code
81 LineSeries {
81 LineSeries {
82 XyPoint { x: 0; y: 0 }
82 XYPoint { x: 0; y: 0 }
83 XyPoint { x: 1.1; y: 2.1 }
83 XYPoint { x: 1.1; y: 2.1 }
84 onClicked: console.log("onClicked: " + point.x + ", " + point.y);
84 onClicked: console.log("onClicked: " + point.x + ", " + point.y);
85 }
85 }
86 \endcode
86 \endcode
87 */
87 */
88
88
89 /*!
89 /*!
90 \fn void QXYSeries::pointReplaced(int index)
90 \fn void QXYSeries::pointReplaced(int index)
91 Signal is emitted when a point has been replaced at \a index.
91 Signal is emitted when a point has been replaced at \a index.
92 \sa replace()
92 \sa replace()
93 */
93 */
94 /*!
94 /*!
95 \qmlsignal XYSeries::onPointReplaced(int index)
95 \qmlsignal XYSeries::onPointReplaced(int index)
96 Signal is emitted when a point has been replaced at \a index.
96 Signal is emitted when a point has been replaced at \a index.
97 */
97 */
98
98
99 /*!
99 /*!
100 \fn void QXYSeries::pointAdded(int index)
100 \fn void QXYSeries::pointAdded(int index)
101 Signal is emitted when a point has been added at \a index.
101 Signal is emitted when a point has been added at \a index.
102 \sa append(), insert()
102 \sa append(), insert()
103 */
103 */
104 /*!
104 /*!
105 \qmlsignal XYSeries::onPointAdded(int index)
105 \qmlsignal XYSeries::onPointAdded(int index)
106 Signal is emitted when a point has been added at \a index.
106 Signal is emitted when a point has been added at \a index.
107 */
107 */
108
108
109 /*!
109 /*!
110 \fn void QXYSeries::pointRemoved(int index)
110 \fn void QXYSeries::pointRemoved(int index)
111 Signal is emitted when a point has been removed from \a index.
111 Signal is emitted when a point has been removed from \a index.
112 \sa remove()
112 \sa remove()
113 */
113 */
114 /*!
114 /*!
115 \qmlsignal XYSeries::onPointRemoved(int index)
115 \qmlsignal XYSeries::onPointRemoved(int index)
116 Signal is emitted when a point has been removed from \a index.
116 Signal is emitted when a point has been removed from \a index.
117 */
117 */
118
118
119 /*!
119 /*!
120 \fn void QXYSeries::colorChanged(QColor color)
120 \fn void QXYSeries::colorChanged(QColor color)
121 \brief Signal is emitted when the line (pen) color has changed to \a color.
121 \brief Signal is emitted when the line (pen) color has changed to \a color.
122 */
122 */
123 /*!
123 /*!
124 \qmlsignal XYSeries::onColorChanged(color color)
124 \qmlsignal XYSeries::onColorChanged(color color)
125 Signal is emitted when the line (pen) color has changed to \a color.
125 Signal is emitted when the line (pen) color has changed to \a color.
126 */
126 */
127
127
128 /*!
128 /*!
129 \fn void QXYSeriesPrivate::updated()
129 \fn void QXYSeriesPrivate::updated()
130 \brief \internal
130 \brief \internal
131 */
131 */
132
132
133 /*!
133 /*!
134 \qmlmethod XYSeries::append(real x, real y)
134 \qmlmethod XYSeries::append(real x, real y)
135 Append point (\a x, \a y) to the series
135 Append point (\a x, \a y) to the series
136 */
136 */
137
137
138 /*!
138 /*!
139 \qmlmethod XYSeries::replace(real oldX, real oldY, real newX, real newY)
139 \qmlmethod XYSeries::replace(real oldX, real oldY, real newX, real newY)
140 Replaces point (\a oldX, \a oldY) with point (\a newX, \a newY). Does nothing, if point (oldX, oldY) does not
140 Replaces point (\a oldX, \a oldY) with point (\a newX, \a newY). Does nothing, if point (oldX, oldY) does not
141 exist.
141 exist.
142 */
142 */
143
143
144 /*!
144 /*!
145 \qmlmethod XYSeries::remove(real x, real y)
145 \qmlmethod XYSeries::remove(real x, real y)
146 Removes point (\a x, \a y) from the series. Does nothing, if point (x, y) does not exist.
146 Removes point (\a x, \a y) from the series. Does nothing, if point (x, y) does not exist.
147 */
147 */
148
148
149 /*!
149 /*!
150 \qmlmethod XYSeries::insert(int index, real x, real y)
150 \qmlmethod XYSeries::insert(int index, real x, real y)
151 Inserts point (\a x, \a y) to the \a index. If index is 0 or smaller than 0 the point is prepended to the list of
151 Inserts point (\a x, \a y) to the \a index. If index is 0 or smaller than 0 the point is prepended to the list of
152 points. If index is the same as or bigger than count, the point is appended to the list of points.
152 points. If index is the same as or bigger than count, the point is appended to the list of points.
153 */
153 */
154
154
155 /*!
155 /*!
156 \qmlmethod QPointF XYSeries::at(int index)
156 \qmlmethod QPointF XYSeries::at(int index)
157 Returns point at \a index. Returns (0, 0) if the index is not valid.
157 Returns point at \a index. Returns (0, 0) if the index is not valid.
158 */
158 */
159
159
160 /*!
160 /*!
161 \internal
161 \internal
162
162
163 Constructs empty series object which is a child of \a parent.
163 Constructs empty series object which is a child of \a parent.
164 When series object is added to QChartView or QChart instance ownerships is transferred.
164 When series object is added to QChartView or QChart instance ownerships is transferred.
165 */
165 */
166 QXYSeries::QXYSeries(QXYSeriesPrivate &d,QObject *parent) : QAbstractSeries(d, parent)
166 QXYSeries::QXYSeries(QXYSeriesPrivate &d,QObject *parent) : QAbstractSeries(d, parent)
167 {
167 {
168 }
168 }
169
169
170 /*!
170 /*!
171 Destroys the object. Series added to QChartView or QChart instances are owned by those,
171 Destroys the object. Series added to QChartView or QChart instances are owned by those,
172 and are deleted when mentioned object are destroyed.
172 and are deleted when mentioned object are destroyed.
173 */
173 */
174 QXYSeries::~QXYSeries()
174 QXYSeries::~QXYSeries()
175 {
175 {
176 }
176 }
177
177
178 /*!
178 /*!
179 Adds data point \a x \a y to the series. Points are connected with lines on the chart.
179 Adds data point \a x \a y to the series. Points are connected with lines on the chart.
180 */
180 */
181 void QXYSeries::append(qreal x,qreal y)
181 void QXYSeries::append(qreal x,qreal y)
182 {
182 {
183 append(QPointF(x,y));
183 append(QPointF(x,y));
184 }
184 }
185
185
186 /*!
186 /*!
187 This is an overloaded function.
187 This is an overloaded function.
188 Adds data \a point to the series. Points are connected with lines on the chart.
188 Adds data \a point to the series. Points are connected with lines on the chart.
189 */
189 */
190 void QXYSeries::append(const QPointF &point)
190 void QXYSeries::append(const QPointF &point)
191 {
191 {
192 Q_D(QXYSeries);
192 Q_D(QXYSeries);
193 d->m_points<<point;
193 d->m_points<<point;
194 // emit d->pointAdded(d->m_points.count()-1);
194 // emit d->pointAdded(d->m_points.count()-1);
195 emit pointAdded(d->m_points.count()-1);
195 emit pointAdded(d->m_points.count()-1);
196 }
196 }
197
197
198 /*!
198 /*!
199 This is an overloaded function.
199 This is an overloaded function.
200 Adds list of data \a points to the series. Points are connected with lines on the chart.
200 Adds list of data \a points to the series. Points are connected with lines on the chart.
201 */
201 */
202 void QXYSeries::append(const QList<QPointF> &points)
202 void QXYSeries::append(const QList<QPointF> &points)
203 {
203 {
204 foreach(const QPointF& point , points) {
204 foreach(const QPointF& point , points) {
205 append(point);
205 append(point);
206 }
206 }
207 }
207 }
208
208
209 /*!
209 /*!
210 Replaces data point \a oldX \a oldY with data point \a newX \a newY.
210 Replaces data point \a oldX \a oldY with data point \a newX \a newY.
211 */
211 */
212 void QXYSeries::replace(qreal oldX,qreal oldY,qreal newX,qreal newY)
212 void QXYSeries::replace(qreal oldX,qreal oldY,qreal newX,qreal newY)
213 {
213 {
214 replace(QPointF(oldX,oldY),QPointF(newX,newY));
214 replace(QPointF(oldX,oldY),QPointF(newX,newY));
215 }
215 }
216
216
217 /*!
217 /*!
218 Replaces \a oldPoint with \a newPoint.
218 Replaces \a oldPoint with \a newPoint.
219 */
219 */
220 void QXYSeries::replace(const QPointF &oldPoint,const QPointF &newPoint)
220 void QXYSeries::replace(const QPointF &oldPoint,const QPointF &newPoint)
221 {
221 {
222 Q_D(QXYSeries);
222 Q_D(QXYSeries);
223 int index = d->m_points.indexOf(oldPoint);
223 int index = d->m_points.indexOf(oldPoint);
224 if(index==-1) return;
224 if(index==-1) return;
225 d->m_points[index] = newPoint;
225 d->m_points[index] = newPoint;
226 // emit d->pointReplaced(index);
226 // emit d->pointReplaced(index);
227 emit pointReplaced(index);
227 emit pointReplaced(index);
228 }
228 }
229
229
230 /*!
230 /*!
231 Removes current \a x and \a y value.
231 Removes current \a x and \a y value.
232 */
232 */
233 void QXYSeries::remove(qreal x,qreal y)
233 void QXYSeries::remove(qreal x,qreal y)
234 {
234 {
235 remove(QPointF(x,y));
235 remove(QPointF(x,y));
236 }
236 }
237
237
238 /*!
238 /*!
239 Removes current \a point x value.
239 Removes current \a point x value.
240
240
241 Note: point y value is ignored.
241 Note: point y value is ignored.
242 */
242 */
243 void QXYSeries::remove(const QPointF &point)
243 void QXYSeries::remove(const QPointF &point)
244 {
244 {
245 Q_D(QXYSeries);
245 Q_D(QXYSeries);
246 int index = d->m_points.indexOf(point);
246 int index = d->m_points.indexOf(point);
247 if(index==-1) return;
247 if(index==-1) return;
248 d->m_points.remove(index);
248 d->m_points.remove(index);
249 // emit d->pointRemoved(index);
249 // emit d->pointRemoved(index);
250 emit pointRemoved(index);
250 emit pointRemoved(index);
251 }
251 }
252
252
253 /*!
253 /*!
254 Inserts a \a point in the series at \a index position.
254 Inserts a \a point in the series at \a index position.
255 */
255 */
256 void QXYSeries::insert(int index, const QPointF &point)
256 void QXYSeries::insert(int index, const QPointF &point)
257 {
257 {
258 Q_D(QXYSeries);
258 Q_D(QXYSeries);
259 d->m_points.insert(index, point);
259 d->m_points.insert(index, point);
260 // emit d->pointAdded(index);
260 // emit d->pointAdded(index);
261 emit pointAdded(index);
261 emit pointAdded(index);
262 }
262 }
263
263
264 /*!
264 /*!
265 Removes all points from the series.
265 Removes all points from the series.
266 */
266 */
267 void QXYSeries::clear()
267 void QXYSeries::clear()
268 {
268 {
269 Q_D(QXYSeries);
269 Q_D(QXYSeries);
270 for (int i = d->m_points.size() - 1; i >= 0; i--)
270 for (int i = d->m_points.size() - 1; i >= 0; i--)
271 remove(d->m_points.at(i));
271 remove(d->m_points.at(i));
272 }
272 }
273
273
274 /*!
274 /*!
275 \internal \a pos
275 \internal \a pos
276 */
276 */
277 QList<QPointF> QXYSeries::points() const
277 QList<QPointF> QXYSeries::points() const
278 {
278 {
279 Q_D(const QXYSeries);
279 Q_D(const QXYSeries);
280 return d->m_points.toList();
280 return d->m_points.toList();
281 }
281 }
282
282
283 /*!
283 /*!
284 Returns number of data points within series.
284 Returns number of data points within series.
285 */
285 */
286 int QXYSeries::count() const
286 int QXYSeries::count() const
287 {
287 {
288 Q_D(const QXYSeries);
288 Q_D(const QXYSeries);
289 return d->m_points.count();
289 return d->m_points.count();
290 }
290 }
291
291
292
292
293 /*!
293 /*!
294 Sets \a pen used for drawing points on the chart. If the pen is not defined, the
294 Sets \a pen used for drawing points on the chart. If the pen is not defined, the
295 pen from chart theme is used.
295 pen from chart theme is used.
296 \sa QChart::setTheme()
296 \sa QChart::setTheme()
297 */
297 */
298 void QXYSeries::setPen(const QPen &pen)
298 void QXYSeries::setPen(const QPen &pen)
299 {
299 {
300 Q_D(QXYSeries);
300 Q_D(QXYSeries);
301 if (d->m_pen!=pen) {
301 if (d->m_pen!=pen) {
302 d->m_pen = pen;
302 d->m_pen = pen;
303 emit d->updated();
303 emit d->updated();
304 }
304 }
305 }
305 }
306
306
307 QPen QXYSeries::pen() const
307 QPen QXYSeries::pen() const
308 {
308 {
309 Q_D(const QXYSeries);
309 Q_D(const QXYSeries);
310 return d->m_pen;
310 return d->m_pen;
311 }
311 }
312
312
313 /*!
313 /*!
314 Sets \a brush used for drawing points on the chart. If the brush is not defined, brush
314 Sets \a brush used for drawing points on the chart. If the brush is not defined, brush
315 from chart theme setting is used.
315 from chart theme setting is used.
316 \sa QChart::setTheme()
316 \sa QChart::setTheme()
317 */
317 */
318 void QXYSeries::setBrush(const QBrush &brush)
318 void QXYSeries::setBrush(const QBrush &brush)
319 {
319 {
320 Q_D(QXYSeries);
320 Q_D(QXYSeries);
321 if (d->m_brush!=brush) {
321 if (d->m_brush!=brush) {
322 d->m_brush = brush;
322 d->m_brush = brush;
323 emit d->updated();
323 emit d->updated();
324 }
324 }
325 }
325 }
326
326
327 QBrush QXYSeries::brush() const
327 QBrush QXYSeries::brush() const
328 {
328 {
329 Q_D(const QXYSeries);
329 Q_D(const QXYSeries);
330 return d->m_brush;
330 return d->m_brush;
331 }
331 }
332
332
333 void QXYSeries::setColor(const QColor &color)
333 void QXYSeries::setColor(const QColor &color)
334 {
334 {
335 QPen p = pen();
335 QPen p = pen();
336 if (p.color() != color) {
336 if (p.color() != color) {
337 p.setColor(color);
337 p.setColor(color);
338 setPen(p);
338 setPen(p);
339 emit colorChanged(color);
339 emit colorChanged(color);
340 }
340 }
341 }
341 }
342
342
343 QColor QXYSeries::color() const
343 QColor QXYSeries::color() const
344 {
344 {
345 return pen().color();
345 return pen().color();
346 }
346 }
347
347
348 void QXYSeries::setPointsVisible(bool visible)
348 void QXYSeries::setPointsVisible(bool visible)
349 {
349 {
350 Q_D(QXYSeries);
350 Q_D(QXYSeries);
351 if (d->m_pointsVisible != visible){
351 if (d->m_pointsVisible != visible){
352 d->m_pointsVisible = visible;
352 d->m_pointsVisible = visible;
353 emit d->updated();
353 emit d->updated();
354 }
354 }
355 }
355 }
356
356
357 bool QXYSeries::pointsVisible() const
357 bool QXYSeries::pointsVisible() const
358 {
358 {
359 Q_D(const QXYSeries);
359 Q_D(const QXYSeries);
360 return d->m_pointsVisible;
360 return d->m_pointsVisible;
361 }
361 }
362
362
363
363
364 /*!
364 /*!
365 Stream operator for adding a data \a point to the series.
365 Stream operator for adding a data \a point to the series.
366 \sa append()
366 \sa append()
367 */
367 */
368 QXYSeries& QXYSeries::operator<< (const QPointF &point)
368 QXYSeries& QXYSeries::operator<< (const QPointF &point)
369 {
369 {
370 append(point);
370 append(point);
371 return *this;
371 return *this;
372 }
372 }
373
373
374
374
375 /*!
375 /*!
376 Stream operator for adding a list of \a points to the series.
376 Stream operator for adding a list of \a points to the series.
377 \sa append()
377 \sa append()
378 */
378 */
379
379
380 QXYSeries& QXYSeries::operator<< (const QList<QPointF>& points)
380 QXYSeries& QXYSeries::operator<< (const QList<QPointF>& points)
381 {
381 {
382 append(points);
382 append(points);
383 return *this;
383 return *this;
384 }
384 }
385
385
386 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
386 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
387
387
388
388
389 QXYSeriesPrivate::QXYSeriesPrivate(QXYSeries *q) :
389 QXYSeriesPrivate::QXYSeriesPrivate(QXYSeries *q) :
390 QAbstractSeriesPrivate(q),
390 QAbstractSeriesPrivate(q),
391 m_pointsVisible(false)
391 m_pointsVisible(false)
392 {
392 {
393 }
393 }
394
394
395 void QXYSeriesPrivate::scaleDomain(Domain& domain)
395 void QXYSeriesPrivate::scaleDomain(Domain& domain)
396 {
396 {
397 qreal minX(domain.minX());
397 qreal minX(domain.minX());
398 qreal minY(domain.minY());
398 qreal minY(domain.minY());
399 qreal maxX(domain.maxX());
399 qreal maxX(domain.maxX());
400 qreal maxY(domain.maxY());
400 qreal maxY(domain.maxY());
401 int tickXCount(domain.tickXCount());
401 int tickXCount(domain.tickXCount());
402 int tickYCount(domain.tickYCount());
402 int tickYCount(domain.tickYCount());
403
403
404 Q_Q(QXYSeries);
404 Q_Q(QXYSeries);
405
405
406 const QList<QPointF>& points = q->points();
406 const QList<QPointF>& points = q->points();
407
407
408
408
409 if(points.isEmpty()){
409 if(points.isEmpty()){
410 minX=0.0;
410 minX=0.0;
411 minY=0.0;
411 minY=0.0;
412 maxX=1.0;
412 maxX=1.0;
413 maxY=1.0;
413 maxY=1.0;
414 }
414 }
415
415
416 for (int i = 0; i < points.count(); i++)
416 for (int i = 0; i < points.count(); i++)
417 {
417 {
418 qreal x = points[i].x();
418 qreal x = points[i].x();
419 qreal y = points[i].y();
419 qreal y = points[i].y();
420 minX = qMin(minX, x);
420 minX = qMin(minX, x);
421 minY = qMin(minY, y);
421 minY = qMin(minY, y);
422 maxX = qMax(maxX, x);
422 maxX = qMax(maxX, x);
423 maxY = qMax(maxY, y);
423 maxY = qMax(maxY, y);
424 }
424 }
425
425
426 domain.setRange(minX,maxX,minY,maxY,tickXCount,tickYCount);
426 domain.setRange(minX,maxX,minY,maxY,tickXCount,tickYCount);
427 }
427 }
428
428
429 QList<LegendMarker*> QXYSeriesPrivate::createLegendMarker(QLegend* legend)
429 QList<LegendMarker*> QXYSeriesPrivate::createLegendMarker(QLegend* legend)
430 {
430 {
431 Q_Q(QXYSeries);
431 Q_Q(QXYSeries);
432 QList<LegendMarker*> list;
432 QList<LegendMarker*> list;
433 return list << new XYLegendMarker(q,legend);
433 return list << new XYLegendMarker(q,legend);
434 }
434 }
435
435
436 #include "moc_qxyseries.cpp"
436 #include "moc_qxyseries.cpp"
437 #include "moc_qxyseries_p.cpp"
437 #include "moc_qxyseries_p.cpp"
438
438
439 QTCOMMERCIALCHART_END_NAMESPACE
439 QTCOMMERCIALCHART_END_NAMESPACE
@@ -1,72 +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 import QtQuick 1.0
21 import QtQuick 1.0
22 import QtCommercial.Chart 1.0
22 import QtCommercial.Chart 1.0
23
23
24 ChartView {
24 ChartView {
25 title: "area series"
25 title: "area series"
26 anchors.fill: parent
26 anchors.fill: parent
27 axisXLabels: ["0", "2000", "1", "2001", "2", "2002", "3", "2003", "4", "2004", "5", "2005",
27 axisXLabels: ["0", "2000", "1", "2001", "2", "2002", "3", "2003", "4", "2004", "5", "2005",
28 "6", "2006", "7", "2007", "8", "2008", "9", "2009", "10", "2010", "11", "2011"]
28 "6", "2006", "7", "2007", "8", "2008", "9", "2009", "10", "2010", "11", "2011"]
29
29
30 property variant series: areaSeries
30 property variant series: areaSeries
31
31
32 AreaSeries {
32 AreaSeries {
33 id: areaSeries
33 id: areaSeries
34 name: "area 1"
34 name: "area 1"
35 upperSeries: LineSeries {
35 upperSeries: LineSeries {
36 XyPoint { x: 0; y: 1 }
36 XYPoint { x: 0; y: 1 }
37 XyPoint { x: 1; y: 1 }
37 XYPoint { x: 1; y: 1 }
38 XyPoint { x: 2; y: 3 }
38 XYPoint { x: 2; y: 3 }
39 XyPoint { x: 3; y: 3 }
39 XYPoint { x: 3; y: 3 }
40 XyPoint { x: 4; y: 2 }
40 XYPoint { x: 4; y: 2 }
41 XyPoint { x: 5; y: 0 }
41 XYPoint { x: 5; y: 0 }
42 XyPoint { x: 6; y: 2 }
42 XYPoint { x: 6; y: 2 }
43 XyPoint { x: 7; y: 1 }
43 XYPoint { x: 7; y: 1 }
44 XyPoint { x: 8; y: 2 }
44 XYPoint { x: 8; y: 2 }
45 XyPoint { x: 9; y: 1 }
45 XYPoint { x: 9; y: 1 }
46 XyPoint { x: 10; y: 3 }
46 XYPoint { x: 10; y: 3 }
47 XyPoint { x: 11; y: 3 }
47 XYPoint { x: 11; y: 3 }
48 }
48 }
49 lowerSeries: LineSeries {
49 lowerSeries: LineSeries {
50 XyPoint { x: 0; y: 0 }
50 XYPoint { x: 0; y: 0 }
51 XyPoint { x: 1; y: 0 }
51 XYPoint { x: 1; y: 0 }
52 XyPoint { x: 2; y: 0 }
52 XYPoint { x: 2; y: 0 }
53 XyPoint { x: 3; y: 0 }
53 XYPoint { x: 3; y: 0 }
54 XyPoint { x: 4; y: 0 }
54 XYPoint { x: 4; y: 0 }
55 XyPoint { x: 5; y: 0 }
55 XYPoint { x: 5; y: 0 }
56 XyPoint { x: 6; y: 0 }
56 XYPoint { x: 6; y: 0 }
57 XyPoint { x: 7; y: 0 }
57 XYPoint { x: 7; y: 0 }
58 XyPoint { x: 8; y: 0 }
58 XYPoint { x: 8; y: 0 }
59 XyPoint { x: 9; y: 0 }
59 XYPoint { x: 9; y: 0 }
60 XyPoint { x: 10; y: 0 }
60 XYPoint { x: 10; y: 0 }
61 XyPoint { x: 11; y: 0 }
61 XYPoint { x: 11; y: 0 }
62 }
62 }
63
63
64 onNameChanged: console.log("areaSeries.onNameChanged: " + name);
64 onNameChanged: console.log("areaSeries.onNameChanged: " + name);
65 onVisibleChanged: console.log("areaSeries.onVisibleChanged: " + visible);
65 onVisibleChanged: console.log("areaSeries.onVisibleChanged: " + visible);
66 onClicked: console.log(name + ".onClicked: " + point.x + ", " + point.y);
66 onClicked: console.log(name + ".onClicked: " + point.x + ", " + point.y);
67 onSelected: console.log("areaSeries.onSelected");
67 onSelected: console.log("areaSeries.onSelected");
68 onColorChanged: console.log("areaSeries.onColorChanged: " + color);
68 onColorChanged: console.log("areaSeries.onColorChanged: " + color);
69 onBorderColorChanged: console.log("areaSeries.onBorderColorChanged: " + borderColor);
69 onBorderColorChanged: console.log("areaSeries.onBorderColorChanged: " + borderColor);
70 // onCountChanged: console.log("areaSeries.onCountChanged: " + count);
70 // onCountChanged: console.log("areaSeries.onCountChanged: " + count);
71 }
71 }
72 }
72 }
@@ -1,107 +1,107
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.0
22 import QtCommercial.Chart 1.0
23
23
24 ChartView {
24 ChartView {
25 id: chartView
25 id: chartView
26 title: "Chart Title"
26 title: "Chart Title"
27 anchors.fill: parent
27 anchors.fill: parent
28 property variant series: chartView
28 property variant series: chartView
29
29
30 LineSeries {
30 LineSeries {
31 name: "line"
31 name: "line"
32 XyPoint { x: 0; y: 0 }
32 XYPoint { x: 0; y: 0 }
33 XyPoint { x: 1.1; y: 2.1 }
33 XYPoint { x: 1.1; y: 2.1 }
34 XyPoint { x: 1.9; y: 3.3 }
34 XYPoint { x: 1.9; y: 3.3 }
35 XyPoint { x: 2.1; y: 2.1 }
35 XYPoint { x: 2.1; y: 2.1 }
36 XyPoint { x: 2.9; y: 4.9 }
36 XYPoint { x: 2.9; y: 4.9 }
37 XyPoint { x: 3.4; y: 3.0 }
37 XYPoint { x: 3.4; y: 3.0 }
38 XyPoint { x: 4.1; y: 3.3 }
38 XYPoint { x: 4.1; y: 3.3 }
39 }
39 }
40
40
41 onVisibleChanged: console.log("chart.onVisibleChanged: " + visible);
41 onVisibleChanged: console.log("chart.onVisibleChanged: " + visible);
42 onTitleColorChanged: console.log("chart.onTitleColorChanged: " + color);
42 onTitleColorChanged: console.log("chart.onTitleColorChanged: " + color);
43 onBackgroundColorChanged: console.log("chart.onBackgroundColorChanged: " + series.backgroundColor);
43 onBackgroundColorChanged: console.log("chart.onBackgroundColorChanged: " + series.backgroundColor);
44 onDropShadowEnabledChanged: console.log("chart.onDropShadowEnabledChanged: " + enabled);
44 onDropShadowEnabledChanged: console.log("chart.onDropShadowEnabledChanged: " + enabled);
45 onTopMarginChanged: {
45 onTopMarginChanged: {
46 console.log("chart.onTopMarginChanged: " + margin);
46 console.log("chart.onTopMarginChanged: " + margin);
47 marginVisualizer.opacity = 1.0;
47 marginVisualizer.opacity = 1.0;
48 }
48 }
49 onBottomMarginChanged: {
49 onBottomMarginChanged: {
50 console.log("chart.onBottomMarginChanged: " + margin);
50 console.log("chart.onBottomMarginChanged: " + margin);
51 marginVisualizer.opacity = 1.0;
51 marginVisualizer.opacity = 1.0;
52 }
52 }
53 onLeftMarginChanged: {
53 onLeftMarginChanged: {
54 console.log("chart.onLeftMarginChanged: " + margin);
54 console.log("chart.onLeftMarginChanged: " + margin);
55 marginVisualizer.opacity = 1.0;
55 marginVisualizer.opacity = 1.0;
56 }
56 }
57 onRightMarginChanged: {
57 onRightMarginChanged: {
58 console.log("chart.onRightMarginChanged: " + margin);
58 console.log("chart.onRightMarginChanged: " + margin);
59 marginVisualizer.opacity = 1.0;
59 marginVisualizer.opacity = 1.0;
60 }
60 }
61
61
62 legend.onVisibleChanged: console.log("legend.onVisibleChanged: " + series.legend.visible);
62 legend.onVisibleChanged: console.log("legend.onVisibleChanged: " + series.legend.visible);
63 legend.onBackgroundVisibleChanged: console.log("legend.onBackgroundVisibleChanged: " + visible);
63 legend.onBackgroundVisibleChanged: console.log("legend.onBackgroundVisibleChanged: " + visible);
64 legend.onColorChanged: console.log("legend.onColorChanged: " + color);
64 legend.onColorChanged: console.log("legend.onColorChanged: " + color);
65 legend.onBorderColorChanged: console.log("legend.onBorderColorChanged: " + color);
65 legend.onBorderColorChanged: console.log("legend.onBorderColorChanged: " + color);
66 legend.onLabelColorChanged: console.log("legend.onLabelColorChanged: " + color);
66 legend.onLabelColorChanged: console.log("legend.onLabelColorChanged: " + color);
67 legend.onLabelBrushChanged: console.log("legend.onLabelBrushChanged: " + brush);
67 legend.onLabelBrushChanged: console.log("legend.onLabelBrushChanged: " + brush);
68
68
69 axisX.onColorChanged: console.log("axisX.onColorChanged: " + color);
69 axisX.onColorChanged: console.log("axisX.onColorChanged: " + color);
70 axisX.onLabelsVisibleChanged: console.log("axisX.onLabelsVisibleChanged: " + visible);
70 axisX.onLabelsVisibleChanged: console.log("axisX.onLabelsVisibleChanged: " + visible);
71 axisX.onLabelsColorChanged: console.log("axisX.onLabelsColorChanged: " + color);
71 axisX.onLabelsColorChanged: console.log("axisX.onLabelsColorChanged: " + color);
72 axisX.onVisibleChanged: console.log("axisX.onVisibleChanged: " + visible);
72 axisX.onVisibleChanged: console.log("axisX.onVisibleChanged: " + visible);
73 axisX.onGridVisibleChanged: console.log("axisX.onGridVisibleChanged: " + visible);
73 axisX.onGridVisibleChanged: console.log("axisX.onGridVisibleChanged: " + visible);
74 axisX.onShadesVisibleChanged: console.log("axisX.onShadesVisibleChanged: " + visible);
74 axisX.onShadesVisibleChanged: console.log("axisX.onShadesVisibleChanged: " + visible);
75 axisX.onShadesColorChanged: console.log("axisX.onShadesColorChanged: " + color);
75 axisX.onShadesColorChanged: console.log("axisX.onShadesColorChanged: " + color);
76 axisX.onShadesBorderColorChanged: console.log("axisX.onShadesBorderColorChanged: " + color);
76 axisX.onShadesBorderColorChanged: console.log("axisX.onShadesBorderColorChanged: " + color);
77 axisX.onMinChanged: console.log("axisX.onMinChanged: " + min);
77 axisX.onMinChanged: console.log("axisX.onMinChanged: " + min);
78 axisX.onMaxChanged: console.log("axisX.onMaxChanged: " + max);
78 axisX.onMaxChanged: console.log("axisX.onMaxChanged: " + max);
79
79
80 axisY.onColorChanged: console.log("axisY.onColorChanged: " + color);
80 axisY.onColorChanged: console.log("axisY.onColorChanged: " + color);
81 axisY.onLabelsVisibleChanged: console.log("axisY.onLabelsVisibleChanged: " + visible);
81 axisY.onLabelsVisibleChanged: console.log("axisY.onLabelsVisibleChanged: " + visible);
82 axisY.onLabelsColorChanged: console.log("axisY.onLabelsColorChanged: " + color);
82 axisY.onLabelsColorChanged: console.log("axisY.onLabelsColorChanged: " + color);
83 axisY.onVisibleChanged: console.log("axisY.onVisibleChanged: " + visible);
83 axisY.onVisibleChanged: console.log("axisY.onVisibleChanged: " + visible);
84 axisY.onGridVisibleChanged: console.log("axisY.onGridVisibleChanged: " + visible);
84 axisY.onGridVisibleChanged: console.log("axisY.onGridVisibleChanged: " + visible);
85 axisY.onShadesVisibleChanged: console.log("axisY.onShadesVisibleChanged: " + visible);
85 axisY.onShadesVisibleChanged: console.log("axisY.onShadesVisibleChanged: " + visible);
86 axisY.onShadesColorChanged: console.log("axisY.onShadesColorChanged: " + color);
86 axisY.onShadesColorChanged: console.log("axisY.onShadesColorChanged: " + color);
87 axisY.onShadesBorderColorChanged: console.log("axisY.onShadesBorderColorChanged: " + color);
87 axisY.onShadesBorderColorChanged: console.log("axisY.onShadesBorderColorChanged: " + color);
88 axisY.onMinChanged: console.log("axisY.onMinChanged: " + min);
88 axisY.onMinChanged: console.log("axisY.onMinChanged: " + min);
89 axisY.onMaxChanged: console.log("axisY.onMaxChanged: " + max);
89 axisY.onMaxChanged: console.log("axisY.onMaxChanged: " + max);
90
90
91
91
92 Rectangle {
92 Rectangle {
93 id: marginVisualizer
93 id: marginVisualizer
94 color: "transparent"
94 color: "transparent"
95 border.color: "red"
95 border.color: "red"
96 anchors.fill: parent
96 anchors.fill: parent
97 anchors.topMargin: parent.topMargin
97 anchors.topMargin: parent.topMargin
98 anchors.bottomMargin: parent.bottomMargin
98 anchors.bottomMargin: parent.bottomMargin
99 anchors.leftMargin: parent.leftMargin
99 anchors.leftMargin: parent.leftMargin
100 anchors.rightMargin: parent.rightMargin
100 anchors.rightMargin: parent.rightMargin
101 opacity: 0.0
101 opacity: 0.0
102 onOpacityChanged: if (opacity > 0.9) opacity = 0.0;
102 onOpacityChanged: if (opacity > 0.9) opacity = 0.0;
103 Behavior on opacity {
103 Behavior on opacity {
104 NumberAnimation { duration: 800 }
104 NumberAnimation { duration: 800 }
105 }
105 }
106 }
106 }
107 }
107 }
@@ -1,61 +1,61
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.0
22 import QtCommercial.Chart 1.0
23
23
24 ChartView {
24 ChartView {
25 property variant series: lineSeries
25 property variant series: lineSeries
26
26
27 title: "line series"
27 title: "line series"
28 anchors.fill: parent
28 anchors.fill: parent
29
29
30 LineSeries {
30 LineSeries {
31 id: lineSeries
31 id: lineSeries
32 name: "line 1"
32 name: "line 1"
33 XyPoint { x: 0; y: 0 }
33 XYPoint { x: 0; y: 0 }
34 XyPoint { x: 1.1; y: 2.1 }
34 XYPoint { x: 1.1; y: 2.1 }
35 XyPoint { x: 1.9; y: 3.3 }
35 XYPoint { x: 1.9; y: 3.3 }
36 XyPoint { x: 2.1; y: 2.1 }
36 XYPoint { x: 2.1; y: 2.1 }
37 XyPoint { x: 2.9; y: 4.9 }
37 XYPoint { x: 2.9; y: 4.9 }
38 XyPoint { x: 3.4; y: 3.0 }
38 XYPoint { x: 3.4; y: 3.0 }
39 XyPoint { x: 4.1; y: 3.3 }
39 XYPoint { x: 4.1; y: 3.3 }
40
40
41 onNameChanged: console.log("lineSeries.onNameChanged: " + name);
41 onNameChanged: console.log("lineSeries.onNameChanged: " + name);
42 onVisibleChanged: console.log("lineSeries.onVisibleChanged: " + visible);
42 onVisibleChanged: console.log("lineSeries.onVisibleChanged: " + visible);
43 onClicked: console.log(name + ".onClicked: " + point.x + ", " + point.y);
43 onClicked: console.log(name + ".onClicked: " + point.x + ", " + point.y);
44 onPointReplaced: console.log("lineSeries.onPointReplaced: " + index);
44 onPointReplaced: console.log("lineSeries.onPointReplaced: " + index);
45 onPointRemoved: console.log("lineSeries.onPointRemoved: " + index);
45 onPointRemoved: console.log("lineSeries.onPointRemoved: " + index);
46 onPointAdded: console.log("lineSeries.onPointAdded: " + series.at(index).x + ", " + series.at(index).y);
46 onPointAdded: console.log("lineSeries.onPointAdded: " + series.at(index).x + ", " + series.at(index).y);
47 onColorChanged: console.log("lineSeries.onColorChanged: " + color);
47 onColorChanged: console.log("lineSeries.onColorChanged: " + color);
48 onCountChanged: console.log("lineSeries.onCountChanged: " + count);
48 onCountChanged: console.log("lineSeries.onCountChanged: " + count);
49 }
49 }
50
50
51 LineSeries {
51 LineSeries {
52 name: "line 2"
52 name: "line 2"
53 XyPoint { x: 1.1; y: 1.1 }
53 XYPoint { x: 1.1; y: 1.1 }
54 XyPoint { x: 1.9; y: 2.3 }
54 XYPoint { x: 1.9; y: 2.3 }
55 XyPoint { x: 2.1; y: 1.1 }
55 XYPoint { x: 2.1; y: 1.1 }
56 XyPoint { x: 2.9; y: 3.9 }
56 XYPoint { x: 2.9; y: 3.9 }
57 XyPoint { x: 3.4; y: 2.0 }
57 XYPoint { x: 3.4; y: 2.0 }
58 XyPoint { x: 4.1; y: 2.3 }
58 XYPoint { x: 4.1; y: 2.3 }
59 onClicked: console.log(name + ".onClicked: " + point.x + ", " + point.y);
59 onClicked: console.log(name + ".onClicked: " + point.x + ", " + point.y);
60 }
60 }
61 }
61 }
@@ -1,62 +1,62
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.0
22 import QtCommercial.Chart 1.0
23
23
24 ChartView {
24 ChartView {
25 title: "scatter series"
25 title: "scatter series"
26 axisX.max: 4
26 axisX.max: 4
27 axisY.max: 4
27 axisY.max: 4
28 property variant series: scatterSeries
28 property variant series: scatterSeries
29
29
30 ScatterSeries {
30 ScatterSeries {
31 id: scatterSeries
31 id: scatterSeries
32 name: "scatter 1"
32 name: "scatter 1"
33 XyPoint { x: 1.5; y: 1.5 }
33 XYPoint { x: 1.5; y: 1.5 }
34 XyPoint { x: 1.5; y: 1.6 }
34 XYPoint { x: 1.5; y: 1.6 }
35 XyPoint { x: 1.57; y: 1.55 }
35 XYPoint { x: 1.57; y: 1.55 }
36 XyPoint { x: 1.8; y: 1.8 }
36 XYPoint { x: 1.8; y: 1.8 }
37 XyPoint { x: 1.9; y: 1.6 }
37 XYPoint { x: 1.9; y: 1.6 }
38 XyPoint { x: 2.1; y: 1.3 }
38 XYPoint { x: 2.1; y: 1.3 }
39 XyPoint { x: 2.5; y: 2.1 }
39 XYPoint { x: 2.5; y: 2.1 }
40
40
41 onNameChanged: console.log("scatterSeries.onNameChanged: " + name);
41 onNameChanged: console.log("scatterSeries.onNameChanged: " + name);
42 onVisibleChanged: console.log("scatterSeries.onVisibleChanged: " + visible);
42 onVisibleChanged: console.log("scatterSeries.onVisibleChanged: " + visible);
43 onClicked: console.log(name + ".onClicked: " + point.x + ", " + point.y);
43 onClicked: console.log(name + ".onClicked: " + point.x + ", " + point.y);
44 onPointReplaced: console.log("scatterSeries.onPointReplaced: " + index);
44 onPointReplaced: console.log("scatterSeries.onPointReplaced: " + index);
45 onPointRemoved: console.log("scatterSeries.onPointRemoved: " + index);
45 onPointRemoved: console.log("scatterSeries.onPointRemoved: " + index);
46 onPointAdded: console.log("scatterSeries.onPointAdded: " + series.at(index).x + ", " + series.at(index).y);
46 onPointAdded: console.log("scatterSeries.onPointAdded: " + series.at(index).x + ", " + series.at(index).y);
47 onColorChanged: console.log("scatterSeries.onColorChanged: " + color);
47 onColorChanged: console.log("scatterSeries.onColorChanged: " + color);
48 onBorderColorChanged: console.log("scatterSeries.onBorderColorChanged: " + borderColor);
48 onBorderColorChanged: console.log("scatterSeries.onBorderColorChanged: " + borderColor);
49 onCountChanged: console.log("scatterSeries.onCountChanged: " + count);
49 onCountChanged: console.log("scatterSeries.onCountChanged: " + count);
50 }
50 }
51
51
52 ScatterSeries {
52 ScatterSeries {
53 name: "scatter2"
53 name: "scatter2"
54 XyPoint { x: 2.0; y: 2.0 }
54 XYPoint { x: 2.0; y: 2.0 }
55 XyPoint { x: 2.0; y: 2.1 }
55 XYPoint { x: 2.0; y: 2.1 }
56 XyPoint { x: 2.07; y: 2.05 }
56 XYPoint { x: 2.07; y: 2.05 }
57 XyPoint { x: 2.2; y: 2.9 }
57 XYPoint { x: 2.2; y: 2.9 }
58 XyPoint { x: 2.4; y: 2.7 }
58 XYPoint { x: 2.4; y: 2.7 }
59 XyPoint { x: 2.67; y: 2.65 }
59 XYPoint { x: 2.67; y: 2.65 }
60 onClicked: console.log(name + ".onClicked: " + point.x + ", " + point.y);
60 onClicked: console.log(name + ".onClicked: " + point.x + ", " + point.y);
61 }
61 }
62 }
62 }
@@ -1,60 +1,60
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.0
22 import QtCommercial.Chart 1.0
23
23
24 ChartView {
24 ChartView {
25 title: "spline series"
25 title: "spline series"
26 anchors.fill: parent
26 anchors.fill: parent
27 property variant series: splineSeries
27 property variant series: splineSeries
28
28
29 SplineSeries {
29 SplineSeries {
30 id: splineSeries
30 id: splineSeries
31 name: "spline 1"
31 name: "spline 1"
32 XyPoint { x: 0; y: 0 }
32 XYPoint { x: 0; y: 0 }
33 XyPoint { x: 1.1; y: 2.1 }
33 XYPoint { x: 1.1; y: 2.1 }
34 XyPoint { x: 1.9; y: 3.3 }
34 XYPoint { x: 1.9; y: 3.3 }
35 XyPoint { x: 2.1; y: 2.1 }
35 XYPoint { x: 2.1; y: 2.1 }
36 XyPoint { x: 2.9; y: 4.9 }
36 XYPoint { x: 2.9; y: 4.9 }
37 XyPoint { x: 3.4; y: 3.0 }
37 XYPoint { x: 3.4; y: 3.0 }
38 XyPoint { x: 4.1; y: 3.3 }
38 XYPoint { x: 4.1; y: 3.3 }
39
39
40 onNameChanged: console.log("splineSeries.onNameChanged: " + name);
40 onNameChanged: console.log("splineSeries.onNameChanged: " + name);
41 onVisibleChanged: console.log("splineSeries.onVisibleChanged: " + visible);
41 onVisibleChanged: console.log("splineSeries.onVisibleChanged: " + visible);
42 onClicked: console.log(name + ".onClicked: " + point.x + ", " + point.y);
42 onClicked: console.log(name + ".onClicked: " + point.x + ", " + point.y);
43 onPointReplaced: console.log("splineSeries.onPointReplaced: " + index);
43 onPointReplaced: console.log("splineSeries.onPointReplaced: " + index);
44 onPointRemoved: console.log("splineSeries.onPointRemoved: " + index);
44 onPointRemoved: console.log("splineSeries.onPointRemoved: " + index);
45 onPointAdded: console.log("splineSeries.onPointAdded: " + series.at(index).x + ", " + series.at(index).y);
45 onPointAdded: console.log("splineSeries.onPointAdded: " + series.at(index).x + ", " + series.at(index).y);
46 onColorChanged: console.log("splineSeries.onColorChanged: " + color);
46 onColorChanged: console.log("splineSeries.onColorChanged: " + color);
47 onCountChanged: console.log("splineSeries.onCountChanged: " + count);
47 onCountChanged: console.log("splineSeries.onCountChanged: " + count);
48 }
48 }
49
49
50 SplineSeries {
50 SplineSeries {
51 name: "spline 2"
51 name: "spline 2"
52 XyPoint { x: 1.1; y: 1.1 }
52 XYPoint { x: 1.1; y: 1.1 }
53 XyPoint { x: 1.9; y: 2.3 }
53 XYPoint { x: 1.9; y: 2.3 }
54 XyPoint { x: 2.1; y: 1.1 }
54 XYPoint { x: 2.1; y: 1.1 }
55 XyPoint { x: 2.9; y: 3.9 }
55 XYPoint { x: 2.9; y: 3.9 }
56 XyPoint { x: 3.4; y: 2.0 }
56 XYPoint { x: 3.4; y: 2.0 }
57 XyPoint { x: 4.1; y: 2.3 }
57 XYPoint { x: 4.1; y: 2.3 }
58 onClicked: console.log(name + ".onClicked: " + point.x + ", " + point.y);
58 onClicked: console.log(name + ".onClicked: " + point.x + ", " + point.y);
59 }
59 }
60 }
60 }
General Comments 0
You need to be logged in to leave comments. Login now