@@ -1,112 +1,117 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2012 Digia Plc |
|
3 | ** Copyright (C) 2012 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
8 | ** |
|
8 | ** | |
9 | ** $QT_BEGIN_LICENSE$ |
|
9 | ** $QT_BEGIN_LICENSE$ | |
10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and Digia. |
|
13 | ** a written agreement between you and Digia. | |
14 | ** |
|
14 | ** | |
15 | ** If you have questions regarding the use of this file, please use |
|
15 | ** If you have questions regarding the use of this file, please use | |
16 | ** contact form at http://qt.digia.com |
|
16 | ** contact form at http://qt.digia.com | |
17 | ** $QT_END_LICENSE$ |
|
17 | ** $QT_END_LICENSE$ | |
18 | ** |
|
18 | ** | |
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 | import QtQuick 1.0 |
|
21 | import QtQuick 1.0 | |
22 | import QtCommercial.Chart 1.1 |
|
22 | import QtCommercial.Chart 1.1 | |
23 |
|
23 | |||
24 | 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 |
|
31 | |||
32 | CategoryAxis { |
|
32 | CategoryAxis { | |
33 | id: categoriesAxis |
|
33 | id: categoriesAxis | |
34 | startValue: -0.5 |
|
34 | startValue: -0.5 | |
35 | CategoryRange { endValue: 0.5; label: "2000" } |
|
35 | CategoryRange { endValue: 0.5; label: "2000" } | |
36 | CategoryRange { endValue: 1.5; label: "2001" } |
|
36 | CategoryRange { endValue: 1.5; label: "2001" } | |
37 | CategoryRange { endValue: 2.5; label: "2002" } |
|
37 | CategoryRange { endValue: 2.5; label: "2002" } | |
38 | CategoryRange { endValue: 3.5; label: "2003" } |
|
38 | CategoryRange { endValue: 3.5; label: "2003" } | |
39 | CategoryRange { endValue: 4.5; label: "2004" } |
|
39 | CategoryRange { endValue: 4.5; label: "2004" } | |
40 | CategoryRange { endValue: 5.5; label: "2005" } |
|
40 | CategoryRange { endValue: 5.5; label: "2005" } | |
41 | CategoryRange { endValue: 6.5; label: "2006" } |
|
41 | CategoryRange { endValue: 6.5; label: "2006" } | |
42 | CategoryRange { endValue: 7.5; label: "2007" } |
|
42 | CategoryRange { endValue: 7.5; label: "2007" } | |
43 | CategoryRange { endValue: 8.5; label: "2008" } |
|
43 | CategoryRange { endValue: 8.5; label: "2008" } | |
44 | CategoryRange { endValue: 9.5; label: "2009" } |
|
44 | CategoryRange { endValue: 9.5; label: "2009" } | |
45 | CategoryRange { endValue: 10.5; label: "2010" } |
|
45 | CategoryRange { endValue: 10.5; label: "2010" } | |
46 | CategoryRange { endValue: 11.5; label: "2011" } |
|
46 | CategoryRange { endValue: 11.5; label: "2011" } | |
47 | } |
|
47 | } | |
48 |
|
48 | |||
49 | AreaSeries { |
|
49 | AreaSeries { | |
50 | name: "Russian" |
|
50 | name: "Russian" | |
|
51 | color: "#FFD52B1E" | |||
|
52 | borderColor: "#FF0039A5" | |||
|
53 | borderWidth: 3 | |||
51 | axisX: categoriesAxis |
|
54 | axisX: categoriesAxis | |
52 | upperSeries: LineSeries { |
|
55 | upperSeries: LineSeries { | |
53 | XYPoint { x: 0; y: 1 } |
|
56 | XYPoint { x: 0; y: 1 } | |
54 | XYPoint { x: 1; y: 1 } |
|
57 | XYPoint { x: 1; y: 1 } | |
55 | XYPoint { x: 2; y: 1 } |
|
58 | XYPoint { x: 2; y: 1 } | |
56 | XYPoint { x: 3; y: 1 } |
|
59 | XYPoint { x: 3; y: 1 } | |
57 | XYPoint { x: 4; y: 1 } |
|
60 | XYPoint { x: 4; y: 1 } | |
58 | XYPoint { x: 5; y: 0 } |
|
61 | XYPoint { x: 5; y: 0 } | |
59 | XYPoint { x: 6; y: 1 } |
|
62 | XYPoint { x: 6; y: 1 } | |
60 | XYPoint { x: 7; y: 1 } |
|
63 | XYPoint { x: 7; y: 1 } | |
61 | XYPoint { x: 8; y: 4 } |
|
64 | XYPoint { x: 8; y: 4 } | |
62 | XYPoint { x: 9; y: 3 } |
|
65 | XYPoint { x: 9; y: 3 } | |
63 | XYPoint { x: 10; y: 2 } |
|
66 | XYPoint { x: 10; y: 2 } | |
64 | XYPoint { x: 11; y: 1 } |
|
67 | XYPoint { x: 11; y: 1 } | |
65 | } |
|
68 | } | |
66 | } |
|
69 | } | |
67 | // ... |
|
70 | // ... | |
68 | //![1] |
|
71 | //![1] | |
69 |
|
72 | |||
70 | AreaSeries { |
|
73 | AreaSeries { | |
71 | name: "Swedish" |
|
74 | name: "Swedish" | |
|
75 | color: "#AF005292" | |||
|
76 | borderColor: "#AFFDCA00" | |||
|
77 | borderWidth: 3 | |||
72 | axisX: categoriesAxis |
|
78 | axisX: categoriesAxis | |
73 | upperSeries: LineSeries { |
|
79 | upperSeries: LineSeries { | |
74 | XYPoint { x: 0; y: 1 } |
|
80 | XYPoint { x: 0; y: 1 } | |
75 | XYPoint { x: 1; y: 1 } |
|
81 | XYPoint { x: 1; y: 1 } | |
76 | XYPoint { x: 2; y: 3 } |
|
82 | XYPoint { x: 2; y: 3 } | |
77 | XYPoint { x: 3; y: 3 } |
|
83 | XYPoint { x: 3; y: 3 } | |
78 | XYPoint { x: 4; y: 2 } |
|
84 | XYPoint { x: 4; y: 2 } | |
79 | XYPoint { x: 5; y: 0 } |
|
85 | XYPoint { x: 5; y: 0 } | |
80 | XYPoint { x: 6; y: 2 } |
|
86 | XYPoint { x: 6; y: 2 } | |
81 | XYPoint { x: 7; y: 1 } |
|
87 | XYPoint { x: 7; y: 1 } | |
82 | XYPoint { x: 8; y: 2 } |
|
88 | XYPoint { x: 8; y: 2 } | |
83 | XYPoint { x: 9; y: 1 } |
|
89 | XYPoint { x: 9; y: 1 } | |
84 | XYPoint { x: 10; y: 3 } |
|
90 | XYPoint { x: 10; y: 3 } | |
85 | XYPoint { x: 11; y: 3 } |
|
91 | XYPoint { x: 11; y: 3 } | |
86 | } |
|
92 | } | |
87 | } |
|
93 | } | |
88 |
|
94 | |||
89 | AreaSeries { |
|
95 | AreaSeries { | |
90 | name: "Finnish" |
|
96 | name: "Finnish" | |
|
97 | color: "#00357F" | |||
|
98 | borderColor: "#FEFEFE" | |||
|
99 | borderWidth: 3 | |||
91 | axisX: categoriesAxis |
|
100 | axisX: categoriesAxis | |
92 | upperSeries: LineSeries { |
|
101 | upperSeries: LineSeries { | |
93 | XYPoint { x: 0; y: 0 } |
|
102 | XYPoint { x: 0; y: 0 } | |
94 | XYPoint { x: 1; y: 0 } |
|
103 | XYPoint { x: 1; y: 0 } | |
95 | XYPoint { x: 2; y: 0 } |
|
104 | XYPoint { x: 2; y: 0 } | |
96 | XYPoint { x: 3; y: 0 } |
|
105 | XYPoint { x: 3; y: 0 } | |
97 | XYPoint { x: 4; y: 0 } |
|
106 | XYPoint { x: 4; y: 0 } | |
98 | XYPoint { x: 5; y: 0 } |
|
107 | XYPoint { x: 5; y: 0 } | |
99 | XYPoint { x: 6; y: 1 } |
|
108 | XYPoint { x: 6; y: 1 } | |
100 | XYPoint { x: 7; y: 0 } |
|
109 | XYPoint { x: 7; y: 0 } | |
101 | XYPoint { x: 8; y: 0 } |
|
110 | XYPoint { x: 8; y: 0 } | |
102 | XYPoint { x: 9; y: 0 } |
|
111 | XYPoint { x: 9; y: 0 } | |
103 | XYPoint { x: 10; y: 0 } |
|
112 | XYPoint { x: 10; y: 0 } | |
104 | XYPoint { x: 11; y: 1 } |
|
113 | XYPoint { x: 11; y: 1 } | |
105 | } |
|
114 | } | |
106 | onClicked: { |
|
|||
107 | color = "white"; |
|
|||
108 | borderColor = "blue"; |
|
|||
109 | } |
|
|||
110 | } |
|
115 | } | |
111 | } |
|
116 | } | |
112 | } |
|
117 | } |
@@ -1,401 +1,403 | |||||
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 "qareaseries.h" |
|
21 | #include "qareaseries.h" | |
22 | #include "qareaseries_p.h" |
|
22 | #include "qareaseries_p.h" | |
23 | #include "qlineseries.h" |
|
23 | #include "qlineseries.h" | |
24 | #include "areachartitem_p.h" |
|
24 | #include "areachartitem_p.h" | |
25 | #include "legendmarker_p.h" |
|
25 | #include "legendmarker_p.h" | |
26 | #include "domain_p.h" |
|
26 | #include "domain_p.h" | |
27 | #include "chartdataset_p.h" |
|
27 | #include "chartdataset_p.h" | |
28 | #include "charttheme_p.h" |
|
28 | #include "charttheme_p.h" | |
29 | #include "qvalueaxis.h" |
|
29 | #include "qvalueaxis.h" | |
30 |
|
30 | |||
31 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
31 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
32 |
|
32 | |||
33 | /*! |
|
33 | /*! | |
34 | \class QAreaSeries |
|
34 | \class QAreaSeries | |
35 | \brief The QAreaSeries class is used for making area charts. |
|
35 | \brief The QAreaSeries class is used for making area charts. | |
36 |
|
36 | |||
37 | \mainclass |
|
37 | \mainclass | |
38 |
|
38 | |||
39 | An area chart is used to show quantitative data. It is based on line chart, in the way that area between axis and the line |
|
39 | An area chart is used to show quantitative data. It is based on line chart, in the way that area between axis and the line | |
40 | is emphasized with color. Since the area chart is based on line chart, QAreaSeries constructor needs QLineSeries instance, |
|
40 | is emphasized with color. Since the area chart is based on line chart, QAreaSeries constructor needs QLineSeries instance, | |
41 | which defines "upper" boundary of the area. "Lower" boundary is defined by default by axis X. Instead of axis X "lower" boundary can be specified by other line. |
|
41 | which defines "upper" boundary of the area. "Lower" boundary is defined by default by axis X. Instead of axis X "lower" boundary can be specified by other line. | |
42 | In that case QAreaSeries should be initiated with two QLineSeries instances. Please note terms "upper" and "lower" boundary can be misleading in cases |
|
42 | In that case QAreaSeries should be initiated with two QLineSeries instances. Please note terms "upper" and "lower" boundary can be misleading in cases | |
43 | where "lower" boundary had bigger values than the "upper" one, however the main point that area between these two boundary lines will be filled. |
|
43 | where "lower" boundary had bigger values than the "upper" one, however the main point that area between these two boundary lines will be filled. | |
44 |
|
44 | |||
45 | See the \l {AreaChart Example} {area chart example} to learn how to create a simple area chart. |
|
45 | See the \l {AreaChart Example} {area chart example} to learn how to create a simple area chart. | |
46 | \image examples_areachart.png |
|
46 | \image examples_areachart.png | |
47 | */ |
|
47 | */ | |
48 | /*! |
|
48 | /*! | |
49 | \qmlclass AreaSeries QAreaSeries |
|
49 | \qmlclass AreaSeries QAreaSeries | |
50 |
|
50 | |||
51 | The following QML shows how to create a simple area chart: |
|
51 | The following QML shows how to create a simple area chart: | |
52 | \snippet ../demos/qmlchart/qml/qmlchart/View4.qml 1 |
|
52 | \snippet ../demos/qmlchart/qml/qmlchart/View4.qml 1 | |
53 | \beginfloatleft |
|
53 | \beginfloatleft | |
54 | \image demos_qmlchart4.png |
|
54 | \image demos_qmlchart4.png | |
55 | \endfloat |
|
55 | \endfloat | |
56 | \clearfloat |
|
56 | \clearfloat | |
57 | */ |
|
57 | */ | |
58 |
|
58 | |||
59 | /*! |
|
59 | /*! | |
60 | \property QAreaSeries::upperSeries |
|
60 | \property QAreaSeries::upperSeries | |
61 | \brief The upper one of the two line series used to define area series boundaries. |
|
61 | \brief The upper one of the two line series used to define area series boundaries. | |
62 | */ |
|
62 | */ | |
63 | /*! |
|
63 | /*! | |
64 | \qmlproperty LineSeries AreaSeries::upperSeries |
|
64 | \qmlproperty LineSeries AreaSeries::upperSeries | |
65 | The upper one of the two line series used to define area series boundaries. |
|
65 | The upper one of the two line series used to define area series boundaries. | |
66 | */ |
|
66 | */ | |
67 |
|
67 | |||
68 | /*! |
|
68 | /*! | |
69 | \property QAreaSeries::lowerSeries |
|
69 | \property QAreaSeries::lowerSeries | |
70 | The lower one of the two line series used to define are series boundaries. Note if |
|
70 | The lower one of the two line series used to define are series boundaries. Note if | |
71 | QAreaSeries was counstucted wihtout a\ lowerSeries this is null. |
|
71 | QAreaSeries was counstucted wihtout a\ lowerSeries this is null. | |
72 | */ |
|
72 | */ | |
73 | /*! |
|
73 | /*! | |
74 | \qmlproperty LineSeries AreaSeries::lowerSeries |
|
74 | \qmlproperty LineSeries AreaSeries::lowerSeries | |
75 | The lower one of the two line series used to define are series boundaries. Note if |
|
75 | The lower one of the two line series used to define are series boundaries. Note if | |
76 | AreaSeries was counstucted wihtout a\ lowerSeries this is null. |
|
76 | AreaSeries was counstucted wihtout a\ lowerSeries this is null. | |
77 | */ |
|
77 | */ | |
78 |
|
78 | |||
79 | /*! |
|
79 | /*! | |
80 | \property QAreaSeries::color |
|
80 | \property QAreaSeries::color | |
81 | Fill (brush) color of the series. This is a convenience property for modifying the color of brush. |
|
81 | Fill (brush) color of the series. This is a convenience property for modifying the color of brush. | |
82 | \sa QAreaSeries::brush() |
|
82 | \sa QAreaSeries::brush() | |
83 | */ |
|
83 | */ | |
84 | /*! |
|
84 | /*! | |
85 | \qmlproperty color AreaSeries::color |
|
85 | \qmlproperty color AreaSeries::color | |
86 | Fill (brush) color of the series. |
|
86 | Fill (brush) color of the series. | |
87 | */ |
|
87 | */ | |
88 |
|
88 | |||
89 | /*! |
|
89 | /*! | |
90 | \property QAreaSeries::borderColor |
|
90 | \property QAreaSeries::borderColor | |
91 | Line (pen) color of the series. This is a convenience property for modifying the color of pen. |
|
91 | Line (pen) color of the series. This is a convenience property for modifying the color of pen. | |
92 | \sa QAreaSeries::pen() |
|
92 | \sa QAreaSeries::pen() | |
93 | */ |
|
93 | */ | |
94 | /*! |
|
94 | /*! | |
95 | \qmlproperty color AreaSeries::borderColor |
|
95 | \qmlproperty color AreaSeries::borderColor | |
96 | Line (pen) color of the series. |
|
96 | Line (pen) color of the series. | |
97 | */ |
|
97 | */ | |
98 |
|
98 | |||
99 | /*! |
|
99 | /*! | |
100 | \qmlproperty real AreaSeries::borderWidth |
|
100 | \qmlproperty real AreaSeries::borderWidth | |
101 | The width of the border line. By default the width is 2.0. |
|
101 | The width of the border line. By default the width is 2.0. | |
102 | */ |
|
102 | */ | |
103 |
|
103 | |||
104 | /*! |
|
104 | /*! | |
105 | \fn QPen QAreaSeries::pen() const |
|
105 | \fn QPen QAreaSeries::pen() const | |
106 | \brief Returns the pen used to draw line for this series. |
|
106 | \brief Returns the pen used to draw line for this series. | |
107 | \sa setPen() |
|
107 | \sa setPen() | |
108 | */ |
|
108 | */ | |
109 |
|
109 | |||
110 | /*! |
|
110 | /*! | |
111 | \fn QPen QAreaSeries::brush() const |
|
111 | \fn QPen QAreaSeries::brush() const | |
112 | \brief Returns the brush used to draw line for this series. |
|
112 | \brief Returns the brush used to draw line for this series. | |
113 | \sa setBrush() |
|
113 | \sa setBrush() | |
114 | */ |
|
114 | */ | |
115 |
|
115 | |||
116 | /*! |
|
116 | /*! | |
117 | \fn void QAreaSeries::colorChanged(QColor color) |
|
117 | \fn void QAreaSeries::colorChanged(QColor color) | |
118 | \brief Signal is emitted when the fill (brush) color has changed to \a color. |
|
118 | \brief Signal is emitted when the fill (brush) color has changed to \a color. | |
119 | */ |
|
119 | */ | |
120 | /*! |
|
120 | /*! | |
121 | \qmlsignal AreaSeries::onColorChanged(color color) |
|
121 | \qmlsignal AreaSeries::onColorChanged(color color) | |
122 | Signal is emitted when the fill (brush) color has changed to \a color. |
|
122 | Signal is emitted when the fill (brush) color has changed to \a color. | |
123 | */ |
|
123 | */ | |
124 |
|
124 | |||
125 | /*! |
|
125 | /*! | |
126 | \fn void QAreaSeries::borderColorChanged(QColor color) |
|
126 | \fn void QAreaSeries::borderColorChanged(QColor color) | |
127 | \brief Signal is emitted when the line (pen) color has changed to \a color. |
|
127 | \brief Signal is emitted when the line (pen) color has changed to \a color. | |
128 | */ |
|
128 | */ | |
129 | /*! |
|
129 | /*! | |
130 | \qmlsignal AreaSeries::onBorderColorChanged(color color) |
|
130 | \qmlsignal AreaSeries::onBorderColorChanged(color color) | |
131 | Signal is emitted when the line (pen) color has changed to \a color. |
|
131 | Signal is emitted when the line (pen) color has changed to \a color. | |
132 | */ |
|
132 | */ | |
133 |
|
133 | |||
134 | /*! |
|
134 | /*! | |
135 | \fn void QAreaSeries::clicked(const QPointF& point) |
|
135 | \fn void QAreaSeries::clicked(const QPointF& point) | |
136 | \brief Signal is emitted when user clicks the \a point on area chart. |
|
136 | \brief Signal is emitted when user clicks the \a point on area chart. | |
137 | */ |
|
137 | */ | |
138 | /*! |
|
138 | /*! | |
139 | \qmlsignal AreaSeries::onClicked(QPointF point) |
|
139 | \qmlsignal AreaSeries::onClicked(QPointF point) | |
140 | Signal is emitted when user clicks the \a point on area chart. |
|
140 | Signal is emitted when user clicks the \a point on area chart. | |
141 | */ |
|
141 | */ | |
142 |
|
142 | |||
143 | /*! |
|
143 | /*! | |
144 | \fn void QAreaSeries::selected() |
|
144 | \fn void QAreaSeries::selected() | |
145 | The signal is emitted if the user selects/deselects the XY series. The logic for maintaining selections should be |
|
145 | The signal is emitted if the user selects/deselects the XY series. The logic for maintaining selections should be | |
146 | implemented by the user of QAreaSeries API. |
|
146 | implemented by the user of QAreaSeries API. | |
147 | */ |
|
147 | */ | |
148 | /*! |
|
148 | /*! | |
149 | \qmlsignal AreaSeries::onSelected() |
|
149 | \qmlsignal AreaSeries::onSelected() | |
150 | The signal is emitted if the user selects/deselects the XY series. The logic for maintaining selections should be |
|
150 | The signal is emitted if the user selects/deselects the XY series. The logic for maintaining selections should be | |
151 | implemented by the user of AreaSeries API. |
|
151 | implemented by the user of AreaSeries API. | |
152 | */ |
|
152 | */ | |
153 |
|
153 | |||
154 | /*! |
|
154 | /*! | |
155 | \fn void QAreaSeriesPrivate::updated() |
|
155 | \fn void QAreaSeriesPrivate::updated() | |
156 | \brief \internal |
|
156 | \brief \internal | |
157 | */ |
|
157 | */ | |
158 |
|
158 | |||
159 | /*! |
|
159 | /*! | |
160 | Constructs area series object which is a child of \a upperSeries. Area will be spanned between \a |
|
160 | Constructs area series object which is a child of \a upperSeries. Area will be spanned between \a | |
161 | upperSeries line and \a lowerSeries line. If no \a lowerSeries is passed to constructor, area is specified by axis x (y=0) instead. |
|
161 | upperSeries line and \a lowerSeries line. If no \a lowerSeries is passed to constructor, area is specified by axis x (y=0) instead. | |
162 | When series object is added to QChartView or QChart instance ownerships is transferred. |
|
162 | When series object is added to QChartView or QChart instance ownerships is transferred. | |
163 | */ |
|
163 | */ | |
164 | QAreaSeries::QAreaSeries(QLineSeries *upperSeries, QLineSeries *lowerSeries) |
|
164 | QAreaSeries::QAreaSeries(QLineSeries *upperSeries, QLineSeries *lowerSeries) | |
165 | : QAbstractSeries(*new QAreaSeriesPrivate(upperSeries,lowerSeries,this),upperSeries) |
|
165 | : QAbstractSeries(*new QAreaSeriesPrivate(upperSeries,lowerSeries,this),upperSeries) | |
166 | { |
|
166 | { | |
167 | } |
|
167 | } | |
168 |
|
168 | |||
169 | /*! |
|
169 | /*! | |
170 | Constructs area series object without upper or lower series with \a parent object. |
|
170 | Constructs area series object without upper or lower series with \a parent object. | |
171 | */ |
|
171 | */ | |
172 | QAreaSeries::QAreaSeries(QObject *parent) |
|
172 | QAreaSeries::QAreaSeries(QObject *parent) | |
173 | : QAbstractSeries(*new QAreaSeriesPrivate(0, 0, this), parent) |
|
173 | : QAbstractSeries(*new QAreaSeriesPrivate(0, 0, this), parent) | |
174 | { |
|
174 | { | |
175 | } |
|
175 | } | |
176 |
|
176 | |||
177 | /*! |
|
177 | /*! | |
178 | Destroys the object. |
|
178 | Destroys the object. | |
179 | */ |
|
179 | */ | |
180 | QAreaSeries::~QAreaSeries() |
|
180 | QAreaSeries::~QAreaSeries() | |
181 | { |
|
181 | { | |
182 | Q_D(QAreaSeries); |
|
182 | Q_D(QAreaSeries); | |
183 | if(d->m_dataset){ |
|
183 | if(d->m_dataset){ | |
184 | d->m_dataset->removeSeries(this); |
|
184 | d->m_dataset->removeSeries(this); | |
185 | } |
|
185 | } | |
186 | } |
|
186 | } | |
187 |
|
187 | |||
188 | /*! |
|
188 | /*! | |
189 | Returns QChartSeries::SeriesTypeArea. |
|
189 | Returns QChartSeries::SeriesTypeArea. | |
190 | */ |
|
190 | */ | |
191 | QAbstractSeries::SeriesType QAreaSeries::type() const |
|
191 | QAbstractSeries::SeriesType QAreaSeries::type() const | |
192 | { |
|
192 | { | |
193 | return QAbstractSeries::SeriesTypeArea; |
|
193 | return QAbstractSeries::SeriesTypeArea; | |
194 | } |
|
194 | } | |
195 |
|
195 | |||
196 | /*! |
|
196 | /*! | |
197 | Sets the \a series that is to be used as the area chart upper series. |
|
197 | Sets the \a series that is to be used as the area chart upper series. | |
198 | */ |
|
198 | */ | |
199 | void QAreaSeries::setUpperSeries(QLineSeries* series) |
|
199 | void QAreaSeries::setUpperSeries(QLineSeries* series) | |
200 | { |
|
200 | { | |
201 | Q_D(QAreaSeries); |
|
201 | Q_D(QAreaSeries); | |
202 | d->m_upperSeries = series; |
|
202 | d->m_upperSeries = series; | |
203 | } |
|
203 | } | |
204 |
|
204 | |||
205 | QLineSeries* QAreaSeries::upperSeries() const |
|
205 | QLineSeries* QAreaSeries::upperSeries() const | |
206 | { |
|
206 | { | |
207 | Q_D(const QAreaSeries); |
|
207 | Q_D(const QAreaSeries); | |
208 | return d->m_upperSeries; |
|
208 | return d->m_upperSeries; | |
209 | } |
|
209 | } | |
210 |
|
210 | |||
211 | /*! |
|
211 | /*! | |
212 | Sets the \a series that is to be used as the area chart lower series. |
|
212 | Sets the \a series that is to be used as the area chart lower series. | |
213 | */ |
|
213 | */ | |
214 | void QAreaSeries::setLowerSeries(QLineSeries* series) |
|
214 | void QAreaSeries::setLowerSeries(QLineSeries* series) | |
215 | { |
|
215 | { | |
216 | Q_D(QAreaSeries); |
|
216 | Q_D(QAreaSeries); | |
217 | d->m_lowerSeries = series; |
|
217 | d->m_lowerSeries = series; | |
218 | } |
|
218 | } | |
219 |
|
219 | |||
220 | QLineSeries* QAreaSeries::lowerSeries() const |
|
220 | QLineSeries* QAreaSeries::lowerSeries() const | |
221 | { |
|
221 | { | |
222 | Q_D(const QAreaSeries); |
|
222 | Q_D(const QAreaSeries); | |
223 | return d->m_lowerSeries; |
|
223 | return d->m_lowerSeries; | |
224 | } |
|
224 | } | |
225 |
|
225 | |||
226 | /*! |
|
226 | /*! | |
227 | Sets \a pen used for drawing area outline. |
|
227 | Sets \a pen used for drawing area outline. | |
228 | */ |
|
228 | */ | |
229 | void QAreaSeries::setPen(const QPen &pen) |
|
229 | void QAreaSeries::setPen(const QPen &pen) | |
230 | { |
|
230 | { | |
231 | Q_D(QAreaSeries); |
|
231 | Q_D(QAreaSeries); | |
232 | if (d->m_pen != pen) { |
|
232 | if (d->m_pen != pen) { | |
233 | d->m_pen = pen; |
|
233 | d->m_pen = pen; | |
234 | emit d->updated(); |
|
234 | emit d->updated(); | |
235 | } |
|
235 | } | |
236 | } |
|
236 | } | |
237 |
|
237 | |||
238 | QPen QAreaSeries::pen() const |
|
238 | QPen QAreaSeries::pen() const | |
239 | { |
|
239 | { | |
240 | Q_D(const QAreaSeries); |
|
240 | Q_D(const QAreaSeries); | |
241 | return d->m_pen; |
|
241 | return d->m_pen; | |
242 | } |
|
242 | } | |
243 |
|
243 | |||
244 | /*! |
|
244 | /*! | |
245 | Sets \a brush used for filling the area. |
|
245 | Sets \a brush used for filling the area. | |
246 | */ |
|
246 | */ | |
247 | void QAreaSeries::setBrush(const QBrush &brush) |
|
247 | void QAreaSeries::setBrush(const QBrush &brush) | |
248 | { |
|
248 | { | |
249 | Q_D(QAreaSeries); |
|
249 | Q_D(QAreaSeries); | |
250 | if (d->m_brush != brush) { |
|
250 | if (d->m_brush != brush) { | |
|
251 | bool emitColorChanged = brush.color() != d->m_brush.color(); | |||
251 | d->m_brush = brush; |
|
252 | d->m_brush = brush; | |
252 | emit d->updated(); |
|
253 | emit d->updated(); | |
|
254 | if (emitColorChanged) | |||
|
255 | emit colorChanged(brush.color()); | |||
253 | } |
|
256 | } | |
254 | } |
|
257 | } | |
255 |
|
258 | |||
256 | QBrush QAreaSeries::brush() const |
|
259 | QBrush QAreaSeries::brush() const | |
257 | { |
|
260 | { | |
258 | Q_D(const QAreaSeries); |
|
261 | Q_D(const QAreaSeries); | |
259 | return d->m_brush; |
|
262 | return d->m_brush; | |
260 | } |
|
263 | } | |
261 |
|
264 | |||
262 | void QAreaSeries::setColor(const QColor &color) |
|
265 | void QAreaSeries::setColor(const QColor &color) | |
263 | { |
|
266 | { | |
264 | QBrush b = brush(); |
|
267 | QBrush b = brush(); | |
265 | if (b.color() != color) { |
|
268 | if (b == QBrush()) | |
266 | b.setColor(color); |
|
269 | b.setStyle(Qt::SolidPattern); | |
267 | setBrush(b); |
|
270 | b.setColor(color); | |
268 | emit colorChanged(color); |
|
271 | setBrush(b); | |
269 | } |
|
|||
270 | } |
|
272 | } | |
271 |
|
273 | |||
272 | QColor QAreaSeries::color() const |
|
274 | QColor QAreaSeries::color() const | |
273 | { |
|
275 | { | |
274 | return brush().color(); |
|
276 | return brush().color(); | |
275 | } |
|
277 | } | |
276 |
|
278 | |||
277 | void QAreaSeries::setBorderColor(const QColor &color) |
|
279 | void QAreaSeries::setBorderColor(const QColor &color) | |
278 | { |
|
280 | { | |
279 | QPen p = pen(); |
|
281 | QPen p = pen(); | |
280 | if (p.color() != color) { |
|
282 | if (p.color() != color) { | |
281 | p.setColor(color); |
|
283 | p.setColor(color); | |
282 | setPen(p); |
|
284 | setPen(p); | |
283 | emit borderColorChanged(color); |
|
285 | emit borderColorChanged(color); | |
284 | } |
|
286 | } | |
285 | } |
|
287 | } | |
286 |
|
288 | |||
287 | QColor QAreaSeries::borderColor() const |
|
289 | QColor QAreaSeries::borderColor() const | |
288 | { |
|
290 | { | |
289 | return pen().color(); |
|
291 | return pen().color(); | |
290 | } |
|
292 | } | |
291 |
|
293 | |||
292 | /*! |
|
294 | /*! | |
293 | Sets if data points are \a visible and should be drawn on line. |
|
295 | Sets if data points are \a visible and should be drawn on line. | |
294 | */ |
|
296 | */ | |
295 | void QAreaSeries::setPointsVisible(bool visible) |
|
297 | void QAreaSeries::setPointsVisible(bool visible) | |
296 | { |
|
298 | { | |
297 | Q_D(QAreaSeries); |
|
299 | Q_D(QAreaSeries); | |
298 | if (d->m_pointsVisible != visible) { |
|
300 | if (d->m_pointsVisible != visible) { | |
299 | d->m_pointsVisible = visible; |
|
301 | d->m_pointsVisible = visible; | |
300 | emit d->updated(); |
|
302 | emit d->updated(); | |
301 | } |
|
303 | } | |
302 | } |
|
304 | } | |
303 |
|
305 | |||
304 | /*! |
|
306 | /*! | |
305 | Returns if the points are drawn for this series. |
|
307 | Returns if the points are drawn for this series. | |
306 | \sa setPointsVisible() |
|
308 | \sa setPointsVisible() | |
307 | */ |
|
309 | */ | |
308 | bool QAreaSeries::pointsVisible() const |
|
310 | bool QAreaSeries::pointsVisible() const | |
309 | { |
|
311 | { | |
310 | Q_D(const QAreaSeries); |
|
312 | Q_D(const QAreaSeries); | |
311 | return d->m_pointsVisible; |
|
313 | return d->m_pointsVisible; | |
312 | } |
|
314 | } | |
313 |
|
315 | |||
314 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
|
316 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |
315 |
|
317 | |||
316 | QAreaSeriesPrivate::QAreaSeriesPrivate(QLineSeries *upperSeries, QLineSeries *lowerSeries,QAreaSeries* q) : |
|
318 | QAreaSeriesPrivate::QAreaSeriesPrivate(QLineSeries *upperSeries, QLineSeries *lowerSeries,QAreaSeries* q) : | |
317 | QAbstractSeriesPrivate(q), |
|
319 | QAbstractSeriesPrivate(q), | |
318 | m_upperSeries(upperSeries), |
|
320 | m_upperSeries(upperSeries), | |
319 | m_lowerSeries(lowerSeries), |
|
321 | m_lowerSeries(lowerSeries), | |
320 | m_pointsVisible(false) |
|
322 | m_pointsVisible(false) | |
321 | { |
|
323 | { | |
322 | } |
|
324 | } | |
323 |
|
325 | |||
324 | void QAreaSeriesPrivate::scaleDomain(Domain& domain) |
|
326 | void QAreaSeriesPrivate::scaleDomain(Domain& domain) | |
325 | { |
|
327 | { | |
326 | Q_Q(QAreaSeries); |
|
328 | Q_Q(QAreaSeries); | |
327 |
|
329 | |||
328 | qreal minX(domain.minX()); |
|
330 | qreal minX(domain.minX()); | |
329 | qreal minY(domain.minY()); |
|
331 | qreal minY(domain.minY()); | |
330 | qreal maxX(domain.maxX()); |
|
332 | qreal maxX(domain.maxX()); | |
331 | qreal maxY(domain.maxY()); |
|
333 | qreal maxY(domain.maxY()); | |
332 |
|
334 | |||
333 | QLineSeries* upperSeries = q->upperSeries(); |
|
335 | QLineSeries* upperSeries = q->upperSeries(); | |
334 | QLineSeries* lowerSeries = q->lowerSeries(); |
|
336 | QLineSeries* lowerSeries = q->lowerSeries(); | |
335 |
|
337 | |||
336 | const QList<QPointF>& points = upperSeries->points(); |
|
338 | const QList<QPointF>& points = upperSeries->points(); | |
337 |
|
339 | |||
338 | for (int i = 0; i < points.count(); i++) |
|
340 | for (int i = 0; i < points.count(); i++) | |
339 | { |
|
341 | { | |
340 | qreal x = points[i].x(); |
|
342 | qreal x = points[i].x(); | |
341 | qreal y = points[i].y(); |
|
343 | qreal y = points[i].y(); | |
342 | minX = qMin(minX, x); |
|
344 | minX = qMin(minX, x); | |
343 | minY = qMin(minY, y); |
|
345 | minY = qMin(minY, y); | |
344 | maxX = qMax(maxX, x); |
|
346 | maxX = qMax(maxX, x); | |
345 | maxY = qMax(maxY, y); |
|
347 | maxY = qMax(maxY, y); | |
346 | } |
|
348 | } | |
347 | if(lowerSeries) { |
|
349 | if(lowerSeries) { | |
348 |
|
350 | |||
349 | const QList<QPointF>& points = lowerSeries->points(); |
|
351 | const QList<QPointF>& points = lowerSeries->points(); | |
350 |
|
352 | |||
351 | for (int i = 0; i < points.count(); i++) |
|
353 | for (int i = 0; i < points.count(); i++) | |
352 | { |
|
354 | { | |
353 | qreal x = points[i].x(); |
|
355 | qreal x = points[i].x(); | |
354 | qreal y = points[i].y(); |
|
356 | qreal y = points[i].y(); | |
355 | minX = qMin(minX, x); |
|
357 | minX = qMin(minX, x); | |
356 | minY = qMin(minY, y); |
|
358 | minY = qMin(minY, y); | |
357 | maxX = qMax(maxX, x); |
|
359 | maxX = qMax(maxX, x); | |
358 | maxY = qMax(maxY, y); |
|
360 | maxY = qMax(maxY, y); | |
359 | }} |
|
361 | }} | |
360 |
|
362 | |||
361 | domain.setRange(minX,maxX,minY,maxY); |
|
363 | domain.setRange(minX,maxX,minY,maxY); | |
362 | } |
|
364 | } | |
363 |
|
365 | |||
364 | ChartElement* QAreaSeriesPrivate::createGraphics(ChartPresenter* presenter) |
|
366 | ChartElement* QAreaSeriesPrivate::createGraphics(ChartPresenter* presenter) | |
365 | { |
|
367 | { | |
366 | Q_Q(QAreaSeries); |
|
368 | Q_Q(QAreaSeries); | |
367 |
|
369 | |||
368 | AreaChartItem* area = new AreaChartItem(q,presenter); |
|
370 | AreaChartItem* area = new AreaChartItem(q,presenter); | |
369 | if(presenter->animationOptions().testFlag(QChart::SeriesAnimations)) { |
|
371 | if(presenter->animationOptions().testFlag(QChart::SeriesAnimations)) { | |
370 | area->upperLineItem()->setAnimation(new XYAnimation(area->upperLineItem())); |
|
372 | area->upperLineItem()->setAnimation(new XYAnimation(area->upperLineItem())); | |
371 | if(q->lowerSeries()) { |
|
373 | if(q->lowerSeries()) { | |
372 | area->lowerLineItem()->setAnimation(new XYAnimation(area->lowerLineItem())); |
|
374 | area->lowerLineItem()->setAnimation(new XYAnimation(area->lowerLineItem())); | |
373 | } |
|
375 | } | |
374 | } |
|
376 | } | |
375 | presenter->chartTheme()->decorate(q, presenter->dataSet()->seriesIndex(q)); |
|
377 | presenter->chartTheme()->decorate(q, presenter->dataSet()->seriesIndex(q)); | |
376 | return area; |
|
378 | return area; | |
377 | } |
|
379 | } | |
378 |
|
380 | |||
379 | QList<LegendMarker*> QAreaSeriesPrivate::createLegendMarker(QLegend* legend) |
|
381 | QList<LegendMarker*> QAreaSeriesPrivate::createLegendMarker(QLegend* legend) | |
380 | { |
|
382 | { | |
381 | Q_Q(QAreaSeries); |
|
383 | Q_Q(QAreaSeries); | |
382 | QList<LegendMarker*> list; |
|
384 | QList<LegendMarker*> list; | |
383 | return list << new AreaLegendMarker(q,legend); |
|
385 | return list << new AreaLegendMarker(q,legend); | |
384 | } |
|
386 | } | |
385 |
|
387 | |||
386 |
|
388 | |||
387 | void QAreaSeriesPrivate::initializeAxis(QAbstractAxis* axis) |
|
389 | void QAreaSeriesPrivate::initializeAxis(QAbstractAxis* axis) | |
388 | { |
|
390 | { | |
389 | Q_UNUSED(axis); |
|
391 | Q_UNUSED(axis); | |
390 | } |
|
392 | } | |
391 |
|
393 | |||
392 | QAbstractAxis::AxisType QAreaSeriesPrivate::defaultAxisType(Qt::Orientation orientation) const |
|
394 | QAbstractAxis::AxisType QAreaSeriesPrivate::defaultAxisType(Qt::Orientation orientation) const | |
393 | { |
|
395 | { | |
394 | Q_UNUSED(orientation); |
|
396 | Q_UNUSED(orientation); | |
395 | return QAbstractAxis::AxisTypeValue; |
|
397 | return QAbstractAxis::AxisTypeValue; | |
396 | } |
|
398 | } | |
397 |
|
399 | |||
398 | #include "moc_qareaseries.cpp" |
|
400 | #include "moc_qareaseries.cpp" | |
399 | #include "moc_qareaseries_p.cpp" |
|
401 | #include "moc_qareaseries_p.cpp" | |
400 |
|
402 | |||
401 | QTCOMMERCIALCHART_END_NAMESPACE |
|
403 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -1,266 +1,266 | |||||
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 "qscatterseries.h" |
|
21 | #include "qscatterseries.h" | |
22 | #include "qscatterseries_p.h" |
|
22 | #include "qscatterseries_p.h" | |
23 | #include "scatterchartitem_p.h" |
|
23 | #include "scatterchartitem_p.h" | |
24 | #include "chartdataset_p.h" |
|
24 | #include "chartdataset_p.h" | |
25 | #include "charttheme_p.h" |
|
25 | #include "charttheme_p.h" | |
26 |
|
26 | |||
27 | /*! |
|
27 | /*! | |
28 | \class QScatterSeries |
|
28 | \class QScatterSeries | |
29 | \brief The QScatterSeries class is used for making scatter charts. |
|
29 | \brief The QScatterSeries class is used for making scatter charts. | |
30 |
|
30 | |||
31 | \mainclass |
|
31 | \mainclass | |
32 |
|
32 | |||
33 | The scatter data is displayed as a collection of points on the chart. Each point determines the position on the horizontal axis |
|
33 | The scatter data is displayed as a collection of points on the chart. Each point determines the position on the horizontal axis | |
34 | and the vertical axis. |
|
34 | and the vertical axis. | |
35 |
|
35 | |||
36 | \image examples_scatterchart.png |
|
36 | \image examples_scatterchart.png | |
37 |
|
37 | |||
38 | Creating basic scatter chart is simple: |
|
38 | Creating basic scatter chart is simple: | |
39 | \code |
|
39 | \code | |
40 | QScatterSeries* series = new QScatterSeries(); |
|
40 | QScatterSeries* series = new QScatterSeries(); | |
41 | series->append(0, 6); |
|
41 | series->append(0, 6); | |
42 | series->append(2, 4); |
|
42 | series->append(2, 4); | |
43 | ... |
|
43 | ... | |
44 | chart->addSeries(series); |
|
44 | chart->addSeries(series); | |
45 | \endcode |
|
45 | \endcode | |
46 | */ |
|
46 | */ | |
47 | /*! |
|
47 | /*! | |
48 | \qmlclass ScatterSeries QScatterSeries |
|
48 | \qmlclass ScatterSeries QScatterSeries | |
49 | \inherits XYSeries |
|
49 | \inherits XYSeries | |
50 |
|
50 | |||
51 | The following QML shows how to create a chart with two simple scatter series: |
|
51 | The following QML shows how to create a chart with two simple scatter series: | |
52 | \snippet ../demos/qmlchart/qml/qmlchart/View5.qml 1 |
|
52 | \snippet ../demos/qmlchart/qml/qmlchart/View5.qml 1 | |
53 |
|
53 | |||
54 | \beginfloatleft |
|
54 | \beginfloatleft | |
55 | \image demos_qmlchart5.png |
|
55 | \image demos_qmlchart5.png | |
56 | \endfloat |
|
56 | \endfloat | |
57 | \clearfloat |
|
57 | \clearfloat | |
58 | */ |
|
58 | */ | |
59 |
|
59 | |||
60 | /*! |
|
60 | /*! | |
61 | \enum QScatterSeries::MarkerShape |
|
61 | \enum QScatterSeries::MarkerShape | |
62 |
|
62 | |||
63 | This enum describes the shape used when rendering marker items. |
|
63 | This enum describes the shape used when rendering marker items. | |
64 |
|
64 | |||
65 | \value MarkerShapeCircle |
|
65 | \value MarkerShapeCircle | |
66 | \value MarkerShapeRectangle |
|
66 | \value MarkerShapeRectangle | |
67 | */ |
|
67 | */ | |
68 |
|
68 | |||
69 | /*! |
|
69 | /*! | |
70 | \property QScatterSeries::color |
|
70 | \property QScatterSeries::color | |
71 | Fill (brush) color of the series. This is a convenience property for modifying the color of brush. |
|
71 | Fill (brush) color of the series. This is a convenience property for modifying the color of brush. | |
72 | \sa QScatterSeries::brush() |
|
72 | \sa QScatterSeries::brush() | |
73 | */ |
|
73 | */ | |
74 |
|
74 | |||
75 | /*! |
|
75 | /*! | |
76 | \property QScatterSeries::borderColor |
|
76 | \property QScatterSeries::borderColor | |
77 | Line (pen) color of the series. This is a convenience property for modifying the color of pen. |
|
77 | Line (pen) color of the series. This is a convenience property for modifying the color of pen. | |
78 | \sa QScatterSeries::pen() |
|
78 | \sa QScatterSeries::pen() | |
79 | */ |
|
79 | */ | |
80 |
|
80 | |||
81 | /*! |
|
81 | /*! | |
82 | \qmlproperty real ScatterSeries::borderWidth |
|
82 | \qmlproperty real ScatterSeries::borderWidth | |
83 | The width of the border line. By default the width is 2.0. |
|
83 | The width of the border line. By default the width is 2.0. | |
84 | */ |
|
84 | */ | |
85 |
|
85 | |||
86 | /*! |
|
86 | /*! | |
87 | \property QScatterSeries::markerShape |
|
87 | \property QScatterSeries::markerShape | |
88 | Defines the shape of the marker used to draw the points in the series. The default shape is MarkerShapeCircle. |
|
88 | Defines the shape of the marker used to draw the points in the series. The default shape is MarkerShapeCircle. | |
89 | */ |
|
89 | */ | |
90 | /*! |
|
90 | /*! | |
91 | \qmlproperty MarkerShape ScatterSeries::markerShape |
|
91 | \qmlproperty MarkerShape ScatterSeries::markerShape | |
92 | Defines the shape of the marker used to draw the points in the series. One of ScatterSeries |
|
92 | Defines the shape of the marker used to draw the points in the series. One of ScatterSeries | |
93 | ScatterSeries.MarkerShapeCircle or ScatterSeries.MarkerShapeRectangle. |
|
93 | ScatterSeries.MarkerShapeCircle or ScatterSeries.MarkerShapeRectangle. | |
94 | The default shape is ScatterSeries.MarkerShapeCircle. |
|
94 | The default shape is ScatterSeries.MarkerShapeCircle. | |
95 | */ |
|
95 | */ | |
96 |
|
96 | |||
97 | /*! |
|
97 | /*! | |
98 | \property QScatterSeries::markerSize |
|
98 | \property QScatterSeries::markerSize | |
99 | Defines the size of the marker used to draw the points in the series. The default size is 15.0. |
|
99 | Defines the size of the marker used to draw the points in the series. The default size is 15.0. | |
100 | */ |
|
100 | */ | |
101 | /*! |
|
101 | /*! | |
102 | \qmlproperty real ScatterSeries::markerSize |
|
102 | \qmlproperty real ScatterSeries::markerSize | |
103 | Defines the size of the marker used to draw the points in the series. The default size is 15.0. |
|
103 | Defines the size of the marker used to draw the points in the series. The default size is 15.0. | |
104 | */ |
|
104 | */ | |
105 |
|
105 | |||
106 | /*! |
|
106 | /*! | |
107 | \fn void QScatterSeries::colorChanged(QColor color) |
|
107 | \fn void QScatterSeries::colorChanged(QColor color) | |
108 | Signal is emitted when the fill (brush) color has changed to \a color. |
|
108 | Signal is emitted when the fill (brush) color has changed to \a color. | |
109 | */ |
|
109 | */ | |
110 |
|
110 | |||
111 | /*! |
|
111 | /*! | |
112 | \fn void QScatterSeries::borderColorChanged(QColor color) |
|
112 | \fn void QScatterSeries::borderColorChanged(QColor color) | |
113 | Signal is emitted when the line (pen) color has changed to \a color. |
|
113 | Signal is emitted when the line (pen) color has changed to \a color. | |
114 | */ |
|
114 | */ | |
115 | /*! |
|
115 | /*! | |
116 | \qmlsignal ScatterSeries::borderColorChanged(color color) |
|
116 | \qmlsignal ScatterSeries::borderColorChanged(color color) | |
117 | Signal is emitted when the line (pen) color has changed to \a color. |
|
117 | Signal is emitted when the line (pen) color has changed to \a color. | |
118 | */ |
|
118 | */ | |
119 |
|
119 | |||
120 | /*! |
|
120 | /*! | |
121 | \fn QChartSeriesType QScatterSeries::type() const |
|
121 | \fn QChartSeriesType QScatterSeries::type() const | |
122 | Returns QChartSeries::SeriesTypeScatter. |
|
122 | Returns QChartSeries::SeriesTypeScatter. | |
123 | \sa QAbstractSeries, SeriesType |
|
123 | \sa QAbstractSeries, SeriesType | |
124 | */ |
|
124 | */ | |
125 |
|
125 | |||
126 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
126 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
127 |
|
127 | |||
128 | /*! |
|
128 | /*! | |
129 | Constructs a series object which is a child of \a parent. |
|
129 | Constructs a series object which is a child of \a parent. | |
130 | */ |
|
130 | */ | |
131 | QScatterSeries::QScatterSeries(QObject *parent) : QXYSeries(*new QScatterSeriesPrivate(this),parent) |
|
131 | QScatterSeries::QScatterSeries(QObject *parent) : QXYSeries(*new QScatterSeriesPrivate(this),parent) | |
132 | { |
|
132 | { | |
133 | } |
|
133 | } | |
134 |
|
134 | |||
135 | /*! |
|
135 | /*! | |
136 | Destroys the object. Note that adding series to QChart transfers the ownership to the chart. |
|
136 | Destroys the object. Note that adding series to QChart transfers the ownership to the chart. | |
137 | */ |
|
137 | */ | |
138 | QScatterSeries::~QScatterSeries() |
|
138 | QScatterSeries::~QScatterSeries() | |
139 | { |
|
139 | { | |
140 | Q_D(QScatterSeries); |
|
140 | Q_D(QScatterSeries); | |
141 | if(d->m_dataset) { |
|
141 | if(d->m_dataset) { | |
142 | d->m_dataset->removeSeries(this); |
|
142 | d->m_dataset->removeSeries(this); | |
143 | } |
|
143 | } | |
144 | } |
|
144 | } | |
145 |
|
145 | |||
146 | QAbstractSeries::SeriesType QScatterSeries::type() const |
|
146 | QAbstractSeries::SeriesType QScatterSeries::type() const | |
147 | { |
|
147 | { | |
148 | return QAbstractSeries::SeriesTypeScatter; |
|
148 | return QAbstractSeries::SeriesTypeScatter; | |
149 | } |
|
149 | } | |
150 |
|
150 | |||
151 | /*! |
|
151 | /*! | |
152 | Sets \a pen used for drawing points' border on the chart. If the pen is not defined, the |
|
152 | Sets \a pen used for drawing points' border on the chart. If the pen is not defined, the | |
153 | pen from chart theme is used. |
|
153 | pen from chart theme is used. | |
154 | \sa QChart::setTheme() |
|
154 | \sa QChart::setTheme() | |
155 | */ |
|
155 | */ | |
156 | void QScatterSeries::setPen(const QPen &pen) |
|
156 | void QScatterSeries::setPen(const QPen &pen) | |
157 | { |
|
157 | { | |
158 | Q_D(QXYSeries); |
|
158 | Q_D(QXYSeries); | |
159 | if (d->m_pen != pen) { |
|
159 | if (d->m_pen != pen) { | |
160 | bool emitColorChanged = d->m_pen.color() != pen.color(); |
|
160 | bool emitColorChanged = d->m_pen.color() != pen.color(); | |
161 | d->m_pen = pen; |
|
161 | d->m_pen = pen; | |
162 | emit d->updated(); |
|
162 | emit d->updated(); | |
163 | if (emitColorChanged) |
|
163 | if (emitColorChanged) | |
164 | emit borderColorChanged(pen.color()); |
|
164 | emit borderColorChanged(pen.color()); | |
165 | } |
|
165 | } | |
166 | } |
|
166 | } | |
167 |
|
167 | |||
168 | /*! |
|
168 | /*! | |
169 | Sets \a brush used for drawing points on the chart. If the brush is not defined, brush |
|
169 | Sets \a brush used for drawing points on the chart. If the brush is not defined, brush | |
170 | from chart theme setting is used. |
|
170 | from chart theme setting is used. | |
171 | \sa QChart::setTheme() |
|
171 | \sa QChart::setTheme() | |
172 | */ |
|
172 | */ | |
173 | void QScatterSeries::setBrush(const QBrush &brush) |
|
173 | void QScatterSeries::setBrush(const QBrush &brush) | |
174 | { |
|
174 | { | |
175 | Q_D(QScatterSeries); |
|
175 | Q_D(QScatterSeries); | |
176 | if (d->m_brush != brush) { |
|
176 | if (d->m_brush != brush) { | |
177 | bool emitColorChanged = d->m_brush.color() != brush.color(); |
|
177 | bool emitColorChanged = d->m_brush.color() != brush.color(); | |
178 | d->m_brush = brush; |
|
178 | d->m_brush = brush; | |
179 | emit d->updated(); |
|
179 | emit d->updated(); | |
180 | if (emitColorChanged) |
|
180 | if (emitColorChanged) | |
181 | emit colorChanged(brush.color()); |
|
181 | emit colorChanged(brush.color()); | |
182 | } |
|
182 | } | |
183 | } |
|
183 | } | |
184 |
|
184 | |||
185 | void QScatterSeries::setColor(const QColor &color) |
|
185 | void QScatterSeries::setColor(const QColor &color) | |
186 | { |
|
186 | { | |
187 | QBrush b = brush(); |
|
187 | QBrush b = brush(); | |
188 | if (b.color() != color) { |
|
188 | if (b == QBrush()) | |
189 | b.setColor(color); |
|
189 | b.setStyle(Qt::SolidPattern); | |
190 | setBrush(b); |
|
190 | b.setColor(color); | |
191 | } |
|
191 | setBrush(b); | |
192 | } |
|
192 | } | |
193 |
|
193 | |||
194 | QColor QScatterSeries::color() const |
|
194 | QColor QScatterSeries::color() const | |
195 | { |
|
195 | { | |
196 | return brush().color(); |
|
196 | return brush().color(); | |
197 | } |
|
197 | } | |
198 |
|
198 | |||
199 | void QScatterSeries::setBorderColor(const QColor &color) |
|
199 | void QScatterSeries::setBorderColor(const QColor &color) | |
200 | { |
|
200 | { | |
201 | QPen p = pen(); |
|
201 | QPen p = pen(); | |
202 | if (p.color() != color) { |
|
202 | if (p.color() != color) { | |
203 | p.setColor(color); |
|
203 | p.setColor(color); | |
204 | setPen(p); |
|
204 | setPen(p); | |
205 | } |
|
205 | } | |
206 | } |
|
206 | } | |
207 |
|
207 | |||
208 | QColor QScatterSeries::borderColor() const |
|
208 | QColor QScatterSeries::borderColor() const | |
209 | { |
|
209 | { | |
210 | return pen().color(); |
|
210 | return pen().color(); | |
211 | } |
|
211 | } | |
212 |
|
212 | |||
213 | QScatterSeries::MarkerShape QScatterSeries::markerShape() const |
|
213 | QScatterSeries::MarkerShape QScatterSeries::markerShape() const | |
214 | { |
|
214 | { | |
215 | Q_D(const QScatterSeries); |
|
215 | Q_D(const QScatterSeries); | |
216 | return d->m_shape; |
|
216 | return d->m_shape; | |
217 | } |
|
217 | } | |
218 |
|
218 | |||
219 | void QScatterSeries::setMarkerShape(MarkerShape shape) |
|
219 | void QScatterSeries::setMarkerShape(MarkerShape shape) | |
220 | { |
|
220 | { | |
221 | Q_D(QScatterSeries); |
|
221 | Q_D(QScatterSeries); | |
222 | if (d->m_shape != shape) { |
|
222 | if (d->m_shape != shape) { | |
223 | d->m_shape = shape; |
|
223 | d->m_shape = shape; | |
224 | emit d->updated(); |
|
224 | emit d->updated(); | |
225 | } |
|
225 | } | |
226 | } |
|
226 | } | |
227 |
|
227 | |||
228 | qreal QScatterSeries::markerSize() const |
|
228 | qreal QScatterSeries::markerSize() const | |
229 | { |
|
229 | { | |
230 | Q_D(const QScatterSeries); |
|
230 | Q_D(const QScatterSeries); | |
231 | return d->m_size; |
|
231 | return d->m_size; | |
232 | } |
|
232 | } | |
233 |
|
233 | |||
234 | void QScatterSeries::setMarkerSize(qreal size) |
|
234 | void QScatterSeries::setMarkerSize(qreal size) | |
235 | { |
|
235 | { | |
236 | Q_D(QScatterSeries); |
|
236 | Q_D(QScatterSeries); | |
237 |
|
237 | |||
238 | if (!qFuzzyIsNull(d->m_size - size)) { |
|
238 | if (!qFuzzyIsNull(d->m_size - size)) { | |
239 | d->m_size = size; |
|
239 | d->m_size = size; | |
240 | emit d->updated(); |
|
240 | emit d->updated(); | |
241 | } |
|
241 | } | |
242 | } |
|
242 | } | |
243 |
|
243 | |||
244 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
|
244 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |
245 |
|
245 | |||
246 | QScatterSeriesPrivate::QScatterSeriesPrivate(QScatterSeries* q) : |
|
246 | QScatterSeriesPrivate::QScatterSeriesPrivate(QScatterSeries* q) : | |
247 | QXYSeriesPrivate(q), |
|
247 | QXYSeriesPrivate(q), | |
248 | m_shape(QScatterSeries::MarkerShapeCircle), |
|
248 | m_shape(QScatterSeries::MarkerShapeCircle), | |
249 | m_size(15.0) |
|
249 | m_size(15.0) | |
250 | { |
|
250 | { | |
251 | } |
|
251 | } | |
252 |
|
252 | |||
253 | ChartElement* QScatterSeriesPrivate::createGraphics(ChartPresenter* presenter) |
|
253 | ChartElement* QScatterSeriesPrivate::createGraphics(ChartPresenter* presenter) | |
254 | { |
|
254 | { | |
255 | Q_Q(QScatterSeries); |
|
255 | Q_Q(QScatterSeries); | |
256 | ScatterChartItem *scatter = new ScatterChartItem(q,presenter); |
|
256 | ScatterChartItem *scatter = new ScatterChartItem(q,presenter); | |
257 | if(presenter->animationOptions().testFlag(QChart::SeriesAnimations)) { |
|
257 | if(presenter->animationOptions().testFlag(QChart::SeriesAnimations)) { | |
258 | scatter->setAnimation(new XYAnimation(scatter)); |
|
258 | scatter->setAnimation(new XYAnimation(scatter)); | |
259 | } |
|
259 | } | |
260 | presenter->chartTheme()->decorate(q, presenter->dataSet()->seriesIndex(q)); |
|
260 | presenter->chartTheme()->decorate(q, presenter->dataSet()->seriesIndex(q)); | |
261 | return scatter; |
|
261 | return scatter; | |
262 | } |
|
262 | } | |
263 |
|
263 | |||
264 | #include "moc_qscatterseries.cpp" |
|
264 | #include "moc_qscatterseries.cpp" | |
265 |
|
265 | |||
266 | QTCOMMERCIALCHART_END_NAMESPACE |
|
266 | QTCOMMERCIALCHART_END_NAMESPACE |
General Comments 0
You need to be logged in to leave comments.
Login now