@@ -1,501 +1,525 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2012 Digia Plc |
|
3 | ** Copyright (C) 2012 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
8 | ** |
|
8 | ** | |
9 | ** $QT_BEGIN_LICENSE$ |
|
9 | ** $QT_BEGIN_LICENSE$ | |
10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and Digia. |
|
13 | ** a written agreement between you and Digia. | |
14 | ** |
|
14 | ** | |
15 | ** If you have questions regarding the use of this file, please use |
|
15 | ** If you have questions regarding the use of this file, please use | |
16 | ** contact form at http://qt.digia.com |
|
16 | ** contact form at http://qt.digia.com | |
17 | ** $QT_END_LICENSE$ |
|
17 | ** $QT_END_LICENSE$ | |
18 | ** |
|
18 | ** | |
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 | #include "declarativechart.h" |
|
21 | #include "declarativechart.h" | |
22 | #include <QPainter> |
|
22 | #include <QPainter> | |
23 | #include "declarativelineseries.h" |
|
23 | #include "declarativelineseries.h" | |
24 | #include "declarativeareaseries.h" |
|
24 | #include "declarativeareaseries.h" | |
25 | #include "declarativebarseries.h" |
|
25 | #include "declarativebarseries.h" | |
26 | #include "declarativepieseries.h" |
|
26 | #include "declarativepieseries.h" | |
27 | #include "declarativesplineseries.h" |
|
27 | #include "declarativesplineseries.h" | |
28 | #include "declarativescatterseries.h" |
|
28 | #include "declarativescatterseries.h" | |
29 |
|
29 | |||
30 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
30 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
31 |
|
31 | |||
32 | /*! |
|
32 | /*! | |
33 | \qmlclass ChartView DeclarativeChart |
|
33 | \qmlclass ChartView DeclarativeChart | |
34 |
|
34 | |||
35 | ChartView element is the parent that is responsible for showing different chart series types. |
|
35 | ChartView element is the parent that is responsible for showing different chart series types. | |
36 |
|
36 | |||
37 | The following QML shows how to create a simple chart with one pie series: |
|
37 | The following QML shows how to create a simple chart with one pie series: | |
38 | \snippet ../examples/qmlpiechart/qml/qmlpiechart/main.qml 1 |
|
38 | \snippet ../examples/qmlpiechart/qml/qmlpiechart/main.qml 1 | |
39 | \snippet ../examples/qmlpiechart/qml/qmlpiechart/main.qml 2 |
|
39 | \snippet ../examples/qmlpiechart/qml/qmlpiechart/main.qml 2 | |
40 | \snippet ../examples/qmlpiechart/qml/qmlpiechart/main.qml 3 |
|
40 | \snippet ../examples/qmlpiechart/qml/qmlpiechart/main.qml 3 | |
41 |
|
41 | |||
42 | \beginfloatleft |
|
42 | \beginfloatleft | |
43 | \image examples_qmlpiechart.png |
|
43 | \image examples_qmlpiechart.png | |
44 | \endfloat |
|
44 | \endfloat | |
45 | \clearfloat |
|
45 | \clearfloat | |
46 | */ |
|
46 | */ | |
47 |
|
47 | |||
48 | /*! |
|
48 | /*! | |
49 | \qmlproperty Theme ChartView::theme |
|
49 | \qmlproperty Theme ChartView::theme | |
50 | Theme defines the visual appearance of the chart, including for example colors, fonts, line |
|
50 | Theme defines the visual appearance of the chart, including for example colors, fonts, line | |
51 | widths and chart background. |
|
51 | widths and chart background. | |
52 | */ |
|
52 | */ | |
53 |
|
53 | |||
54 | /*! |
|
54 | /*! | |
55 | \qmlproperty Animation ChartView::animation |
|
55 | \qmlproperty Animation ChartView::animation | |
56 | Animation configuration of the chart. One of ChartView.NoAnimation, ChartView.GridAxisAnimations, |
|
56 | Animation configuration of the chart. One of ChartView.NoAnimation, ChartView.GridAxisAnimations, | |
57 | ChartView.SeriesAnimations or ChartView.AllAnimations. |
|
57 | ChartView.SeriesAnimations or ChartView.AllAnimations. | |
58 | */ |
|
58 | */ | |
59 |
|
59 | |||
60 | /*! |
|
60 | /*! | |
61 | \qmlproperty Font ChartView::titleFont |
|
61 | \qmlproperty Font ChartView::titleFont | |
62 | The title font of the chart |
|
62 | The title font of the chart | |
63 |
|
63 | |||
64 | See the \l {Font} {QML Font Element} for detailed documentation. |
|
64 | See the \l {Font} {QML Font Element} for detailed documentation. | |
65 | */ |
|
65 | */ | |
66 |
|
66 | |||
67 | /*! |
|
67 | /*! | |
68 | \qmlproperty string ChartView::title |
|
68 | \qmlproperty string ChartView::title | |
69 | The title of the chart, shown on top of the chart. |
|
69 | The title of the chart, shown on top of the chart. | |
70 | \sa ChartView::titleColor |
|
70 | \sa ChartView::titleColor | |
71 | */ |
|
71 | */ | |
72 |
|
72 | |||
73 | /*! |
|
73 | /*! | |
74 | \qmlproperty string ChartView::titleColor |
|
74 | \qmlproperty string ChartView::titleColor | |
75 | The color of the title text. |
|
75 | The color of the title text. | |
76 | */ |
|
76 | */ | |
77 |
|
77 | |||
78 | /*! |
|
78 | /*! | |
79 | \qmlproperty Axis ChartView::axisX |
|
79 | \qmlproperty Axis ChartView::axisX | |
80 | The x-axis of the chart. |
|
80 | The x-axis of the chart. | |
81 | */ |
|
81 | */ | |
82 |
|
82 | |||
83 | /*! |
|
83 | /*! | |
84 | \qmlproperty Axis ChartView::axisY |
|
84 | \qmlproperty Axis ChartView::axisY | |
85 | The default y-axis of the chart. |
|
85 | The default y-axis of the chart. | |
86 | */ |
|
86 | */ | |
87 |
|
87 | |||
88 | /*! |
|
88 | /*! | |
89 | \qmlproperty Legend ChartView::legend |
|
89 | \qmlproperty Legend ChartView::legend | |
90 | The legend of the chart. Legend lists all the series, pie slices and bar sets added on the chart. |
|
90 | The legend of the chart. Legend lists all the series, pie slices and bar sets added on the chart. | |
91 | */ |
|
91 | */ | |
92 |
|
92 | |||
93 | /*! |
|
93 | /*! | |
94 | \qmlproperty int ChartView::count |
|
94 | \qmlproperty int ChartView::count | |
95 | The count of series added to the chart. |
|
95 | The count of series added to the chart. | |
96 | */ |
|
96 | */ | |
97 |
|
97 | |||
98 | /*! |
|
98 | /*! | |
99 | \qmlproperty color ChartView::backgroundColor |
|
99 | \qmlproperty color ChartView::backgroundColor | |
100 | The color of the chart's background. By default background color is defined by chart theme. |
|
100 | The color of the chart's background. By default background color is defined by chart theme. | |
101 | \sa ChartView::theme |
|
101 | \sa ChartView::theme | |
102 | */ |
|
102 | */ | |
103 |
|
103 | |||
104 | /*! |
|
104 | /*! | |
105 | \qmlproperty bool ChartView::dropShadowEnabled |
|
105 | \qmlproperty bool ChartView::dropShadowEnabled | |
106 | The chart's border drop shadow. Set to true to enable drop shadow. |
|
106 | The chart's border drop shadow. Set to true to enable drop shadow. | |
107 | */ |
|
107 | */ | |
108 |
|
108 | |||
109 | /*! |
|
109 | /*! | |
110 | \qmlproperty real ChartView::topMargin |
|
110 | \qmlproperty real ChartView::topMargin | |
111 | The space between the top of chart view and the top of the plot area. The title (if non-empty) is drawn on top margin |
|
111 | The space between the top of chart view and the top of the plot area. The title (if non-empty) is drawn on top margin | |
112 | area of the chart view. Top margin area is also used by legend, if aligned to top. |
|
112 | area of the chart view. Top margin area is also used by legend, if aligned to top. | |
113 | */ |
|
113 | */ | |
114 |
|
114 | |||
115 | /*! |
|
115 | /*! | |
116 | \qmlproperty real ChartView::bottomMargin |
|
116 | \qmlproperty real ChartView::bottomMargin | |
117 | The space between the bottom of chart view and the bottom of the plot area. The bottom margin area may be used by |
|
117 | The space between the bottom of chart view and the bottom of the plot area. The bottom margin area may be used by | |
118 | legend (if aligned to bottom), x-axis, x-axis labels and x-axis tick marks. |
|
118 | legend (if aligned to bottom), x-axis, x-axis labels and x-axis tick marks. | |
119 | */ |
|
119 | */ | |
120 |
|
120 | |||
121 | /*! |
|
121 | /*! | |
122 | \qmlproperty real ChartView::leftMargin |
|
122 | \qmlproperty real ChartView::leftMargin | |
123 | The space between the left side of chart view and the left side of the plot area. The left margin area may be used by |
|
123 | The space between the left side of chart view and the left side of the plot area. The left margin area may be used by | |
124 | legend (if aligned to left), y-axis, y-axis labels and y-axis tick marks. |
|
124 | legend (if aligned to left), y-axis, y-axis labels and y-axis tick marks. | |
125 | */ |
|
125 | */ | |
126 |
|
126 | |||
127 | /*! |
|
127 | /*! | |
128 | \qmlproperty real ChartView::rightMargin |
|
128 | \qmlproperty real ChartView::rightMargin | |
129 | The space between the right side of chart view and the right side of the plot area. The right margin area may be used |
|
129 | The space between the right side of chart view and the right side of the plot area. The right margin area may be used | |
130 | by legend (if aligned to right). |
|
130 | by legend (if aligned to right). | |
131 | */ |
|
131 | */ | |
132 |
|
132 | |||
133 | /*! |
|
133 | /*! | |
134 | \qmlmethod AbstractSeries ChartView::series(int index) |
|
134 | \qmlmethod AbstractSeries ChartView::series(int index) | |
135 | Returns the series with \a index on the chart. This allows you to loop through the series of a chart together with |
|
135 | Returns the series with \a index on the chart. This allows you to loop through the series of a chart together with | |
136 | the count property of the chart. |
|
136 | the count property of the chart. | |
137 | */ |
|
137 | */ | |
138 |
|
138 | |||
139 | /*! |
|
139 | /*! | |
140 | \qmlmethod AbstractSeries ChartView::series(string name) |
|
140 | \qmlmethod AbstractSeries ChartView::series(string name) | |
141 | Returns the first series on the chart with \a name. If there is no series with that name, returns null. |
|
141 | Returns the first series on the chart with \a name. If there is no series with that name, returns null. | |
142 | */ |
|
142 | */ | |
143 |
|
143 | |||
144 | /*! |
|
144 | /*! | |
145 | \qmlmethod AbstractSeries ChartView::createSeries(SeriesType type, string name) |
|
145 | \qmlmethod AbstractSeries ChartView::createSeries(SeriesType type, string name) | |
146 | Creates a series object of \a type to the chart. For example: |
|
146 | Creates a series object of \a type to the chart. For example: | |
147 | \code |
|
147 | \code | |
148 | var scatter = chartView.createSeries(ChartView.SeriesTypeScatter, "scatter series"); |
|
148 | var scatter = chartView.createSeries(ChartView.SeriesTypeScatter, "scatter series"); | |
149 | scatter.markerSize = 22; |
|
149 | scatter.markerSize = 22; | |
150 | scatter.append(1.1, 2.0); |
|
150 | scatter.append(1.1, 2.0); | |
151 | \endcode |
|
151 | \endcode | |
152 | */ |
|
152 | */ | |
153 |
|
153 | |||
154 | /*! |
|
154 | /*! | |
155 | \qmlmethod Axis ChartView::axisY(QAbstractSeries *series) |
|
155 | \qmlmethod Axis ChartView::axisY(QAbstractSeries *series) | |
156 | The y-axis of the series. This is the same as the default y-axis of the chart as multiple y-axes are not yet supported. |
|
156 | The y-axis of the series. This is the same as the default y-axis of the chart as multiple y-axes are not yet supported. | |
157 | */ |
|
157 | */ | |
158 |
|
158 | |||
159 | /*! |
|
159 | /*! | |
160 | \qmlmethod ChartView::zoomY(real factor) |
|
160 | \qmlmethod ChartView::zoomY(real factor) | |
161 | Zooms in by \a factor on the center of the chart. |
|
161 | Zooms in by \a factor on the center of the chart. | |
162 | */ |
|
162 | */ | |
163 |
|
163 | |||
164 | /*! |
|
164 | /*! | |
165 | \qmlmethod ChartView::scrollLeft(real pixels) |
|
165 | \qmlmethod ChartView::scrollLeft(real pixels) | |
166 | Scrolls to left by \a pixels. This is a convenience function that suits for example for key navigation. |
|
166 | Scrolls to left by \a pixels. This is a convenience function that suits for example for key navigation. | |
167 | \sa Axis::min, Axis::max |
|
167 | \sa Axis::min, Axis::max | |
168 | */ |
|
168 | */ | |
169 |
|
169 | |||
170 | /*! |
|
170 | /*! | |
171 | \qmlmethod ChartView::scrollRight(real pixels) |
|
171 | \qmlmethod ChartView::scrollRight(real pixels) | |
172 | Scrolls to right by \a pixels. This is a convenience function that suits for example for key navigation. |
|
172 | Scrolls to right by \a pixels. This is a convenience function that suits for example for key navigation. | |
173 | \sa Axis::min, Axis::max |
|
173 | \sa Axis::min, Axis::max | |
174 | */ |
|
174 | */ | |
175 |
|
175 | |||
176 | /*! |
|
176 | /*! | |
177 | \qmlmethod ChartView::scrollUp(real pixels) |
|
177 | \qmlmethod ChartView::scrollUp(real pixels) | |
178 | Scrolls up by \a pixels. This is a convenience function that suits for example for key navigation. |
|
178 | Scrolls up by \a pixels. This is a convenience function that suits for example for key navigation. | |
179 | \sa Axis::min, Axis::max |
|
179 | \sa Axis::min, Axis::max | |
180 | */ |
|
180 | */ | |
181 |
|
181 | |||
182 | /*! |
|
182 | /*! | |
183 | \qmlmethod ChartView::scrollDown(real pixels) |
|
183 | \qmlmethod ChartView::scrollDown(real pixels) | |
184 | Scrolls down by \a pixels. This is a convenience function that suits for example for key navigation. |
|
184 | Scrolls down by \a pixels. This is a convenience function that suits for example for key navigation. | |
185 | \sa Axis::min, Axis::max |
|
185 | \sa Axis::min, Axis::max | |
186 | */ |
|
186 | */ | |
187 |
|
187 | |||
|
188 | /*! | |||
|
189 | \qmlsignal ChartView::onTopMarginChanged(real margin) | |||
|
190 | The top margin of the chart view has changed to \a margin. This may happen for example if you modify font size | |||
|
191 | related properties of the legend or chart title. | |||
|
192 | */ | |||
|
193 | ||||
|
194 | /*! | |||
|
195 | \qmlsignal ChartView::onBottomMarginChanged(real margin) | |||
|
196 | The bottom margin of the chart view has changed to \a margin. This may happen for example if you modify font size | |||
|
197 | related properties of the legend or chart title. | |||
|
198 | */ | |||
|
199 | ||||
|
200 | /*! | |||
|
201 | \qmlsignal ChartView::onLeftMarginChanged(real margin) | |||
|
202 | The left margin of the chart view has changed to \a margin. This may happen for example if you modify font size | |||
|
203 | related properties of the legend or chart title. | |||
|
204 | */ | |||
|
205 | ||||
|
206 | /*! | |||
|
207 | \qmlsignal ChartView::onRightMarginChanged(real margin) | |||
|
208 | The right margin of the chart view has changed to \a margin. This may happen for example if you modify font size | |||
|
209 | related properties of the legend or chart title. | |||
|
210 | */ | |||
|
211 | ||||
188 | DeclarativeChart::DeclarativeChart(QDeclarativeItem *parent) |
|
212 | DeclarativeChart::DeclarativeChart(QDeclarativeItem *parent) | |
189 | : QDeclarativeItem(parent), |
|
213 | : QDeclarativeItem(parent), | |
190 | m_chart(new QChart(this)) |
|
214 | m_chart(new QChart(this)) | |
191 | { |
|
215 | { | |
192 | setFlag(QGraphicsItem::ItemHasNoContents, false); |
|
216 | setFlag(QGraphicsItem::ItemHasNoContents, false); | |
193 | // m_chart->axisX()->setNiceNumbersEnabled(false); |
|
217 | // m_chart->axisX()->setNiceNumbersEnabled(false); | |
194 | m_chartMargins = m_chart->margins(); |
|
218 | m_chartMargins = m_chart->margins(); | |
195 | connect(m_chart, SIGNAL(marginsChanged(QRectF)), this, SLOT(handleMarginsChanged(QRectF))); |
|
219 | connect(m_chart, SIGNAL(marginsChanged(QRectF)), this, SLOT(handleMarginsChanged(QRectF))); | |
196 | } |
|
220 | } | |
197 |
|
221 | |||
198 | void DeclarativeChart::handleMarginsChanged(QRectF newMargins) |
|
222 | void DeclarativeChart::handleMarginsChanged(QRectF newMargins) | |
199 | { |
|
223 | { | |
200 | if (m_chartMargins.top() != newMargins.top()) |
|
224 | if (m_chartMargins.top() != newMargins.top()) | |
201 | topMarginChanged(m_chart->margins().top()); |
|
225 | topMarginChanged(m_chart->margins().top()); | |
202 | if (m_chartMargins.bottom() != newMargins.bottom()) |
|
226 | if (m_chartMargins.bottom() != newMargins.bottom()) | |
203 | bottomMarginChanged(m_chart->margins().bottom()); |
|
227 | bottomMarginChanged(m_chart->margins().bottom()); | |
204 | if (m_chartMargins.left() != newMargins.left()) |
|
228 | if (m_chartMargins.left() != newMargins.left()) | |
205 | leftMarginChanged(m_chart->margins().left()); |
|
229 | leftMarginChanged(m_chart->margins().left()); | |
206 | if (m_chartMargins.right() != newMargins.right()) |
|
230 | if (m_chartMargins.right() != newMargins.right()) | |
207 | rightMarginChanged(m_chart->margins().right()); |
|
231 | rightMarginChanged(m_chart->margins().right()); | |
208 |
|
232 | |||
209 | m_chartMargins = m_chart->margins(); |
|
233 | m_chartMargins = m_chart->margins(); | |
210 | } |
|
234 | } | |
211 |
|
235 | |||
212 | DeclarativeChart::~DeclarativeChart() |
|
236 | DeclarativeChart::~DeclarativeChart() | |
213 | { |
|
237 | { | |
214 | delete m_chart; |
|
238 | delete m_chart; | |
215 | } |
|
239 | } | |
216 |
|
240 | |||
217 | void DeclarativeChart::childEvent(QChildEvent *event) |
|
241 | void DeclarativeChart::childEvent(QChildEvent *event) | |
218 | { |
|
242 | { | |
219 | if (event->type() == QEvent::ChildAdded) { |
|
243 | if (event->type() == QEvent::ChildAdded) { | |
220 | if (qobject_cast<QAbstractSeries *>(event->child())) { |
|
244 | if (qobject_cast<QAbstractSeries *>(event->child())) { | |
221 | m_chart->addSeries(qobject_cast<QAbstractSeries *>(event->child())); |
|
245 | m_chart->addSeries(qobject_cast<QAbstractSeries *>(event->child())); | |
222 | } |
|
246 | } | |
223 | } |
|
247 | } | |
224 | } |
|
248 | } | |
225 |
|
249 | |||
226 | void DeclarativeChart::componentComplete() |
|
250 | void DeclarativeChart::componentComplete() | |
227 | { |
|
251 | { | |
228 | foreach(QObject *child, children()) { |
|
252 | foreach(QObject *child, children()) { | |
229 | if (qobject_cast<QAbstractSeries *>(child)) { |
|
253 | if (qobject_cast<QAbstractSeries *>(child)) { | |
230 | // qDebug() << "DeclarativeChart::componentComplete(), add: " << child; |
|
254 | // qDebug() << "DeclarativeChart::componentComplete(), add: " << child; | |
231 | // TODO: how about optional y-axis? |
|
255 | // TODO: how about optional y-axis? | |
232 | m_chart->addSeries(qobject_cast<QAbstractSeries *>(child)); |
|
256 | m_chart->addSeries(qobject_cast<QAbstractSeries *>(child)); | |
233 | } |
|
257 | } | |
234 | } |
|
258 | } | |
235 | QDeclarativeItem::componentComplete(); |
|
259 | QDeclarativeItem::componentComplete(); | |
236 | } |
|
260 | } | |
237 |
|
261 | |||
238 | void DeclarativeChart::geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) |
|
262 | void DeclarativeChart::geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) | |
239 | { |
|
263 | { | |
240 | // qDebug() << "DeclarativeChart::geometryChanged" << newGeometry.width() << newGeometry.height(); |
|
264 | // qDebug() << "DeclarativeChart::geometryChanged" << newGeometry.width() << newGeometry.height(); | |
241 | if (newGeometry.isValid()) { |
|
265 | if (newGeometry.isValid()) { | |
242 | if (newGeometry.width() > 0 && newGeometry.height() > 0) { |
|
266 | if (newGeometry.width() > 0 && newGeometry.height() > 0) { | |
243 | m_chart->resize(newGeometry.width(), newGeometry.height()); |
|
267 | m_chart->resize(newGeometry.width(), newGeometry.height()); | |
244 | } |
|
268 | } | |
245 | } |
|
269 | } | |
246 | QDeclarativeItem::geometryChanged(newGeometry, oldGeometry); |
|
270 | QDeclarativeItem::geometryChanged(newGeometry, oldGeometry); | |
247 | } |
|
271 | } | |
248 |
|
272 | |||
249 | void DeclarativeChart::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) |
|
273 | void DeclarativeChart::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) | |
250 | { |
|
274 | { | |
251 | Q_UNUSED(option) |
|
275 | Q_UNUSED(option) | |
252 | Q_UNUSED(widget) |
|
276 | Q_UNUSED(widget) | |
253 |
|
277 | |||
254 | // TODO: optimized? |
|
278 | // TODO: optimized? | |
255 | painter->setRenderHint(QPainter::Antialiasing, true); |
|
279 | painter->setRenderHint(QPainter::Antialiasing, true); | |
256 | } |
|
280 | } | |
257 |
|
281 | |||
258 | void DeclarativeChart::setTheme(DeclarativeChart::Theme theme) |
|
282 | void DeclarativeChart::setTheme(DeclarativeChart::Theme theme) | |
259 | { |
|
283 | { | |
260 | QChart::ChartTheme chartTheme = (QChart::ChartTheme) theme; |
|
284 | QChart::ChartTheme chartTheme = (QChart::ChartTheme) theme; | |
261 | if (chartTheme != m_chart->theme()) |
|
285 | if (chartTheme != m_chart->theme()) | |
262 | m_chart->setTheme(chartTheme); |
|
286 | m_chart->setTheme(chartTheme); | |
263 | } |
|
287 | } | |
264 |
|
288 | |||
265 | DeclarativeChart::Theme DeclarativeChart::theme() |
|
289 | DeclarativeChart::Theme DeclarativeChart::theme() | |
266 | { |
|
290 | { | |
267 | return (DeclarativeChart::Theme) m_chart->theme(); |
|
291 | return (DeclarativeChart::Theme) m_chart->theme(); | |
268 | } |
|
292 | } | |
269 |
|
293 | |||
270 | void DeclarativeChart::setAnimationOptions(DeclarativeChart::Animation animations) |
|
294 | void DeclarativeChart::setAnimationOptions(DeclarativeChart::Animation animations) | |
271 | { |
|
295 | { | |
272 | QChart::AnimationOption animationOptions = (QChart::AnimationOption) animations; |
|
296 | QChart::AnimationOption animationOptions = (QChart::AnimationOption) animations; | |
273 | if (animationOptions != m_chart->animationOptions()) |
|
297 | if (animationOptions != m_chart->animationOptions()) | |
274 | m_chart->setAnimationOptions(animationOptions); |
|
298 | m_chart->setAnimationOptions(animationOptions); | |
275 | } |
|
299 | } | |
276 |
|
300 | |||
277 | DeclarativeChart::Animation DeclarativeChart::animationOptions() |
|
301 | DeclarativeChart::Animation DeclarativeChart::animationOptions() | |
278 | { |
|
302 | { | |
279 | if (m_chart->animationOptions().testFlag(QChart::AllAnimations)) |
|
303 | if (m_chart->animationOptions().testFlag(QChart::AllAnimations)) | |
280 | return DeclarativeChart::AllAnimations; |
|
304 | return DeclarativeChart::AllAnimations; | |
281 | else if (m_chart->animationOptions().testFlag(QChart::GridAxisAnimations)) |
|
305 | else if (m_chart->animationOptions().testFlag(QChart::GridAxisAnimations)) | |
282 | return DeclarativeChart::GridAxisAnimations; |
|
306 | return DeclarativeChart::GridAxisAnimations; | |
283 | else if (m_chart->animationOptions().testFlag(QChart::SeriesAnimations)) |
|
307 | else if (m_chart->animationOptions().testFlag(QChart::SeriesAnimations)) | |
284 | return DeclarativeChart::SeriesAnimations; |
|
308 | return DeclarativeChart::SeriesAnimations; | |
285 | else |
|
309 | else | |
286 | return DeclarativeChart::NoAnimation; |
|
310 | return DeclarativeChart::NoAnimation; | |
287 | } |
|
311 | } | |
288 |
|
312 | |||
289 | void DeclarativeChart::setTitle(QString title) |
|
313 | void DeclarativeChart::setTitle(QString title) | |
290 | { |
|
314 | { | |
291 | if (title != m_chart->title()) |
|
315 | if (title != m_chart->title()) | |
292 | m_chart->setTitle(title); |
|
316 | m_chart->setTitle(title); | |
293 | } |
|
317 | } | |
294 | QString DeclarativeChart::title() |
|
318 | QString DeclarativeChart::title() | |
295 | { |
|
319 | { | |
296 | return m_chart->title(); |
|
320 | return m_chart->title(); | |
297 | } |
|
321 | } | |
298 |
|
322 | |||
299 | QAxis *DeclarativeChart::axisX() |
|
323 | QAxis *DeclarativeChart::axisX() | |
300 | { |
|
324 | { | |
301 | return m_chart->axisX(); |
|
325 | return m_chart->axisX(); | |
302 | } |
|
326 | } | |
303 |
|
327 | |||
304 | QAxis *DeclarativeChart::axisY(QAbstractSeries *series) |
|
328 | QAxis *DeclarativeChart::axisY(QAbstractSeries *series) | |
305 | { |
|
329 | { | |
306 | return m_chart->axisY(series); |
|
330 | return m_chart->axisY(series); | |
307 | } |
|
331 | } | |
308 |
|
332 | |||
309 | QLegend *DeclarativeChart::legend() |
|
333 | QLegend *DeclarativeChart::legend() | |
310 | { |
|
334 | { | |
311 | return m_chart->legend(); |
|
335 | return m_chart->legend(); | |
312 | } |
|
336 | } | |
313 |
|
337 | |||
314 | QVariantList DeclarativeChart::axisXLabels() |
|
338 | QVariantList DeclarativeChart::axisXLabels() | |
315 | { |
|
339 | { | |
316 | QVariantList labels; |
|
340 | QVariantList labels; | |
317 | foreach (qreal value, m_chart->axisX()->categories()->values()) { |
|
341 | foreach (qreal value, m_chart->axisX()->categories()->values()) { | |
318 | labels.append(value); |
|
342 | labels.append(value); | |
319 | labels.append(m_chart->axisX()->categories()->label(value)); |
|
343 | labels.append(m_chart->axisX()->categories()->label(value)); | |
320 | } |
|
344 | } | |
321 | return labels; |
|
345 | return labels; | |
322 | } |
|
346 | } | |
323 |
|
347 | |||
324 | void DeclarativeChart::setAxisXLabels(QVariantList list) |
|
348 | void DeclarativeChart::setAxisXLabels(QVariantList list) | |
325 | { |
|
349 | { | |
326 | QVariant value(QVariant::Invalid); |
|
350 | QVariant value(QVariant::Invalid); | |
327 | foreach (QVariant element, list) { |
|
351 | foreach (QVariant element, list) { | |
328 | if (value.isValid() && element.type() == QVariant::String) { |
|
352 | if (value.isValid() && element.type() == QVariant::String) { | |
329 | m_chart->axisX()->categories()->insert(value.toDouble(), element.toString()); |
|
353 | m_chart->axisX()->categories()->insert(value.toDouble(), element.toString()); | |
330 | value = QVariant(QVariant::Invalid); |
|
354 | value = QVariant(QVariant::Invalid); | |
331 | } else { |
|
355 | } else { | |
332 | if (element.canConvert(QVariant::Double)) |
|
356 | if (element.canConvert(QVariant::Double)) | |
333 | value = element; |
|
357 | value = element; | |
334 | } |
|
358 | } | |
335 | } |
|
359 | } | |
336 | emit axisLabelsChanged(); |
|
360 | emit axisLabelsChanged(); | |
337 | } |
|
361 | } | |
338 |
|
362 | |||
339 | void DeclarativeChart::setTitleColor(QColor color) |
|
363 | void DeclarativeChart::setTitleColor(QColor color) | |
340 | { |
|
364 | { | |
341 | QBrush b = m_chart->titleBrush(); |
|
365 | QBrush b = m_chart->titleBrush(); | |
342 | if (color != b.color()) { |
|
366 | if (color != b.color()) { | |
343 | b.setColor(color); |
|
367 | b.setColor(color); | |
344 | m_chart->setTitleBrush(b); |
|
368 | m_chart->setTitleBrush(b); | |
345 | emit titleColorChanged(color); |
|
369 | emit titleColorChanged(color); | |
346 | } |
|
370 | } | |
347 | } |
|
371 | } | |
348 |
|
372 | |||
349 | QFont DeclarativeChart::titleFont() const |
|
373 | QFont DeclarativeChart::titleFont() const | |
350 | { |
|
374 | { | |
351 | return m_chart->titleFont(); |
|
375 | return m_chart->titleFont(); | |
352 | } |
|
376 | } | |
353 |
|
377 | |||
354 | void DeclarativeChart::setTitleFont(const QFont& font) |
|
378 | void DeclarativeChart::setTitleFont(const QFont& font) | |
355 | { |
|
379 | { | |
356 | m_chart->setTitleFont(font); |
|
380 | m_chart->setTitleFont(font); | |
357 | } |
|
381 | } | |
358 |
|
382 | |||
359 | QColor DeclarativeChart::titleColor() |
|
383 | QColor DeclarativeChart::titleColor() | |
360 | { |
|
384 | { | |
361 | return m_chart->titleBrush().color(); |
|
385 | return m_chart->titleBrush().color(); | |
362 | } |
|
386 | } | |
363 |
|
387 | |||
364 | void DeclarativeChart::setBackgroundColor(QColor color) |
|
388 | void DeclarativeChart::setBackgroundColor(QColor color) | |
365 | { |
|
389 | { | |
366 | QBrush b = m_chart->backgroundBrush(); |
|
390 | QBrush b = m_chart->backgroundBrush(); | |
367 | if (b.style() != Qt::SolidPattern || color != b.color()) { |
|
391 | if (b.style() != Qt::SolidPattern || color != b.color()) { | |
368 | b.setStyle(Qt::SolidPattern); |
|
392 | b.setStyle(Qt::SolidPattern); | |
369 | b.setColor(color); |
|
393 | b.setColor(color); | |
370 | m_chart->setBackgroundBrush(b); |
|
394 | m_chart->setBackgroundBrush(b); | |
371 | emit backgroundColorChanged(); |
|
395 | emit backgroundColorChanged(); | |
372 | } |
|
396 | } | |
373 | } |
|
397 | } | |
374 |
|
398 | |||
375 | QColor DeclarativeChart::backgroundColor() |
|
399 | QColor DeclarativeChart::backgroundColor() | |
376 | { |
|
400 | { | |
377 | return m_chart->backgroundBrush().color(); |
|
401 | return m_chart->backgroundBrush().color(); | |
378 | } |
|
402 | } | |
379 |
|
403 | |||
380 | int DeclarativeChart::count() |
|
404 | int DeclarativeChart::count() | |
381 | { |
|
405 | { | |
382 | return m_chart->series().count(); |
|
406 | return m_chart->series().count(); | |
383 | } |
|
407 | } | |
384 |
|
408 | |||
385 | void DeclarativeChart::setDropShadowEnabled(bool enabled) |
|
409 | void DeclarativeChart::setDropShadowEnabled(bool enabled) | |
386 | { |
|
410 | { | |
387 | if (enabled != m_chart->isDropShadowEnabled()) { |
|
411 | if (enabled != m_chart->isDropShadowEnabled()) { | |
388 | m_chart->setDropShadowEnabled(enabled); |
|
412 | m_chart->setDropShadowEnabled(enabled); | |
389 | dropShadowEnabledChanged(enabled); |
|
413 | dropShadowEnabledChanged(enabled); | |
390 | } |
|
414 | } | |
391 | } |
|
415 | } | |
392 |
|
416 | |||
393 | bool DeclarativeChart::dropShadowEnabled() |
|
417 | bool DeclarativeChart::dropShadowEnabled() | |
394 | { |
|
418 | { | |
395 | return m_chart->isDropShadowEnabled(); |
|
419 | return m_chart->isDropShadowEnabled(); | |
396 | } |
|
420 | } | |
397 |
|
421 | |||
398 | qreal DeclarativeChart::topMargin() |
|
422 | qreal DeclarativeChart::topMargin() | |
399 | { |
|
423 | { | |
400 | return m_chart->margins().top(); |
|
424 | return m_chart->margins().top(); | |
401 | } |
|
425 | } | |
402 |
|
426 | |||
403 | qreal DeclarativeChart::bottomMargin() |
|
427 | qreal DeclarativeChart::bottomMargin() | |
404 | { |
|
428 | { | |
405 | return m_chart->margins().bottom(); |
|
429 | return m_chart->margins().bottom(); | |
406 | } |
|
430 | } | |
407 |
|
431 | |||
408 | qreal DeclarativeChart::leftMargin() |
|
432 | qreal DeclarativeChart::leftMargin() | |
409 | { |
|
433 | { | |
410 | return m_chart->margins().left(); |
|
434 | return m_chart->margins().left(); | |
411 | } |
|
435 | } | |
412 |
|
436 | |||
413 | qreal DeclarativeChart::rightMargin() |
|
437 | qreal DeclarativeChart::rightMargin() | |
414 | { |
|
438 | { | |
415 | return m_chart->margins().right(); |
|
439 | return m_chart->margins().right(); | |
416 | } |
|
440 | } | |
417 |
|
441 | |||
418 | void DeclarativeChart::zoom(qreal factor) |
|
442 | void DeclarativeChart::zoom(qreal factor) | |
419 | { |
|
443 | { | |
420 | m_chart->zoom(factor); |
|
444 | m_chart->zoom(factor); | |
421 | } |
|
445 | } | |
422 |
|
446 | |||
423 | void DeclarativeChart::scrollLeft(qreal pixels) |
|
447 | void DeclarativeChart::scrollLeft(qreal pixels) | |
424 | { |
|
448 | { | |
425 | m_chart->scroll(QPointF(pixels, 0)); |
|
449 | m_chart->scroll(QPointF(pixels, 0)); | |
426 | } |
|
450 | } | |
427 |
|
451 | |||
428 | void DeclarativeChart::scrollRight(qreal pixels) |
|
452 | void DeclarativeChart::scrollRight(qreal pixels) | |
429 | { |
|
453 | { | |
430 | m_chart->scroll(QPointF(-pixels, 0)); |
|
454 | m_chart->scroll(QPointF(-pixels, 0)); | |
431 | } |
|
455 | } | |
432 |
|
456 | |||
433 | void DeclarativeChart::scrollUp(qreal pixels) |
|
457 | void DeclarativeChart::scrollUp(qreal pixels) | |
434 | { |
|
458 | { | |
435 | m_chart->scroll(QPointF(0, pixels)); |
|
459 | m_chart->scroll(QPointF(0, pixels)); | |
436 | } |
|
460 | } | |
437 |
|
461 | |||
438 | void DeclarativeChart::scrollDown(qreal pixels) |
|
462 | void DeclarativeChart::scrollDown(qreal pixels) | |
439 | { |
|
463 | { | |
440 | m_chart->scroll(QPointF(0, -pixels)); |
|
464 | m_chart->scroll(QPointF(0, -pixels)); | |
441 | } |
|
465 | } | |
442 |
|
466 | |||
443 | QAbstractSeries *DeclarativeChart::series(int index) |
|
467 | QAbstractSeries *DeclarativeChart::series(int index) | |
444 | { |
|
468 | { | |
445 | if (index < m_chart->series().count()) { |
|
469 | if (index < m_chart->series().count()) { | |
446 | return m_chart->series().at(index); |
|
470 | return m_chart->series().at(index); | |
447 | } |
|
471 | } | |
448 | return 0; |
|
472 | return 0; | |
449 | } |
|
473 | } | |
450 |
|
474 | |||
451 | QAbstractSeries *DeclarativeChart::series(QString seriesName) |
|
475 | QAbstractSeries *DeclarativeChart::series(QString seriesName) | |
452 | { |
|
476 | { | |
453 | foreach(QAbstractSeries *series, m_chart->series()) { |
|
477 | foreach(QAbstractSeries *series, m_chart->series()) { | |
454 | if (series->name() == seriesName) |
|
478 | if (series->name() == seriesName) | |
455 | return series; |
|
479 | return series; | |
456 | } |
|
480 | } | |
457 | return 0; |
|
481 | return 0; | |
458 | } |
|
482 | } | |
459 |
|
483 | |||
460 | QAbstractSeries *DeclarativeChart::createSeries(DeclarativeChart::SeriesType type, QString name) |
|
484 | QAbstractSeries *DeclarativeChart::createSeries(DeclarativeChart::SeriesType type, QString name) | |
461 | { |
|
485 | { | |
462 | QAbstractSeries *series = 0; |
|
486 | QAbstractSeries *series = 0; | |
463 | switch (type) { |
|
487 | switch (type) { | |
464 | case DeclarativeChart::SeriesTypeLine: |
|
488 | case DeclarativeChart::SeriesTypeLine: | |
465 | series = new DeclarativeLineSeries(); |
|
489 | series = new DeclarativeLineSeries(); | |
466 | break; |
|
490 | break; | |
467 | case DeclarativeChart::SeriesTypeArea: |
|
491 | case DeclarativeChart::SeriesTypeArea: | |
468 | series = new DeclarativeAreaSeries(); |
|
492 | series = new DeclarativeAreaSeries(); | |
469 | break; |
|
493 | break; | |
470 | case DeclarativeChart::SeriesTypeBar: |
|
494 | case DeclarativeChart::SeriesTypeBar: | |
471 | series = new DeclarativeBarSeries(); |
|
495 | series = new DeclarativeBarSeries(); | |
472 | break; |
|
496 | break; | |
473 | case DeclarativeChart::SeriesTypeStackedBar: |
|
497 | case DeclarativeChart::SeriesTypeStackedBar: | |
474 | // TODO |
|
498 | // TODO | |
475 | break; |
|
499 | break; | |
476 | case DeclarativeChart::SeriesTypePercentBar: |
|
500 | case DeclarativeChart::SeriesTypePercentBar: | |
477 | // TODO |
|
501 | // TODO | |
478 | break; |
|
502 | break; | |
479 | case DeclarativeChart::SeriesTypeGroupedBar: |
|
503 | case DeclarativeChart::SeriesTypeGroupedBar: | |
480 | series = new DeclarativeGroupedBarSeries(); |
|
504 | series = new DeclarativeGroupedBarSeries(); | |
481 | break; |
|
505 | break; | |
482 | case DeclarativeChart::SeriesTypePie: |
|
506 | case DeclarativeChart::SeriesTypePie: | |
483 | series = new DeclarativePieSeries(); |
|
507 | series = new DeclarativePieSeries(); | |
484 | break; |
|
508 | break; | |
485 | case DeclarativeChart::SeriesTypeScatter: |
|
509 | case DeclarativeChart::SeriesTypeScatter: | |
486 | series = new DeclarativeScatterSeries(); |
|
510 | series = new DeclarativeScatterSeries(); | |
487 | break; |
|
511 | break; | |
488 | case DeclarativeChart::SeriesTypeSpline: |
|
512 | case DeclarativeChart::SeriesTypeSpline: | |
489 | series = new DeclarativeSplineSeries(); |
|
513 | series = new DeclarativeSplineSeries(); | |
490 | break; |
|
514 | break; | |
491 | default: |
|
515 | default: | |
492 | qWarning() << "Illegal series type"; |
|
516 | qWarning() << "Illegal series type"; | |
493 | } |
|
517 | } | |
494 | series->setName(name); |
|
518 | series->setName(name); | |
495 | m_chart->addSeries(series); |
|
519 | m_chart->addSeries(series); | |
496 | return series; |
|
520 | return series; | |
497 | } |
|
521 | } | |
498 |
|
522 | |||
499 | #include "moc_declarativechart.cpp" |
|
523 | #include "moc_declarativechart.cpp" | |
500 |
|
524 | |||
501 | QTCOMMERCIALCHART_END_NAMESPACE |
|
525 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -1,384 +1,384 | |||||
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 "chartanimator_p.h" |
|
29 | #include "chartanimator_p.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 | \fn QPen QAreaSeries::pen() const |
|
100 | \fn QPen QAreaSeries::pen() const | |
101 | \brief Returns the pen used to draw line for this series. |
|
101 | \brief Returns the pen used to draw line for this series. | |
102 | \sa setPen() |
|
102 | \sa setPen() | |
103 | */ |
|
103 | */ | |
104 |
|
104 | |||
105 | /*! |
|
105 | /*! | |
106 | \fn QPen QAreaSeries::brush() const |
|
106 | \fn QPen QAreaSeries::brush() const | |
107 | \brief Returns the brush used to draw line for this series. |
|
107 | \brief Returns the brush used to draw line for this series. | |
108 | \sa setBrush() |
|
108 | \sa setBrush() | |
109 | */ |
|
109 | */ | |
110 |
|
110 | |||
111 | /*! |
|
111 | /*! | |
112 | \fn void QAreaSeries::colorChanged(QColor color) |
|
112 | \fn void QAreaSeries::colorChanged(QColor color) | |
113 | \brief Signal is emitted when the fill (brush) color has changed to \a color. |
|
113 | \brief Signal is emitted when the fill (brush) color has changed to \a color. | |
114 | */ |
|
114 | */ | |
115 | /*! |
|
115 | /*! | |
116 |
\qmlsignal AreaSeries:: |
|
116 | \qmlsignal AreaSeries::onColorChanged(color color) | |
117 | Signal is emitted when the fill (brush) color has changed to \a color. |
|
117 | Signal is emitted when the fill (brush) color has changed to \a color. | |
118 | */ |
|
118 | */ | |
119 |
|
119 | |||
120 | /*! |
|
120 | /*! | |
121 | \fn void QAreaSeries::borderColorChanged(QColor color) |
|
121 | \fn void QAreaSeries::borderColorChanged(QColor color) | |
122 | \brief Signal is emitted when the line (pen) color has changed to \a color. |
|
122 | \brief Signal is emitted when the line (pen) color has changed to \a color. | |
123 | */ |
|
123 | */ | |
124 | /*! |
|
124 | /*! | |
125 |
\qmlsignal AreaSeries:: |
|
125 | \qmlsignal AreaSeries::onBorderColorChanged(color color) | |
126 | Signal is emitted when the line (pen) color has changed to \a color. |
|
126 | Signal is emitted when the line (pen) color has changed to \a color. | |
127 | */ |
|
127 | */ | |
128 |
|
128 | |||
129 | /*! |
|
129 | /*! | |
130 | \fn void QAreaSeries::clicked(const QPointF& point) |
|
130 | \fn void QAreaSeries::clicked(const QPointF& point) | |
131 | \brief Signal is emitted when user clicks the \a point on area chart. |
|
131 | \brief Signal is emitted when user clicks the \a point on area chart. | |
132 | */ |
|
132 | */ | |
133 | /*! |
|
133 | /*! | |
134 |
\qmlsignal AreaSeries:: |
|
134 | \qmlsignal AreaSeries::onClicked(QPointF point) | |
135 | Signal is emitted when user clicks the \a point on area chart. |
|
135 | Signal is emitted when user clicks the \a point on area chart. | |
136 | */ |
|
136 | */ | |
137 |
|
137 | |||
138 | /*! |
|
138 | /*! | |
139 | \fn void QAreaSeries::selected() |
|
139 | \fn void QAreaSeries::selected() | |
140 | The signal is emitted if the user selects/deselects the XY series. The logic for maintaining selections should be |
|
140 | The signal is emitted if the user selects/deselects the XY series. The logic for maintaining selections should be | |
141 | implemented by the user of QAreaSeries API. |
|
141 | implemented by the user of QAreaSeries API. | |
142 | */ |
|
142 | */ | |
143 | /*! |
|
143 | /*! | |
144 |
\qmlsignal AreaSeries:: |
|
144 | \qmlsignal AreaSeries::onSelected() | |
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 AreaSeries API. |
|
146 | implemented by the user of AreaSeries API. | |
147 | */ |
|
147 | */ | |
148 |
|
148 | |||
149 | /*! |
|
149 | /*! | |
150 | \fn void QAreaSeriesPrivate::updated() |
|
150 | \fn void QAreaSeriesPrivate::updated() | |
151 | \brief \internal |
|
151 | \brief \internal | |
152 | */ |
|
152 | */ | |
153 |
|
153 | |||
154 | /*! |
|
154 | /*! | |
155 | Constructs area series object which is a child of \a upperSeries. Area will be spanned between \a |
|
155 | Constructs area series object which is a child of \a upperSeries. Area will be spanned between \a | |
156 | upperSeries line and \a lowerSeries line. If no \a lowerSeries is passed to constructor, area is specified by axis x (y=0) instead. |
|
156 | upperSeries line and \a lowerSeries line. If no \a lowerSeries is passed to constructor, area is specified by axis x (y=0) instead. | |
157 | When series object is added to QChartView or QChart instance ownerships is transferred. |
|
157 | When series object is added to QChartView or QChart instance ownerships is transferred. | |
158 | */ |
|
158 | */ | |
159 | QAreaSeries::QAreaSeries(QLineSeries *upperSeries, QLineSeries *lowerSeries) |
|
159 | QAreaSeries::QAreaSeries(QLineSeries *upperSeries, QLineSeries *lowerSeries) | |
160 | : QAbstractSeries(*new QAreaSeriesPrivate(upperSeries,lowerSeries,this),upperSeries) |
|
160 | : QAbstractSeries(*new QAreaSeriesPrivate(upperSeries,lowerSeries,this),upperSeries) | |
161 | { |
|
161 | { | |
162 | } |
|
162 | } | |
163 |
|
163 | |||
164 | /*! |
|
164 | /*! | |
165 | Constructs area series object without upper or lower series with \a parent object. |
|
165 | Constructs area series object without upper or lower series with \a parent object. | |
166 | */ |
|
166 | */ | |
167 | QAreaSeries::QAreaSeries(QObject *parent) |
|
167 | QAreaSeries::QAreaSeries(QObject *parent) | |
168 | : QAbstractSeries(*new QAreaSeriesPrivate(0, 0, this), parent) |
|
168 | : QAbstractSeries(*new QAreaSeriesPrivate(0, 0, this), parent) | |
169 | { |
|
169 | { | |
170 | } |
|
170 | } | |
171 |
|
171 | |||
172 | /*! |
|
172 | /*! | |
173 | Destroys the object. |
|
173 | Destroys the object. | |
174 | */ |
|
174 | */ | |
175 | QAreaSeries::~QAreaSeries() |
|
175 | QAreaSeries::~QAreaSeries() | |
176 | { |
|
176 | { | |
177 | } |
|
177 | } | |
178 |
|
178 | |||
179 | /*! |
|
179 | /*! | |
180 | Returns QChartSeries::SeriesTypeArea. |
|
180 | Returns QChartSeries::SeriesTypeArea. | |
181 | */ |
|
181 | */ | |
182 | QAbstractSeries::SeriesType QAreaSeries::type() const |
|
182 | QAbstractSeries::SeriesType QAreaSeries::type() const | |
183 | { |
|
183 | { | |
184 | return QAbstractSeries::SeriesTypeArea; |
|
184 | return QAbstractSeries::SeriesTypeArea; | |
185 | } |
|
185 | } | |
186 |
|
186 | |||
187 | /*! |
|
187 | /*! | |
188 | Sets the \a series that is to be used as the area chart upper series. |
|
188 | Sets the \a series that is to be used as the area chart upper series. | |
189 | */ |
|
189 | */ | |
190 | void QAreaSeries::setUpperSeries(QLineSeries* series) |
|
190 | void QAreaSeries::setUpperSeries(QLineSeries* series) | |
191 | { |
|
191 | { | |
192 | Q_D(QAreaSeries); |
|
192 | Q_D(QAreaSeries); | |
193 | d->m_upperSeries = series; |
|
193 | d->m_upperSeries = series; | |
194 | } |
|
194 | } | |
195 |
|
195 | |||
196 | QLineSeries* QAreaSeries::upperSeries() const |
|
196 | QLineSeries* QAreaSeries::upperSeries() const | |
197 | { |
|
197 | { | |
198 | Q_D(const QAreaSeries); |
|
198 | Q_D(const QAreaSeries); | |
199 | return d->m_upperSeries; |
|
199 | return d->m_upperSeries; | |
200 | } |
|
200 | } | |
201 |
|
201 | |||
202 | /*! |
|
202 | /*! | |
203 | Sets the \a series that is to be used as the area chart lower series. |
|
203 | Sets the \a series that is to be used as the area chart lower series. | |
204 | */ |
|
204 | */ | |
205 | void QAreaSeries::setLowerSeries(QLineSeries* series) |
|
205 | void QAreaSeries::setLowerSeries(QLineSeries* series) | |
206 | { |
|
206 | { | |
207 | Q_D(QAreaSeries); |
|
207 | Q_D(QAreaSeries); | |
208 | d->m_lowerSeries = series; |
|
208 | d->m_lowerSeries = series; | |
209 | } |
|
209 | } | |
210 |
|
210 | |||
211 | QLineSeries* QAreaSeries::lowerSeries() const |
|
211 | QLineSeries* QAreaSeries::lowerSeries() const | |
212 | { |
|
212 | { | |
213 | Q_D(const QAreaSeries); |
|
213 | Q_D(const QAreaSeries); | |
214 | return d->m_lowerSeries; |
|
214 | return d->m_lowerSeries; | |
215 | } |
|
215 | } | |
216 |
|
216 | |||
217 | /*! |
|
217 | /*! | |
218 | Sets \a pen used for drawing area outline. |
|
218 | Sets \a pen used for drawing area outline. | |
219 | */ |
|
219 | */ | |
220 | void QAreaSeries::setPen(const QPen &pen) |
|
220 | void QAreaSeries::setPen(const QPen &pen) | |
221 | { |
|
221 | { | |
222 | Q_D(QAreaSeries); |
|
222 | Q_D(QAreaSeries); | |
223 | if (d->m_pen != pen) { |
|
223 | if (d->m_pen != pen) { | |
224 | d->m_pen = pen; |
|
224 | d->m_pen = pen; | |
225 | emit d->updated(); |
|
225 | emit d->updated(); | |
226 | } |
|
226 | } | |
227 | } |
|
227 | } | |
228 |
|
228 | |||
229 | QPen QAreaSeries::pen() const |
|
229 | QPen QAreaSeries::pen() const | |
230 | { |
|
230 | { | |
231 | Q_D(const QAreaSeries); |
|
231 | Q_D(const QAreaSeries); | |
232 | return d->m_pen; |
|
232 | return d->m_pen; | |
233 | } |
|
233 | } | |
234 |
|
234 | |||
235 | /*! |
|
235 | /*! | |
236 | Sets \a brush used for filling the area. |
|
236 | Sets \a brush used for filling the area. | |
237 | */ |
|
237 | */ | |
238 | void QAreaSeries::setBrush(const QBrush &brush) |
|
238 | void QAreaSeries::setBrush(const QBrush &brush) | |
239 | { |
|
239 | { | |
240 | Q_D(QAreaSeries); |
|
240 | Q_D(QAreaSeries); | |
241 | if (d->m_brush != brush) { |
|
241 | if (d->m_brush != brush) { | |
242 | d->m_brush = brush; |
|
242 | d->m_brush = brush; | |
243 | emit d->updated(); |
|
243 | emit d->updated(); | |
244 | } |
|
244 | } | |
245 | } |
|
245 | } | |
246 |
|
246 | |||
247 | QBrush QAreaSeries::brush() const |
|
247 | QBrush QAreaSeries::brush() const | |
248 | { |
|
248 | { | |
249 | Q_D(const QAreaSeries); |
|
249 | Q_D(const QAreaSeries); | |
250 | return d->m_brush; |
|
250 | return d->m_brush; | |
251 | } |
|
251 | } | |
252 |
|
252 | |||
253 | void QAreaSeries::setColor(const QColor &color) |
|
253 | void QAreaSeries::setColor(const QColor &color) | |
254 | { |
|
254 | { | |
255 | QBrush b = brush(); |
|
255 | QBrush b = brush(); | |
256 | if (b.color() != color) { |
|
256 | if (b.color() != color) { | |
257 | b.setColor(color); |
|
257 | b.setColor(color); | |
258 | setBrush(b); |
|
258 | setBrush(b); | |
259 | emit colorChanged(color); |
|
259 | emit colorChanged(color); | |
260 | } |
|
260 | } | |
261 | } |
|
261 | } | |
262 |
|
262 | |||
263 | QColor QAreaSeries::color() const |
|
263 | QColor QAreaSeries::color() const | |
264 | { |
|
264 | { | |
265 | return brush().color(); |
|
265 | return brush().color(); | |
266 | } |
|
266 | } | |
267 |
|
267 | |||
268 | void QAreaSeries::setBorderColor(const QColor &color) |
|
268 | void QAreaSeries::setBorderColor(const QColor &color) | |
269 | { |
|
269 | { | |
270 | QPen p = pen(); |
|
270 | QPen p = pen(); | |
271 | if (p.color() != color) { |
|
271 | if (p.color() != color) { | |
272 | p.setColor(color); |
|
272 | p.setColor(color); | |
273 | setPen(p); |
|
273 | setPen(p); | |
274 | emit borderColorChanged(color); |
|
274 | emit borderColorChanged(color); | |
275 | } |
|
275 | } | |
276 | } |
|
276 | } | |
277 |
|
277 | |||
278 | QColor QAreaSeries::borderColor() const |
|
278 | QColor QAreaSeries::borderColor() const | |
279 | { |
|
279 | { | |
280 | return pen().color(); |
|
280 | return pen().color(); | |
281 | } |
|
281 | } | |
282 |
|
282 | |||
283 | /*! |
|
283 | /*! | |
284 | Sets if data points are \a visible and should be drawn on line. |
|
284 | Sets if data points are \a visible and should be drawn on line. | |
285 | */ |
|
285 | */ | |
286 | void QAreaSeries::setPointsVisible(bool visible) |
|
286 | void QAreaSeries::setPointsVisible(bool visible) | |
287 | { |
|
287 | { | |
288 | Q_D(QAreaSeries); |
|
288 | Q_D(QAreaSeries); | |
289 | if (d->m_pointsVisible != visible) { |
|
289 | if (d->m_pointsVisible != visible) { | |
290 | d->m_pointsVisible = visible; |
|
290 | d->m_pointsVisible = visible; | |
291 | emit d->updated(); |
|
291 | emit d->updated(); | |
292 | } |
|
292 | } | |
293 | } |
|
293 | } | |
294 |
|
294 | |||
295 | /*! |
|
295 | /*! | |
296 | Returns if the points are drawn for this series. |
|
296 | Returns if the points are drawn for this series. | |
297 | \sa setPointsVisible() |
|
297 | \sa setPointsVisible() | |
298 | */ |
|
298 | */ | |
299 | bool QAreaSeries::pointsVisible() const |
|
299 | bool QAreaSeries::pointsVisible() const | |
300 | { |
|
300 | { | |
301 | Q_D(const QAreaSeries); |
|
301 | Q_D(const QAreaSeries); | |
302 | return d->m_pointsVisible; |
|
302 | return d->m_pointsVisible; | |
303 | } |
|
303 | } | |
304 |
|
304 | |||
305 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
|
305 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |
306 |
|
306 | |||
307 | QAreaSeriesPrivate::QAreaSeriesPrivate(QLineSeries *upperSeries, QLineSeries *lowerSeries,QAreaSeries* q) : |
|
307 | QAreaSeriesPrivate::QAreaSeriesPrivate(QLineSeries *upperSeries, QLineSeries *lowerSeries,QAreaSeries* q) : | |
308 | QAbstractSeriesPrivate(q), |
|
308 | QAbstractSeriesPrivate(q), | |
309 | m_upperSeries(upperSeries), |
|
309 | m_upperSeries(upperSeries), | |
310 | m_lowerSeries(lowerSeries), |
|
310 | m_lowerSeries(lowerSeries), | |
311 | m_pointsVisible(false) |
|
311 | m_pointsVisible(false) | |
312 | { |
|
312 | { | |
313 | } |
|
313 | } | |
314 |
|
314 | |||
315 | void QAreaSeriesPrivate::scaleDomain(Domain& domain) |
|
315 | void QAreaSeriesPrivate::scaleDomain(Domain& domain) | |
316 | { |
|
316 | { | |
317 | Q_Q(QAreaSeries); |
|
317 | Q_Q(QAreaSeries); | |
318 |
|
318 | |||
319 | qreal minX(domain.minX()); |
|
319 | qreal minX(domain.minX()); | |
320 | qreal minY(domain.minY()); |
|
320 | qreal minY(domain.minY()); | |
321 | qreal maxX(domain.maxX()); |
|
321 | qreal maxX(domain.maxX()); | |
322 | qreal maxY(domain.maxY()); |
|
322 | qreal maxY(domain.maxY()); | |
323 | int tickXCount(domain.tickXCount()); |
|
323 | int tickXCount(domain.tickXCount()); | |
324 | int tickYCount(domain.tickYCount()); |
|
324 | int tickYCount(domain.tickYCount()); | |
325 |
|
325 | |||
326 | QLineSeries* upperSeries = q->upperSeries(); |
|
326 | QLineSeries* upperSeries = q->upperSeries(); | |
327 | QLineSeries* lowerSeries = q->lowerSeries(); |
|
327 | QLineSeries* lowerSeries = q->lowerSeries(); | |
328 |
|
328 | |||
329 | const QList<QPointF>& points = upperSeries->points(); |
|
329 | const QList<QPointF>& points = upperSeries->points(); | |
330 |
|
330 | |||
331 | for (int i = 0; i < points.count(); i++) |
|
331 | for (int i = 0; i < points.count(); i++) | |
332 | { |
|
332 | { | |
333 | qreal x = points[i].x(); |
|
333 | qreal x = points[i].x(); | |
334 | qreal y = points[i].y(); |
|
334 | qreal y = points[i].y(); | |
335 | minX = qMin(minX, x); |
|
335 | minX = qMin(minX, x); | |
336 | minY = qMin(minY, y); |
|
336 | minY = qMin(minY, y); | |
337 | maxX = qMax(maxX, x); |
|
337 | maxX = qMax(maxX, x); | |
338 | maxY = qMax(maxY, y); |
|
338 | maxY = qMax(maxY, y); | |
339 | } |
|
339 | } | |
340 | if(lowerSeries) { |
|
340 | if(lowerSeries) { | |
341 |
|
341 | |||
342 | const QList<QPointF>& points = lowerSeries->points(); |
|
342 | const QList<QPointF>& points = lowerSeries->points(); | |
343 |
|
343 | |||
344 | for (int i = 0; i < points.count(); i++) |
|
344 | for (int i = 0; i < points.count(); i++) | |
345 | { |
|
345 | { | |
346 | qreal x = points[i].x(); |
|
346 | qreal x = points[i].x(); | |
347 | qreal y = points[i].y(); |
|
347 | qreal y = points[i].y(); | |
348 | minX = qMin(minX, x); |
|
348 | minX = qMin(minX, x); | |
349 | minY = qMin(minY, y); |
|
349 | minY = qMin(minY, y); | |
350 | maxX = qMax(maxX, x); |
|
350 | maxX = qMax(maxX, x); | |
351 | maxY = qMax(maxY, y); |
|
351 | maxY = qMax(maxY, y); | |
352 | }} |
|
352 | }} | |
353 |
|
353 | |||
354 | domain.setRange(minX,maxX,minY,maxY,tickXCount,tickYCount); |
|
354 | domain.setRange(minX,maxX,minY,maxY,tickXCount,tickYCount); | |
355 | } |
|
355 | } | |
356 |
|
356 | |||
357 | Chart* QAreaSeriesPrivate::createGraphics(ChartPresenter* presenter) |
|
357 | Chart* QAreaSeriesPrivate::createGraphics(ChartPresenter* presenter) | |
358 | { |
|
358 | { | |
359 | Q_Q(QAreaSeries); |
|
359 | Q_Q(QAreaSeries); | |
360 |
|
360 | |||
361 | AreaChartItem* area = new AreaChartItem(q,presenter); |
|
361 | AreaChartItem* area = new AreaChartItem(q,presenter); | |
362 | if(presenter->animationOptions().testFlag(QChart::SeriesAnimations)) { |
|
362 | if(presenter->animationOptions().testFlag(QChart::SeriesAnimations)) { | |
363 | area->upperLineItem()->setAnimator(presenter->animator()); |
|
363 | area->upperLineItem()->setAnimator(presenter->animator()); | |
364 | area->upperLineItem()->setAnimation(new XYAnimation(area->upperLineItem())); |
|
364 | area->upperLineItem()->setAnimation(new XYAnimation(area->upperLineItem())); | |
365 | if(q->lowerSeries()) { |
|
365 | if(q->lowerSeries()) { | |
366 | area->lowerLineItem()->setAnimator(presenter->animator()); |
|
366 | area->lowerLineItem()->setAnimator(presenter->animator()); | |
367 | area->lowerLineItem()->setAnimation(new XYAnimation(area->lowerLineItem())); |
|
367 | area->lowerLineItem()->setAnimation(new XYAnimation(area->lowerLineItem())); | |
368 | } |
|
368 | } | |
369 | } |
|
369 | } | |
370 | presenter->chartTheme()->decorate(q, presenter->dataSet()->seriesIndex(q)); |
|
370 | presenter->chartTheme()->decorate(q, presenter->dataSet()->seriesIndex(q)); | |
371 | return area; |
|
371 | return area; | |
372 | } |
|
372 | } | |
373 |
|
373 | |||
374 | QList<LegendMarker*> QAreaSeriesPrivate::createLegendMarker(QLegend* legend) |
|
374 | QList<LegendMarker*> QAreaSeriesPrivate::createLegendMarker(QLegend* legend) | |
375 | { |
|
375 | { | |
376 | Q_Q(QAreaSeries); |
|
376 | Q_Q(QAreaSeries); | |
377 | QList<LegendMarker*> list; |
|
377 | QList<LegendMarker*> list; | |
378 | return list << new AreaLegendMarker(q,legend); |
|
378 | return list << new AreaLegendMarker(q,legend); | |
379 | } |
|
379 | } | |
380 |
|
380 | |||
381 | #include "moc_qareaseries.cpp" |
|
381 | #include "moc_qareaseries.cpp" | |
382 | #include "moc_qareaseries_p.cpp" |
|
382 | #include "moc_qareaseries_p.cpp" | |
383 |
|
383 | |||
384 | QTCOMMERCIALCHART_END_NAMESPACE |
|
384 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -1,665 +1,680 | |||||
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 "qaxis.h" |
|
21 | #include "qaxis.h" | |
22 | #include "qaxis_p.h" |
|
22 | #include "qaxis_p.h" | |
23 |
|
23 | |||
24 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
24 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
25 |
|
25 | |||
26 | /*! |
|
26 | /*! | |
27 | \class QAxis |
|
27 | \class QAxis | |
28 | \brief The QAxis class is used for manipulating chart's axis |
|
28 | \brief The QAxis class is used for manipulating chart's axis | |
29 | and for adding optional axes to the chart. |
|
29 | and for adding optional axes to the chart. | |
30 | \mainclass |
|
30 | \mainclass | |
31 |
|
31 | |||
32 | There is only one x Axis, however there can be multiple y axes. |
|
32 | There is only one x Axis, however there can be multiple y axes. | |
33 | Each chart series can be bound to exactly one Y axis and the shared common X axis. |
|
33 | Each chart series can be bound to exactly one Y axis and the shared common X axis. | |
34 | Axis can be setup to show axis line with tick marks, grid lines and shades. |
|
34 | Axis can be setup to show axis line with tick marks, grid lines and shades. | |
35 | */ |
|
35 | */ | |
36 |
|
36 | |||
37 | /*! |
|
37 | /*! | |
38 | \qmlclass Axis QAxis |
|
38 | \qmlclass Axis QAxis | |
39 | \brief The Axis element is used for manipulating chart's axes |
|
39 | \brief The Axis element is used for manipulating chart's axes | |
40 |
|
40 | |||
41 | There is only one x Axis, however there can be multiple y axes on a ChartView. |
|
41 | There is only one x Axis, however there can be multiple y axes on a ChartView. | |
42 | Each chart series can be bound to exactly one Y axis and the shared common X axis. |
|
42 | Each chart series can be bound to exactly one Y axis and the shared common X axis. | |
43 | Axis can be setup to show axis line with tick marks, grid lines and shades. |
|
43 | Axis can be setup to show axis line with tick marks, grid lines and shades. | |
44 |
|
44 | |||
45 | To access Axes you can use ChartView API. For example: |
|
45 | To access Axes you can use ChartView API. For example: | |
46 | \code |
|
46 | \code | |
47 | ChartView { |
|
47 | ChartView { | |
48 | axisX.min: 0 |
|
48 | axisX.min: 0 | |
49 | axisX.max: 3 |
|
49 | axisX.max: 3 | |
50 | axisX.ticksCount: 4 |
|
50 | axisX.ticksCount: 4 | |
51 | axisY.min: 0 |
|
51 | axisY.min: 0 | |
52 | axisY.max: 4 |
|
52 | axisY.max: 4 | |
53 | // Add a few series... |
|
53 | // Add a few series... | |
54 | } |
|
54 | } | |
55 | \endcode |
|
55 | \endcode | |
56 | */ |
|
56 | */ | |
57 |
|
57 | |||
58 | /*! |
|
58 | /*! | |
59 | \property QAxis::labelsVisible |
|
59 | \property QAxis::labelsVisible | |
60 | Defines if axis labels are visible. |
|
60 | Defines if axis labels are visible. | |
61 | */ |
|
61 | */ | |
62 | /*! |
|
62 | /*! | |
63 | \qmlproperty bool Axis::labelsVisible |
|
63 | \qmlproperty bool Axis::labelsVisible | |
64 | Defines if axis labels are visible. |
|
64 | Defines if axis labels are visible. | |
65 | */ |
|
65 | */ | |
66 |
|
66 | |||
67 | /*! |
|
67 | /*! | |
68 | \property QAxis::min |
|
68 | \property QAxis::min | |
69 | Defines the minimum value on the axis. |
|
69 | Defines the minimum value on the axis. | |
70 | */ |
|
70 | */ | |
71 | /*! |
|
71 | /*! | |
72 | \qmlproperty real Axis::min |
|
72 | \qmlproperty real Axis::min | |
73 | Defines the minimum value on the axis. |
|
73 | Defines the minimum value on the axis. | |
74 | */ |
|
74 | */ | |
75 |
|
75 | |||
76 | /*! |
|
76 | /*! | |
77 | \property QAxis::max |
|
77 | \property QAxis::max | |
78 | Defines the maximum value on the axis. |
|
78 | Defines the maximum value on the axis. | |
79 | */ |
|
79 | */ | |
80 | /*! |
|
80 | /*! | |
81 | \qmlproperty real Axis::max |
|
81 | \qmlproperty real Axis::max | |
82 | Defines the maximum value on the axis. |
|
82 | Defines the maximum value on the axis. | |
83 | */ |
|
83 | */ | |
84 |
|
84 | |||
85 | /*! |
|
85 | /*! | |
86 | \property QAxis::visible |
|
86 | \property QAxis::visible | |
87 | The visibility of the axis. |
|
87 | The visibility of the axis. | |
88 | */ |
|
88 | */ | |
89 | /*! |
|
89 | /*! | |
90 | \qmlproperty bool Axis::visible |
|
90 | \qmlproperty bool Axis::visible | |
91 | The visibility of the axis. |
|
91 | The visibility of the axis. | |
92 | */ |
|
92 | */ | |
93 |
|
93 | |||
94 | /*! |
|
94 | /*! | |
95 | \property QAxis::gridVisible |
|
95 | \property QAxis::gridVisible | |
96 | The visibility of the grid lines. |
|
96 | The visibility of the grid lines. | |
97 | */ |
|
97 | */ | |
98 | /*! |
|
98 | /*! | |
99 | \qmlproperty bool Axis::gridVisible |
|
99 | \qmlproperty bool Axis::gridVisible | |
100 | The visibility of the grid lines. |
|
100 | The visibility of the grid lines. | |
101 | */ |
|
101 | */ | |
102 |
|
102 | |||
103 | /*! |
|
103 | /*! | |
104 | \property QAxis::color |
|
104 | \property QAxis::color | |
105 | The color of the axis and ticks. |
|
105 | The color of the axis and ticks. | |
106 | */ |
|
106 | */ | |
107 | /*! |
|
107 | /*! | |
108 | \qmlproperty color Axis::color |
|
108 | \qmlproperty color Axis::color | |
109 | The color of the axis and ticks. |
|
109 | The color of the axis and ticks. | |
110 | */ |
|
110 | */ | |
111 |
|
111 | |||
112 | /*! |
|
112 | /*! | |
113 | \property QAxis::labelsFont |
|
113 | \property QAxis::labelsFont | |
114 | The font of the axis labels. |
|
114 | The font of the axis labels. | |
115 | */ |
|
115 | */ | |
116 | /*! |
|
116 | /*! | |
117 | \qmlproperty Font Axis::labelsFont |
|
117 | \qmlproperty Font Axis::labelsFont | |
118 | The font of the axis labels. |
|
118 | The font of the axis labels. | |
119 |
|
119 | |||
120 | See the \l {Font} {QML Font Element} for detailed documentation. |
|
120 | See the \l {Font} {QML Font Element} for detailed documentation. | |
121 | */ |
|
121 | */ | |
122 |
|
122 | |||
123 | /*! |
|
123 | /*! | |
124 | \property QAxis::labelsColor |
|
124 | \property QAxis::labelsColor | |
125 | The color of the axis labels. |
|
125 | The color of the axis labels. | |
126 | */ |
|
126 | */ | |
127 | /*! |
|
127 | /*! | |
128 | \qmlproperty color Axis::labelsColor |
|
128 | \qmlproperty color Axis::labelsColor | |
129 | The color of the axis labels. |
|
129 | The color of the axis labels. | |
130 | */ |
|
130 | */ | |
131 |
|
131 | |||
132 | /*! |
|
132 | /*! | |
133 | \property QAxis::labelsAngle |
|
133 | \property QAxis::labelsAngle | |
134 | The angle of the axis labels in degrees. |
|
134 | The angle of the axis labels in degrees. | |
135 | */ |
|
135 | */ | |
136 | /*! |
|
136 | /*! | |
137 | \qmlproperty int Axis::labelsAngle |
|
137 | \qmlproperty int Axis::labelsAngle | |
138 | The angle of the axis labels in degrees. |
|
138 | The angle of the axis labels in degrees. | |
139 | */ |
|
139 | */ | |
140 |
|
140 | |||
141 | /*! |
|
141 | /*! | |
142 | \property QAxis::shadesVisible |
|
142 | \property QAxis::shadesVisible | |
143 | The visibility of the axis shades. |
|
143 | The visibility of the axis shades. | |
144 | */ |
|
144 | */ | |
145 | /*! |
|
145 | /*! | |
146 | \qmlproperty bool Axis::shadesVisible |
|
146 | \qmlproperty bool Axis::shadesVisible | |
147 | The visibility of the axis shades. |
|
147 | The visibility of the axis shades. | |
148 | */ |
|
148 | */ | |
149 |
|
149 | |||
150 | /*! |
|
150 | /*! | |
151 | \property QAxis::shadesColor |
|
151 | \property QAxis::shadesColor | |
152 | The fill (brush) color of the axis shades. |
|
152 | The fill (brush) color of the axis shades. | |
153 | */ |
|
153 | */ | |
154 | /*! |
|
154 | /*! | |
155 | \qmlproperty color Axis::shadesColor |
|
155 | \qmlproperty color Axis::shadesColor | |
156 | The fill (brush) color of the axis shades. |
|
156 | The fill (brush) color of the axis shades. | |
157 | */ |
|
157 | */ | |
158 |
|
158 | |||
159 | /*! |
|
159 | /*! | |
160 | \property QAxis::shadesBorderColor |
|
160 | \property QAxis::shadesBorderColor | |
161 | The border (pen) color of the axis shades. |
|
161 | The border (pen) color of the axis shades. | |
162 | */ |
|
162 | */ | |
163 | /*! |
|
163 | /*! | |
164 | \qmlproperty color Axis::shadesBorderColor |
|
164 | \qmlproperty color Axis::shadesBorderColor | |
165 | The border (pen) color of the axis shades. |
|
165 | The border (pen) color of the axis shades. | |
166 | */ |
|
166 | */ | |
167 |
|
167 | |||
168 | /*! |
|
168 | /*! | |
169 | \property QAxis::ticksCount |
|
169 | \property QAxis::ticksCount | |
170 | The number of tick marks for the axis. |
|
170 | The number of tick marks for the axis. | |
171 | */ |
|
171 | */ | |
172 | /*! |
|
172 | /*! | |
173 | \qmlproperty int Axis::ticksCount |
|
173 | \qmlproperty int Axis::ticksCount | |
174 | The number of tick marks for the axis. |
|
174 | The number of tick marks for the axis. | |
175 | */ |
|
175 | */ | |
176 |
|
176 | |||
177 | /*! |
|
177 | /*! | |
178 | \property QAxis::niceNumbersEnabled |
|
178 | \property QAxis::niceNumbersEnabled | |
179 | Whether the nice numbers algorithm is enabled or not for the axis. |
|
179 | Whether the nice numbers algorithm is enabled or not for the axis. | |
180 | */ |
|
180 | */ | |
181 | /*! |
|
181 | /*! | |
182 | \qmlproperty bool Axis::niceNumbersEnabled |
|
182 | \qmlproperty bool Axis::niceNumbersEnabled | |
183 | Whether the nice numbers algorithm is enabled or not for the axis. |
|
183 | Whether the nice numbers algorithm is enabled or not for the axis. | |
184 | */ |
|
184 | */ | |
185 |
|
185 | |||
186 | /*! |
|
186 | /*! | |
187 | \fn void QAxis::visibleChanged(bool) |
|
187 | \fn void QAxis::visibleChanged(bool) | |
188 | Visiblity of the axis has changed to \a visible. |
|
188 | Visiblity of the axis has changed to \a visible. | |
189 | */ |
|
189 | */ | |
190 |
|
190 | |||
191 | /*! |
|
191 | /*! | |
192 | \fn void QAxis::labelsVisibleChanged(bool) |
|
192 | \fn void QAxis::labelsVisibleChanged(bool) | |
193 | Visiblity of the labels of the axis has changed to \a visible. |
|
193 | Visiblity of the labels of the axis has changed to \a visible. | |
194 | */ |
|
194 | */ | |
195 |
|
195 | |||
196 | /*! |
|
196 | /*! | |
197 | \fn void QAxis::gridVisibleChanged(bool) |
|
197 | \fn void QAxis::gridVisibleChanged(bool) | |
198 | Visiblity of the grid lines of the axis has changed to \a visible. |
|
198 | Visiblity of the grid lines of the axis has changed to \a visible. | |
199 | */ |
|
199 | */ | |
200 |
|
200 | |||
201 | /*! |
|
201 | /*! | |
202 | \fn void QAxis::minChanged(qreal min) |
|
202 | \fn void QAxis::minChanged(qreal min) | |
203 | Axis emits signal when \a min of axis has changed. |
|
203 | Axis emits signal when \a min of axis has changed. | |
204 | */ |
|
204 | */ | |
|
205 | /*! | |||
|
206 | \qmlsignal Axis::onMinChanged(real min) | |||
|
207 | Axis emits signal when \a min of axis has changed. This may happen for example if you zoom, scroll or | |||
|
208 | enable nice numbers algorithm. | |||
|
209 | */ | |||
205 |
|
210 | |||
206 | /*! |
|
211 | /*! | |
207 | \fn void QAxis::maxChanged(qreal max) |
|
212 | \fn void QAxis::maxChanged(qreal max) | |
208 | Axis emits signal when \a max of axis has changed. |
|
213 | Axis emits signal when \a max of axis has changed. | |
209 | */ |
|
214 | */ | |
|
215 | /*! | |||
|
216 | \qmlsignal Axis::onMaxChanged(real max) | |||
|
217 | Axis emits signal when \a max of axis has changed. This may happen for example if you zoom, scroll or | |||
|
218 | enable nice numbers algorithm. | |||
|
219 | */ | |||
210 |
|
220 | |||
211 | /*! |
|
221 | /*! | |
212 | \fn void QAxis::rangeChanged(qreal min, qreal max) |
|
222 | \fn void QAxis::rangeChanged(qreal min, qreal max) | |
213 | Axis emits signal when \a min or \a max of axis has changed. |
|
223 | Axis emits signal when \a min or \a max of axis has changed. | |
214 | */ |
|
224 | */ | |
|
225 | /*! | |||
|
226 | \qmlsignal Axis::onRangeChanged(real min, real max) | |||
|
227 | Axis emits signal when \a min or \a max of axis has changed. This may happen for example if you zoom, scroll or | |||
|
228 | enable nice numbers algorithm. | |||
|
229 | */ | |||
215 |
|
230 | |||
216 | /*! |
|
231 | /*! | |
217 | \fn QChartAxisCategories* QAxis::categories() |
|
232 | \fn QChartAxisCategories* QAxis::categories() | |
218 | Returns pointer to the list of categories which correspond to the values on the axis. |
|
233 | Returns pointer to the list of categories which correspond to the values on the axis. | |
219 | */ |
|
234 | */ | |
220 |
|
235 | |||
221 | /*! |
|
236 | /*! | |
222 | \fn void QAxis::colorChanged(QColor) |
|
237 | \fn void QAxis::colorChanged(QColor) | |
223 | Emitted if the \a color of the axis is changed. |
|
238 | Emitted if the \a color of the axis is changed. | |
224 | */ |
|
239 | */ | |
225 |
|
240 | |||
226 | /*! |
|
241 | /*! | |
227 | \fn void QAxis::labelsColorChanged(QColor) |
|
242 | \fn void QAxis::labelsColorChanged(QColor) | |
228 | Emitted if the \a color of the axis labels is changed. |
|
243 | Emitted if the \a color of the axis labels is changed. | |
229 | */ |
|
244 | */ | |
230 |
|
245 | |||
231 | /*! |
|
246 | /*! | |
232 | \fn void QAxis::shadesVisibleChanged(bool) |
|
247 | \fn void QAxis::shadesVisibleChanged(bool) | |
233 | Emitted if the visibility of the axis shades is changed to \a visible. |
|
248 | Emitted if the visibility of the axis shades is changed to \a visible. | |
234 | */ |
|
249 | */ | |
235 |
|
250 | |||
236 | /*! |
|
251 | /*! | |
237 | \fn void QAxis::shadesColorChanged(QColor) |
|
252 | \fn void QAxis::shadesColorChanged(QColor) | |
238 | Emitted if the \a color of the axis shades is changed. |
|
253 | Emitted if the \a color of the axis shades is changed. | |
239 | */ |
|
254 | */ | |
240 |
|
255 | |||
241 | /*! |
|
256 | /*! | |
242 | \fn void QAxis::shadesBorderColorChanged(QColor) |
|
257 | \fn void QAxis::shadesBorderColorChanged(QColor) | |
243 | Emitted if the border \a color of the axis shades is changed. |
|
258 | Emitted if the border \a color of the axis shades is changed. | |
244 | */ |
|
259 | */ | |
245 |
|
260 | |||
246 | /*! |
|
261 | /*! | |
247 | Constructs new axis object which is a child of \a parent. Ownership is taken by |
|
262 | Constructs new axis object which is a child of \a parent. Ownership is taken by | |
248 | QChart when axis added. |
|
263 | QChart when axis added. | |
249 | */ |
|
264 | */ | |
250 | QAxis::QAxis(QObject *parent) : QObject(parent), |
|
265 | QAxis::QAxis(QObject *parent) : QObject(parent), | |
251 | d_ptr(new QAxisPrivate(this)) |
|
266 | d_ptr(new QAxisPrivate(this)) | |
252 | { |
|
267 | { | |
253 |
|
268 | |||
254 | } |
|
269 | } | |
255 |
|
270 | |||
256 | /*! |
|
271 | /*! | |
257 | Destructor of the axis object. When axis is added to chart, chart object takes ownership. |
|
272 | Destructor of the axis object. When axis is added to chart, chart object takes ownership. | |
258 | */ |
|
273 | */ | |
259 |
|
274 | |||
260 | QAxis::~QAxis() |
|
275 | QAxis::~QAxis() | |
261 | { |
|
276 | { | |
262 | } |
|
277 | } | |
263 |
|
278 | |||
264 | /*! |
|
279 | /*! | |
265 | Sets \a pen used to draw axis line and ticks. |
|
280 | Sets \a pen used to draw axis line and ticks. | |
266 | */ |
|
281 | */ | |
267 | void QAxis::setAxisPen(const QPen &pen) |
|
282 | void QAxis::setAxisPen(const QPen &pen) | |
268 | { |
|
283 | { | |
269 | if (d_ptr->m_axisPen!=pen) { |
|
284 | if (d_ptr->m_axisPen!=pen) { | |
270 | d_ptr->m_axisPen = pen; |
|
285 | d_ptr->m_axisPen = pen; | |
271 | emit d_ptr->updated(); |
|
286 | emit d_ptr->updated(); | |
272 | } |
|
287 | } | |
273 | } |
|
288 | } | |
274 |
|
289 | |||
275 | /*! |
|
290 | /*! | |
276 | Returns pen used to draw axis and ticks. |
|
291 | Returns pen used to draw axis and ticks. | |
277 | */ |
|
292 | */ | |
278 | QPen QAxis::axisPen() const |
|
293 | QPen QAxis::axisPen() const | |
279 | { |
|
294 | { | |
280 | return d_ptr->m_axisPen; |
|
295 | return d_ptr->m_axisPen; | |
281 | } |
|
296 | } | |
282 |
|
297 | |||
283 | void QAxis::setAxisPenColor(QColor color) |
|
298 | void QAxis::setAxisPenColor(QColor color) | |
284 | { |
|
299 | { | |
285 | QPen p = d_ptr->m_axisPen; |
|
300 | QPen p = d_ptr->m_axisPen; | |
286 | if (p.color() != color) { |
|
301 | if (p.color() != color) { | |
287 | p.setColor(color); |
|
302 | p.setColor(color); | |
288 | setAxisPen(p); |
|
303 | setAxisPen(p); | |
289 | emit colorChanged(color); |
|
304 | emit colorChanged(color); | |
290 | } |
|
305 | } | |
291 | } |
|
306 | } | |
292 |
|
307 | |||
293 | QColor QAxis::axisPenColor() const |
|
308 | QColor QAxis::axisPenColor() const | |
294 | { |
|
309 | { | |
295 | return d_ptr->m_axisPen.color(); |
|
310 | return d_ptr->m_axisPen.color(); | |
296 | } |
|
311 | } | |
297 |
|
312 | |||
298 | /*! |
|
313 | /*! | |
299 | Sets if axis and ticks are \a visible. |
|
314 | Sets if axis and ticks are \a visible. | |
300 | */ |
|
315 | */ | |
301 | void QAxis::setAxisVisible(bool visible) |
|
316 | void QAxis::setAxisVisible(bool visible) | |
302 | { |
|
317 | { | |
303 | if (d_ptr->m_axisVisible != visible) { |
|
318 | if (d_ptr->m_axisVisible != visible) { | |
304 | d_ptr->m_axisVisible = visible; |
|
319 | d_ptr->m_axisVisible = visible; | |
305 | emit d_ptr->updated(); |
|
320 | emit d_ptr->updated(); | |
306 | emit visibleChanged(visible); |
|
321 | emit visibleChanged(visible); | |
307 | } |
|
322 | } | |
308 | } |
|
323 | } | |
309 |
|
324 | |||
310 | bool QAxis::isAxisVisible() const |
|
325 | bool QAxis::isAxisVisible() const | |
311 | { |
|
326 | { | |
312 | return d_ptr->m_axisVisible; |
|
327 | return d_ptr->m_axisVisible; | |
313 | } |
|
328 | } | |
314 |
|
329 | |||
315 | void QAxis::setGridLineVisible(bool visible) |
|
330 | void QAxis::setGridLineVisible(bool visible) | |
316 | { |
|
331 | { | |
317 | if (d_ptr->m_gridLineVisible != visible) { |
|
332 | if (d_ptr->m_gridLineVisible != visible) { | |
318 | d_ptr->m_gridLineVisible = visible; |
|
333 | d_ptr->m_gridLineVisible = visible; | |
319 | emit d_ptr->updated(); |
|
334 | emit d_ptr->updated(); | |
320 | emit gridVisibleChanged(visible); |
|
335 | emit gridVisibleChanged(visible); | |
321 | } |
|
336 | } | |
322 | } |
|
337 | } | |
323 |
|
338 | |||
324 | bool QAxis::isGridLineVisible() const |
|
339 | bool QAxis::isGridLineVisible() const | |
325 | { |
|
340 | { | |
326 | return d_ptr->m_gridLineVisible; |
|
341 | return d_ptr->m_gridLineVisible; | |
327 | } |
|
342 | } | |
328 |
|
343 | |||
329 | /*! |
|
344 | /*! | |
330 | Sets \a pen used to draw grid line. |
|
345 | Sets \a pen used to draw grid line. | |
331 | */ |
|
346 | */ | |
332 | void QAxis::setGridLinePen(const QPen &pen) |
|
347 | void QAxis::setGridLinePen(const QPen &pen) | |
333 | { |
|
348 | { | |
334 | if (d_ptr->m_gridLinePen != pen) { |
|
349 | if (d_ptr->m_gridLinePen != pen) { | |
335 | d_ptr->m_gridLinePen = pen; |
|
350 | d_ptr->m_gridLinePen = pen; | |
336 | emit d_ptr->updated(); |
|
351 | emit d_ptr->updated(); | |
337 | } |
|
352 | } | |
338 | } |
|
353 | } | |
339 |
|
354 | |||
340 | /*! |
|
355 | /*! | |
341 | Returns pen used to draw grid. |
|
356 | Returns pen used to draw grid. | |
342 | */ |
|
357 | */ | |
343 | QPen QAxis::gridLinePen() const |
|
358 | QPen QAxis::gridLinePen() const | |
344 | { |
|
359 | { | |
345 | return d_ptr->m_gridLinePen; |
|
360 | return d_ptr->m_gridLinePen; | |
346 | } |
|
361 | } | |
347 |
|
362 | |||
348 | void QAxis::setLabelsVisible(bool visible) |
|
363 | void QAxis::setLabelsVisible(bool visible) | |
349 | { |
|
364 | { | |
350 | if (d_ptr->m_labelsVisible != visible) { |
|
365 | if (d_ptr->m_labelsVisible != visible) { | |
351 | d_ptr->m_labelsVisible = visible; |
|
366 | d_ptr->m_labelsVisible = visible; | |
352 | emit d_ptr->updated(); |
|
367 | emit d_ptr->updated(); | |
353 | emit labelsVisibleChanged(visible); |
|
368 | emit labelsVisibleChanged(visible); | |
354 | } |
|
369 | } | |
355 | } |
|
370 | } | |
356 |
|
371 | |||
357 | bool QAxis::labelsVisible() const |
|
372 | bool QAxis::labelsVisible() const | |
358 | { |
|
373 | { | |
359 | return d_ptr->m_labelsVisible; |
|
374 | return d_ptr->m_labelsVisible; | |
360 | } |
|
375 | } | |
361 |
|
376 | |||
362 | /*! |
|
377 | /*! | |
363 | Sets \a pen used to draw labels. |
|
378 | Sets \a pen used to draw labels. | |
364 | */ |
|
379 | */ | |
365 | void QAxis::setLabelsPen(const QPen &pen) |
|
380 | void QAxis::setLabelsPen(const QPen &pen) | |
366 | { |
|
381 | { | |
367 | if (d_ptr->m_labelsPen != pen) { |
|
382 | if (d_ptr->m_labelsPen != pen) { | |
368 | d_ptr->m_labelsPen = pen; |
|
383 | d_ptr->m_labelsPen = pen; | |
369 | emit d_ptr->updated(); |
|
384 | emit d_ptr->updated(); | |
370 | } |
|
385 | } | |
371 | } |
|
386 | } | |
372 |
|
387 | |||
373 | /*! |
|
388 | /*! | |
374 | Returns the pen used to labels. |
|
389 | Returns the pen used to labels. | |
375 | */ |
|
390 | */ | |
376 | QPen QAxis::labelsPen() const |
|
391 | QPen QAxis::labelsPen() const | |
377 | { |
|
392 | { | |
378 | return d_ptr->m_labelsPen; |
|
393 | return d_ptr->m_labelsPen; | |
379 | } |
|
394 | } | |
380 |
|
395 | |||
381 | /*! |
|
396 | /*! | |
382 | Sets \a brush used to draw labels. |
|
397 | Sets \a brush used to draw labels. | |
383 | */ |
|
398 | */ | |
384 | void QAxis::setLabelsBrush(const QBrush &brush) |
|
399 | void QAxis::setLabelsBrush(const QBrush &brush) | |
385 | { |
|
400 | { | |
386 | if (d_ptr->m_labelsBrush != brush) { |
|
401 | if (d_ptr->m_labelsBrush != brush) { | |
387 | d_ptr->m_labelsBrush = brush; |
|
402 | d_ptr->m_labelsBrush = brush; | |
388 | emit d_ptr->updated(); |
|
403 | emit d_ptr->updated(); | |
389 | } |
|
404 | } | |
390 | } |
|
405 | } | |
391 |
|
406 | |||
392 | /*! |
|
407 | /*! | |
393 | Returns brush used to draw labels. |
|
408 | Returns brush used to draw labels. | |
394 | */ |
|
409 | */ | |
395 | QBrush QAxis::labelsBrush() const |
|
410 | QBrush QAxis::labelsBrush() const | |
396 | { |
|
411 | { | |
397 | return d_ptr->m_labelsBrush; |
|
412 | return d_ptr->m_labelsBrush; | |
398 | } |
|
413 | } | |
399 |
|
414 | |||
400 | /*! |
|
415 | /*! | |
401 | Sets \a font used to draw labels. |
|
416 | Sets \a font used to draw labels. | |
402 | */ |
|
417 | */ | |
403 | void QAxis::setLabelsFont(const QFont &font) |
|
418 | void QAxis::setLabelsFont(const QFont &font) | |
404 | { |
|
419 | { | |
405 | if (d_ptr->m_labelsFont != font) { |
|
420 | if (d_ptr->m_labelsFont != font) { | |
406 | d_ptr->m_labelsFont = font; |
|
421 | d_ptr->m_labelsFont = font; | |
407 | emit d_ptr->updated(); |
|
422 | emit d_ptr->updated(); | |
408 | } |
|
423 | } | |
409 | } |
|
424 | } | |
410 |
|
425 | |||
411 | /*! |
|
426 | /*! | |
412 | Returns font used to draw labels. |
|
427 | Returns font used to draw labels. | |
413 | */ |
|
428 | */ | |
414 | QFont QAxis::labelsFont() const |
|
429 | QFont QAxis::labelsFont() const | |
415 | { |
|
430 | { | |
416 | return d_ptr->m_labelsFont; |
|
431 | return d_ptr->m_labelsFont; | |
417 | } |
|
432 | } | |
418 |
|
433 | |||
419 | void QAxis::setLabelsAngle(int angle) |
|
434 | void QAxis::setLabelsAngle(int angle) | |
420 | { |
|
435 | { | |
421 | if (d_ptr->m_labelsAngle != angle) { |
|
436 | if (d_ptr->m_labelsAngle != angle) { | |
422 | d_ptr->m_labelsAngle = angle; |
|
437 | d_ptr->m_labelsAngle = angle; | |
423 | emit d_ptr->updated(); |
|
438 | emit d_ptr->updated(); | |
424 | } |
|
439 | } | |
425 | } |
|
440 | } | |
426 |
|
441 | |||
427 | int QAxis::labelsAngle() const |
|
442 | int QAxis::labelsAngle() const | |
428 | { |
|
443 | { | |
429 | return d_ptr->m_labelsAngle; |
|
444 | return d_ptr->m_labelsAngle; | |
430 | } |
|
445 | } | |
431 |
|
446 | |||
432 | void QAxis::setLabelsColor(QColor color) |
|
447 | void QAxis::setLabelsColor(QColor color) | |
433 | { |
|
448 | { | |
434 | QBrush b = d_ptr->m_labelsBrush; |
|
449 | QBrush b = d_ptr->m_labelsBrush; | |
435 | if (b.color() != color) { |
|
450 | if (b.color() != color) { | |
436 | b.setColor(color); |
|
451 | b.setColor(color); | |
437 | setLabelsBrush(b); |
|
452 | setLabelsBrush(b); | |
438 | emit labelsColorChanged(color); |
|
453 | emit labelsColorChanged(color); | |
439 | } |
|
454 | } | |
440 | } |
|
455 | } | |
441 |
|
456 | |||
442 | QColor QAxis::labelsColor() const |
|
457 | QColor QAxis::labelsColor() const | |
443 | { |
|
458 | { | |
444 | return d_ptr->m_labelsBrush.color(); |
|
459 | return d_ptr->m_labelsBrush.color(); | |
445 | } |
|
460 | } | |
446 |
|
461 | |||
447 | void QAxis::setShadesVisible(bool visible) |
|
462 | void QAxis::setShadesVisible(bool visible) | |
448 | { |
|
463 | { | |
449 | if (d_ptr->m_shadesVisible != visible) { |
|
464 | if (d_ptr->m_shadesVisible != visible) { | |
450 | d_ptr->m_shadesVisible = visible; |
|
465 | d_ptr->m_shadesVisible = visible; | |
451 | emit d_ptr->updated(); |
|
466 | emit d_ptr->updated(); | |
452 | emit shadesVisibleChanged(visible); |
|
467 | emit shadesVisibleChanged(visible); | |
453 | } |
|
468 | } | |
454 | } |
|
469 | } | |
455 |
|
470 | |||
456 | bool QAxis::shadesVisible() const |
|
471 | bool QAxis::shadesVisible() const | |
457 | { |
|
472 | { | |
458 | return d_ptr->m_shadesVisible; |
|
473 | return d_ptr->m_shadesVisible; | |
459 | } |
|
474 | } | |
460 |
|
475 | |||
461 | /*! |
|
476 | /*! | |
462 | Sets \a pen used to draw shades. |
|
477 | Sets \a pen used to draw shades. | |
463 | */ |
|
478 | */ | |
464 | void QAxis::setShadesPen(const QPen &pen) |
|
479 | void QAxis::setShadesPen(const QPen &pen) | |
465 | { |
|
480 | { | |
466 | if (d_ptr->m_shadesPen != pen) { |
|
481 | if (d_ptr->m_shadesPen != pen) { | |
467 | d_ptr->m_shadesPen = pen; |
|
482 | d_ptr->m_shadesPen = pen; | |
468 | emit d_ptr->updated(); |
|
483 | emit d_ptr->updated(); | |
469 | } |
|
484 | } | |
470 | } |
|
485 | } | |
471 |
|
486 | |||
472 | /*! |
|
487 | /*! | |
473 | Returns pen used to draw shades. |
|
488 | Returns pen used to draw shades. | |
474 | */ |
|
489 | */ | |
475 | QPen QAxis::shadesPen() const |
|
490 | QPen QAxis::shadesPen() const | |
476 | { |
|
491 | { | |
477 | return d_ptr->m_shadesPen; |
|
492 | return d_ptr->m_shadesPen; | |
478 | } |
|
493 | } | |
479 |
|
494 | |||
480 | /*! |
|
495 | /*! | |
481 | Sets \a brush used to draw shades. |
|
496 | Sets \a brush used to draw shades. | |
482 | */ |
|
497 | */ | |
483 | void QAxis::setShadesBrush(const QBrush &brush) |
|
498 | void QAxis::setShadesBrush(const QBrush &brush) | |
484 | { |
|
499 | { | |
485 | if (d_ptr->m_shadesBrush != brush) { |
|
500 | if (d_ptr->m_shadesBrush != brush) { | |
486 | d_ptr->m_shadesBrush = brush; |
|
501 | d_ptr->m_shadesBrush = brush; | |
487 | emit d_ptr->updated(); |
|
502 | emit d_ptr->updated(); | |
488 | emit shadesColorChanged(brush.color()); |
|
503 | emit shadesColorChanged(brush.color()); | |
489 | } |
|
504 | } | |
490 | } |
|
505 | } | |
491 |
|
506 | |||
492 | /*! |
|
507 | /*! | |
493 | \brief Returns brush used to draw shades. |
|
508 | \brief Returns brush used to draw shades. | |
494 | */ |
|
509 | */ | |
495 | QBrush QAxis::shadesBrush() const |
|
510 | QBrush QAxis::shadesBrush() const | |
496 | { |
|
511 | { | |
497 | return d_ptr->m_shadesBrush; |
|
512 | return d_ptr->m_shadesBrush; | |
498 | } |
|
513 | } | |
499 |
|
514 | |||
500 | void QAxis::setShadesColor(QColor color) |
|
515 | void QAxis::setShadesColor(QColor color) | |
501 | { |
|
516 | { | |
502 | QBrush b = d_ptr->m_shadesBrush; |
|
517 | QBrush b = d_ptr->m_shadesBrush; | |
503 | b.setColor(color); |
|
518 | b.setColor(color); | |
504 | setShadesBrush(b); |
|
519 | setShadesBrush(b); | |
505 | } |
|
520 | } | |
506 |
|
521 | |||
507 | QColor QAxis::shadesColor() const |
|
522 | QColor QAxis::shadesColor() const | |
508 | { |
|
523 | { | |
509 | return d_ptr->m_shadesBrush.color(); |
|
524 | return d_ptr->m_shadesBrush.color(); | |
510 | } |
|
525 | } | |
511 |
|
526 | |||
512 | void QAxis::setShadesBorderColor(QColor color) |
|
527 | void QAxis::setShadesBorderColor(QColor color) | |
513 | { |
|
528 | { | |
514 | QPen p = d_ptr->m_shadesPen; |
|
529 | QPen p = d_ptr->m_shadesPen; | |
515 | p.setColor(color); |
|
530 | p.setColor(color); | |
516 | setShadesPen(p); |
|
531 | setShadesPen(p); | |
517 | } |
|
532 | } | |
518 |
|
533 | |||
519 | QColor QAxis::shadesBorderColor() const |
|
534 | QColor QAxis::shadesBorderColor() const | |
520 | { |
|
535 | { | |
521 | return d_ptr->m_shadesPen.color(); |
|
536 | return d_ptr->m_shadesPen.color(); | |
522 | } |
|
537 | } | |
523 |
|
538 | |||
524 | void QAxis::setMin(qreal min) |
|
539 | void QAxis::setMin(qreal min) | |
525 | { |
|
540 | { | |
526 | setRange(min,d_ptr->m_max); |
|
541 | setRange(min,d_ptr->m_max); | |
527 | } |
|
542 | } | |
528 |
|
543 | |||
529 | qreal QAxis::min() const |
|
544 | qreal QAxis::min() const | |
530 | { |
|
545 | { | |
531 | return d_ptr->m_min; |
|
546 | return d_ptr->m_min; | |
532 | } |
|
547 | } | |
533 |
|
548 | |||
534 | void QAxis::setMax(qreal max) |
|
549 | void QAxis::setMax(qreal max) | |
535 | { |
|
550 | { | |
536 | setRange(d_ptr->m_min,max); |
|
551 | setRange(d_ptr->m_min,max); | |
537 | } |
|
552 | } | |
538 |
|
553 | |||
539 | qreal QAxis::max() const |
|
554 | qreal QAxis::max() const | |
540 | { |
|
555 | { | |
541 | return d_ptr->m_max; |
|
556 | return d_ptr->m_max; | |
542 | } |
|
557 | } | |
543 |
|
558 | |||
544 | /*! |
|
559 | /*! | |
545 | Sets range from \a min to \a max on the axis. |
|
560 | Sets range from \a min to \a max on the axis. | |
546 | */ |
|
561 | */ | |
547 | void QAxis::setRange(qreal min, qreal max) |
|
562 | void QAxis::setRange(qreal min, qreal max) | |
548 | { |
|
563 | { | |
549 | bool changed = false; |
|
564 | bool changed = false; | |
550 | if (!qFuzzyIsNull(d_ptr->m_min - min)) { |
|
565 | if (!qFuzzyIsNull(d_ptr->m_min - min)) { | |
551 | d_ptr->m_min = min; |
|
566 | d_ptr->m_min = min; | |
552 | changed = true; |
|
567 | changed = true; | |
553 | emit minChanged(min); |
|
568 | emit minChanged(min); | |
554 | } |
|
569 | } | |
555 |
|
570 | |||
556 | if (!qFuzzyIsNull(d_ptr->m_max - max)) { |
|
571 | if (!qFuzzyIsNull(d_ptr->m_max - max)) { | |
557 | d_ptr->m_max = max; |
|
572 | d_ptr->m_max = max; | |
558 | changed = true; |
|
573 | changed = true; | |
559 | emit maxChanged(max); |
|
574 | emit maxChanged(max); | |
560 | } |
|
575 | } | |
561 |
|
576 | |||
562 | if (changed) { |
|
577 | if (changed) { | |
563 | emit rangeChanged(d_ptr->m_min,d_ptr->m_max); |
|
578 | emit rangeChanged(d_ptr->m_min,d_ptr->m_max); | |
564 | emit d_ptr->changed(d_ptr->m_min, d_ptr->m_max, d_ptr->m_ticksCount, d_ptr->m_niceNumbers); |
|
579 | emit d_ptr->changed(d_ptr->m_min, d_ptr->m_max, d_ptr->m_ticksCount, d_ptr->m_niceNumbers); | |
565 | } |
|
580 | } | |
566 | } |
|
581 | } | |
567 |
|
582 | |||
568 | /*! |
|
583 | /*! | |
569 | Sets \a count for ticks on the axis. |
|
584 | Sets \a count for ticks on the axis. | |
570 | */ |
|
585 | */ | |
571 | void QAxis::setTicksCount(int count) |
|
586 | void QAxis::setTicksCount(int count) | |
572 | { |
|
587 | { | |
573 | if (d_ptr->m_ticksCount != count) { |
|
588 | if (d_ptr->m_ticksCount != count) { | |
574 | d_ptr->m_ticksCount = count; |
|
589 | d_ptr->m_ticksCount = count; | |
575 | emit d_ptr->changed(d_ptr->m_min, d_ptr->m_max, d_ptr->m_ticksCount, d_ptr->m_niceNumbers); |
|
590 | emit d_ptr->changed(d_ptr->m_min, d_ptr->m_max, d_ptr->m_ticksCount, d_ptr->m_niceNumbers); | |
576 | } |
|
591 | } | |
577 | } |
|
592 | } | |
578 |
|
593 | |||
579 | /*! |
|
594 | /*! | |
580 | \fn int QAxis::ticksCount() const |
|
595 | \fn int QAxis::ticksCount() const | |
581 | Return number of ticks on the axis |
|
596 | Return number of ticks on the axis | |
582 | */ |
|
597 | */ | |
583 | int QAxis::ticksCount() const |
|
598 | int QAxis::ticksCount() const | |
584 | { |
|
599 | { | |
585 | return d_ptr->m_ticksCount; |
|
600 | return d_ptr->m_ticksCount; | |
586 | } |
|
601 | } | |
587 |
|
602 | |||
588 | /*! |
|
603 | /*! | |
589 | Sets axis, shades, labels and grid lines to be visible. |
|
604 | Sets axis, shades, labels and grid lines to be visible. | |
590 | */ |
|
605 | */ | |
591 | void QAxis::show() |
|
606 | void QAxis::show() | |
592 | { |
|
607 | { | |
593 | d_ptr->m_axisVisible=true; |
|
608 | d_ptr->m_axisVisible=true; | |
594 | d_ptr->m_gridLineVisible=true; |
|
609 | d_ptr->m_gridLineVisible=true; | |
595 | d_ptr->m_labelsVisible=true; |
|
610 | d_ptr->m_labelsVisible=true; | |
596 | d_ptr->m_shadesVisible=true; |
|
611 | d_ptr->m_shadesVisible=true; | |
597 | emit d_ptr->updated(); |
|
612 | emit d_ptr->updated(); | |
598 | } |
|
613 | } | |
599 |
|
614 | |||
600 | /*! |
|
615 | /*! | |
601 | Sets axis, shades, labels and grid lines to not be visible. |
|
616 | Sets axis, shades, labels and grid lines to not be visible. | |
602 | */ |
|
617 | */ | |
603 | void QAxis::hide() |
|
618 | void QAxis::hide() | |
604 | { |
|
619 | { | |
605 | d_ptr->m_axisVisible = false; |
|
620 | d_ptr->m_axisVisible = false; | |
606 | d_ptr->m_gridLineVisible = false; |
|
621 | d_ptr->m_gridLineVisible = false; | |
607 | d_ptr->m_labelsVisible = false; |
|
622 | d_ptr->m_labelsVisible = false; | |
608 | d_ptr->m_shadesVisible = false; |
|
623 | d_ptr->m_shadesVisible = false; | |
609 | emit d_ptr->updated(); |
|
624 | emit d_ptr->updated(); | |
610 | } |
|
625 | } | |
611 |
|
626 | |||
612 | void QAxis::setNiceNumbersEnabled(bool enable) |
|
627 | void QAxis::setNiceNumbersEnabled(bool enable) | |
613 | { |
|
628 | { | |
614 | if (d_ptr->m_niceNumbers != enable){ |
|
629 | if (d_ptr->m_niceNumbers != enable){ | |
615 | d_ptr->m_niceNumbers = enable; |
|
630 | d_ptr->m_niceNumbers = enable; | |
616 | emit d_ptr->changed(d_ptr->m_min, d_ptr->m_max, d_ptr->m_ticksCount, d_ptr->m_niceNumbers); |
|
631 | emit d_ptr->changed(d_ptr->m_min, d_ptr->m_max, d_ptr->m_ticksCount, d_ptr->m_niceNumbers); | |
617 | } |
|
632 | } | |
618 | } |
|
633 | } | |
619 |
|
634 | |||
620 | bool QAxis::niceNumbersEnabled() const |
|
635 | bool QAxis::niceNumbersEnabled() const | |
621 | { |
|
636 | { | |
622 | return d_ptr->m_niceNumbers; |
|
637 | return d_ptr->m_niceNumbers; | |
623 | } |
|
638 | } | |
624 |
|
639 | |||
625 | QAxisCategories* QAxis::categories() |
|
640 | QAxisCategories* QAxis::categories() | |
626 | { |
|
641 | { | |
627 | return &d_ptr->m_category; |
|
642 | return &d_ptr->m_category; | |
628 | } |
|
643 | } | |
629 |
|
644 | |||
630 | ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
|
645 | ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |
631 |
|
646 | |||
632 | QAxisPrivate::QAxisPrivate(QAxis* q): |
|
647 | QAxisPrivate::QAxisPrivate(QAxis* q): | |
633 | q_ptr(q), |
|
648 | q_ptr(q), | |
634 | m_axisVisible(true), |
|
649 | m_axisVisible(true), | |
635 | m_gridLineVisible(true), |
|
650 | m_gridLineVisible(true), | |
636 | m_labelsVisible(true), |
|
651 | m_labelsVisible(true), | |
637 | m_labelsAngle(0), |
|
652 | m_labelsAngle(0), | |
638 | m_shadesVisible(false), |
|
653 | m_shadesVisible(false), | |
639 | m_shadesBrush(Qt::SolidPattern), |
|
654 | m_shadesBrush(Qt::SolidPattern), | |
640 | m_shadesOpacity(1.0), |
|
655 | m_shadesOpacity(1.0), | |
641 | m_min(0), |
|
656 | m_min(0), | |
642 | m_max(0), |
|
657 | m_max(0), | |
643 | m_ticksCount(5), |
|
658 | m_ticksCount(5), | |
644 | m_niceNumbers(false) |
|
659 | m_niceNumbers(false) | |
645 | { |
|
660 | { | |
646 |
|
661 | |||
647 | } |
|
662 | } | |
648 |
|
663 | |||
649 | QAxisPrivate::~QAxisPrivate() |
|
664 | QAxisPrivate::~QAxisPrivate() | |
650 | { |
|
665 | { | |
651 |
|
666 | |||
652 | } |
|
667 | } | |
653 |
|
668 | |||
654 | void QAxisPrivate::handleAxisRangeChanged(qreal min, qreal max,int count) |
|
669 | void QAxisPrivate::handleAxisRangeChanged(qreal min, qreal max,int count) | |
655 | { |
|
670 | { | |
656 | q_ptr->setRange(min,max); |
|
671 | q_ptr->setRange(min,max); | |
657 | q_ptr->setTicksCount(count); |
|
672 | q_ptr->setTicksCount(count); | |
658 | } |
|
673 | } | |
659 |
|
674 | |||
660 | QTCOMMERCIALCHART_END_NAMESPACE |
|
675 | QTCOMMERCIALCHART_END_NAMESPACE | |
661 |
|
676 | |||
662 | QTCOMMERCIALCHART_USE_NAMESPACE |
|
677 | QTCOMMERCIALCHART_USE_NAMESPACE | |
663 |
|
678 | |||
664 | #include "moc_qaxis.cpp" |
|
679 | #include "moc_qaxis.cpp" | |
665 | #include "moc_qaxis_p.cpp" |
|
680 | #include "moc_qaxis_p.cpp" |
@@ -1,722 +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 |
|
||||
98 | 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. | |
99 | Clicked bar inside set is indexed by \a index |
|
98 | Clicked bar inside set is indexed by \a index | |
100 | */ |
|
99 | */ | |
101 | /*! |
|
100 | /*! | |
102 | \qmlsignal BarSeries::onClicked(BarSet barset, int index) |
|
101 | \qmlsignal BarSeries::onClicked(BarSet barset, int index) | |
103 |
|
||||
104 | 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. | |
105 | Clicked bar inside set is indexed by \a index |
|
103 | Clicked bar inside set is indexed by \a index | |
106 | */ |
|
104 | */ | |
107 |
|
105 | |||
108 | /*! |
|
106 | /*! | |
109 | \fn void QBarSeries::hovered(QBarSet* barset, bool status) |
|
107 | \fn void QBarSeries::hovered(QBarSet* barset, bool status) | |
110 |
|
108 | |||
111 | 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. | |
112 | Parameter \a barset is the pointer of barset, where hover happened. |
|
110 | Parameter \a barset is the pointer of barset, where hover happened. | |
113 | 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. | |
114 | */ |
|
112 | */ | |
115 | /*! |
|
113 | /*! | |
116 | \qmlsignal BarSeries::onHovered(BarSet barset, bool status) |
|
114 | \qmlsignal BarSeries::onHovered(BarSet barset, bool status) | |
117 |
|
115 | |||
118 | 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. | |
119 | Parameter \a barset is the pointer of barset, where hover happened. |
|
117 | Parameter \a barset is the pointer of barset, where hover happened. | |
120 | 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. | |
121 | */ |
|
119 | */ | |
122 |
|
120 | |||
123 | /*! |
|
121 | /*! | |
124 | \fn void QBarSeries::countChanged() |
|
122 | \fn void QBarSeries::countChanged() | |
125 | 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. | |
126 | */ |
|
124 | */ | |
127 | /*! |
|
125 | /*! | |
128 |
\qmlsignal BarSeries:: |
|
126 | \qmlsignal BarSeries::onCountChanged() | |
129 | 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. | |
130 | */ |
|
128 | */ | |
131 |
|
129 | |||
132 | /*! |
|
130 | /*! | |
133 | \fn void QBarSeries::labelsVisibleChanged() |
|
131 | \fn void QBarSeries::labelsVisibleChanged() | |
134 | This signal is emitted when labels visibility have changed. |
|
132 | This signal is emitted when labels visibility have changed. | |
135 | \sa isLabelsVisible(), setLabelsVisible() |
|
133 | \sa isLabelsVisible(), setLabelsVisible() | |
136 | */ |
|
134 | */ | |
137 |
|
135 | |||
138 | /*! |
|
136 | /*! | |
139 | \fn void QBarSeries::barsetsAdded(QList<QBarSet*> sets) |
|
137 | \fn void QBarSeries::barsetsAdded(QList<QBarSet*> sets) | |
140 | 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. | |
141 | \sa append(), insert() |
|
139 | \sa append(), insert() | |
142 | */ |
|
140 | */ | |
143 | /*! |
|
141 | /*! | |
144 |
\qmlsignal BarSeries:: |
|
142 | \qmlsignal BarSeries::onAdded(BarSet barset) | |
145 | Emitted when \a barset has been added to the series. |
|
143 | Emitted when \a barset has been added to the series. | |
146 | */ |
|
144 | */ | |
147 |
|
145 | |||
148 | /*! |
|
146 | /*! | |
149 | \fn void QBarSeries::barsetsRemoved(QList<QBarSet*> sets) |
|
147 | \fn void QBarSeries::barsetsRemoved(QList<QBarSet*> sets) | |
150 | 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. | |
151 | \sa remove() |
|
149 | \sa remove() | |
152 | */ |
|
150 | */ | |
153 | /*! |
|
151 | /*! | |
154 |
\qmlsignal BarSeries:: |
|
152 | \qmlsignal BarSeries::onRemoved(BarSet barset) | |
155 | Emitted when \a barset has been removed from the series. |
|
153 | Emitted when \a barset has been removed from the series. | |
156 | */ |
|
154 | */ | |
157 |
|
155 | |||
158 | /*! |
|
156 | /*! | |
159 | \qmlmethod BarSet BarSeries::at(int index) |
|
157 | \qmlmethod BarSet BarSeries::at(int index) | |
160 | 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. | |
161 | */ |
|
159 | */ | |
162 |
|
160 | |||
163 | /*! |
|
161 | /*! | |
164 | \qmlmethod BarSet BarSeries::append(string label, VariantList values) |
|
162 | \qmlmethod BarSet BarSeries::append(string label, VariantList values) | |
165 | 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. | |
166 | For example: |
|
164 | For example: | |
167 | \code |
|
165 | \code | |
168 | 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]); | |
169 | 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)]); | |
170 | \endcode |
|
168 | \endcode | |
171 | */ |
|
169 | */ | |
172 |
|
170 | |||
173 | /*! |
|
171 | /*! | |
174 | \qmlmethod BarSet BarSeries::insert(int index, string label, VariantList values) |
|
172 | \qmlmethod BarSet BarSeries::insert(int index, string label, VariantList values) | |
175 | 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. | |
176 | 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 | |
177 | appended. |
|
175 | appended. | |
178 | \sa BarSeries::append() |
|
176 | \sa BarSeries::append() | |
179 | */ |
|
177 | */ | |
180 |
|
178 | |||
181 | /*! |
|
179 | /*! | |
182 | \qmlmethod bool BarSeries::remove(BarSet barset) |
|
180 | \qmlmethod bool BarSeries::remove(BarSet barset) | |
183 | 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. | |
184 | */ |
|
182 | */ | |
185 |
|
183 | |||
186 | /*! |
|
184 | /*! | |
187 | \qmlmethod BarSeries::clear() |
|
185 | \qmlmethod BarSeries::clear() | |
188 | Removes all barsets from the series. |
|
186 | Removes all barsets from the series. | |
189 | */ |
|
187 | */ | |
190 |
|
188 | |||
191 | /*! |
|
189 | /*! | |
192 | Constructs empty QBarSeries. |
|
190 | Constructs empty QBarSeries. | |
193 | QBarSeries is QObject which is a child of a \a parent. |
|
191 | QBarSeries is QObject which is a child of a \a parent. | |
194 | */ |
|
192 | */ | |
195 | QBarSeries::QBarSeries(QObject *parent) : |
|
193 | QBarSeries::QBarSeries(QObject *parent) : | |
196 | QAbstractSeries(*new QBarSeriesPrivate(this),parent) |
|
194 | QAbstractSeries(*new QBarSeriesPrivate(this),parent) | |
197 | { |
|
195 | { | |
198 | } |
|
196 | } | |
199 |
|
197 | |||
200 | /*! |
|
198 | /*! | |
201 | Destructs barseries and owned barsets. |
|
199 | Destructs barseries and owned barsets. | |
202 | */ |
|
200 | */ | |
203 | QBarSeries::~QBarSeries() |
|
201 | QBarSeries::~QBarSeries() | |
204 | { |
|
202 | { | |
205 | Q_D(QBarSeries); |
|
203 | Q_D(QBarSeries); | |
206 | if(d->m_dataset){ |
|
204 | if(d->m_dataset){ | |
207 | d->m_dataset->removeSeries(this); |
|
205 | d->m_dataset->removeSeries(this); | |
208 | } |
|
206 | } | |
209 | } |
|
207 | } | |
210 |
|
208 | |||
211 | /*! |
|
209 | /*! | |
212 | \internal |
|
210 | \internal | |
213 | */ |
|
211 | */ | |
214 | QBarSeries::QBarSeries(QBarSeriesPrivate &d, QObject *parent) : |
|
212 | QBarSeries::QBarSeries(QBarSeriesPrivate &d, QObject *parent) : | |
215 | QAbstractSeries(d,parent) |
|
213 | QAbstractSeries(d,parent) | |
216 | { |
|
214 | { | |
217 | } |
|
215 | } | |
218 |
|
216 | |||
219 | /*! |
|
217 | /*! | |
220 | Returns the type of series. Derived classes override this. |
|
218 | Returns the type of series. Derived classes override this. | |
221 | */ |
|
219 | */ | |
222 | QAbstractSeries::SeriesType QBarSeries::type() const |
|
220 | QAbstractSeries::SeriesType QBarSeries::type() const | |
223 | { |
|
221 | { | |
224 | return QAbstractSeries::SeriesTypeBar; |
|
222 | return QAbstractSeries::SeriesTypeBar; | |
225 | } |
|
223 | } | |
226 |
|
224 | |||
227 | /*! |
|
225 | /*! | |
228 | 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 | |
229 | 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 | |
230 | 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. | |
231 | 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. | |
232 | */ |
|
230 | */ | |
233 | void QBarSeries::setBarWidth(qreal width) |
|
231 | void QBarSeries::setBarWidth(qreal width) | |
234 | { |
|
232 | { | |
235 | Q_D(QBarSeries); |
|
233 | Q_D(QBarSeries); | |
236 | d->setBarWidth(width); |
|
234 | d->setBarWidth(width); | |
237 | } |
|
235 | } | |
238 |
|
236 | |||
239 | /*! |
|
237 | /*! | |
240 | Returns the width of the bars of the series. |
|
238 | Returns the width of the bars of the series. | |
241 | \sa setBarWidth() |
|
239 | \sa setBarWidth() | |
242 | */ |
|
240 | */ | |
243 | qreal QBarSeries::barWidth() const |
|
241 | qreal QBarSeries::barWidth() const | |
244 | { |
|
242 | { | |
245 | Q_D(const QBarSeries); |
|
243 | Q_D(const QBarSeries); | |
246 | return d->barWidth(); |
|
244 | return d->barWidth(); | |
247 | } |
|
245 | } | |
248 |
|
246 | |||
249 | /*! |
|
247 | /*! | |
250 | 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. | |
251 | Returns true, if appending succeeded. |
|
249 | Returns true, if appending succeeded. | |
252 | */ |
|
250 | */ | |
253 | bool QBarSeries::append(QBarSet *set) |
|
251 | bool QBarSeries::append(QBarSet *set) | |
254 | { |
|
252 | { | |
255 | Q_D(QBarSeries); |
|
253 | Q_D(QBarSeries); | |
256 | bool success = d->append(set); |
|
254 | bool success = d->append(set); | |
257 | if (success) { |
|
255 | if (success) { | |
258 | QList<QBarSet*> sets; |
|
256 | QList<QBarSet*> sets; | |
259 | sets.append(set); |
|
257 | sets.append(set); | |
260 | emit barsetsAdded(sets); |
|
258 | emit barsetsAdded(sets); | |
261 | emit countChanged(); |
|
259 | emit countChanged(); | |
262 | } |
|
260 | } | |
263 | return success; |
|
261 | return success; | |
264 | } |
|
262 | } | |
265 |
|
263 | |||
266 | /*! |
|
264 | /*! | |
267 | 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. | |
268 | Returns true, if set was removed. |
|
266 | Returns true, if set was removed. | |
269 | */ |
|
267 | */ | |
270 | bool QBarSeries::remove(QBarSet *set) |
|
268 | bool QBarSeries::remove(QBarSet *set) | |
271 | { |
|
269 | { | |
272 | Q_D(QBarSeries); |
|
270 | Q_D(QBarSeries); | |
273 | bool success = d->remove(set); |
|
271 | bool success = d->remove(set); | |
274 | if (success) { |
|
272 | if (success) { | |
275 | QList<QBarSet*> sets; |
|
273 | QList<QBarSet*> sets; | |
276 | sets.append(set); |
|
274 | sets.append(set); | |
277 | emit barsetsRemoved(sets); |
|
275 | emit barsetsRemoved(sets); | |
278 | emit countChanged(); |
|
276 | emit countChanged(); | |
279 | } |
|
277 | } | |
280 | return success; |
|
278 | return success; | |
281 | } |
|
279 | } | |
282 |
|
280 | |||
283 | /*! |
|
281 | /*! | |
284 | 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. | |
285 | 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, | |
286 | 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 | |
287 | and function returns false. |
|
285 | and function returns false. | |
288 | */ |
|
286 | */ | |
289 | bool QBarSeries::append(QList<QBarSet* > sets) |
|
287 | bool QBarSeries::append(QList<QBarSet* > sets) | |
290 | { |
|
288 | { | |
291 | Q_D(QBarSeries); |
|
289 | Q_D(QBarSeries); | |
292 | bool success = d->append(sets); |
|
290 | bool success = d->append(sets); | |
293 | if (success) { |
|
291 | if (success) { | |
294 | emit barsetsAdded(sets); |
|
292 | emit barsetsAdded(sets); | |
295 | emit countChanged(); |
|
293 | emit countChanged(); | |
296 | } |
|
294 | } | |
297 | return success; |
|
295 | return success; | |
298 | } |
|
296 | } | |
299 |
|
297 | |||
300 | /*! |
|
298 | /*! | |
301 | 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. | |
302 | Returns true, if inserting succeeded. |
|
300 | Returns true, if inserting succeeded. | |
303 |
|
301 | |||
304 | */ |
|
302 | */ | |
305 | bool QBarSeries::insert(int index, QBarSet *set) |
|
303 | bool QBarSeries::insert(int index, QBarSet *set) | |
306 | { |
|
304 | { | |
307 | Q_D(QBarSeries); |
|
305 | Q_D(QBarSeries); | |
308 | bool success = d->insert(index, set); |
|
306 | bool success = d->insert(index, set); | |
309 | if (success) { |
|
307 | if (success) { | |
310 | QList<QBarSet*> sets; |
|
308 | QList<QBarSet*> sets; | |
311 | sets.append(set); |
|
309 | sets.append(set); | |
312 | emit barsetsAdded(sets); |
|
310 | emit barsetsAdded(sets); | |
313 | emit countChanged(); |
|
311 | emit countChanged(); | |
314 | } |
|
312 | } | |
315 | return success; |
|
313 | return success; | |
316 | } |
|
314 | } | |
317 |
|
315 | |||
318 | /*! |
|
316 | /*! | |
319 | Removes all of the bar sets from the series |
|
317 | Removes all of the bar sets from the series | |
320 | */ |
|
318 | */ | |
321 | void QBarSeries::clear() |
|
319 | void QBarSeries::clear() | |
322 | { |
|
320 | { | |
323 | Q_D(QBarSeries); |
|
321 | Q_D(QBarSeries); | |
324 | QList<QBarSet *> sets = barSets(); |
|
322 | QList<QBarSet *> sets = barSets(); | |
325 | bool success = d->remove(sets); |
|
323 | bool success = d->remove(sets); | |
326 | if (success) { |
|
324 | if (success) { | |
327 | emit barsetsRemoved(sets); |
|
325 | emit barsetsRemoved(sets); | |
328 | emit countChanged(); |
|
326 | emit countChanged(); | |
329 | } |
|
327 | } | |
330 | } |
|
328 | } | |
331 |
|
329 | |||
332 | /*! |
|
330 | /*! | |
333 | Returns number of sets in series. |
|
331 | Returns number of sets in series. | |
334 | */ |
|
332 | */ | |
335 | int QBarSeries::count() const |
|
333 | int QBarSeries::count() const | |
336 | { |
|
334 | { | |
337 | Q_D(const QBarSeries); |
|
335 | Q_D(const QBarSeries); | |
338 | return d->m_barSets.count(); |
|
336 | return d->m_barSets.count(); | |
339 | } |
|
337 | } | |
340 |
|
338 | |||
341 | /*! |
|
339 | /*! | |
342 | Returns a list of sets in series. Keeps ownership of sets. |
|
340 | Returns a list of sets in series. Keeps ownership of sets. | |
343 | */ |
|
341 | */ | |
344 | QList<QBarSet*> QBarSeries::barSets() const |
|
342 | QList<QBarSet*> QBarSeries::barSets() const | |
345 | { |
|
343 | { | |
346 | Q_D(const QBarSeries); |
|
344 | Q_D(const QBarSeries); | |
347 | return d->m_barSets; |
|
345 | return d->m_barSets; | |
348 | } |
|
346 | } | |
349 |
|
347 | |||
350 | /*! |
|
348 | /*! | |
351 | Sets the visibility of labels in series to \a visible |
|
349 | Sets the visibility of labels in series to \a visible | |
352 | */ |
|
350 | */ | |
353 | void QBarSeries::setLabelsVisible(bool visible) |
|
351 | void QBarSeries::setLabelsVisible(bool visible) | |
354 | { |
|
352 | { | |
355 | Q_D(QBarSeries); |
|
353 | Q_D(QBarSeries); | |
356 | if (d->m_labelsVisible != visible) { |
|
354 | if (d->m_labelsVisible != visible) { | |
357 | d->setLabelsVisible(visible); |
|
355 | d->setLabelsVisible(visible); | |
358 | emit labelsVisibleChanged(); |
|
356 | emit labelsVisibleChanged(); | |
359 | } |
|
357 | } | |
360 | } |
|
358 | } | |
361 |
|
359 | |||
362 | /*! |
|
360 | /*! | |
363 | Returns the visibility of labels |
|
361 | Returns the visibility of labels | |
364 | */ |
|
362 | */ | |
365 | bool QBarSeries::isLabelsVisible() const |
|
363 | bool QBarSeries::isLabelsVisible() const | |
366 | { |
|
364 | { | |
367 | Q_D(const QBarSeries); |
|
365 | Q_D(const QBarSeries); | |
368 | return d->m_labelsVisible; |
|
366 | return d->m_labelsVisible; | |
369 | } |
|
367 | } | |
370 |
|
368 | |||
371 | /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
|
369 | /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |
372 |
|
370 | |||
373 | QBarSeriesPrivate::QBarSeriesPrivate(QBarSeries *q) : |
|
371 | QBarSeriesPrivate::QBarSeriesPrivate(QBarSeries *q) : | |
374 | QAbstractSeriesPrivate(q), |
|
372 | QAbstractSeriesPrivate(q), | |
375 | m_barWidth(0.5), // Default value is 50% of category width |
|
373 | m_barWidth(0.5), // Default value is 50% of category width | |
376 | m_labelsVisible(false), |
|
374 | m_labelsVisible(false), | |
377 | m_visible(true) |
|
375 | m_visible(true) | |
378 | { |
|
376 | { | |
379 | } |
|
377 | } | |
380 |
|
378 | |||
381 | int QBarSeriesPrivate::categoryCount() const |
|
379 | int QBarSeriesPrivate::categoryCount() const | |
382 | { |
|
380 | { | |
383 | // No categories defined. return count of longest set. |
|
381 | // No categories defined. return count of longest set. | |
384 | int count = 0; |
|
382 | int count = 0; | |
385 | for (int i=0; i<m_barSets.count(); i++) { |
|
383 | for (int i=0; i<m_barSets.count(); i++) { | |
386 | if (m_barSets.at(i)->count() > count) { |
|
384 | if (m_barSets.at(i)->count() > count) { | |
387 | count = m_barSets.at(i)->count(); |
|
385 | count = m_barSets.at(i)->count(); | |
388 | } |
|
386 | } | |
389 | } |
|
387 | } | |
390 |
|
388 | |||
391 | return count; |
|
389 | return count; | |
392 | } |
|
390 | } | |
393 |
|
391 | |||
394 | void QBarSeriesPrivate::setBarWidth(qreal width) |
|
392 | void QBarSeriesPrivate::setBarWidth(qreal width) | |
395 | { |
|
393 | { | |
396 | if (width < 0.0) { |
|
394 | if (width < 0.0) { | |
397 | width = 0.0; |
|
395 | width = 0.0; | |
398 | } |
|
396 | } | |
399 | m_barWidth = width; |
|
397 | m_barWidth = width; | |
400 | emit updatedBars(); |
|
398 | emit updatedBars(); | |
401 | } |
|
399 | } | |
402 |
|
400 | |||
403 | qreal QBarSeriesPrivate::barWidth() const |
|
401 | qreal QBarSeriesPrivate::barWidth() const | |
404 | { |
|
402 | { | |
405 | return m_barWidth; |
|
403 | return m_barWidth; | |
406 | } |
|
404 | } | |
407 |
|
405 | |||
408 | QBarSet* QBarSeriesPrivate::barsetAt(int index) |
|
406 | QBarSet* QBarSeriesPrivate::barsetAt(int index) | |
409 | { |
|
407 | { | |
410 | return m_barSets.at(index); |
|
408 | return m_barSets.at(index); | |
411 | } |
|
409 | } | |
412 |
|
410 | |||
413 | void QBarSeriesPrivate::setVisible(bool visible) |
|
411 | void QBarSeriesPrivate::setVisible(bool visible) | |
414 | { |
|
412 | { | |
415 | m_visible = visible; |
|
413 | m_visible = visible; | |
416 | emit updatedBars(); |
|
414 | emit updatedBars(); | |
417 | } |
|
415 | } | |
418 |
|
416 | |||
419 | void QBarSeriesPrivate::setLabelsVisible(bool visible) |
|
417 | void QBarSeriesPrivate::setLabelsVisible(bool visible) | |
420 | { |
|
418 | { | |
421 | m_labelsVisible = visible; |
|
419 | m_labelsVisible = visible; | |
422 | emit labelsVisibleChanged(visible); |
|
420 | emit labelsVisibleChanged(visible); | |
423 | } |
|
421 | } | |
424 |
|
422 | |||
425 | qreal QBarSeriesPrivate::min() |
|
423 | qreal QBarSeriesPrivate::min() | |
426 | { |
|
424 | { | |
427 | if (m_barSets.count() <= 0) { |
|
425 | if (m_barSets.count() <= 0) { | |
428 | return 0; |
|
426 | return 0; | |
429 | } |
|
427 | } | |
430 | qreal min = INT_MAX; |
|
428 | qreal min = INT_MAX; | |
431 |
|
429 | |||
432 | for (int i = 0; i < m_barSets.count(); i++) { |
|
430 | for (int i = 0; i < m_barSets.count(); i++) { | |
433 | int categoryCount = m_barSets.at(i)->count(); |
|
431 | int categoryCount = m_barSets.at(i)->count(); | |
434 | for (int j = 0; j < categoryCount; j++) { |
|
432 | for (int j = 0; j < categoryCount; j++) { | |
435 | qreal temp = m_barSets.at(i)->at(j).y(); |
|
433 | qreal temp = m_barSets.at(i)->at(j).y(); | |
436 | if (temp < min) |
|
434 | if (temp < min) | |
437 | min = temp; |
|
435 | min = temp; | |
438 | } |
|
436 | } | |
439 | } |
|
437 | } | |
440 | return min; |
|
438 | return min; | |
441 | } |
|
439 | } | |
442 |
|
440 | |||
443 | qreal QBarSeriesPrivate::max() |
|
441 | qreal QBarSeriesPrivate::max() | |
444 | { |
|
442 | { | |
445 | if (m_barSets.count() <= 0) { |
|
443 | if (m_barSets.count() <= 0) { | |
446 | return 0; |
|
444 | return 0; | |
447 | } |
|
445 | } | |
448 | qreal max = INT_MIN; |
|
446 | qreal max = INT_MIN; | |
449 |
|
447 | |||
450 | for (int i = 0; i < m_barSets.count(); i++) { |
|
448 | for (int i = 0; i < m_barSets.count(); i++) { | |
451 | int categoryCount = m_barSets.at(i)->count(); |
|
449 | int categoryCount = m_barSets.at(i)->count(); | |
452 | for (int j = 0; j < categoryCount; j++) { |
|
450 | for (int j = 0; j < categoryCount; j++) { | |
453 | qreal temp = m_barSets.at(i)->at(j).y(); |
|
451 | qreal temp = m_barSets.at(i)->at(j).y(); | |
454 | if (temp > max) |
|
452 | if (temp > max) | |
455 | max = temp; |
|
453 | max = temp; | |
456 | } |
|
454 | } | |
457 | } |
|
455 | } | |
458 |
|
456 | |||
459 | return max; |
|
457 | return max; | |
460 | } |
|
458 | } | |
461 |
|
459 | |||
462 | qreal QBarSeriesPrivate::valueAt(int set, int category) |
|
460 | qreal QBarSeriesPrivate::valueAt(int set, int category) | |
463 | { |
|
461 | { | |
464 | if ((set < 0) || (set >= m_barSets.count())) { |
|
462 | if ((set < 0) || (set >= m_barSets.count())) { | |
465 | // No set, no value. |
|
463 | // No set, no value. | |
466 | return 0; |
|
464 | return 0; | |
467 | } else if ((category < 0) || (category >= m_barSets.at(set)->count())) { |
|
465 | } else if ((category < 0) || (category >= m_barSets.at(set)->count())) { | |
468 | // No category, no value. |
|
466 | // No category, no value. | |
469 | return 0; |
|
467 | return 0; | |
470 | } |
|
468 | } | |
471 |
|
469 | |||
472 | return m_barSets.at(set)->at(category).y(); |
|
470 | return m_barSets.at(set)->at(category).y(); | |
473 | } |
|
471 | } | |
474 |
|
472 | |||
475 | qreal QBarSeriesPrivate::percentageAt(int set, int category) |
|
473 | qreal QBarSeriesPrivate::percentageAt(int set, int category) | |
476 | { |
|
474 | { | |
477 | if ((set < 0) || (set >= m_barSets.count())) { |
|
475 | if ((set < 0) || (set >= m_barSets.count())) { | |
478 | // No set, no value. |
|
476 | // No set, no value. | |
479 | return 0; |
|
477 | return 0; | |
480 | } else if ((category < 0) || (category >= m_barSets.at(set)->count())) { |
|
478 | } else if ((category < 0) || (category >= m_barSets.at(set)->count())) { | |
481 | // No category, no value. |
|
479 | // No category, no value. | |
482 | return 0; |
|
480 | return 0; | |
483 | } |
|
481 | } | |
484 |
|
482 | |||
485 | qreal value = m_barSets.at(set)->at(category).y(); |
|
483 | qreal value = m_barSets.at(set)->at(category).y(); | |
486 | qreal sum = categorySum(category); |
|
484 | qreal sum = categorySum(category); | |
487 | if ( qFuzzyIsNull(sum) ) { |
|
485 | if ( qFuzzyIsNull(sum) ) { | |
488 | return 0; |
|
486 | return 0; | |
489 | } |
|
487 | } | |
490 |
|
488 | |||
491 | return value / sum; |
|
489 | return value / sum; | |
492 | } |
|
490 | } | |
493 |
|
491 | |||
494 | qreal QBarSeriesPrivate::categorySum(int category) |
|
492 | qreal QBarSeriesPrivate::categorySum(int category) | |
495 | { |
|
493 | { | |
496 | qreal sum(0); |
|
494 | qreal sum(0); | |
497 | int count = m_barSets.count(); // Count sets |
|
495 | int count = m_barSets.count(); // Count sets | |
498 | for (int set = 0; set < count; set++) { |
|
496 | for (int set = 0; set < count; set++) { | |
499 | if (category < m_barSets.at(set)->count()) |
|
497 | if (category < m_barSets.at(set)->count()) | |
500 | sum += m_barSets.at(set)->at(category).y(); |
|
498 | sum += m_barSets.at(set)->at(category).y(); | |
501 | } |
|
499 | } | |
502 | return sum; |
|
500 | return sum; | |
503 | } |
|
501 | } | |
504 |
|
502 | |||
505 | qreal QBarSeriesPrivate::absoluteCategorySum(int category) |
|
503 | qreal QBarSeriesPrivate::absoluteCategorySum(int category) | |
506 | { |
|
504 | { | |
507 | qreal sum(0); |
|
505 | qreal sum(0); | |
508 | int count = m_barSets.count(); // Count sets |
|
506 | int count = m_barSets.count(); // Count sets | |
509 | for (int set = 0; set < count; set++) { |
|
507 | for (int set = 0; set < count; set++) { | |
510 | if (category < m_barSets.at(set)->count()) |
|
508 | if (category < m_barSets.at(set)->count()) | |
511 | sum += qAbs(m_barSets.at(set)->at(category).y()); |
|
509 | sum += qAbs(m_barSets.at(set)->at(category).y()); | |
512 | } |
|
510 | } | |
513 | return sum; |
|
511 | return sum; | |
514 | } |
|
512 | } | |
515 |
|
513 | |||
516 | qreal QBarSeriesPrivate::maxCategorySum() |
|
514 | qreal QBarSeriesPrivate::maxCategorySum() | |
517 | { |
|
515 | { | |
518 | qreal max = INT_MIN; |
|
516 | qreal max = INT_MIN; | |
519 | int count = categoryCount(); |
|
517 | int count = categoryCount(); | |
520 | for (int i = 0; i < count; i++) { |
|
518 | for (int i = 0; i < count; i++) { | |
521 | qreal sum = categorySum(i); |
|
519 | qreal sum = categorySum(i); | |
522 | if (sum > max) |
|
520 | if (sum > max) | |
523 | max = sum; |
|
521 | max = sum; | |
524 | } |
|
522 | } | |
525 | return max; |
|
523 | return max; | |
526 | } |
|
524 | } | |
527 |
|
525 | |||
528 | qreal QBarSeriesPrivate::minX() |
|
526 | qreal QBarSeriesPrivate::minX() | |
529 | { |
|
527 | { | |
530 | if (m_barSets.count() <= 0) { |
|
528 | if (m_barSets.count() <= 0) { | |
531 | return 0; |
|
529 | return 0; | |
532 | } |
|
530 | } | |
533 | qreal min = INT_MAX; |
|
531 | qreal min = INT_MAX; | |
534 |
|
532 | |||
535 | for (int i = 0; i < m_barSets.count(); i++) { |
|
533 | for (int i = 0; i < m_barSets.count(); i++) { | |
536 | int categoryCount = m_barSets.at(i)->count(); |
|
534 | int categoryCount = m_barSets.at(i)->count(); | |
537 | for (int j = 0; j < categoryCount; j++) { |
|
535 | for (int j = 0; j < categoryCount; j++) { | |
538 | qreal temp = m_barSets.at(i)->at(j).x(); |
|
536 | qreal temp = m_barSets.at(i)->at(j).x(); | |
539 | if (temp < min) |
|
537 | if (temp < min) | |
540 | min = temp; |
|
538 | min = temp; | |
541 | } |
|
539 | } | |
542 | } |
|
540 | } | |
543 | return min; |
|
541 | return min; | |
544 | } |
|
542 | } | |
545 |
|
543 | |||
546 | qreal QBarSeriesPrivate::maxX() |
|
544 | qreal QBarSeriesPrivate::maxX() | |
547 | { |
|
545 | { | |
548 | if (m_barSets.count() <= 0) { |
|
546 | if (m_barSets.count() <= 0) { | |
549 | return 0; |
|
547 | return 0; | |
550 | } |
|
548 | } | |
551 | qreal max = INT_MIN; |
|
549 | qreal max = INT_MIN; | |
552 |
|
550 | |||
553 | for (int i = 0; i < m_barSets.count(); i++) { |
|
551 | for (int i = 0; i < m_barSets.count(); i++) { | |
554 | int categoryCount = m_barSets.at(i)->count(); |
|
552 | int categoryCount = m_barSets.at(i)->count(); | |
555 | for (int j = 0; j < categoryCount; j++) { |
|
553 | for (int j = 0; j < categoryCount; j++) { | |
556 | qreal temp = m_barSets.at(i)->at(j).x(); |
|
554 | qreal temp = m_barSets.at(i)->at(j).x(); | |
557 | if (temp > max) |
|
555 | if (temp > max) | |
558 | max = temp; |
|
556 | max = temp; | |
559 | } |
|
557 | } | |
560 | } |
|
558 | } | |
561 |
|
559 | |||
562 | return max; |
|
560 | return max; | |
563 | } |
|
561 | } | |
564 |
|
562 | |||
565 |
|
563 | |||
566 | void QBarSeriesPrivate::scaleDomain(Domain& domain) |
|
564 | void QBarSeriesPrivate::scaleDomain(Domain& domain) | |
567 | { |
|
565 | { | |
568 | qreal minX(domain.minX()); |
|
566 | qreal minX(domain.minX()); | |
569 | qreal minY(domain.minY()); |
|
567 | qreal minY(domain.minY()); | |
570 | qreal maxX(domain.maxX()); |
|
568 | qreal maxX(domain.maxX()); | |
571 | qreal maxY(domain.maxY()); |
|
569 | qreal maxY(domain.maxY()); | |
572 | int tickXCount(domain.tickXCount()); |
|
570 | int tickXCount(domain.tickXCount()); | |
573 | int tickYCount(domain.tickYCount()); |
|
571 | int tickYCount(domain.tickYCount()); | |
574 |
|
572 | |||
575 | qreal seriesMinX = this->minX(); |
|
573 | qreal seriesMinX = this->minX(); | |
576 | qreal seriesMaxX = this->maxX(); |
|
574 | qreal seriesMaxX = this->maxX(); | |
577 | qreal y = max(); |
|
575 | qreal y = max(); | |
578 | minX = qMin(minX, seriesMinX - 0.5); |
|
576 | minX = qMin(minX, seriesMinX - 0.5); | |
579 | minY = qMin(minY, y); |
|
577 | minY = qMin(minY, y); | |
580 | maxX = qMax(maxX, seriesMaxX + 0.5); |
|
578 | maxX = qMax(maxX, seriesMaxX + 0.5); | |
581 | maxY = qMax(maxY, y); |
|
579 | maxY = qMax(maxY, y); | |
582 | tickXCount = categoryCount()+1; |
|
580 | tickXCount = categoryCount()+1; | |
583 |
|
581 | |||
584 | domain.setRange(minX,maxX,minY,maxY,tickXCount,tickYCount); |
|
582 | domain.setRange(minX,maxX,minY,maxY,tickXCount,tickYCount); | |
585 | } |
|
583 | } | |
586 |
|
584 | |||
587 | Chart* QBarSeriesPrivate::createGraphics(ChartPresenter* presenter) |
|
585 | Chart* QBarSeriesPrivate::createGraphics(ChartPresenter* presenter) | |
588 | { |
|
586 | { | |
589 | Q_Q(QBarSeries); |
|
587 | Q_Q(QBarSeries); | |
590 |
|
588 | |||
591 | BarChartItem* bar = new BarChartItem(q,presenter); |
|
589 | BarChartItem* bar = new BarChartItem(q,presenter); | |
592 | if(presenter->animationOptions().testFlag(QChart::SeriesAnimations)) { |
|
590 | if(presenter->animationOptions().testFlag(QChart::SeriesAnimations)) { | |
593 | presenter->animator()->addAnimation(bar); |
|
591 | presenter->animator()->addAnimation(bar); | |
594 | } |
|
592 | } | |
595 | presenter->chartTheme()->decorate(q, presenter->dataSet()->seriesIndex(q)); |
|
593 | presenter->chartTheme()->decorate(q, presenter->dataSet()->seriesIndex(q)); | |
596 | return bar; |
|
594 | return bar; | |
597 |
|
595 | |||
598 | } |
|
596 | } | |
599 |
|
597 | |||
600 | QList<LegendMarker*> QBarSeriesPrivate::createLegendMarker(QLegend* legend) |
|
598 | QList<LegendMarker*> QBarSeriesPrivate::createLegendMarker(QLegend* legend) | |
601 | { |
|
599 | { | |
602 | Q_Q(QBarSeries); |
|
600 | Q_Q(QBarSeries); | |
603 | QList<LegendMarker*> markers; |
|
601 | QList<LegendMarker*> markers; | |
604 | foreach(QBarSet* set, q->barSets()) { |
|
602 | foreach(QBarSet* set, q->barSets()) { | |
605 | BarLegendMarker* marker = new BarLegendMarker(q,set,legend); |
|
603 | BarLegendMarker* marker = new BarLegendMarker(q,set,legend); | |
606 | markers << marker; |
|
604 | markers << marker; | |
607 | } |
|
605 | } | |
608 |
|
606 | |||
609 | return markers; |
|
607 | return markers; | |
610 | } |
|
608 | } | |
611 |
|
609 | |||
612 | bool QBarSeriesPrivate::append(QBarSet *set) |
|
610 | bool QBarSeriesPrivate::append(QBarSet *set) | |
613 | { |
|
611 | { | |
614 | Q_Q(QBarSeries); |
|
612 | Q_Q(QBarSeries); | |
615 | if ((m_barSets.contains(set)) || (set == 0)) { |
|
613 | if ((m_barSets.contains(set)) || (set == 0)) { | |
616 | // Fail if set is already in list or set is null. |
|
614 | // Fail if set is already in list or set is null. | |
617 | return false; |
|
615 | return false; | |
618 | } |
|
616 | } | |
619 | m_barSets.append(set); |
|
617 | m_barSets.append(set); | |
620 | QObject::connect(set->d_ptr.data(), SIGNAL(updatedBars()), this, SIGNAL(updatedBars())); |
|
618 | QObject::connect(set->d_ptr.data(), SIGNAL(updatedBars()), this, SIGNAL(updatedBars())); | |
621 | QObject::connect(set->d_ptr.data(), SIGNAL(restructuredBars()), this, SIGNAL(restructuredBars())); |
|
619 | QObject::connect(set->d_ptr.data(), SIGNAL(restructuredBars()), this, SIGNAL(restructuredBars())); | |
622 | emit restructuredBars(); // this notifies barchartitem |
|
620 | emit restructuredBars(); // this notifies barchartitem | |
623 | if (m_dataset) { |
|
621 | if (m_dataset) { | |
624 | m_dataset->updateSeries(q); // this notifies legend |
|
622 | m_dataset->updateSeries(q); // this notifies legend | |
625 | } |
|
623 | } | |
626 | return true; |
|
624 | return true; | |
627 | } |
|
625 | } | |
628 |
|
626 | |||
629 | bool QBarSeriesPrivate::remove(QBarSet *set) |
|
627 | bool QBarSeriesPrivate::remove(QBarSet *set) | |
630 | { |
|
628 | { | |
631 | Q_Q(QBarSeries); |
|
629 | Q_Q(QBarSeries); | |
632 | if (!m_barSets.contains(set)) { |
|
630 | if (!m_barSets.contains(set)) { | |
633 | // Fail if set is not in list |
|
631 | // Fail if set is not in list | |
634 | return false; |
|
632 | return false; | |
635 | } |
|
633 | } | |
636 | m_barSets.removeOne(set); |
|
634 | m_barSets.removeOne(set); | |
637 | QObject::disconnect(set->d_ptr.data(), SIGNAL(updatedBars()), this, SIGNAL(updatedBars())); |
|
635 | QObject::disconnect(set->d_ptr.data(), SIGNAL(updatedBars()), this, SIGNAL(updatedBars())); | |
638 | QObject::disconnect(set->d_ptr.data(), SIGNAL(restructuredBars()), this, SIGNAL(restructuredBars())); |
|
636 | QObject::disconnect(set->d_ptr.data(), SIGNAL(restructuredBars()), this, SIGNAL(restructuredBars())); | |
639 | emit restructuredBars(); // this notifies barchartitem |
|
637 | emit restructuredBars(); // this notifies barchartitem | |
640 | if (m_dataset) { |
|
638 | if (m_dataset) { | |
641 | m_dataset->updateSeries(q); // this notifies legend |
|
639 | m_dataset->updateSeries(q); // this notifies legend | |
642 | } |
|
640 | } | |
643 | return true; |
|
641 | return true; | |
644 | } |
|
642 | } | |
645 |
|
643 | |||
646 | bool QBarSeriesPrivate::append(QList<QBarSet* > sets) |
|
644 | bool QBarSeriesPrivate::append(QList<QBarSet* > sets) | |
647 | { |
|
645 | { | |
648 | Q_Q(QBarSeries); |
|
646 | Q_Q(QBarSeries); | |
649 | foreach (QBarSet* set, sets) { |
|
647 | foreach (QBarSet* set, sets) { | |
650 | if ((set == 0) || (m_barSets.contains(set))) { |
|
648 | if ((set == 0) || (m_barSets.contains(set))) { | |
651 | // 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. | |
652 | return false; |
|
650 | return false; | |
653 | } |
|
651 | } | |
654 | if (sets.count(set) != 1) { |
|
652 | if (sets.count(set) != 1) { | |
655 | // 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. | |
656 | return false; |
|
654 | return false; | |
657 | } |
|
655 | } | |
658 | } |
|
656 | } | |
659 |
|
657 | |||
660 | foreach (QBarSet* set, sets) { |
|
658 | foreach (QBarSet* set, sets) { | |
661 | m_barSets.append(set); |
|
659 | m_barSets.append(set); | |
662 | QObject::connect(set->d_ptr.data(), SIGNAL(updatedBars()), this, SIGNAL(updatedBars())); |
|
660 | QObject::connect(set->d_ptr.data(), SIGNAL(updatedBars()), this, SIGNAL(updatedBars())); | |
663 | QObject::connect(set->d_ptr.data(), SIGNAL(restructuredBars()), this, SIGNAL(restructuredBars())); |
|
661 | QObject::connect(set->d_ptr.data(), SIGNAL(restructuredBars()), this, SIGNAL(restructuredBars())); | |
664 | } |
|
662 | } | |
665 | emit restructuredBars(); // this notifies barchartitem |
|
663 | emit restructuredBars(); // this notifies barchartitem | |
666 | if (m_dataset) { |
|
664 | if (m_dataset) { | |
667 | m_dataset->updateSeries(q); // this notifies legend |
|
665 | m_dataset->updateSeries(q); // this notifies legend | |
668 | } |
|
666 | } | |
669 | return true; |
|
667 | return true; | |
670 | } |
|
668 | } | |
671 |
|
669 | |||
672 | bool QBarSeriesPrivate::remove(QList<QBarSet* > sets) |
|
670 | bool QBarSeriesPrivate::remove(QList<QBarSet* > sets) | |
673 | { |
|
671 | { | |
674 | Q_Q(QBarSeries); |
|
672 | Q_Q(QBarSeries); | |
675 | if (sets.count() == 0) { |
|
673 | if (sets.count() == 0) { | |
676 | return false; |
|
674 | return false; | |
677 | } |
|
675 | } | |
678 | foreach (QBarSet* set, sets) { |
|
676 | foreach (QBarSet* set, sets) { | |
679 | if ((set == 0) || (!m_barSets.contains(set))) { |
|
677 | if ((set == 0) || (!m_barSets.contains(set))) { | |
680 | // 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 | |
681 | return false; |
|
679 | return false; | |
682 | } |
|
680 | } | |
683 | if (sets.count(set) != 1) { |
|
681 | if (sets.count(set) != 1) { | |
684 | // 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. | |
685 | return false; |
|
683 | return false; | |
686 | } |
|
684 | } | |
687 | } |
|
685 | } | |
688 |
|
686 | |||
689 | foreach (QBarSet* set, sets) { |
|
687 | foreach (QBarSet* set, sets) { | |
690 | m_barSets.removeOne(set); |
|
688 | m_barSets.removeOne(set); | |
691 | QObject::disconnect(set->d_ptr.data(), SIGNAL(updatedBars()), this, SIGNAL(updatedBars())); |
|
689 | QObject::disconnect(set->d_ptr.data(), SIGNAL(updatedBars()), this, SIGNAL(updatedBars())); | |
692 | QObject::disconnect(set->d_ptr.data(), SIGNAL(restructuredBars()), this, SIGNAL(restructuredBars())); |
|
690 | QObject::disconnect(set->d_ptr.data(), SIGNAL(restructuredBars()), this, SIGNAL(restructuredBars())); | |
693 | } |
|
691 | } | |
694 |
|
692 | |||
695 | emit restructuredBars(); // this notifies barchartitem |
|
693 | emit restructuredBars(); // this notifies barchartitem | |
696 | if (m_dataset) { |
|
694 | if (m_dataset) { | |
697 | m_dataset->updateSeries(q); // this notifies legend |
|
695 | m_dataset->updateSeries(q); // this notifies legend | |
698 | } |
|
696 | } | |
699 | return true; |
|
697 | return true; | |
700 | } |
|
698 | } | |
701 |
|
699 | |||
702 | bool QBarSeriesPrivate::insert(int index, QBarSet *set) |
|
700 | bool QBarSeriesPrivate::insert(int index, QBarSet *set) | |
703 | { |
|
701 | { | |
704 | Q_Q(QBarSeries); |
|
702 | Q_Q(QBarSeries); | |
705 | if ((m_barSets.contains(set)) || (set == 0)) { |
|
703 | if ((m_barSets.contains(set)) || (set == 0)) { | |
706 | // Fail if set is already in list or set is null. |
|
704 | // Fail if set is already in list or set is null. | |
707 | return false; |
|
705 | return false; | |
708 | } |
|
706 | } | |
709 | m_barSets.insert(index, set); |
|
707 | m_barSets.insert(index, set); | |
710 | QObject::connect(set->d_ptr.data(), SIGNAL(updatedBars()), this, SIGNAL(updatedBars())); |
|
708 | QObject::connect(set->d_ptr.data(), SIGNAL(updatedBars()), this, SIGNAL(updatedBars())); | |
711 | QObject::connect(set->d_ptr.data(), SIGNAL(restructuredBars()), this, SIGNAL(restructuredBars())); |
|
709 | QObject::connect(set->d_ptr.data(), SIGNAL(restructuredBars()), this, SIGNAL(restructuredBars())); | |
712 | emit restructuredBars(); // this notifies barchartitem |
|
710 | emit restructuredBars(); // this notifies barchartitem | |
713 | if (m_dataset) { |
|
711 | if (m_dataset) { | |
714 | m_dataset->updateSeries(q); // this notifies legend |
|
712 | m_dataset->updateSeries(q); // this notifies legend | |
715 | } |
|
713 | } | |
716 | return true; |
|
714 | return true; | |
717 | } |
|
715 | } | |
718 |
|
716 | |||
719 | #include "moc_qbarseries.cpp" |
|
717 | #include "moc_qbarseries.cpp" | |
720 | #include "moc_qbarseries_p.cpp" |
|
718 | #include "moc_qbarseries_p.cpp" | |
721 |
|
719 | |||
722 | QTCOMMERCIALCHART_END_NAMESPACE |
|
720 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -1,671 +1,675 | |||||
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 "qbarset.h" |
|
21 | #include "qbarset.h" | |
22 | #include "qbarset_p.h" |
|
22 | #include "qbarset_p.h" | |
23 |
|
23 | |||
24 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
24 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
25 |
|
25 | |||
26 | /*! |
|
26 | /*! | |
27 | \class QBarSet |
|
27 | \class QBarSet | |
28 | \brief Building block for different bar charts |
|
28 | \brief Building block for different bar charts | |
29 |
|
29 | |||
30 | QBarSet represents one set of bars. Set of bars contains one data value for each category. |
|
30 | QBarSet represents one set of bars. Set of bars contains one data value for each category. | |
31 | First value of set is assumed to belong to first category, second to second category and so on. |
|
31 | First value of set is assumed to belong to first category, second to second category and so on. | |
32 | If set has fewer values than there are categories, then the missing values are assumed to be |
|
32 | If set has fewer values than there are categories, then the missing values are assumed to be | |
33 | at the end of set. For missing values in middle of a set, numerical value of zero is used. |
|
33 | at the end of set. For missing values in middle of a set, numerical value of zero is used. | |
34 |
|
34 | |||
35 | \mainclass |
|
35 | \mainclass | |
36 |
|
36 | |||
37 | \sa QBarSeries, QGroupedBarSeries, QStackedBarSeries, QPercentBarSeries |
|
37 | \sa QBarSeries, QGroupedBarSeries, QStackedBarSeries, QPercentBarSeries | |
38 | */ |
|
38 | */ | |
39 | /*! |
|
39 | /*! | |
40 | \qmlclass BarSet QBarSet |
|
40 | \qmlclass BarSet QBarSet | |
41 |
|
41 | |||
42 | BarSet represents one set of bars. Set of bars contains one data value for each category. |
|
42 | BarSet represents one set of bars. Set of bars contains one data value for each category. | |
43 | First value of set is assumed to belong to first category, second to second category and so on. |
|
43 | First value of set is assumed to belong to first category, second to second category and so on. | |
44 | If set has fewer values than there are categories, then the missing values are assumed to be |
|
44 | If set has fewer values than there are categories, then the missing values are assumed to be | |
45 | at the end of set. For missing values in middle of a set, numerical value of zero is used. |
|
45 | at the end of set. For missing values in middle of a set, numerical value of zero is used. | |
46 | \sa BarSeries, GroupedBarSeries, StackedBarSeries, PercentBarSeries |
|
46 | \sa BarSeries, GroupedBarSeries, StackedBarSeries, PercentBarSeries | |
47 | */ |
|
47 | */ | |
48 |
|
48 | |||
49 | /*! |
|
49 | /*! | |
50 | \property QBarSet::label |
|
50 | \property QBarSet::label | |
51 | Defines the label of the barSet. |
|
51 | Defines the label of the barSet. | |
52 | */ |
|
52 | */ | |
53 | /*! |
|
53 | /*! | |
54 | \qmlproperty string BarSet::label |
|
54 | \qmlproperty string BarSet::label | |
55 | Defines the label of the barSet. |
|
55 | Defines the label of the barSet. | |
56 | */ |
|
56 | */ | |
57 |
|
57 | |||
58 | /*! |
|
58 | /*! | |
59 | \property QBarSet::pen |
|
59 | \property QBarSet::pen | |
60 | \brief Defines the pen used by the barSet. |
|
60 | \brief Defines the pen used by the barSet. | |
61 | */ |
|
61 | */ | |
62 |
|
62 | |||
63 | /*! |
|
63 | /*! | |
64 | \property QBarSet::brush |
|
64 | \property QBarSet::brush | |
65 | \brief Defines the brush used by the barSet. |
|
65 | \brief Defines the brush used by the barSet. | |
66 | */ |
|
66 | */ | |
67 |
|
67 | |||
68 | /*! |
|
68 | /*! | |
69 | \property QBarSet::labelBrush |
|
69 | \property QBarSet::labelBrush | |
70 | \brief Defines the brush used by the barSet's label. |
|
70 | \brief Defines the brush used by the barSet's label. | |
71 | */ |
|
71 | */ | |
72 |
|
72 | |||
73 | /*! |
|
73 | /*! | |
74 | \property QBarSet::labelFont |
|
74 | \property QBarSet::labelFont | |
75 | \brief Defines the font used by the barSet's label. |
|
75 | \brief Defines the font used by the barSet's label. | |
76 | */ |
|
76 | */ | |
77 |
|
77 | |||
78 | /*! |
|
78 | /*! | |
79 | \qmlproperty Font BarSet::labelFont |
|
79 | \qmlproperty Font BarSet::labelFont | |
80 | Defines the font used by the barSet's label. |
|
80 | Defines the font used by the barSet's label. | |
81 |
|
81 | |||
82 | See the \l {Font} {QML Font Element} for detailed documentation. |
|
82 | See the \l {Font} {QML Font Element} for detailed documentation. | |
83 | */ |
|
83 | */ | |
84 |
|
84 | |||
85 | /*! |
|
85 | /*! | |
86 | \property QBarSet::color |
|
86 | \property QBarSet::color | |
87 | The fill (brush) color of the bar set. |
|
87 | The fill (brush) color of the bar set. | |
88 | */ |
|
88 | */ | |
89 | /*! |
|
89 | /*! | |
90 | \qmlproperty color BarSet::color |
|
90 | \qmlproperty color BarSet::color | |
91 | The fill (brush) color of the bar set. |
|
91 | The fill (brush) color of the bar set. | |
92 | */ |
|
92 | */ | |
93 |
|
93 | |||
94 | /*! |
|
94 | /*! | |
95 | \property QBarSet::borderColor |
|
95 | \property QBarSet::borderColor | |
96 | The line (pen) color of the bar set. |
|
96 | The line (pen) color of the bar set. | |
97 | */ |
|
97 | */ | |
98 | /*! |
|
98 | /*! | |
99 | \qmlproperty color BarSet::borderColor |
|
99 | \qmlproperty color BarSet::borderColor | |
100 | The line (pen) color of the bar set. |
|
100 | The line (pen) color of the bar set. | |
101 | */ |
|
101 | */ | |
102 |
|
102 | |||
103 | /*! |
|
103 | /*! | |
104 | \property QBarSet::labelColor |
|
104 | \property QBarSet::labelColor | |
105 | The text (label) color of the bar set. |
|
105 | The text (label) color of the bar set. | |
106 | */ |
|
106 | */ | |
107 | /*! |
|
107 | /*! | |
108 | \qmlproperty color BarSet::labelColor |
|
108 | \qmlproperty color BarSet::labelColor | |
109 | The text (label) color of the bar set. |
|
109 | The text (label) color of the bar set. | |
110 | */ |
|
110 | */ | |
111 |
|
111 | |||
112 | /*! |
|
112 | /*! | |
113 | \fn void QBarSet::clicked(int index) |
|
113 | \fn void QBarSet::clicked(int index) | |
114 |
|
114 | |||
115 | The signal is emitted if the user clicks with a mouse on top of barset. |
|
115 | The signal is emitted if the user clicks with a mouse on top of barset. | |
116 | Clicked bar inside set is indexed by \a index |
|
116 | Clicked bar inside set is indexed by \a index | |
117 | */ |
|
117 | */ | |
118 |
|
118 | |||
119 | /*! |
|
119 | /*! | |
120 | \fn void QBarSet::hovered(bool status) |
|
120 | \fn void QBarSet::hovered(bool status) | |
121 |
|
121 | |||
122 | The signal is emitted if mouse is hovered on top of barset. |
|
122 | The signal is emitted if mouse is hovered on top of barset. | |
123 | Parameter \a status is true, if mouse entered on top of barset, false if mouse left from top of barset. |
|
123 | Parameter \a status is true, if mouse entered on top of barset, false if mouse left from top of barset. | |
124 | */ |
|
124 | */ | |
125 |
|
125 | |||
126 |
|
126 | |||
127 | /*! |
|
127 | /*! | |
128 | \fn void QBarSet::labelChanged() |
|
128 | \fn void QBarSet::labelChanged() | |
129 | This signal is emitted when the label of the barSet has changed. |
|
129 | This signal is emitted when the label of the barSet has changed. | |
130 | \sa label |
|
130 | \sa label | |
131 | */ |
|
131 | */ | |
|
132 | /*! | |||
|
133 | \qmlsignal BarSet::onLabelChanged() | |||
|
134 | This signal is emitted when the label of the barSet has changed. | |||
|
135 | */ | |||
132 |
|
136 | |||
133 | /*! |
|
137 | /*! | |
134 | \fn void QBarSet::penChanged() |
|
138 | \fn void QBarSet::penChanged() | |
135 | This signal is emitted when the pen of the barSet has changed. |
|
139 | This signal is emitted when the pen of the barSet has changed. | |
136 | \sa pen |
|
140 | \sa pen | |
137 | */ |
|
141 | */ | |
138 |
|
142 | |||
139 | /*! |
|
143 | /*! | |
140 | \fn void QBarSet::brushChanged() |
|
144 | \fn void QBarSet::brushChanged() | |
141 | This signal is emitted when the brush of the barSet has changed. |
|
145 | This signal is emitted when the brush of the barSet has changed. | |
142 | \sa brush |
|
146 | \sa brush | |
143 | */ |
|
147 | */ | |
144 |
|
148 | |||
145 | /*! |
|
149 | /*! | |
146 | \fn void QBarSet::labelBrushChanged() |
|
150 | \fn void QBarSet::labelBrushChanged() | |
147 | This signal is emitted when the brush of the barSet's label has changed. |
|
151 | This signal is emitted when the brush of the barSet's label has changed. | |
148 | \sa labelBrush |
|
152 | \sa labelBrush | |
149 | */ |
|
153 | */ | |
150 |
|
154 | |||
151 | /*! |
|
155 | /*! | |
152 | \fn void QBarSet::labelFontChanged() |
|
156 | \fn void QBarSet::labelFontChanged() | |
153 | This signal is emitted when the font of the barSet's label has changed. |
|
157 | This signal is emitted when the font of the barSet's label has changed. | |
154 | \sa labelBrush |
|
158 | \sa labelBrush | |
155 | */ |
|
159 | */ | |
156 |
|
160 | |||
157 | /*! |
|
161 | /*! | |
158 | \fn void QBarSet::colorChanged(QColor) |
|
162 | \fn void QBarSet::colorChanged(QColor) | |
159 | This signal is emitted when the fill (brush) color of the set has changed to \a color. |
|
163 | This signal is emitted when the fill (brush) color of the set has changed to \a color. | |
160 | */ |
|
164 | */ | |
161 | /*! |
|
165 | /*! | |
162 | \qmlsignal BarSet::onColorChanged(color color) |
|
166 | \qmlsignal BarSet::onColorChanged(color color) | |
163 | This signal is emitted when the fill (brush) color of the set has changed to \a color. |
|
167 | This signal is emitted when the fill (brush) color of the set has changed to \a color. | |
164 | */ |
|
168 | */ | |
165 |
|
169 | |||
166 | /*! |
|
170 | /*! | |
167 | \fn void QBarSet::borderColorChanged(QColor) |
|
171 | \fn void QBarSet::borderColorChanged(QColor) | |
168 | This signal is emitted when the line (pen) color of the set has changed to \a color. |
|
172 | This signal is emitted when the line (pen) color of the set has changed to \a color. | |
169 | */ |
|
173 | */ | |
170 | /*! |
|
174 | /*! | |
171 | \qmlsignal BarSet::onBorderColorChanged(color color) |
|
175 | \qmlsignal BarSet::onBorderColorChanged(color color) | |
172 | This signal is emitted when the line (pen) color of the set has changed to \a color. |
|
176 | This signal is emitted when the line (pen) color of the set has changed to \a color. | |
173 | */ |
|
177 | */ | |
174 |
|
178 | |||
175 | /*! |
|
179 | /*! | |
176 | \fn void QBarSet::labelColorChanged(QColor) |
|
180 | \fn void QBarSet::labelColorChanged(QColor) | |
177 | This signal is emitted when the text (label) color of the set has changed to \a color. |
|
181 | This signal is emitted when the text (label) color of the set has changed to \a color. | |
178 | */ |
|
182 | */ | |
179 | /*! |
|
183 | /*! | |
180 | \qmlsignal BarSet::onLabelColorChanged(color color) |
|
184 | \qmlsignal BarSet::onLabelColorChanged(color color) | |
181 | This signal is emitted when the text (label) color of the set has changed to \a color. |
|
185 | This signal is emitted when the text (label) color of the set has changed to \a color. | |
182 | */ |
|
186 | */ | |
183 |
|
187 | |||
184 | /*! |
|
188 | /*! | |
185 | \fn void QBarSet::valuesAdded(int index, int count) |
|
189 | \fn void QBarSet::valuesAdded(int index, int count) | |
186 | This signal is emitted when new values have been added to the set. |
|
190 | This signal is emitted when new values have been added to the set. | |
187 | Parameter \a index indicates the position of the first inserted value. |
|
191 | Parameter \a index indicates the position of the first inserted value. | |
188 | Parameter \a count is the number of iserted values. |
|
192 | Parameter \a count is the number of iserted values. | |
189 | \sa append(), insert() |
|
193 | \sa append(), insert() | |
190 | */ |
|
194 | */ | |
191 | /*! |
|
195 | /*! | |
192 | \qmlsignal BarSet::onValuesAdded(int index, int count) |
|
196 | \qmlsignal BarSet::onValuesAdded(int index, int count) | |
193 | This signal is emitted when new values have been added to the set. |
|
197 | This signal is emitted when new values have been added to the set. | |
194 | Parameter \a index indicates the position of the first inserted value. |
|
198 | Parameter \a index indicates the position of the first inserted value. | |
195 | Parameter \a count is the number of iserted values. |
|
199 | Parameter \a count is the number of iserted values. | |
196 | */ |
|
200 | */ | |
197 |
|
201 | |||
198 | /*! |
|
202 | /*! | |
199 | \fn void QBarSet::valuesRemoved(int index, int count) |
|
203 | \fn void QBarSet::valuesRemoved(int index, int count) | |
200 | This signal is emitted values have been removed from the set. |
|
204 | This signal is emitted values have been removed from the set. | |
201 | Parameter \a index indicates the position of the first removed value. |
|
205 | Parameter \a index indicates the position of the first removed value. | |
202 | Parameter \a count is the number of removed values. |
|
206 | Parameter \a count is the number of removed values. | |
203 | \sa remove() |
|
207 | \sa remove() | |
204 | */ |
|
208 | */ | |
205 | /*! |
|
209 | /*! | |
206 | \qmlsignal BarSet::onValuesRemoved(int index, int count) |
|
210 | \qmlsignal BarSet::onValuesRemoved(int index, int count) | |
207 | This signal is emitted values have been removed from the set. |
|
211 | This signal is emitted values have been removed from the set. | |
208 | Parameter \a index indicates the position of the first removed value. |
|
212 | Parameter \a index indicates the position of the first removed value. | |
209 | Parameter \a count is the number of removed values. |
|
213 | Parameter \a count is the number of removed values. | |
210 | */ |
|
214 | */ | |
211 |
|
215 | |||
212 | /*! |
|
216 | /*! | |
213 | \fn void QBarSet::valueChanged(int index) |
|
217 | \fn void QBarSet::valueChanged(int index) | |
214 | This signal is emitted values the value in the set has been modified. |
|
218 | This signal is emitted values the value in the set has been modified. | |
215 | Parameter \a index indicates the position of the modified value. |
|
219 | Parameter \a index indicates the position of the modified value. | |
216 | \sa at() |
|
220 | \sa at() | |
217 | */ |
|
221 | */ | |
218 | /*! |
|
222 | /*! | |
219 | \qmlsignal BarSet::onValueChanged(int index) |
|
223 | \qmlsignal BarSet::onValueChanged(int index) | |
220 | This signal is emitted values the value in the set has been modified. |
|
224 | This signal is emitted values the value in the set has been modified. | |
221 | Parameter \a index indicates the position of the modified value. |
|
225 | Parameter \a index indicates the position of the modified value. | |
222 | */ |
|
226 | */ | |
223 |
|
227 | |||
224 | /*! |
|
228 | /*! | |
225 | \qmlproperty int BarSet::count |
|
229 | \qmlproperty int BarSet::count | |
226 | The count of values on the barset |
|
230 | The count of values on the barset | |
227 | */ |
|
231 | */ | |
228 |
|
232 | |||
229 | /*! |
|
233 | /*! | |
230 | \qmlproperty QVariantList BarSet::values |
|
234 | \qmlproperty QVariantList BarSet::values | |
231 | The values of the barset. You can set either a list of reals or a list of points as values. If you set a list of |
|
235 | The values of the barset. You can set either a list of reals or a list of points as values. If you set a list of | |
232 | reals as values, the values are automatically completed to points by using the index of a value as it's |
|
236 | reals as values, the values are automatically completed to points by using the index of a value as it's | |
233 | x-coordinate. For example: |
|
237 | x-coordinate. For example: | |
234 | \code |
|
238 | \code | |
235 | myBarSet1.values = [0, 5, 1, 5]; |
|
239 | myBarSet1.values = [0, 5, 1, 5]; | |
236 | myBarSet2.values = [Qt.point(0, 1), Qt.point(1, 5), Qt.point(2.2, 4.3)]; |
|
240 | myBarSet2.values = [Qt.point(0, 1), Qt.point(1, 5), Qt.point(2.2, 4.3)]; | |
237 | \endcode |
|
241 | \endcode | |
238 | */ |
|
242 | */ | |
239 |
|
243 | |||
240 | /*! |
|
244 | /*! | |
241 | Constructs QBarSet with a label of \a label and with parent of \a parent |
|
245 | Constructs QBarSet with a label of \a label and with parent of \a parent | |
242 | */ |
|
246 | */ | |
243 | QBarSet::QBarSet(const QString label, QObject *parent) |
|
247 | QBarSet::QBarSet(const QString label, QObject *parent) | |
244 | : QObject(parent) |
|
248 | : QObject(parent) | |
245 | ,d_ptr(new QBarSetPrivate(label,this)) |
|
249 | ,d_ptr(new QBarSetPrivate(label,this)) | |
246 | { |
|
250 | { | |
247 | } |
|
251 | } | |
248 |
|
252 | |||
249 | /*! |
|
253 | /*! | |
250 | Destroys the barset |
|
254 | Destroys the barset | |
251 | */ |
|
255 | */ | |
252 | QBarSet::~QBarSet() |
|
256 | QBarSet::~QBarSet() | |
253 | { |
|
257 | { | |
254 | // NOTE: d_ptr destroyed by QObject |
|
258 | // NOTE: d_ptr destroyed by QObject | |
255 | } |
|
259 | } | |
256 |
|
260 | |||
257 | /*! |
|
261 | /*! | |
258 | Sets new \a label for set. |
|
262 | Sets new \a label for set. | |
259 | */ |
|
263 | */ | |
260 | void QBarSet::setLabel(const QString label) |
|
264 | void QBarSet::setLabel(const QString label) | |
261 | { |
|
265 | { | |
262 | d_ptr->m_label = label; |
|
266 | d_ptr->m_label = label; | |
263 | emit labelChanged(); |
|
267 | emit labelChanged(); | |
264 | } |
|
268 | } | |
265 |
|
269 | |||
266 | /*! |
|
270 | /*! | |
267 | Returns label of the set. |
|
271 | Returns label of the set. | |
268 | */ |
|
272 | */ | |
269 | QString QBarSet::label() const |
|
273 | QString QBarSet::label() const | |
270 | { |
|
274 | { | |
271 | return d_ptr->m_label; |
|
275 | return d_ptr->m_label; | |
272 | } |
|
276 | } | |
273 |
|
277 | |||
274 | /*! |
|
278 | /*! | |
275 | Appends a point to set. Parameter \a value x coordinate defines the |
|
279 | Appends a point to set. Parameter \a value x coordinate defines the | |
276 | position in x-axis and y coordinate defines the height of bar. |
|
280 | position in x-axis and y coordinate defines the height of bar. | |
277 | Depending on presentation (QBarSeries, QGroupedBarSeries, QStackedBarSeries, QPercentBarSeries) |
|
281 | Depending on presentation (QBarSeries, QGroupedBarSeries, QStackedBarSeries, QPercentBarSeries) | |
278 | the x values are used or ignored. |
|
282 | the x values are used or ignored. | |
279 | */ |
|
283 | */ | |
280 | void QBarSet::append(const QPointF value) |
|
284 | void QBarSet::append(const QPointF value) | |
281 | { |
|
285 | { | |
282 | int index = d_ptr->m_values.count(); |
|
286 | int index = d_ptr->m_values.count(); | |
283 | d_ptr->append(value); |
|
287 | d_ptr->append(value); | |
284 | emit valuesAdded(index, 1); |
|
288 | emit valuesAdded(index, 1); | |
285 | } |
|
289 | } | |
286 |
|
290 | |||
287 | /*! |
|
291 | /*! | |
288 | Appends a list of \a values to set. Works like append with single point. |
|
292 | Appends a list of \a values to set. Works like append with single point. | |
289 | \sa append() |
|
293 | \sa append() | |
290 | */ |
|
294 | */ | |
291 | void QBarSet::append(const QList<QPointF> &values) |
|
295 | void QBarSet::append(const QList<QPointF> &values) | |
292 | { |
|
296 | { | |
293 | int index = d_ptr->m_values.count(); |
|
297 | int index = d_ptr->m_values.count(); | |
294 | d_ptr->append(values); |
|
298 | d_ptr->append(values); | |
295 | emit valuesAdded(index, values.count()); |
|
299 | emit valuesAdded(index, values.count()); | |
296 | } |
|
300 | } | |
297 |
|
301 | |||
298 | /*! |
|
302 | /*! | |
299 | Appends new value \a value to the end of set. Internally the value is converted to QPointF, |
|
303 | Appends new value \a value to the end of set. Internally the value is converted to QPointF, | |
300 | with x coordinate being the index of appended value and y coordinate is the value. |
|
304 | with x coordinate being the index of appended value and y coordinate is the value. | |
301 | */ |
|
305 | */ | |
302 | void QBarSet::append(const qreal value) |
|
306 | void QBarSet::append(const qreal value) | |
303 | { |
|
307 | { | |
304 | // Convert to QPointF and use other append(QPointF) method. |
|
308 | // Convert to QPointF and use other append(QPointF) method. | |
305 | append(QPointF(d_ptr->m_values.count(), value)); |
|
309 | append(QPointF(d_ptr->m_values.count(), value)); | |
306 | } |
|
310 | } | |
307 |
|
311 | |||
308 | /*! |
|
312 | /*! | |
309 | Appends a list of reals to set. Works like append with single real value. The \a values in list |
|
313 | Appends a list of reals to set. Works like append with single real value. The \a values in list | |
310 | are converted to QPointF, where x coordinate is the index of point and y coordinate is the value. |
|
314 | are converted to QPointF, where x coordinate is the index of point and y coordinate is the value. | |
311 | \sa append() |
|
315 | \sa append() | |
312 | */ |
|
316 | */ | |
313 | void QBarSet::append(const QList<qreal> &values) |
|
317 | void QBarSet::append(const QList<qreal> &values) | |
314 | { |
|
318 | { | |
315 | int index = d_ptr->m_values.count(); |
|
319 | int index = d_ptr->m_values.count(); | |
316 | d_ptr->append(values); |
|
320 | d_ptr->append(values); | |
317 | emit valuesAdded(index, values.count()); |
|
321 | emit valuesAdded(index, values.count()); | |
318 | } |
|
322 | } | |
319 |
|
323 | |||
320 | /*! |
|
324 | /*! | |
321 | Convinience operator. Same as append, with real \a value. |
|
325 | Convinience operator. Same as append, with real \a value. | |
322 | \sa append() |
|
326 | \sa append() | |
323 | */ |
|
327 | */ | |
324 | QBarSet& QBarSet::operator << (const qreal &value) |
|
328 | QBarSet& QBarSet::operator << (const qreal &value) | |
325 | { |
|
329 | { | |
326 | append(value); |
|
330 | append(value); | |
327 | return *this; |
|
331 | return *this; | |
328 | } |
|
332 | } | |
329 |
|
333 | |||
330 | /*! |
|
334 | /*! | |
331 | Convinience operator. Same as append, with QPointF \a value. |
|
335 | Convinience operator. Same as append, with QPointF \a value. | |
332 | \sa append() |
|
336 | \sa append() | |
333 | */ |
|
337 | */ | |
334 | QBarSet& QBarSet::operator << (const QPointF &value) |
|
338 | QBarSet& QBarSet::operator << (const QPointF &value) | |
335 | { |
|
339 | { | |
336 | append(value); |
|
340 | append(value); | |
337 | return *this; |
|
341 | return *this; | |
338 | } |
|
342 | } | |
339 |
|
343 | |||
340 | /*! |
|
344 | /*! | |
341 | Inserts new \a value on the \a index position. |
|
345 | Inserts new \a value on the \a index position. | |
342 | The value that is currently at this postion is moved to postion index + 1 |
|
346 | The value that is currently at this postion is moved to postion index + 1 | |
343 | \sa remove() |
|
347 | \sa remove() | |
344 | */ |
|
348 | */ | |
345 | void QBarSet::insert(const int index, const qreal value) |
|
349 | void QBarSet::insert(const int index, const qreal value) | |
346 | { |
|
350 | { | |
347 | d_ptr->insert(index, value); |
|
351 | d_ptr->insert(index, value); | |
348 | emit valuesAdded(index,1); |
|
352 | emit valuesAdded(index,1); | |
349 | } |
|
353 | } | |
350 |
|
354 | |||
351 | /*! |
|
355 | /*! | |
352 | Inserts new \a value on the \a index position. |
|
356 | Inserts new \a value on the \a index position. | |
353 | The value that is currently at this postion is moved to postion index + 1 |
|
357 | The value that is currently at this postion is moved to postion index + 1 | |
354 | \sa remove() |
|
358 | \sa remove() | |
355 | */ |
|
359 | */ | |
356 | void QBarSet::insert(const int index, const QPointF value) |
|
360 | void QBarSet::insert(const int index, const QPointF value) | |
357 | { |
|
361 | { | |
358 | d_ptr->insert(index,value); |
|
362 | d_ptr->insert(index,value); | |
359 | emit valuesAdded(index,1); |
|
363 | emit valuesAdded(index,1); | |
360 | } |
|
364 | } | |
361 |
|
365 | |||
362 | /*! |
|
366 | /*! | |
363 | Removes \a count number of values from the set starting at \a index. |
|
367 | Removes \a count number of values from the set starting at \a index. | |
364 | \sa insert() |
|
368 | \sa insert() | |
365 | */ |
|
369 | */ | |
366 | void QBarSet::remove(const int index, const int count) |
|
370 | void QBarSet::remove(const int index, const int count) | |
367 | { |
|
371 | { | |
368 | int removedCount = d_ptr->remove(index,count); |
|
372 | int removedCount = d_ptr->remove(index,count); | |
369 | if (removedCount > 0) { |
|
373 | if (removedCount > 0) { | |
370 | emit valuesRemoved(index,removedCount); |
|
374 | emit valuesRemoved(index,removedCount); | |
371 | } |
|
375 | } | |
372 | return; |
|
376 | return; | |
373 | } |
|
377 | } | |
374 |
|
378 | |||
375 | /*! |
|
379 | /*! | |
376 | Sets a new value \a value to set, indexed by \a index |
|
380 | Sets a new value \a value to set, indexed by \a index | |
377 | */ |
|
381 | */ | |
378 | void QBarSet::replace(const int index, const qreal value) |
|
382 | void QBarSet::replace(const int index, const qreal value) | |
379 | { |
|
383 | { | |
380 | if (index >= 0 && index < d_ptr->m_values.count()) { |
|
384 | if (index >= 0 && index < d_ptr->m_values.count()) { | |
381 | d_ptr->replace(index,value); |
|
385 | d_ptr->replace(index,value); | |
382 | emit valueChanged(index); |
|
386 | emit valueChanged(index); | |
383 | } |
|
387 | } | |
384 | } |
|
388 | } | |
385 |
|
389 | |||
386 | /*! |
|
390 | /*! | |
387 | Sets a new value \a value to set, indexed by \a index |
|
391 | Sets a new value \a value to set, indexed by \a index | |
388 | */ |
|
392 | */ | |
389 | void QBarSet::replace(const int index, const QPointF value) |
|
393 | void QBarSet::replace(const int index, const QPointF value) | |
390 | { |
|
394 | { | |
391 | if (index >= 0 && index < d_ptr->m_values.count()) { |
|
395 | if (index >= 0 && index < d_ptr->m_values.count()) { | |
392 | d_ptr->replace(index,value); |
|
396 | d_ptr->replace(index,value); | |
393 | emit valueChanged(index); |
|
397 | emit valueChanged(index); | |
394 | } |
|
398 | } | |
395 | } |
|
399 | } | |
396 |
|
400 | |||
397 | /*! |
|
401 | /*! | |
398 | Returns value of set indexed by \a index. Note that all appended values are stored internally as QPointF. |
|
402 | Returns value of set indexed by \a index. Note that all appended values are stored internally as QPointF. | |
399 | The returned QPointF has x coordinate, which is index (if appended with qreal append) or the x value |
|
403 | The returned QPointF has x coordinate, which is index (if appended with qreal append) or the x value | |
400 | of the QPointF (if appended with QPointF append). |
|
404 | of the QPointF (if appended with QPointF append). | |
401 | If the index is out of bounds QPointF(0, 0.0) is returned. |
|
405 | If the index is out of bounds QPointF(0, 0.0) is returned. | |
402 | */ |
|
406 | */ | |
403 | QPointF QBarSet::at(const int index) const |
|
407 | QPointF QBarSet::at(const int index) const | |
404 | { |
|
408 | { | |
405 | if (index < 0 || index >= d_ptr->m_values.count()) { |
|
409 | if (index < 0 || index >= d_ptr->m_values.count()) { | |
406 | return QPointF(index, 0.0); |
|
410 | return QPointF(index, 0.0); | |
407 | } |
|
411 | } | |
408 |
|
412 | |||
409 | return d_ptr->m_values.at(index); |
|
413 | return d_ptr->m_values.at(index); | |
410 | } |
|
414 | } | |
411 |
|
415 | |||
412 | /*! |
|
416 | /*! | |
413 | Returns value of set indexed by \a index. ote that all appended values are stored internally as QPointF. |
|
417 | Returns value of set indexed by \a index. ote that all appended values are stored internally as QPointF. | |
414 | The returned QPointF has x coordinate, which is index (if appended with qreal append) or the x value |
|
418 | The returned QPointF has x coordinate, which is index (if appended with qreal append) or the x value | |
415 | of the QPointF (if appended with QPointF append). |
|
419 | of the QPointF (if appended with QPointF append). | |
416 | */ |
|
420 | */ | |
417 | QPointF QBarSet::operator [](const int index) const |
|
421 | QPointF QBarSet::operator [](const int index) const | |
418 | { |
|
422 | { | |
419 | return d_ptr->m_values.at(index); |
|
423 | return d_ptr->m_values.at(index); | |
420 | } |
|
424 | } | |
421 |
|
425 | |||
422 | /*! |
|
426 | /*! | |
423 | Returns count of values in set. |
|
427 | Returns count of values in set. | |
424 | */ |
|
428 | */ | |
425 | int QBarSet::count() const |
|
429 | int QBarSet::count() const | |
426 | { |
|
430 | { | |
427 | return d_ptr->m_values.count(); |
|
431 | return d_ptr->m_values.count(); | |
428 | } |
|
432 | } | |
429 |
|
433 | |||
430 | /*! |
|
434 | /*! | |
431 | Returns sum of all values in barset. The sum is sum of y coordinates in the QPointF representation. |
|
435 | Returns sum of all values in barset. The sum is sum of y coordinates in the QPointF representation. | |
432 | */ |
|
436 | */ | |
433 | qreal QBarSet::sum() const |
|
437 | qreal QBarSet::sum() const | |
434 | { |
|
438 | { | |
435 | qreal total(0); |
|
439 | qreal total(0); | |
436 | for (int i=0; i < d_ptr->m_values.count(); i++) { |
|
440 | for (int i=0; i < d_ptr->m_values.count(); i++) { | |
437 | //total += d_ptr->m_values.at(i); |
|
441 | //total += d_ptr->m_values.at(i); | |
438 | total += d_ptr->m_values.at(i).y(); |
|
442 | total += d_ptr->m_values.at(i).y(); | |
439 | } |
|
443 | } | |
440 | return total; |
|
444 | return total; | |
441 | } |
|
445 | } | |
442 |
|
446 | |||
443 | /*! |
|
447 | /*! | |
444 | Sets pen for set. Bars of this set are drawn using \a pen |
|
448 | Sets pen for set. Bars of this set are drawn using \a pen | |
445 | */ |
|
449 | */ | |
446 | void QBarSet::setPen(const QPen &pen) |
|
450 | void QBarSet::setPen(const QPen &pen) | |
447 | { |
|
451 | { | |
448 | if(d_ptr->m_pen!=pen){ |
|
452 | if(d_ptr->m_pen!=pen){ | |
449 | d_ptr->m_pen = pen; |
|
453 | d_ptr->m_pen = pen; | |
450 | emit d_ptr->updatedBars(); |
|
454 | emit d_ptr->updatedBars(); | |
451 | emit penChanged(); |
|
455 | emit penChanged(); | |
452 | } |
|
456 | } | |
453 | } |
|
457 | } | |
454 |
|
458 | |||
455 | /*! |
|
459 | /*! | |
456 | Returns pen of the set. |
|
460 | Returns pen of the set. | |
457 | */ |
|
461 | */ | |
458 | QPen QBarSet::pen() const |
|
462 | QPen QBarSet::pen() const | |
459 | { |
|
463 | { | |
460 | return d_ptr->m_pen; |
|
464 | return d_ptr->m_pen; | |
461 | } |
|
465 | } | |
462 |
|
466 | |||
463 | /*! |
|
467 | /*! | |
464 | Sets brush for the set. Bars of this set are drawn using \a brush |
|
468 | Sets brush for the set. Bars of this set are drawn using \a brush | |
465 | */ |
|
469 | */ | |
466 | void QBarSet::setBrush(const QBrush &brush) |
|
470 | void QBarSet::setBrush(const QBrush &brush) | |
467 | { |
|
471 | { | |
468 | if(d_ptr->m_brush!=brush){ |
|
472 | if(d_ptr->m_brush!=brush){ | |
469 | d_ptr->m_brush = brush; |
|
473 | d_ptr->m_brush = brush; | |
470 | emit d_ptr->updatedBars(); |
|
474 | emit d_ptr->updatedBars(); | |
471 | emit brushChanged(); |
|
475 | emit brushChanged(); | |
472 | } |
|
476 | } | |
473 | } |
|
477 | } | |
474 |
|
478 | |||
475 | /*! |
|
479 | /*! | |
476 | Returns brush of the set. |
|
480 | Returns brush of the set. | |
477 | */ |
|
481 | */ | |
478 | QBrush QBarSet::brush() const |
|
482 | QBrush QBarSet::brush() const | |
479 | { |
|
483 | { | |
480 | return d_ptr->m_brush; |
|
484 | return d_ptr->m_brush; | |
481 | } |
|
485 | } | |
482 |
|
486 | |||
483 | /*! |
|
487 | /*! | |
484 | Sets \a brush of the values that are drawn on top of this barset |
|
488 | Sets \a brush of the values that are drawn on top of this barset | |
485 | */ |
|
489 | */ | |
486 | void QBarSet::setLabelBrush(const QBrush &brush) |
|
490 | void QBarSet::setLabelBrush(const QBrush &brush) | |
487 | { |
|
491 | { | |
488 | if(d_ptr->m_labelBrush!=brush){ |
|
492 | if(d_ptr->m_labelBrush!=brush){ | |
489 | d_ptr->m_labelBrush = brush; |
|
493 | d_ptr->m_labelBrush = brush; | |
490 | emit d_ptr->updatedBars(); |
|
494 | emit d_ptr->updatedBars(); | |
491 | emit labelBrushChanged(); |
|
495 | emit labelBrushChanged(); | |
492 | } |
|
496 | } | |
493 | } |
|
497 | } | |
494 |
|
498 | |||
495 | /*! |
|
499 | /*! | |
496 | Returns brush of the values that are drawn on top of this barset |
|
500 | Returns brush of the values that are drawn on top of this barset | |
497 | */ |
|
501 | */ | |
498 | QBrush QBarSet::labelBrush() const |
|
502 | QBrush QBarSet::labelBrush() const | |
499 | { |
|
503 | { | |
500 | return d_ptr->m_labelBrush; |
|
504 | return d_ptr->m_labelBrush; | |
501 | } |
|
505 | } | |
502 |
|
506 | |||
503 | /*! |
|
507 | /*! | |
504 | Sets the \a font for values that are drawn on top of this barset |
|
508 | Sets the \a font for values that are drawn on top of this barset | |
505 | */ |
|
509 | */ | |
506 | void QBarSet::setLabelFont(const QFont &font) |
|
510 | void QBarSet::setLabelFont(const QFont &font) | |
507 | { |
|
511 | { | |
508 | if(d_ptr->m_labelFont!=font) { |
|
512 | if(d_ptr->m_labelFont!=font) { | |
509 | d_ptr->m_labelFont = font; |
|
513 | d_ptr->m_labelFont = font; | |
510 | emit d_ptr->updatedBars(); |
|
514 | emit d_ptr->updatedBars(); | |
511 | emit labelFontChanged(); |
|
515 | emit labelFontChanged(); | |
512 | } |
|
516 | } | |
513 |
|
517 | |||
514 | } |
|
518 | } | |
515 |
|
519 | |||
516 | /*! |
|
520 | /*! | |
517 | Returns the pen for values that are drawn on top of this barset |
|
521 | Returns the pen for values that are drawn on top of this barset | |
518 | */ |
|
522 | */ | |
519 | QFont QBarSet::labelFont() const |
|
523 | QFont QBarSet::labelFont() const | |
520 | { |
|
524 | { | |
521 | return d_ptr->m_labelFont; |
|
525 | return d_ptr->m_labelFont; | |
522 | } |
|
526 | } | |
523 |
|
527 | |||
524 | /*! |
|
528 | /*! | |
525 | Returns the color of the brush of barset. |
|
529 | Returns the color of the brush of barset. | |
526 | */ |
|
530 | */ | |
527 | QColor QBarSet::color() |
|
531 | QColor QBarSet::color() | |
528 | { |
|
532 | { | |
529 | return brush().color(); |
|
533 | return brush().color(); | |
530 | } |
|
534 | } | |
531 |
|
535 | |||
532 | /*! |
|
536 | /*! | |
533 | Sets the \a color of brush for this barset |
|
537 | Sets the \a color of brush for this barset | |
534 | */ |
|
538 | */ | |
535 | void QBarSet::setColor(QColor color) |
|
539 | void QBarSet::setColor(QColor color) | |
536 | { |
|
540 | { | |
537 | QBrush b = brush(); |
|
541 | QBrush b = brush(); | |
538 | if (b.color() != color) { |
|
542 | if (b.color() != color) { | |
539 | b.setColor(color); |
|
543 | b.setColor(color); | |
540 | setBrush(b); |
|
544 | setBrush(b); | |
541 | emit colorChanged(color); |
|
545 | emit colorChanged(color); | |
542 | } |
|
546 | } | |
543 | } |
|
547 | } | |
544 |
|
548 | |||
545 | /*! |
|
549 | /*! | |
546 | Returns the color of pen of this barset |
|
550 | Returns the color of pen of this barset | |
547 | */ |
|
551 | */ | |
548 | QColor QBarSet::borderColor() |
|
552 | QColor QBarSet::borderColor() | |
549 | { |
|
553 | { | |
550 | return pen().color(); |
|
554 | return pen().color(); | |
551 | } |
|
555 | } | |
552 |
|
556 | |||
553 | /*! |
|
557 | /*! | |
554 | Sets the color of pen for this barset |
|
558 | Sets the color of pen for this barset | |
555 | */ |
|
559 | */ | |
556 | void QBarSet::setBorderColor(QColor color) |
|
560 | void QBarSet::setBorderColor(QColor color) | |
557 | { |
|
561 | { | |
558 | QPen p = pen(); |
|
562 | QPen p = pen(); | |
559 | if (p.color() != color) { |
|
563 | if (p.color() != color) { | |
560 | p.setColor(color); |
|
564 | p.setColor(color); | |
561 | setPen(p); |
|
565 | setPen(p); | |
562 | emit borderColorChanged(color); |
|
566 | emit borderColorChanged(color); | |
563 | } |
|
567 | } | |
564 | } |
|
568 | } | |
565 |
|
569 | |||
566 | /*! |
|
570 | /*! | |
567 | Returns the color of labels of this barset |
|
571 | Returns the color of labels of this barset | |
568 | */ |
|
572 | */ | |
569 | QColor QBarSet::labelColor() |
|
573 | QColor QBarSet::labelColor() | |
570 | { |
|
574 | { | |
571 | return labelBrush().color(); |
|
575 | return labelBrush().color(); | |
572 | } |
|
576 | } | |
573 |
|
577 | |||
574 | /*! |
|
578 | /*! | |
575 | Sets the color of labels for this barset |
|
579 | Sets the color of labels for this barset | |
576 | */ |
|
580 | */ | |
577 | void QBarSet::setLabelColor(QColor color) |
|
581 | void QBarSet::setLabelColor(QColor color) | |
578 | { |
|
582 | { | |
579 | QBrush b = labelBrush(); |
|
583 | QBrush b = labelBrush(); | |
580 | if (b.color() != color) { |
|
584 | if (b.color() != color) { | |
581 | b.setColor(color); |
|
585 | b.setColor(color); | |
582 | setLabelBrush(b); |
|
586 | setLabelBrush(b); | |
583 | emit labelColorChanged(color); |
|
587 | emit labelColorChanged(color); | |
584 | } |
|
588 | } | |
585 | } |
|
589 | } | |
586 |
|
590 | |||
587 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
|
591 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |
588 |
|
592 | |||
589 | QBarSetPrivate::QBarSetPrivate(const QString label, QBarSet *parent) : QObject(parent), |
|
593 | QBarSetPrivate::QBarSetPrivate(const QString label, QBarSet *parent) : QObject(parent), | |
590 | q_ptr(parent), |
|
594 | q_ptr(parent), | |
591 | m_label(label) |
|
595 | m_label(label) | |
592 | { |
|
596 | { | |
593 | } |
|
597 | } | |
594 |
|
598 | |||
595 | QBarSetPrivate::~QBarSetPrivate() |
|
599 | QBarSetPrivate::~QBarSetPrivate() | |
596 | { |
|
600 | { | |
597 | } |
|
601 | } | |
598 |
|
602 | |||
599 | void QBarSetPrivate::append(QPointF value) |
|
603 | void QBarSetPrivate::append(QPointF value) | |
600 | { |
|
604 | { | |
601 | m_values.append(value); |
|
605 | m_values.append(value); | |
602 | emit restructuredBars(); |
|
606 | emit restructuredBars(); | |
603 | } |
|
607 | } | |
604 |
|
608 | |||
605 | void QBarSetPrivate::append(QList<QPointF> values) |
|
609 | void QBarSetPrivate::append(QList<QPointF> values) | |
606 | { |
|
610 | { | |
607 | for (int i=0; i<values.count(); i++) { |
|
611 | for (int i=0; i<values.count(); i++) { | |
608 | m_values.append(values.at(i)); |
|
612 | m_values.append(values.at(i)); | |
609 | } |
|
613 | } | |
610 | emit restructuredBars(); |
|
614 | emit restructuredBars(); | |
611 | } |
|
615 | } | |
612 |
|
616 | |||
613 | void QBarSetPrivate::append(QList<qreal> values) |
|
617 | void QBarSetPrivate::append(QList<qreal> values) | |
614 | { |
|
618 | { | |
615 | int index = m_values.count(); |
|
619 | int index = m_values.count(); | |
616 | for (int i=0; i<values.count(); i++) { |
|
620 | for (int i=0; i<values.count(); i++) { | |
617 | m_values.append(QPointF(index,values.at(i))); |
|
621 | m_values.append(QPointF(index,values.at(i))); | |
618 | index++; |
|
622 | index++; | |
619 | } |
|
623 | } | |
620 | emit restructuredBars(); |
|
624 | emit restructuredBars(); | |
621 | } |
|
625 | } | |
622 |
|
626 | |||
623 | void QBarSetPrivate::insert(const int index, const qreal value) |
|
627 | void QBarSetPrivate::insert(const int index, const qreal value) | |
624 | { |
|
628 | { | |
625 | m_values.insert(index, QPointF(index, value)); |
|
629 | m_values.insert(index, QPointF(index, value)); | |
626 | emit restructuredBars(); |
|
630 | emit restructuredBars(); | |
627 | } |
|
631 | } | |
628 |
|
632 | |||
629 | void QBarSetPrivate::insert(const int index, const QPointF value) |
|
633 | void QBarSetPrivate::insert(const int index, const QPointF value) | |
630 | { |
|
634 | { | |
631 | m_values.insert(index, value); |
|
635 | m_values.insert(index, value); | |
632 | emit restructuredBars(); |
|
636 | emit restructuredBars(); | |
633 | } |
|
637 | } | |
634 |
|
638 | |||
635 | int QBarSetPrivate::remove(const int index, const int count) |
|
639 | int QBarSetPrivate::remove(const int index, const int count) | |
636 | { |
|
640 | { | |
637 | int removeCount = count; |
|
641 | int removeCount = count; | |
638 |
|
642 | |||
639 | if ((index <0) || (m_values.count() == 0)) { |
|
643 | if ((index <0) || (m_values.count() == 0)) { | |
640 | // Invalid index or not values in list, remove nothing. |
|
644 | // Invalid index or not values in list, remove nothing. | |
641 | return 0; |
|
645 | return 0; | |
642 | } else if ((index + count) > m_values.count()) { |
|
646 | } else if ((index + count) > m_values.count()) { | |
643 | // Trying to remove more items than list has. Limit amount to be removed. |
|
647 | // Trying to remove more items than list has. Limit amount to be removed. | |
644 | removeCount = m_values.count() - index; |
|
648 | removeCount = m_values.count() - index; | |
645 | } |
|
649 | } | |
646 |
|
650 | |||
647 | int c = 0; |
|
651 | int c = 0; | |
648 | while (c < removeCount) { |
|
652 | while (c < removeCount) { | |
649 | m_values.removeAt(index); |
|
653 | m_values.removeAt(index); | |
650 | c++; |
|
654 | c++; | |
651 | } |
|
655 | } | |
652 | emit restructuredBars(); |
|
656 | emit restructuredBars(); | |
653 | return removeCount; |
|
657 | return removeCount; | |
654 | } |
|
658 | } | |
655 |
|
659 | |||
656 | void QBarSetPrivate::replace(const int index, const qreal value) |
|
660 | void QBarSetPrivate::replace(const int index, const qreal value) | |
657 | { |
|
661 | { | |
658 | m_values.replace(index,QPointF(index,value)); |
|
662 | m_values.replace(index,QPointF(index,value)); | |
659 | emit updatedBars(); |
|
663 | emit updatedBars(); | |
660 | } |
|
664 | } | |
661 |
|
665 | |||
662 | void QBarSetPrivate::replace(const int index, const QPointF value) |
|
666 | void QBarSetPrivate::replace(const int index, const QPointF value) | |
663 | { |
|
667 | { | |
664 | m_values.replace(index,value); |
|
668 | m_values.replace(index,value); | |
665 | emit updatedBars(); |
|
669 | emit updatedBars(); | |
666 | } |
|
670 | } | |
667 |
|
671 | |||
668 | #include "moc_qbarset.cpp" |
|
672 | #include "moc_qbarset.cpp" | |
669 | #include "moc_qbarset_p.cpp" |
|
673 | #include "moc_qbarset_p.cpp" | |
670 |
|
674 | |||
671 | QTCOMMERCIALCHART_END_NAMESPACE |
|
675 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -1,751 +1,760 | |||||
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 "qpieseries.h" |
|
21 | #include "qpieseries.h" | |
22 | #include "qpieseries_p.h" |
|
22 | #include "qpieseries_p.h" | |
23 | #include "qpieslice.h" |
|
23 | #include "qpieslice.h" | |
24 | #include "qpieslice_p.h" |
|
24 | #include "qpieslice_p.h" | |
25 | #include "pieslicedata_p.h" |
|
25 | #include "pieslicedata_p.h" | |
26 | #include "chartdataset_p.h" |
|
26 | #include "chartdataset_p.h" | |
27 | #include "charttheme_p.h" |
|
27 | #include "charttheme_p.h" | |
28 | #include "chartanimator_p.h" |
|
28 | #include "chartanimator_p.h" | |
29 | #include "legendmarker_p.h" |
|
29 | #include "legendmarker_p.h" | |
30 |
|
30 | |||
31 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
31 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
32 |
|
32 | |||
33 | /*! |
|
33 | /*! | |
34 | \class QPieSeries |
|
34 | \class QPieSeries | |
35 | \brief Pie series API for QtCommercial Charts |
|
35 | \brief Pie series API for QtCommercial Charts | |
36 |
|
36 | |||
37 | The pie series defines a pie chart which consists of pie slices which are defined as QPieSlice objects. |
|
37 | The pie series defines a pie chart which consists of pie slices which are defined as QPieSlice objects. | |
38 | The slices can have any values as the QPieSeries will calculate its relative value to the sum of all slices. |
|
38 | The slices can have any values as the QPieSeries will calculate its relative value to the sum of all slices. | |
39 | The actual slice size is determined by that relative value. |
|
39 | The actual slice size is determined by that relative value. | |
40 |
|
40 | |||
41 | Pie size and position on the chart is controlled by using relative values which range from 0.0 to 1.0 |
|
41 | Pie size and position on the chart is controlled by using relative values which range from 0.0 to 1.0 | |
42 | These relate to the actual chart rectangle. |
|
42 | These relate to the actual chart rectangle. | |
43 |
|
43 | |||
44 | By default the pie is defined as a full pie but it can also be a partial pie. |
|
44 | By default the pie is defined as a full pie but it can also be a partial pie. | |
45 | This can be done by setting a starting angle and angle span to the series. |
|
45 | This can be done by setting a starting angle and angle span to the series. | |
46 | Full pie is 360 degrees where 0 is at 12 a'clock. |
|
46 | Full pie is 360 degrees where 0 is at 12 a'clock. | |
47 |
|
47 | |||
48 | See the \l {PieChart Example} {pie chart example} to learn how to create a simple pie chart. |
|
48 | See the \l {PieChart Example} {pie chart example} to learn how to create a simple pie chart. | |
49 | \image examples_piechart.png |
|
49 | \image examples_piechart.png | |
50 | */ |
|
50 | */ | |
51 | /*! |
|
51 | /*! | |
52 | \qmlclass PieSeries QPieSeries |
|
52 | \qmlclass PieSeries QPieSeries | |
53 | \inherits AbstractSeries |
|
53 | \inherits AbstractSeries | |
54 |
|
54 | |||
55 | The following QML shows how to create a simple pie chart. |
|
55 | The following QML shows how to create a simple pie chart. | |
56 |
|
56 | |||
57 | \snippet ../demos/qmlchart/qml/qmlchart/View1.qml 1 |
|
57 | \snippet ../demos/qmlchart/qml/qmlchart/View1.qml 1 | |
58 |
|
58 | |||
59 | \beginfloatleft |
|
59 | \beginfloatleft | |
60 | \image demos_qmlchart1.png |
|
60 | \image demos_qmlchart1.png | |
61 | \endfloat |
|
61 | \endfloat | |
62 | \clearfloat |
|
62 | \clearfloat | |
63 | */ |
|
63 | */ | |
64 |
|
64 | |||
65 | /*! |
|
65 | /*! | |
66 | \property QPieSeries::horizontalPosition |
|
66 | \property QPieSeries::horizontalPosition | |
67 | \brief Defines the horizontal position of the pie. |
|
67 | \brief Defines the horizontal position of the pie. | |
68 |
|
68 | |||
69 | The value is a relative value to the chart rectangle where: |
|
69 | The value is a relative value to the chart rectangle where: | |
70 |
|
70 | |||
71 | \list |
|
71 | \list | |
72 | \o 0.0 is the absolute left. |
|
72 | \o 0.0 is the absolute left. | |
73 | \o 1.0 is the absolute right. |
|
73 | \o 1.0 is the absolute right. | |
74 | \endlist |
|
74 | \endlist | |
75 | Default value is 0.5 (center). |
|
75 | Default value is 0.5 (center). | |
76 | \sa verticalPosition |
|
76 | \sa verticalPosition | |
77 | */ |
|
77 | */ | |
78 |
|
78 | |||
79 | /*! |
|
79 | /*! | |
80 | \qmlproperty real PieSeries::horizontalPosition |
|
80 | \qmlproperty real PieSeries::horizontalPosition | |
81 |
|
81 | |||
82 | Defines the horizontal position of the pie. |
|
82 | Defines the horizontal position of the pie. | |
83 |
|
83 | |||
84 | The value is a relative value to the chart rectangle where: |
|
84 | The value is a relative value to the chart rectangle where: | |
85 |
|
85 | |||
86 | \list |
|
86 | \list | |
87 | \o 0.0 is the absolute left. |
|
87 | \o 0.0 is the absolute left. | |
88 | \o 1.0 is the absolute right. |
|
88 | \o 1.0 is the absolute right. | |
89 | \endlist |
|
89 | \endlist | |
90 | Default value is 0.5 (center). |
|
90 | Default value is 0.5 (center). | |
91 | \sa verticalPosition |
|
91 | \sa verticalPosition | |
92 | */ |
|
92 | */ | |
93 |
|
93 | |||
94 | /*! |
|
94 | /*! | |
95 | \property QPieSeries::verticalPosition |
|
95 | \property QPieSeries::verticalPosition | |
96 | \brief Defines the vertical position of the pie. |
|
96 | \brief Defines the vertical position of the pie. | |
97 |
|
97 | |||
98 | The value is a relative value to the chart rectangle where: |
|
98 | The value is a relative value to the chart rectangle where: | |
99 |
|
99 | |||
100 | \list |
|
100 | \list | |
101 | \o 0.0 is the absolute top. |
|
101 | \o 0.0 is the absolute top. | |
102 | \o 1.0 is the absolute bottom. |
|
102 | \o 1.0 is the absolute bottom. | |
103 | \endlist |
|
103 | \endlist | |
104 | Default value is 0.5 (center). |
|
104 | Default value is 0.5 (center). | |
105 | \sa horizontalPosition |
|
105 | \sa horizontalPosition | |
106 | */ |
|
106 | */ | |
107 |
|
107 | |||
108 | /*! |
|
108 | /*! | |
109 | \qmlproperty real PieSeries::verticalPosition |
|
109 | \qmlproperty real PieSeries::verticalPosition | |
110 |
|
110 | |||
111 | Defines the vertical position of the pie. |
|
111 | Defines the vertical position of the pie. | |
112 |
|
112 | |||
113 | The value is a relative value to the chart rectangle where: |
|
113 | The value is a relative value to the chart rectangle where: | |
114 |
|
114 | |||
115 | \list |
|
115 | \list | |
116 | \o 0.0 is the absolute top. |
|
116 | \o 0.0 is the absolute top. | |
117 | \o 1.0 is the absolute bottom. |
|
117 | \o 1.0 is the absolute bottom. | |
118 | \endlist |
|
118 | \endlist | |
119 | Default value is 0.5 (center). |
|
119 | Default value is 0.5 (center). | |
120 | \sa horizontalPosition |
|
120 | \sa horizontalPosition | |
121 | */ |
|
121 | */ | |
122 |
|
122 | |||
123 | /*! |
|
123 | /*! | |
124 | \property QPieSeries::size |
|
124 | \property QPieSeries::size | |
125 | \brief Defines the pie size. |
|
125 | \brief Defines the pie size. | |
126 |
|
126 | |||
127 | The value is a relative value to the chart rectangle where: |
|
127 | The value is a relative value to the chart rectangle where: | |
128 |
|
128 | |||
129 | \list |
|
129 | \list | |
130 | \o 0.0 is the minimum size (pie not drawn). |
|
130 | \o 0.0 is the minimum size (pie not drawn). | |
131 | \o 1.0 is the maximum size that can fit the chart. |
|
131 | \o 1.0 is the maximum size that can fit the chart. | |
132 | \endlist |
|
132 | \endlist | |
133 |
|
133 | |||
134 | Default value is 0.7. |
|
134 | Default value is 0.7. | |
135 | */ |
|
135 | */ | |
136 |
|
136 | |||
137 | /*! |
|
137 | /*! | |
138 | \qmlproperty real PieSeries::size |
|
138 | \qmlproperty real PieSeries::size | |
139 |
|
139 | |||
140 | Defines the pie size. |
|
140 | Defines the pie size. | |
141 |
|
141 | |||
142 | The value is a relative value to the chart rectangle where: |
|
142 | The value is a relative value to the chart rectangle where: | |
143 |
|
143 | |||
144 | \list |
|
144 | \list | |
145 | \o 0.0 is the minimum size (pie not drawn). |
|
145 | \o 0.0 is the minimum size (pie not drawn). | |
146 | \o 1.0 is the maximum size that can fit the chart. |
|
146 | \o 1.0 is the maximum size that can fit the chart. | |
147 | \endlist |
|
147 | \endlist | |
148 |
|
148 | |||
149 | Default value is 0.7. |
|
149 | Default value is 0.7. | |
150 | */ |
|
150 | */ | |
151 |
|
151 | |||
152 | /*! |
|
152 | /*! | |
153 | \property QPieSeries::startAngle |
|
153 | \property QPieSeries::startAngle | |
154 | \brief Defines the starting angle of the pie. |
|
154 | \brief Defines the starting angle of the pie. | |
155 |
|
155 | |||
156 | Full pie is 360 degrees where 0 degrees is at 12 a'clock. |
|
156 | Full pie is 360 degrees where 0 degrees is at 12 a'clock. | |
157 |
|
157 | |||
158 | Default is value is 0. |
|
158 | Default is value is 0. | |
159 | */ |
|
159 | */ | |
160 |
|
160 | |||
161 | /*! |
|
161 | /*! | |
162 | \qmlproperty real PieSeries::startAngle |
|
162 | \qmlproperty real PieSeries::startAngle | |
163 |
|
163 | |||
164 | Defines the starting angle of the pie. |
|
164 | Defines the starting angle of the pie. | |
165 |
|
165 | |||
166 | Full pie is 360 degrees where 0 degrees is at 12 a'clock. |
|
166 | Full pie is 360 degrees where 0 degrees is at 12 a'clock. | |
167 |
|
167 | |||
168 | Default is value is 0. |
|
168 | Default is value is 0. | |
169 | */ |
|
169 | */ | |
170 |
|
170 | |||
171 | /*! |
|
171 | /*! | |
172 | \property QPieSeries::endAngle |
|
172 | \property QPieSeries::endAngle | |
173 | \brief Defines the ending angle of the pie. |
|
173 | \brief Defines the ending angle of the pie. | |
174 |
|
174 | |||
175 | Full pie is 360 degrees where 0 degrees is at 12 a'clock. |
|
175 | Full pie is 360 degrees where 0 degrees is at 12 a'clock. | |
176 |
|
176 | |||
177 | Default is value is 360. |
|
177 | Default is value is 360. | |
178 | */ |
|
178 | */ | |
179 |
|
179 | |||
180 | /*! |
|
180 | /*! | |
181 | \qmlproperty real PieSeries::endAngle |
|
181 | \qmlproperty real PieSeries::endAngle | |
182 |
|
182 | |||
183 | Defines the ending angle of the pie. |
|
183 | Defines the ending angle of the pie. | |
184 |
|
184 | |||
185 | Full pie is 360 degrees where 0 degrees is at 12 a'clock. |
|
185 | Full pie is 360 degrees where 0 degrees is at 12 a'clock. | |
186 |
|
186 | |||
187 | Default is value is 360. |
|
187 | Default is value is 360. | |
188 | */ |
|
188 | */ | |
189 |
|
189 | |||
190 | /*! |
|
190 | /*! | |
191 | \property QPieSeries::count |
|
191 | \property QPieSeries::count | |
192 |
|
192 | |||
193 | Number of slices in the series. |
|
193 | Number of slices in the series. | |
194 | */ |
|
194 | */ | |
195 |
|
195 | |||
196 | /*! |
|
196 | /*! | |
197 | \qmlproperty int PieSeries::count |
|
197 | \qmlproperty int PieSeries::count | |
198 |
|
198 | |||
199 | Number of slices in the series. |
|
199 | Number of slices in the series. | |
200 | */ |
|
200 | */ | |
201 |
|
201 | |||
202 | /*! |
|
202 | /*! | |
203 | \fn void QPieSeries::countChanged() |
|
203 | \fn void QPieSeries::countChanged() | |
204 |
|
||||
205 | Emitted when the slice count has changed. |
|
204 | Emitted when the slice count has changed. | |
206 |
|
||||
207 | \sa count |
|
205 | \sa count | |
208 | */ |
|
206 | */ | |
|
207 | /*! | |||
|
208 | \qmlsignal PieSeries::onCountChanged() | |||
|
209 | Emitted when the slice count has changed. | |||
|
210 | */ | |||
209 |
|
211 | |||
210 | /*! |
|
212 | /*! | |
211 | \property QPieSeries::sum |
|
213 | \property QPieSeries::sum | |
212 |
|
214 | |||
213 | Sum of all slices. |
|
215 | Sum of all slices. | |
214 |
|
216 | |||
215 | The series keeps track of the sum of all slices it holds. |
|
217 | The series keeps track of the sum of all slices it holds. | |
216 | */ |
|
218 | */ | |
217 |
|
219 | |||
218 | /*! |
|
220 | /*! | |
219 | \qmlproperty real PieSeries::sum |
|
221 | \qmlproperty real PieSeries::sum | |
220 |
|
222 | |||
221 | Sum of all slices. |
|
223 | Sum of all slices. | |
222 |
|
224 | |||
223 | The series keeps track of the sum of all slices it holds. |
|
225 | The series keeps track of the sum of all slices it holds. | |
224 | */ |
|
226 | */ | |
225 |
|
227 | |||
226 | /*! |
|
228 | /*! | |
227 | \fn void QPieSeries::sumChanged() |
|
229 | \fn void QPieSeries::sumChanged() | |
228 |
|
||||
229 | Emitted when the sum of all slices has changed. |
|
230 | Emitted when the sum of all slices has changed. | |
230 |
|
||||
231 | \sa sum |
|
231 | \sa sum | |
232 | */ |
|
232 | */ | |
|
233 | /*! | |||
|
234 | \qmlsignal PieSeries::onSumChanged() | |||
|
235 | Emitted when the sum of all slices has changed. This may happen for example if you add or remove slices, or if you | |||
|
236 | change value of a slice. | |||
|
237 | */ | |||
233 |
|
238 | |||
234 | /*! |
|
239 | /*! | |
235 | \fn void QPieSeries::added(QList<QPieSlice*> slices) |
|
240 | \fn void QPieSeries::added(QList<QPieSlice*> slices) | |
236 |
|
241 | |||
237 | This signal is emitted when \a slices have been added to the series. |
|
242 | This signal is emitted when \a slices have been added to the series. | |
238 |
|
243 | |||
239 | \sa append(), insert() |
|
244 | \sa append(), insert() | |
240 | */ |
|
245 | */ | |
241 | /*! |
|
246 | /*! | |
242 |
\qmlsignal PieSeries:: |
|
247 | \qmlsignal PieSeries::onAdded(PieSlice slice) | |
243 | Emitted when \a slice has been added to the series. |
|
248 | Emitted when \a slice has been added to the series. | |
244 | */ |
|
249 | */ | |
245 |
|
250 | |||
246 | /*! |
|
251 | /*! | |
247 | \fn void QPieSeries::removed(QList<QPieSlice*> slices) |
|
252 | \fn void QPieSeries::removed(QList<QPieSlice*> slices) | |
248 | This signal is emitted when \a slices have been removed from the series. |
|
253 | This signal is emitted when \a slices have been removed from the series. | |
249 | \sa remove() |
|
254 | \sa remove() | |
250 | */ |
|
255 | */ | |
251 | /*! |
|
256 | /*! | |
252 |
\qmlsignal PieSeries:: |
|
257 | \qmlsignal PieSeries::onRemoved(PieSlice slice) | |
253 | Emitted when \a slice has been removed from the series. |
|
258 | Emitted when \a slice has been removed from the series. | |
254 | */ |
|
259 | */ | |
255 |
|
260 | |||
256 | /*! |
|
261 | /*! | |
257 | \fn void QPieSeries::clicked(QPieSlice* slice) |
|
262 | \fn void QPieSeries::clicked(QPieSlice* slice) | |
258 |
|
||||
259 | This signal is emitted when a \a slice has been clicked. |
|
263 | This signal is emitted when a \a slice has been clicked. | |
260 |
|
||||
261 | \sa QPieSlice::clicked() |
|
264 | \sa QPieSlice::clicked() | |
262 | */ |
|
265 | */ | |
|
266 | /*! | |||
|
267 | \qmlsignal PieSeries::onClicked(PieSlice slice) | |||
|
268 | This signal is emitted when a \a slice has been clicked. | |||
|
269 | */ | |||
263 |
|
270 | |||
264 | /*! |
|
271 | /*! | |
265 | \fn void QPieSeries::hovered(QPieSlice* slice, bool state) |
|
272 | \fn void QPieSeries::hovered(QPieSlice* slice, bool state) | |
266 |
|
||||
267 | This signal is emitted when user has hovered over or away from the \a slice. |
|
273 | This signal is emitted when user has hovered over or away from the \a slice. | |
268 |
|
||||
269 | \a state is true when user has hovered over the slice and false when hover has moved away from the slice. |
|
274 | \a state is true when user has hovered over the slice and false when hover has moved away from the slice. | |
270 |
|
||||
271 | \sa QPieSlice::hovered() |
|
275 | \sa QPieSlice::hovered() | |
272 | */ |
|
276 | */ | |
|
277 | /*! | |||
|
278 | \qmlsignal PieSeries::onHovered(PieSlice slice, bool state) | |||
|
279 | This signal is emitted when user has hovered over or away from the \a slice. \a state is true when user has hovered | |||
|
280 | over the slice and false when hover has moved away from the slice. | |||
|
281 | */ | |||
273 |
|
282 | |||
274 | /*! |
|
283 | /*! | |
275 | \qmlmethod PieSlice PieSeries::at(int index) |
|
284 | \qmlmethod PieSlice PieSeries::at(int index) | |
276 | Returns slice at \a index. Returns null if the index is not valid. |
|
285 | Returns slice at \a index. Returns null if the index is not valid. | |
277 | */ |
|
286 | */ | |
278 |
|
287 | |||
279 | /*! |
|
288 | /*! | |
280 | \qmlmethod PieSlice PieSeries::find(string label) |
|
289 | \qmlmethod PieSlice PieSeries::find(string label) | |
281 | Returns the first slice with \a label. Returns null if the index is not valid. |
|
290 | Returns the first slice with \a label. Returns null if the index is not valid. | |
282 | */ |
|
291 | */ | |
283 |
|
292 | |||
284 | /*! |
|
293 | /*! | |
285 | \qmlmethod PieSlice PieSeries::append(string label, real value) |
|
294 | \qmlmethod PieSlice PieSeries::append(string label, real value) | |
286 | Adds a new slice with \a label and \a value to the pie. |
|
295 | Adds a new slice with \a label and \a value to the pie. | |
287 | */ |
|
296 | */ | |
288 |
|
297 | |||
289 | /*! |
|
298 | /*! | |
290 | \qmlmethod bool PieSeries::remove(PieSlice slice) |
|
299 | \qmlmethod bool PieSeries::remove(PieSlice slice) | |
291 | Removes the \a slice from the pie. Returns true if the removal was successfull, false otherwise. |
|
300 | Removes the \a slice from the pie. Returns true if the removal was successfull, false otherwise. | |
292 | */ |
|
301 | */ | |
293 |
|
302 | |||
294 | /*! |
|
303 | /*! | |
295 | \qmlmethod PieSeries::clear() |
|
304 | \qmlmethod PieSeries::clear() | |
296 | Removes all slices from the pie. |
|
305 | Removes all slices from the pie. | |
297 | */ |
|
306 | */ | |
298 |
|
307 | |||
299 | /*! |
|
308 | /*! | |
300 | Constructs a series object which is a child of \a parent. |
|
309 | Constructs a series object which is a child of \a parent. | |
301 | */ |
|
310 | */ | |
302 | QPieSeries::QPieSeries(QObject *parent) : |
|
311 | QPieSeries::QPieSeries(QObject *parent) : | |
303 | QAbstractSeries(*new QPieSeriesPrivate(this),parent) |
|
312 | QAbstractSeries(*new QPieSeriesPrivate(this),parent) | |
304 | { |
|
313 | { | |
305 |
|
314 | |||
306 | } |
|
315 | } | |
307 |
|
316 | |||
308 | /*! |
|
317 | /*! | |
309 | Destroys the series and its slices. |
|
318 | Destroys the series and its slices. | |
310 | */ |
|
319 | */ | |
311 | QPieSeries::~QPieSeries() |
|
320 | QPieSeries::~QPieSeries() | |
312 | { |
|
321 | { | |
313 | // NOTE: d_prt destroyed by QObject |
|
322 | // NOTE: d_prt destroyed by QObject | |
314 | } |
|
323 | } | |
315 |
|
324 | |||
316 | /*! |
|
325 | /*! | |
317 | Returns QChartSeries::SeriesTypePie. |
|
326 | Returns QChartSeries::SeriesTypePie. | |
318 | */ |
|
327 | */ | |
319 | QAbstractSeries::SeriesType QPieSeries::type() const |
|
328 | QAbstractSeries::SeriesType QPieSeries::type() const | |
320 | { |
|
329 | { | |
321 | return QAbstractSeries::SeriesTypePie; |
|
330 | return QAbstractSeries::SeriesTypePie; | |
322 | } |
|
331 | } | |
323 |
|
332 | |||
324 | /*! |
|
333 | /*! | |
325 | Appends a single \a slice to the series. |
|
334 | Appends a single \a slice to the series. | |
326 | Slice ownership is passed to the series. |
|
335 | Slice ownership is passed to the series. | |
327 |
|
336 | |||
328 | Returns true if append was succesfull. |
|
337 | Returns true if append was succesfull. | |
329 | */ |
|
338 | */ | |
330 | bool QPieSeries::append(QPieSlice* slice) |
|
339 | bool QPieSeries::append(QPieSlice* slice) | |
331 | { |
|
340 | { | |
332 | return append(QList<QPieSlice*>() << slice); |
|
341 | return append(QList<QPieSlice*>() << slice); | |
333 | } |
|
342 | } | |
334 |
|
343 | |||
335 | /*! |
|
344 | /*! | |
336 | Appends an array of \a slices to the series. |
|
345 | Appends an array of \a slices to the series. | |
337 | Slice ownership is passed to the series. |
|
346 | Slice ownership is passed to the series. | |
338 |
|
347 | |||
339 | Returns true if append was successfull. |
|
348 | Returns true if append was successfull. | |
340 | */ |
|
349 | */ | |
341 | bool QPieSeries::append(QList<QPieSlice*> slices) |
|
350 | bool QPieSeries::append(QList<QPieSlice*> slices) | |
342 | { |
|
351 | { | |
343 | Q_D(QPieSeries); |
|
352 | Q_D(QPieSeries); | |
344 |
|
353 | |||
345 | if (slices.count() == 0) |
|
354 | if (slices.count() == 0) | |
346 | return false; |
|
355 | return false; | |
347 |
|
356 | |||
348 | foreach (QPieSlice* s, slices) { |
|
357 | foreach (QPieSlice* s, slices) { | |
349 | if (!s || d->m_slices.contains(s)) |
|
358 | if (!s || d->m_slices.contains(s)) | |
350 | return false; |
|
359 | return false; | |
351 | if (s->series()) // already added to some series |
|
360 | if (s->series()) // already added to some series | |
352 | return false; |
|
361 | return false; | |
353 | } |
|
362 | } | |
354 |
|
363 | |||
355 | foreach (QPieSlice* s, slices) { |
|
364 | foreach (QPieSlice* s, slices) { | |
356 | s->setParent(this); |
|
365 | s->setParent(this); | |
357 | QPieSlicePrivate::fromSlice(s)->m_series = this; |
|
366 | QPieSlicePrivate::fromSlice(s)->m_series = this; | |
358 | d->m_slices << s; |
|
367 | d->m_slices << s; | |
359 | } |
|
368 | } | |
360 |
|
369 | |||
361 | d->updateDerivativeData(); |
|
370 | d->updateDerivativeData(); | |
362 |
|
371 | |||
363 | foreach (QPieSlice* s, slices) { |
|
372 | foreach (QPieSlice* s, slices) { | |
364 | connect(s, SIGNAL(valueChanged()), d, SLOT(sliceValueChanged())); |
|
373 | connect(s, SIGNAL(valueChanged()), d, SLOT(sliceValueChanged())); | |
365 | connect(s, SIGNAL(clicked()), d, SLOT(sliceClicked())); |
|
374 | connect(s, SIGNAL(clicked()), d, SLOT(sliceClicked())); | |
366 | connect(s, SIGNAL(hovered(bool)), d, SLOT(sliceHovered(bool))); |
|
375 | connect(s, SIGNAL(hovered(bool)), d, SLOT(sliceHovered(bool))); | |
367 | } |
|
376 | } | |
368 |
|
377 | |||
369 | emit added(slices); |
|
378 | emit added(slices); | |
370 | emit countChanged(); |
|
379 | emit countChanged(); | |
371 |
|
380 | |||
372 | return true; |
|
381 | return true; | |
373 | } |
|
382 | } | |
374 |
|
383 | |||
375 | /*! |
|
384 | /*! | |
376 | Appends a single \a slice to the series and returns a reference to the series. |
|
385 | Appends a single \a slice to the series and returns a reference to the series. | |
377 | Slice ownership is passed to the series. |
|
386 | Slice ownership is passed to the series. | |
378 | */ |
|
387 | */ | |
379 | QPieSeries& QPieSeries::operator << (QPieSlice* slice) |
|
388 | QPieSeries& QPieSeries::operator << (QPieSlice* slice) | |
380 | { |
|
389 | { | |
381 | append(slice); |
|
390 | append(slice); | |
382 | return *this; |
|
391 | return *this; | |
383 | } |
|
392 | } | |
384 |
|
393 | |||
385 |
|
394 | |||
386 | /*! |
|
395 | /*! | |
387 | Appends a single slice to the series with give \a value and \a label. |
|
396 | Appends a single slice to the series with give \a value and \a label. | |
388 | Slice ownership is passed to the series. |
|
397 | Slice ownership is passed to the series. | |
389 | */ |
|
398 | */ | |
390 | QPieSlice* QPieSeries::append(QString label, qreal value) |
|
399 | QPieSlice* QPieSeries::append(QString label, qreal value) | |
391 | { |
|
400 | { | |
392 | QPieSlice* slice = new QPieSlice(label, value); |
|
401 | QPieSlice* slice = new QPieSlice(label, value); | |
393 | append(slice); |
|
402 | append(slice); | |
394 | return slice; |
|
403 | return slice; | |
395 | } |
|
404 | } | |
396 |
|
405 | |||
397 | /*! |
|
406 | /*! | |
398 | Inserts a single \a slice to the series before the slice at \a index position. |
|
407 | Inserts a single \a slice to the series before the slice at \a index position. | |
399 | Slice ownership is passed to the series. |
|
408 | Slice ownership is passed to the series. | |
400 |
|
409 | |||
401 | Returns true if insert was successfull. |
|
410 | Returns true if insert was successfull. | |
402 | */ |
|
411 | */ | |
403 | bool QPieSeries::insert(int index, QPieSlice* slice) |
|
412 | bool QPieSeries::insert(int index, QPieSlice* slice) | |
404 | { |
|
413 | { | |
405 | Q_D(QPieSeries); |
|
414 | Q_D(QPieSeries); | |
406 |
|
415 | |||
407 | if (index < 0 || index > d->m_slices.count()) |
|
416 | if (index < 0 || index > d->m_slices.count()) | |
408 | return false; |
|
417 | return false; | |
409 |
|
418 | |||
410 | if (!slice || d->m_slices.contains(slice)) |
|
419 | if (!slice || d->m_slices.contains(slice)) | |
411 | return false; |
|
420 | return false; | |
412 |
|
421 | |||
413 | if (slice->series()) // already added to some series |
|
422 | if (slice->series()) // already added to some series | |
414 | return false; |
|
423 | return false; | |
415 |
|
424 | |||
416 | slice->setParent(this); |
|
425 | slice->setParent(this); | |
417 | QPieSlicePrivate::fromSlice(slice)->m_series = this; |
|
426 | QPieSlicePrivate::fromSlice(slice)->m_series = this; | |
418 | d->m_slices.insert(index, slice); |
|
427 | d->m_slices.insert(index, slice); | |
419 |
|
428 | |||
420 | d->updateDerivativeData(); |
|
429 | d->updateDerivativeData(); | |
421 |
|
430 | |||
422 | connect(slice, SIGNAL(valueChanged()), d, SLOT(sliceValueChanged())); |
|
431 | connect(slice, SIGNAL(valueChanged()), d, SLOT(sliceValueChanged())); | |
423 | connect(slice, SIGNAL(clicked()), d, SLOT(sliceClicked())); |
|
432 | connect(slice, SIGNAL(clicked()), d, SLOT(sliceClicked())); | |
424 | connect(slice, SIGNAL(hovered(bool)), d, SLOT(sliceHovered(bool))); |
|
433 | connect(slice, SIGNAL(hovered(bool)), d, SLOT(sliceHovered(bool))); | |
425 |
|
434 | |||
426 | emit added(QList<QPieSlice*>() << slice); |
|
435 | emit added(QList<QPieSlice*>() << slice); | |
427 | emit countChanged(); |
|
436 | emit countChanged(); | |
428 |
|
437 | |||
429 | return true; |
|
438 | return true; | |
430 | } |
|
439 | } | |
431 |
|
440 | |||
432 | /*! |
|
441 | /*! | |
433 | Removes a single \a slice from the series and deletes the slice. |
|
442 | Removes a single \a slice from the series and deletes the slice. | |
434 |
|
443 | |||
435 | Do not reference the pointer after this call. |
|
444 | Do not reference the pointer after this call. | |
436 |
|
445 | |||
437 | Returns true if remove was successfull. |
|
446 | Returns true if remove was successfull. | |
438 | */ |
|
447 | */ | |
439 | bool QPieSeries::remove(QPieSlice* slice) |
|
448 | bool QPieSeries::remove(QPieSlice* slice) | |
440 | { |
|
449 | { | |
441 | Q_D(QPieSeries); |
|
450 | Q_D(QPieSeries); | |
442 |
|
451 | |||
443 | if (!d->m_slices.removeOne(slice)) |
|
452 | if (!d->m_slices.removeOne(slice)) | |
444 | return false; |
|
453 | return false; | |
445 |
|
454 | |||
446 | d->updateDerivativeData(); |
|
455 | d->updateDerivativeData(); | |
447 |
|
456 | |||
448 | emit removed(QList<QPieSlice*>() << slice); |
|
457 | emit removed(QList<QPieSlice*>() << slice); | |
449 | emit countChanged(); |
|
458 | emit countChanged(); | |
450 |
|
459 | |||
451 | delete slice; |
|
460 | delete slice; | |
452 | slice = 0; |
|
461 | slice = 0; | |
453 |
|
462 | |||
454 | return true; |
|
463 | return true; | |
455 | } |
|
464 | } | |
456 |
|
465 | |||
457 | /*! |
|
466 | /*! | |
458 | Clears all slices from the series. |
|
467 | Clears all slices from the series. | |
459 | */ |
|
468 | */ | |
460 | void QPieSeries::clear() |
|
469 | void QPieSeries::clear() | |
461 | { |
|
470 | { | |
462 | Q_D(QPieSeries); |
|
471 | Q_D(QPieSeries); | |
463 | if (d->m_slices.count() == 0) |
|
472 | if (d->m_slices.count() == 0) | |
464 | return; |
|
473 | return; | |
465 |
|
474 | |||
466 | QList<QPieSlice*> slices = d->m_slices; |
|
475 | QList<QPieSlice*> slices = d->m_slices; | |
467 | foreach (QPieSlice* s, d->m_slices) { |
|
476 | foreach (QPieSlice* s, d->m_slices) { | |
468 | d->m_slices.removeOne(s); |
|
477 | d->m_slices.removeOne(s); | |
469 | delete s; |
|
478 | delete s; | |
470 | } |
|
479 | } | |
471 |
|
480 | |||
472 | d->updateDerivativeData(); |
|
481 | d->updateDerivativeData(); | |
473 |
|
482 | |||
474 | emit removed(slices); |
|
483 | emit removed(slices); | |
475 | emit countChanged(); |
|
484 | emit countChanged(); | |
476 | } |
|
485 | } | |
477 |
|
486 | |||
478 | /*! |
|
487 | /*! | |
479 | Returns a list of slices that belong to this series. |
|
488 | Returns a list of slices that belong to this series. | |
480 | */ |
|
489 | */ | |
481 | QList<QPieSlice*> QPieSeries::slices() const |
|
490 | QList<QPieSlice*> QPieSeries::slices() const | |
482 | { |
|
491 | { | |
483 | Q_D(const QPieSeries); |
|
492 | Q_D(const QPieSeries); | |
484 | return d->m_slices; |
|
493 | return d->m_slices; | |
485 | } |
|
494 | } | |
486 |
|
495 | |||
487 | /*! |
|
496 | /*! | |
488 | returns the number of the slices in this series. |
|
497 | returns the number of the slices in this series. | |
489 | */ |
|
498 | */ | |
490 | int QPieSeries::count() const |
|
499 | int QPieSeries::count() const | |
491 | { |
|
500 | { | |
492 | Q_D(const QPieSeries); |
|
501 | Q_D(const QPieSeries); | |
493 | return d->m_slices.count(); |
|
502 | return d->m_slices.count(); | |
494 | } |
|
503 | } | |
495 |
|
504 | |||
496 | /*! |
|
505 | /*! | |
497 | Returns true is the series is empty. |
|
506 | Returns true is the series is empty. | |
498 | */ |
|
507 | */ | |
499 | bool QPieSeries::isEmpty() const |
|
508 | bool QPieSeries::isEmpty() const | |
500 | { |
|
509 | { | |
501 | Q_D(const QPieSeries); |
|
510 | Q_D(const QPieSeries); | |
502 | return d->m_slices.isEmpty(); |
|
511 | return d->m_slices.isEmpty(); | |
503 | } |
|
512 | } | |
504 |
|
513 | |||
505 | /*! |
|
514 | /*! | |
506 | Returns the sum of all slice values in this series. |
|
515 | Returns the sum of all slice values in this series. | |
507 |
|
516 | |||
508 | \sa QPieSlice::value(), QPieSlice::setValue(), QPieSlice::percentage() |
|
517 | \sa QPieSlice::value(), QPieSlice::setValue(), QPieSlice::percentage() | |
509 | */ |
|
518 | */ | |
510 | qreal QPieSeries::sum() const |
|
519 | qreal QPieSeries::sum() const | |
511 | { |
|
520 | { | |
512 | Q_D(const QPieSeries); |
|
521 | Q_D(const QPieSeries); | |
513 | return d->m_sum; |
|
522 | return d->m_sum; | |
514 | } |
|
523 | } | |
515 |
|
524 | |||
516 | void QPieSeries::setHorizontalPosition(qreal relativePosition) |
|
525 | void QPieSeries::setHorizontalPosition(qreal relativePosition) | |
517 | { |
|
526 | { | |
518 | Q_D(QPieSeries); |
|
527 | Q_D(QPieSeries); | |
519 |
|
528 | |||
520 | if (relativePosition < 0.0) |
|
529 | if (relativePosition < 0.0) | |
521 | relativePosition = 0.0; |
|
530 | relativePosition = 0.0; | |
522 | if (relativePosition > 1.0) |
|
531 | if (relativePosition > 1.0) | |
523 | relativePosition = 1.0; |
|
532 | relativePosition = 1.0; | |
524 |
|
533 | |||
525 | if (!qFuzzyIsNull(d->m_pieRelativeHorPos - relativePosition)) { |
|
534 | if (!qFuzzyIsNull(d->m_pieRelativeHorPos - relativePosition)) { | |
526 | d->m_pieRelativeHorPos = relativePosition; |
|
535 | d->m_pieRelativeHorPos = relativePosition; | |
527 | emit d->horizontalPositionChanged(); |
|
536 | emit d->horizontalPositionChanged(); | |
528 | } |
|
537 | } | |
529 | } |
|
538 | } | |
530 |
|
539 | |||
531 | qreal QPieSeries::horizontalPosition() const |
|
540 | qreal QPieSeries::horizontalPosition() const | |
532 | { |
|
541 | { | |
533 | Q_D(const QPieSeries); |
|
542 | Q_D(const QPieSeries); | |
534 | return d->m_pieRelativeHorPos; |
|
543 | return d->m_pieRelativeHorPos; | |
535 | } |
|
544 | } | |
536 |
|
545 | |||
537 | void QPieSeries::setVerticalPosition(qreal relativePosition) |
|
546 | void QPieSeries::setVerticalPosition(qreal relativePosition) | |
538 | { |
|
547 | { | |
539 | Q_D(QPieSeries); |
|
548 | Q_D(QPieSeries); | |
540 |
|
549 | |||
541 | if (relativePosition < 0.0) |
|
550 | if (relativePosition < 0.0) | |
542 | relativePosition = 0.0; |
|
551 | relativePosition = 0.0; | |
543 | if (relativePosition > 1.0) |
|
552 | if (relativePosition > 1.0) | |
544 | relativePosition = 1.0; |
|
553 | relativePosition = 1.0; | |
545 |
|
554 | |||
546 | if (!qFuzzyIsNull(d->m_pieRelativeVerPos - relativePosition)) { |
|
555 | if (!qFuzzyIsNull(d->m_pieRelativeVerPos - relativePosition)) { | |
547 | d->m_pieRelativeVerPos = relativePosition; |
|
556 | d->m_pieRelativeVerPos = relativePosition; | |
548 | emit d->verticalPositionChanged(); |
|
557 | emit d->verticalPositionChanged(); | |
549 | } |
|
558 | } | |
550 | } |
|
559 | } | |
551 |
|
560 | |||
552 | qreal QPieSeries::verticalPosition() const |
|
561 | qreal QPieSeries::verticalPosition() const | |
553 | { |
|
562 | { | |
554 | Q_D(const QPieSeries); |
|
563 | Q_D(const QPieSeries); | |
555 | return d->m_pieRelativeVerPos; |
|
564 | return d->m_pieRelativeVerPos; | |
556 | } |
|
565 | } | |
557 |
|
566 | |||
558 | void QPieSeries::setPieSize(qreal relativeSize) |
|
567 | void QPieSeries::setPieSize(qreal relativeSize) | |
559 | { |
|
568 | { | |
560 | Q_D(QPieSeries); |
|
569 | Q_D(QPieSeries); | |
561 |
|
570 | |||
562 | if (relativeSize < 0.0) |
|
571 | if (relativeSize < 0.0) | |
563 | relativeSize = 0.0; |
|
572 | relativeSize = 0.0; | |
564 | if (relativeSize > 1.0) |
|
573 | if (relativeSize > 1.0) | |
565 | relativeSize = 1.0; |
|
574 | relativeSize = 1.0; | |
566 |
|
575 | |||
567 | if (!qFuzzyIsNull(d->m_pieRelativeSize - relativeSize)) { |
|
576 | if (!qFuzzyIsNull(d->m_pieRelativeSize - relativeSize)) { | |
568 | d->m_pieRelativeSize = relativeSize; |
|
577 | d->m_pieRelativeSize = relativeSize; | |
569 | emit d->pieSizeChanged(); |
|
578 | emit d->pieSizeChanged(); | |
570 | } |
|
579 | } | |
571 | } |
|
580 | } | |
572 |
|
581 | |||
573 | qreal QPieSeries::pieSize() const |
|
582 | qreal QPieSeries::pieSize() const | |
574 | { |
|
583 | { | |
575 | Q_D(const QPieSeries); |
|
584 | Q_D(const QPieSeries); | |
576 | return d->m_pieRelativeSize; |
|
585 | return d->m_pieRelativeSize; | |
577 | } |
|
586 | } | |
578 |
|
587 | |||
579 |
|
588 | |||
580 | void QPieSeries::setPieStartAngle(qreal angle) |
|
589 | void QPieSeries::setPieStartAngle(qreal angle) | |
581 | { |
|
590 | { | |
582 | Q_D(QPieSeries); |
|
591 | Q_D(QPieSeries); | |
583 | if (qFuzzyIsNull(d->m_pieStartAngle - angle)) |
|
592 | if (qFuzzyIsNull(d->m_pieStartAngle - angle)) | |
584 | return; |
|
593 | return; | |
585 | d->m_pieStartAngle = angle; |
|
594 | d->m_pieStartAngle = angle; | |
586 | d->updateDerivativeData(); |
|
595 | d->updateDerivativeData(); | |
587 | emit d->pieStartAngleChanged(); |
|
596 | emit d->pieStartAngleChanged(); | |
588 | } |
|
597 | } | |
589 |
|
598 | |||
590 | qreal QPieSeries::pieStartAngle() const |
|
599 | qreal QPieSeries::pieStartAngle() const | |
591 | { |
|
600 | { | |
592 | Q_D(const QPieSeries); |
|
601 | Q_D(const QPieSeries); | |
593 | return d->m_pieStartAngle; |
|
602 | return d->m_pieStartAngle; | |
594 | } |
|
603 | } | |
595 |
|
604 | |||
596 | /*! |
|
605 | /*! | |
597 | Sets the end angle of the pie. |
|
606 | Sets the end angle of the pie. | |
598 |
|
607 | |||
599 | Full pie is 360 degrees where 0 degrees is at 12 a'clock. |
|
608 | Full pie is 360 degrees where 0 degrees is at 12 a'clock. | |
600 |
|
609 | |||
601 | \a angle must be greater than start angle. |
|
610 | \a angle must be greater than start angle. | |
602 |
|
611 | |||
603 | \sa pieEndAngle(), pieStartAngle(), setPieStartAngle() |
|
612 | \sa pieEndAngle(), pieStartAngle(), setPieStartAngle() | |
604 | */ |
|
613 | */ | |
605 | void QPieSeries::setPieEndAngle(qreal angle) |
|
614 | void QPieSeries::setPieEndAngle(qreal angle) | |
606 | { |
|
615 | { | |
607 | Q_D(QPieSeries); |
|
616 | Q_D(QPieSeries); | |
608 | if (qFuzzyIsNull(d->m_pieEndAngle - angle)) |
|
617 | if (qFuzzyIsNull(d->m_pieEndAngle - angle)) | |
609 | return; |
|
618 | return; | |
610 | d->m_pieEndAngle = angle; |
|
619 | d->m_pieEndAngle = angle; | |
611 | d->updateDerivativeData(); |
|
620 | d->updateDerivativeData(); | |
612 | emit d->pieEndAngleChanged(); |
|
621 | emit d->pieEndAngleChanged(); | |
613 | } |
|
622 | } | |
614 |
|
623 | |||
615 | /*! |
|
624 | /*! | |
616 | Returns the end angle of the pie. |
|
625 | Returns the end angle of the pie. | |
617 |
|
626 | |||
618 | Full pie is 360 degrees where 0 degrees is at 12 a'clock. |
|
627 | Full pie is 360 degrees where 0 degrees is at 12 a'clock. | |
619 |
|
628 | |||
620 | \sa setPieEndAngle(), pieStartAngle(), setPieStartAngle() |
|
629 | \sa setPieEndAngle(), pieStartAngle(), setPieStartAngle() | |
621 | */ |
|
630 | */ | |
622 | qreal QPieSeries::pieEndAngle() const |
|
631 | qreal QPieSeries::pieEndAngle() const | |
623 | { |
|
632 | { | |
624 | Q_D(const QPieSeries); |
|
633 | Q_D(const QPieSeries); | |
625 | return d->m_pieEndAngle; |
|
634 | return d->m_pieEndAngle; | |
626 | } |
|
635 | } | |
627 |
|
636 | |||
628 | /*! |
|
637 | /*! | |
629 | Sets the all the slice labels \a visible or invisible. |
|
638 | Sets the all the slice labels \a visible or invisible. | |
630 |
|
639 | |||
631 | Note that this affects only the current slices in the series. |
|
640 | Note that this affects only the current slices in the series. | |
632 | If user adds a new slice the default label visibility is false. |
|
641 | If user adds a new slice the default label visibility is false. | |
633 |
|
642 | |||
634 | \sa QPieSlice::isLabelVisible(), QPieSlice::setLabelVisible() |
|
643 | \sa QPieSlice::isLabelVisible(), QPieSlice::setLabelVisible() | |
635 | */ |
|
644 | */ | |
636 | void QPieSeries::setLabelsVisible(bool visible) |
|
645 | void QPieSeries::setLabelsVisible(bool visible) | |
637 | { |
|
646 | { | |
638 | Q_D(QPieSeries); |
|
647 | Q_D(QPieSeries); | |
639 | foreach (QPieSlice* s, d->m_slices) |
|
648 | foreach (QPieSlice* s, d->m_slices) | |
640 | s->setLabelVisible(visible); |
|
649 | s->setLabelVisible(visible); | |
641 | } |
|
650 | } | |
642 |
|
651 | |||
643 | /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
|
652 | /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |
644 |
|
653 | |||
645 |
|
654 | |||
646 | QPieSeriesPrivate::QPieSeriesPrivate(QPieSeries *parent) : |
|
655 | QPieSeriesPrivate::QPieSeriesPrivate(QPieSeries *parent) : | |
647 | QAbstractSeriesPrivate(parent), |
|
656 | QAbstractSeriesPrivate(parent), | |
648 | m_pieRelativeHorPos(0.5), |
|
657 | m_pieRelativeHorPos(0.5), | |
649 | m_pieRelativeVerPos(0.5), |
|
658 | m_pieRelativeVerPos(0.5), | |
650 | m_pieRelativeSize(0.7), |
|
659 | m_pieRelativeSize(0.7), | |
651 | m_pieStartAngle(0), |
|
660 | m_pieStartAngle(0), | |
652 | m_pieEndAngle(360), |
|
661 | m_pieEndAngle(360), | |
653 | m_sum(0) |
|
662 | m_sum(0) | |
654 | { |
|
663 | { | |
655 | } |
|
664 | } | |
656 |
|
665 | |||
657 | QPieSeriesPrivate::~QPieSeriesPrivate() |
|
666 | QPieSeriesPrivate::~QPieSeriesPrivate() | |
658 | { |
|
667 | { | |
659 | } |
|
668 | } | |
660 |
|
669 | |||
661 | void QPieSeriesPrivate::updateDerivativeData() |
|
670 | void QPieSeriesPrivate::updateDerivativeData() | |
662 | { |
|
671 | { | |
663 | // calculate sum of all slices |
|
672 | // calculate sum of all slices | |
664 | qreal sum = 0; |
|
673 | qreal sum = 0; | |
665 | foreach (QPieSlice* s, m_slices) |
|
674 | foreach (QPieSlice* s, m_slices) | |
666 | sum += s->value(); |
|
675 | sum += s->value(); | |
667 |
|
676 | |||
668 | if (!qFuzzyIsNull(m_sum - sum)) { |
|
677 | if (!qFuzzyIsNull(m_sum - sum)) { | |
669 | m_sum = sum; |
|
678 | m_sum = sum; | |
670 | emit q_func()->sumChanged(); |
|
679 | emit q_func()->sumChanged(); | |
671 | } |
|
680 | } | |
672 |
|
681 | |||
673 | // nothing to show.. |
|
682 | // nothing to show.. | |
674 | if (qFuzzyIsNull(m_sum)) |
|
683 | if (qFuzzyIsNull(m_sum)) | |
675 | return; |
|
684 | return; | |
676 |
|
685 | |||
677 | // update slice attributes |
|
686 | // update slice attributes | |
678 | qreal sliceAngle = m_pieStartAngle; |
|
687 | qreal sliceAngle = m_pieStartAngle; | |
679 | qreal pieSpan = m_pieEndAngle - m_pieStartAngle; |
|
688 | qreal pieSpan = m_pieEndAngle - m_pieStartAngle; | |
680 | QVector<QPieSlice*> changed; |
|
689 | QVector<QPieSlice*> changed; | |
681 | foreach (QPieSlice* s, m_slices) { |
|
690 | foreach (QPieSlice* s, m_slices) { | |
682 | QPieSlicePrivate *d = QPieSlicePrivate::fromSlice(s); |
|
691 | QPieSlicePrivate *d = QPieSlicePrivate::fromSlice(s); | |
683 | d->setPercentage(s->value() / m_sum); |
|
692 | d->setPercentage(s->value() / m_sum); | |
684 | d->setStartAngle(sliceAngle); |
|
693 | d->setStartAngle(sliceAngle); | |
685 | d->setAngleSpan(pieSpan * s->percentage()); |
|
694 | d->setAngleSpan(pieSpan * s->percentage()); | |
686 | sliceAngle += s->angleSpan(); |
|
695 | sliceAngle += s->angleSpan(); | |
687 | } |
|
696 | } | |
688 |
|
697 | |||
689 |
|
698 | |||
690 | emit calculatedDataChanged(); |
|
699 | emit calculatedDataChanged(); | |
691 | } |
|
700 | } | |
692 |
|
701 | |||
693 | QPieSeriesPrivate* QPieSeriesPrivate::fromSeries(QPieSeries *series) |
|
702 | QPieSeriesPrivate* QPieSeriesPrivate::fromSeries(QPieSeries *series) | |
694 | { |
|
703 | { | |
695 | return series->d_func(); |
|
704 | return series->d_func(); | |
696 | } |
|
705 | } | |
697 |
|
706 | |||
698 | void QPieSeriesPrivate::sliceValueChanged() |
|
707 | void QPieSeriesPrivate::sliceValueChanged() | |
699 | { |
|
708 | { | |
700 | Q_ASSERT(m_slices.contains(qobject_cast<QPieSlice *>(sender()))); |
|
709 | Q_ASSERT(m_slices.contains(qobject_cast<QPieSlice *>(sender()))); | |
701 | updateDerivativeData(); |
|
710 | updateDerivativeData(); | |
702 | } |
|
711 | } | |
703 |
|
712 | |||
704 | void QPieSeriesPrivate::sliceClicked() |
|
713 | void QPieSeriesPrivate::sliceClicked() | |
705 | { |
|
714 | { | |
706 | QPieSlice* slice = qobject_cast<QPieSlice *>(sender()); |
|
715 | QPieSlice* slice = qobject_cast<QPieSlice *>(sender()); | |
707 | Q_ASSERT(m_slices.contains(slice)); |
|
716 | Q_ASSERT(m_slices.contains(slice)); | |
708 | Q_Q(QPieSeries); |
|
717 | Q_Q(QPieSeries); | |
709 | emit q->clicked(slice); |
|
718 | emit q->clicked(slice); | |
710 | } |
|
719 | } | |
711 |
|
720 | |||
712 | void QPieSeriesPrivate::sliceHovered(bool state) |
|
721 | void QPieSeriesPrivate::sliceHovered(bool state) | |
713 | { |
|
722 | { | |
714 | QPieSlice* slice = qobject_cast<QPieSlice *>(sender()); |
|
723 | QPieSlice* slice = qobject_cast<QPieSlice *>(sender()); | |
715 | Q_ASSERT(m_slices.contains(slice)); |
|
724 | Q_ASSERT(m_slices.contains(slice)); | |
716 | Q_Q(QPieSeries); |
|
725 | Q_Q(QPieSeries); | |
717 | emit q->hovered(slice, state); |
|
726 | emit q->hovered(slice, state); | |
718 | } |
|
727 | } | |
719 |
|
728 | |||
720 | void QPieSeriesPrivate::scaleDomain(Domain& domain) |
|
729 | void QPieSeriesPrivate::scaleDomain(Domain& domain) | |
721 | { |
|
730 | { | |
722 | Q_UNUSED(domain); |
|
731 | Q_UNUSED(domain); | |
723 | // does not apply to pie |
|
732 | // does not apply to pie | |
724 | } |
|
733 | } | |
725 |
|
734 | |||
726 | Chart* QPieSeriesPrivate::createGraphics(ChartPresenter* presenter) |
|
735 | Chart* QPieSeriesPrivate::createGraphics(ChartPresenter* presenter) | |
727 | { |
|
736 | { | |
728 | Q_Q(QPieSeries); |
|
737 | Q_Q(QPieSeries); | |
729 | PieChartItem* pie = new PieChartItem(q,presenter); |
|
738 | PieChartItem* pie = new PieChartItem(q,presenter); | |
730 | if(presenter->animationOptions().testFlag(QChart::SeriesAnimations)) { |
|
739 | if(presenter->animationOptions().testFlag(QChart::SeriesAnimations)) { | |
731 | presenter->animator()->addAnimation(pie); |
|
740 | presenter->animator()->addAnimation(pie); | |
732 | } |
|
741 | } | |
733 | presenter->chartTheme()->decorate(q, presenter->dataSet()->seriesIndex(q)); |
|
742 | presenter->chartTheme()->decorate(q, presenter->dataSet()->seriesIndex(q)); | |
734 | return pie; |
|
743 | return pie; | |
735 | } |
|
744 | } | |
736 |
|
745 | |||
737 | QList<LegendMarker*> QPieSeriesPrivate::createLegendMarker(QLegend* legend) |
|
746 | QList<LegendMarker*> QPieSeriesPrivate::createLegendMarker(QLegend* legend) | |
738 | { |
|
747 | { | |
739 | Q_Q(QPieSeries); |
|
748 | Q_Q(QPieSeries); | |
740 | QList<LegendMarker*> markers; |
|
749 | QList<LegendMarker*> markers; | |
741 | foreach(QPieSlice* slice, q->slices()) { |
|
750 | foreach(QPieSlice* slice, q->slices()) { | |
742 | PieLegendMarker* marker = new PieLegendMarker(q,slice,legend); |
|
751 | PieLegendMarker* marker = new PieLegendMarker(q,slice,legend); | |
743 | markers << marker; |
|
752 | markers << marker; | |
744 | } |
|
753 | } | |
745 | return markers; |
|
754 | return markers; | |
746 | } |
|
755 | } | |
747 |
|
756 | |||
748 | #include "moc_qpieseries.cpp" |
|
757 | #include "moc_qpieseries.cpp" | |
749 | #include "moc_qpieseries_p.cpp" |
|
758 | #include "moc_qpieseries_p.cpp" | |
750 |
|
759 | |||
751 | QTCOMMERCIALCHART_END_NAMESPACE |
|
760 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -1,779 +1,779 | |||||
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 "qpieslice.h" |
|
21 | #include "qpieslice.h" | |
22 | #include "qpieslice_p.h" |
|
22 | #include "qpieslice_p.h" | |
23 |
|
23 | |||
24 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
24 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
25 |
|
25 | |||
26 | /*! |
|
26 | /*! | |
27 | \class QPieSlice |
|
27 | \class QPieSlice | |
28 | \brief Defines a slice in pie series. |
|
28 | \brief Defines a slice in pie series. | |
29 |
|
29 | |||
30 | This object defines the properties of a single slice in a QPieSeries. |
|
30 | This object defines the properties of a single slice in a QPieSeries. | |
31 |
|
31 | |||
32 | In addition to the obvious value and label properties the user can also control |
|
32 | In addition to the obvious value and label properties the user can also control | |
33 | the visual appearance of a slice. By modifying the visual appearance also means that |
|
33 | the visual appearance of a slice. By modifying the visual appearance also means that | |
34 | the user is overriding the default appearance set by the theme. |
|
34 | the user is overriding the default appearance set by the theme. | |
35 |
|
35 | |||
36 | Note that if the user has customized slices and theme is changed all customizations will be lost. |
|
36 | Note that if the user has customized slices and theme is changed all customizations will be lost. | |
37 |
|
37 | |||
38 | To enable user interaction with the pie some basic signals are provided about clicking and hovering. |
|
38 | To enable user interaction with the pie some basic signals are provided about clicking and hovering. | |
39 | */ |
|
39 | */ | |
40 |
|
40 | |||
41 | /*! |
|
41 | /*! | |
42 | \qmlclass PieSlice QPieSlice |
|
42 | \qmlclass PieSlice QPieSlice | |
43 | PieSlice defines the properties of a single slice in a PieSeries. The element should be used |
|
43 | PieSlice defines the properties of a single slice in a PieSeries. The element should be used | |
44 | as a child for a PieSeries. For example: |
|
44 | as a child for a PieSeries. For example: | |
45 | \snippet ../examples/qmlpiechart/qml/qmlpiechart/main.qml 2 |
|
45 | \snippet ../examples/qmlpiechart/qml/qmlpiechart/main.qml 2 | |
46 |
|
46 | |||
47 | An alternative (dynamic) method for adding slices to a PieSeries is using PieSeries.append |
|
47 | An alternative (dynamic) method for adding slices to a PieSeries is using PieSeries.append | |
48 | method. |
|
48 | method. | |
49 | \snippet ../examples/qmlpiechart/qml/qmlpiechart/main.qml 4 |
|
49 | \snippet ../examples/qmlpiechart/qml/qmlpiechart/main.qml 4 | |
50 |
|
50 | |||
51 | In that case you may want to use PieSeries.at or PieSeries.find to access the properties of |
|
51 | In that case you may want to use PieSeries.at or PieSeries.find to access the properties of | |
52 | an individual PieSlice instance. |
|
52 | an individual PieSlice instance. | |
53 | \snippet ../examples/qmlpiechart/qml/qmlpiechart/main.qml 5 |
|
53 | \snippet ../examples/qmlpiechart/qml/qmlpiechart/main.qml 5 | |
54 | \sa PieSeries |
|
54 | \sa PieSeries | |
55 | */ |
|
55 | */ | |
56 |
|
56 | |||
57 | /*! |
|
57 | /*! | |
58 | \enum QPieSlice::LabelPosition |
|
58 | \enum QPieSlice::LabelPosition | |
59 |
|
59 | |||
60 | This enum describes the position of the slice label. |
|
60 | This enum describes the position of the slice label. | |
61 |
|
61 | |||
62 | \value LabelOutside Label is outside the slice with an arm. |
|
62 | \value LabelOutside Label is outside the slice with an arm. | |
63 | \value LabelInside Label is centered inside the slice. |
|
63 | \value LabelInside Label is centered inside the slice. | |
64 |
|
64 | |||
65 | */ |
|
65 | */ | |
66 |
|
66 | |||
67 | /*! |
|
67 | /*! | |
68 | \property QPieSlice::label |
|
68 | \property QPieSlice::label | |
69 | Label of the slice. |
|
69 | Label of the slice. | |
70 | \sa labelVisible, labelBrush, labelFont, labelArmLengthFactor |
|
70 | \sa labelVisible, labelBrush, labelFont, labelArmLengthFactor | |
71 | */ |
|
71 | */ | |
72 | /*! |
|
72 | /*! | |
73 | \qmlproperty string PieSlice::label |
|
73 | \qmlproperty string PieSlice::label | |
74 | Label (text) of the slice. |
|
74 | Label (text) of the slice. | |
75 | */ |
|
75 | */ | |
76 |
|
76 | |||
77 | /*! |
|
77 | /*! | |
78 | \fn void QPieSlice::labelChanged() |
|
78 | \fn void QPieSlice::labelChanged() | |
79 | This signal emitted when the slice label has been changed. |
|
79 | This signal emitted when the slice label has been changed. | |
80 | \sa label |
|
80 | \sa label | |
81 | */ |
|
81 | */ | |
82 | /*! |
|
82 | /*! | |
83 |
\qmlsignal PieSlice:: |
|
83 | \qmlsignal PieSlice::onLabelChanged() | |
84 | This signal emitted when the slice label has been changed. |
|
84 | This signal emitted when the slice label has been changed. | |
85 | \sa label |
|
85 | \sa label | |
86 | */ |
|
86 | */ | |
87 |
|
87 | |||
88 | /*! |
|
88 | /*! | |
89 | \property QPieSlice::value |
|
89 | \property QPieSlice::value | |
90 | Value of the slice. |
|
90 | Value of the slice. | |
91 | Note that if users sets a negative value it is converted to a positive value. |
|
91 | Note that if users sets a negative value it is converted to a positive value. | |
92 | \sa percentage(), QPieSeries::sum() |
|
92 | \sa percentage(), QPieSeries::sum() | |
93 | */ |
|
93 | */ | |
94 | /*! |
|
94 | /*! | |
95 | \qmlproperty real PieSlice::value |
|
95 | \qmlproperty real PieSlice::value | |
96 | Value of the slice. Note that if users sets a negative value it is converted to a positive value. |
|
96 | Value of the slice. Note that if users sets a negative value it is converted to a positive value. | |
97 | */ |
|
97 | */ | |
98 |
|
98 | |||
99 | /*! |
|
99 | /*! | |
100 | \fn void QPieSlice::valueChanged() |
|
100 | \fn void QPieSlice::valueChanged() | |
101 | This signal is emitted when the slice value changes. |
|
101 | This signal is emitted when the slice value changes. | |
102 | \sa value |
|
102 | \sa value | |
103 | */ |
|
103 | */ | |
104 | /*! |
|
104 | /*! | |
105 |
\qmlsignal PieSlice:: |
|
105 | \qmlsignal PieSlice::onValueChanged() | |
106 | This signal is emitted when the slice value changes. |
|
106 | This signal is emitted when the slice value changes. | |
107 | \sa value |
|
107 | \sa value | |
108 | */ |
|
108 | */ | |
109 |
|
109 | |||
110 | /*! |
|
110 | /*! | |
111 | \property QPieSlice::labelVisible |
|
111 | \property QPieSlice::labelVisible | |
112 | Defines the visibility of slice label. By default the label is not visible. |
|
112 | Defines the visibility of slice label. By default the label is not visible. | |
113 | \sa label, labelBrush, labelFont, labelArmLengthFactor |
|
113 | \sa label, labelBrush, labelFont, labelArmLengthFactor | |
114 | */ |
|
114 | */ | |
115 | /*! |
|
115 | /*! | |
116 | \qmlproperty bool PieSlice::labelVisible |
|
116 | \qmlproperty bool PieSlice::labelVisible | |
117 | Defines the visibility of slice label. By default the label is not visible. |
|
117 | Defines the visibility of slice label. By default the label is not visible. | |
118 | */ |
|
118 | */ | |
119 |
|
119 | |||
120 | /*! |
|
120 | /*! | |
121 | \fn void QPieSlice::labelVisibleChanged() |
|
121 | \fn void QPieSlice::labelVisibleChanged() | |
122 | This signal emitted when visibility of the slice label has changed. |
|
122 | This signal emitted when visibility of the slice label has changed. | |
123 | \sa labelVisible |
|
123 | \sa labelVisible | |
124 | */ |
|
124 | */ | |
125 | /*! |
|
125 | /*! | |
126 |
\qmlsignal PieSlice:: |
|
126 | \qmlsignal PieSlice::onLabelVisibleChanged() | |
127 | This signal emitted when visibility of the slice label has changed. |
|
127 | This signal emitted when visibility of the slice label has changed. | |
128 | \sa labelVisible |
|
128 | \sa labelVisible | |
129 | */ |
|
129 | */ | |
130 |
|
130 | |||
131 | /*! |
|
131 | /*! | |
132 | \property QPieSlice::exploded |
|
132 | \property QPieSlice::exploded | |
133 | If set to true the slice is "exploded" away from the pie. |
|
133 | If set to true the slice is "exploded" away from the pie. | |
134 | \sa explodeDistanceFactor |
|
134 | \sa explodeDistanceFactor | |
135 | */ |
|
135 | */ | |
136 | /*! |
|
136 | /*! | |
137 | \qmlproperty bool PieSlice::exploded |
|
137 | \qmlproperty bool PieSlice::exploded | |
138 | If set to true the slice is "exploded" away from the pie. |
|
138 | If set to true the slice is "exploded" away from the pie. | |
139 | \sa explodeDistanceFactor |
|
139 | \sa explodeDistanceFactor | |
140 | */ |
|
140 | */ | |
141 |
|
141 | |||
142 | /*! |
|
142 | /*! | |
143 | \property QPieSlice::pen |
|
143 | \property QPieSlice::pen | |
144 | Pen used to draw the slice border. |
|
144 | Pen used to draw the slice border. | |
145 | */ |
|
145 | */ | |
146 |
|
146 | |||
147 | /*! |
|
147 | /*! | |
148 | \fn void QPieSlice::penChanged() |
|
148 | \fn void QPieSlice::penChanged() | |
149 | This signal is emitted when the pen of the slice has changed. |
|
149 | This signal is emitted when the pen of the slice has changed. | |
150 | \sa pen |
|
150 | \sa pen | |
151 | */ |
|
151 | */ | |
152 |
|
152 | |||
153 | /*! |
|
153 | /*! | |
154 | \property QPieSlice::borderColor |
|
154 | \property QPieSlice::borderColor | |
155 | Color used to draw the slice border. |
|
155 | Color used to draw the slice border. | |
156 | This is a convenience property for modifying the slice pen. |
|
156 | This is a convenience property for modifying the slice pen. | |
157 | \sa pen, borderWidth |
|
157 | \sa pen, borderWidth | |
158 | */ |
|
158 | */ | |
159 | /*! |
|
159 | /*! | |
160 | \qmlproperty color PieSlice::borderColor |
|
160 | \qmlproperty color PieSlice::borderColor | |
161 | Color used to draw the slice border (pen color). |
|
161 | Color used to draw the slice border (pen color). | |
162 | \sa borderWidth |
|
162 | \sa borderWidth | |
163 | */ |
|
163 | */ | |
164 |
|
164 | |||
165 | /*! |
|
165 | /*! | |
166 | \fn void QPieSlice::borderColorChanged() |
|
166 | \fn void QPieSlice::borderColorChanged() | |
167 | This signal is emitted when slice border color changes. |
|
167 | This signal is emitted when slice border color changes. | |
168 | \sa pen, borderColor |
|
168 | \sa pen, borderColor | |
169 | */ |
|
169 | */ | |
170 | /*! |
|
170 | /*! | |
171 |
\qmlsignal PieSlice:: |
|
171 | \qmlsignal PieSlice::onBorderColorChanged() | |
172 | This signal is emitted when slice border color changes. |
|
172 | This signal is emitted when slice border color changes. | |
173 | \sa borderColor |
|
173 | \sa borderColor | |
174 | */ |
|
174 | */ | |
175 |
|
175 | |||
176 | /*! |
|
176 | /*! | |
177 | \property QPieSlice::borderWidth |
|
177 | \property QPieSlice::borderWidth | |
178 | Width of the slice border. |
|
178 | Width of the slice border. | |
179 | This is a convenience property for modifying the slice pen. |
|
179 | This is a convenience property for modifying the slice pen. | |
180 | \sa pen, borderColor |
|
180 | \sa pen, borderColor | |
181 | */ |
|
181 | */ | |
182 | /*! |
|
182 | /*! | |
183 | \qmlproperty int PieSlice::borderWidth |
|
183 | \qmlproperty int PieSlice::borderWidth | |
184 | Width of the slice border. |
|
184 | Width of the slice border. | |
185 | This is a convenience property for modifying the slice pen. |
|
185 | This is a convenience property for modifying the slice pen. | |
186 | \sa borderColor |
|
186 | \sa borderColor | |
187 | */ |
|
187 | */ | |
188 |
|
188 | |||
189 | /*! |
|
189 | /*! | |
190 | \fn void QPieSlice::borderWidthChanged() |
|
190 | \fn void QPieSlice::borderWidthChanged() | |
191 | This signal is emitted when slice border width changes. |
|
191 | This signal is emitted when slice border width changes. | |
192 | \sa pen, borderWidth |
|
192 | \sa pen, borderWidth | |
193 | */ |
|
193 | */ | |
194 | /*! |
|
194 | /*! | |
195 |
\qmlsignal PieSlice:: |
|
195 | \qmlsignal PieSlice::onBorderWidthChanged() | |
196 | This signal is emitted when slice border width changes. |
|
196 | This signal is emitted when slice border width changes. | |
197 | \sa borderWidth |
|
197 | \sa borderWidth | |
198 | */ |
|
198 | */ | |
199 |
|
199 | |||
200 | /*! |
|
200 | /*! | |
201 | \property QPieSlice::brush |
|
201 | \property QPieSlice::brush | |
202 | Brush used to draw the slice. |
|
202 | Brush used to draw the slice. | |
203 | */ |
|
203 | */ | |
204 |
|
204 | |||
205 | /*! |
|
205 | /*! | |
206 | \fn void QPieSlice::brushChanged() |
|
206 | \fn void QPieSlice::brushChanged() | |
207 | This signal is emitted when the brush of the slice has changed. |
|
207 | This signal is emitted when the brush of the slice has changed. | |
208 | \sa brush |
|
208 | \sa brush | |
209 | */ |
|
209 | */ | |
210 |
|
210 | |||
211 | /*! |
|
211 | /*! | |
212 | \property QPieSlice::color |
|
212 | \property QPieSlice::color | |
213 | Fill (brush) color of the slice. |
|
213 | Fill (brush) color of the slice. | |
214 | This is a convenience property for modifying the slice brush. |
|
214 | This is a convenience property for modifying the slice brush. | |
215 | \sa brush |
|
215 | \sa brush | |
216 | */ |
|
216 | */ | |
217 | /*! |
|
217 | /*! | |
218 | \qmlproperty color PieSlice::color |
|
218 | \qmlproperty color PieSlice::color | |
219 | Fill (brush) color of the slice. |
|
219 | Fill (brush) color of the slice. | |
220 | */ |
|
220 | */ | |
221 |
|
221 | |||
222 | /*! |
|
222 | /*! | |
223 | \fn void QPieSlice::colorChanged() |
|
223 | \fn void QPieSlice::colorChanged() | |
224 | This signal is emitted when slice color changes. |
|
224 | This signal is emitted when slice color changes. | |
225 | \sa brush |
|
225 | \sa brush | |
226 | */ |
|
226 | */ | |
227 | /*! |
|
227 | /*! | |
228 |
\qmlsignal PieSlice:: |
|
228 | \qmlsignal PieSlice::onColorChanged() | |
229 | This signal is emitted when slice color changes. |
|
229 | This signal is emitted when slice color changes. | |
230 | */ |
|
230 | */ | |
231 |
|
231 | |||
232 | /*! |
|
232 | /*! | |
233 | \property QPieSlice::labelBrush |
|
233 | \property QPieSlice::labelBrush | |
234 | Brush used to draw label and label arm of the slice. |
|
234 | Brush used to draw label and label arm of the slice. | |
235 | \sa label, labelVisible, labelFont, labelArmLengthFactor |
|
235 | \sa label, labelVisible, labelFont, labelArmLengthFactor | |
236 | */ |
|
236 | */ | |
237 |
|
237 | |||
238 | /*! |
|
238 | /*! | |
239 | \fn void QPieSlice::labelBrushChanged() |
|
239 | \fn void QPieSlice::labelBrushChanged() | |
240 | This signal is emitted when the label brush of the slice has changed. |
|
240 | This signal is emitted when the label brush of the slice has changed. | |
241 | \sa labelBrush |
|
241 | \sa labelBrush | |
242 | */ |
|
242 | */ | |
243 |
|
243 | |||
244 | /*! |
|
244 | /*! | |
245 | \property QPieSlice::labelColor |
|
245 | \property QPieSlice::labelColor | |
246 | Color used to draw the slice label. |
|
246 | Color used to draw the slice label. | |
247 | This is a convenience property for modifying the slice label brush. |
|
247 | This is a convenience property for modifying the slice label brush. | |
248 | \sa labelBrush |
|
248 | \sa labelBrush | |
249 | */ |
|
249 | */ | |
250 | /*! |
|
250 | /*! | |
251 | \qmlproperty color PieSlice::labelColor |
|
251 | \qmlproperty color PieSlice::labelColor | |
252 | Color used to draw the slice label. |
|
252 | Color used to draw the slice label. | |
253 | */ |
|
253 | */ | |
254 |
|
254 | |||
255 | /*! |
|
255 | /*! | |
256 | \fn void QPieSlice::labelColorChanged() |
|
256 | \fn void QPieSlice::labelColorChanged() | |
257 | This signal is emitted when slice label color changes. |
|
257 | This signal is emitted when slice label color changes. | |
258 | \sa labelColor |
|
258 | \sa labelColor | |
259 | */ |
|
259 | */ | |
260 | /*! |
|
260 | /*! | |
261 |
\qmlsignal PieSlice:: |
|
261 | \qmlsignal PieSlice::onLabelColorChanged() | |
262 | This signal is emitted when slice label color changes. |
|
262 | This signal is emitted when slice label color changes. | |
263 | \sa labelColor |
|
263 | \sa labelColor | |
264 | */ |
|
264 | */ | |
265 |
|
265 | |||
266 | /*! |
|
266 | /*! | |
267 | \property QPieSlice::labelFont |
|
267 | \property QPieSlice::labelFont | |
268 | Font used for drawing label text. |
|
268 | Font used for drawing label text. | |
269 | \sa label, labelVisible, labelArmLengthFactor |
|
269 | \sa label, labelVisible, labelArmLengthFactor | |
270 | */ |
|
270 | */ | |
271 |
|
271 | |||
272 | /*! |
|
272 | /*! | |
273 | \fn void QPieSlice::labelFontChanged() |
|
273 | \fn void QPieSlice::labelFontChanged() | |
274 | This signal is emitted when the label font of the slice has changed. |
|
274 | This signal is emitted when the label font of the slice has changed. | |
275 | \sa labelFont |
|
275 | \sa labelFont | |
276 | */ |
|
276 | */ | |
277 |
|
277 | |||
278 | /*! |
|
278 | /*! | |
279 | \qmlproperty Font PieSlice::labelFont |
|
279 | \qmlproperty Font PieSlice::labelFont | |
280 |
|
280 | |||
281 | Defines the font used for slice label. |
|
281 | Defines the font used for slice label. | |
282 |
|
282 | |||
283 | See the \l {Font} {QML Font Element} for detailed documentation. |
|
283 | See the \l {Font} {QML Font Element} for detailed documentation. | |
284 |
|
284 | |||
285 | \sa labelVisible, labelPosition |
|
285 | \sa labelVisible, labelPosition | |
286 | */ |
|
286 | */ | |
287 |
|
287 | |||
288 | /*! |
|
288 | /*! | |
289 | \property QPieSlice::labelPosition |
|
289 | \property QPieSlice::labelPosition | |
290 | Position of the slice label. |
|
290 | Position of the slice label. | |
291 | \sa label, labelVisible |
|
291 | \sa label, labelVisible | |
292 | */ |
|
292 | */ | |
293 | /*! |
|
293 | /*! | |
294 | \qmlproperty LabelPosition PieSlice::labelPosition |
|
294 | \qmlproperty LabelPosition PieSlice::labelPosition | |
295 | Position of the slice label. One of PieSlice.LabelOutside or PieSlice.LabelInside. |
|
295 | Position of the slice label. One of PieSlice.LabelOutside or PieSlice.LabelInside. | |
296 | \sa labelVisible |
|
296 | \sa labelVisible | |
297 | */ |
|
297 | */ | |
298 |
|
298 | |||
299 | /*! |
|
299 | /*! | |
300 | \property QPieSlice::labelArmLengthFactor |
|
300 | \property QPieSlice::labelArmLengthFactor | |
301 | Defines the length of the label arm. |
|
301 | Defines the length of the label arm. | |
302 | The factor is relative to pie radius. For example: |
|
302 | The factor is relative to pie radius. For example: | |
303 | 1.0 means the length is the same as the radius. |
|
303 | 1.0 means the length is the same as the radius. | |
304 | 0.5 means the length is half of the radius. |
|
304 | 0.5 means the length is half of the radius. | |
305 | By default the arm length is 0.15 |
|
305 | By default the arm length is 0.15 | |
306 | \sa label, labelVisible, labelBrush, labelFont |
|
306 | \sa label, labelVisible, labelBrush, labelFont | |
307 | */ |
|
307 | */ | |
308 | /*! |
|
308 | /*! | |
309 | \qmlproperty real PieSlice::labelArmLengthFactor |
|
309 | \qmlproperty real PieSlice::labelArmLengthFactor | |
310 | Defines the length of the label arm. |
|
310 | Defines the length of the label arm. | |
311 | The factor is relative to pie radius. For example: |
|
311 | The factor is relative to pie radius. For example: | |
312 | 1.0 means the length is the same as the radius. |
|
312 | 1.0 means the length is the same as the radius. | |
313 | 0.5 means the length is half of the radius. |
|
313 | 0.5 means the length is half of the radius. | |
314 | By default the arm length is 0.15 |
|
314 | By default the arm length is 0.15 | |
315 | \sa labelVisible |
|
315 | \sa labelVisible | |
316 | */ |
|
316 | */ | |
317 |
|
317 | |||
318 | /*! |
|
318 | /*! | |
319 | \property QPieSlice::explodeDistanceFactor |
|
319 | \property QPieSlice::explodeDistanceFactor | |
320 | When the slice is exploded this factor defines how far the slice is exploded away from the pie. |
|
320 | When the slice is exploded this factor defines how far the slice is exploded away from the pie. | |
321 | The factor is relative to pie radius. For example: |
|
321 | The factor is relative to pie radius. For example: | |
322 | 1.0 means the distance is the same as the radius. |
|
322 | 1.0 means the distance is the same as the radius. | |
323 | 0.5 means the distance is half of the radius. |
|
323 | 0.5 means the distance is half of the radius. | |
324 | By default the distance is is 0.15 |
|
324 | By default the distance is is 0.15 | |
325 | \sa exploded |
|
325 | \sa exploded | |
326 | */ |
|
326 | */ | |
327 | /*! |
|
327 | /*! | |
328 | \qmlproperty real PieSlice::explodeDistanceFactor |
|
328 | \qmlproperty real PieSlice::explodeDistanceFactor | |
329 | When the slice is exploded this factor defines how far the slice is exploded away from the pie. |
|
329 | When the slice is exploded this factor defines how far the slice is exploded away from the pie. | |
330 | The factor is relative to pie radius. For example: |
|
330 | The factor is relative to pie radius. For example: | |
331 | 1.0 means the distance is the same as the radius. |
|
331 | 1.0 means the distance is the same as the radius. | |
332 | 0.5 means the distance is half of the radius. |
|
332 | 0.5 means the distance is half of the radius. | |
333 | By default the distance is is 0.15 |
|
333 | By default the distance is is 0.15 | |
334 | \sa exploded |
|
334 | \sa exploded | |
335 | */ |
|
335 | */ | |
336 |
|
336 | |||
337 | /*! |
|
337 | /*! | |
338 | \property QPieSlice::percentage |
|
338 | \property QPieSlice::percentage | |
339 | Percentage of the slice compared to the sum of all slices in the series. |
|
339 | Percentage of the slice compared to the sum of all slices in the series. | |
340 | The actual value ranges from 0.0 to 1.0. |
|
340 | The actual value ranges from 0.0 to 1.0. | |
341 | Updated automatically once the slice is added to the series. |
|
341 | Updated automatically once the slice is added to the series. | |
342 | \sa value, QPieSeries::sum |
|
342 | \sa value, QPieSeries::sum | |
343 | */ |
|
343 | */ | |
344 | /*! |
|
344 | /*! | |
345 | \qmlproperty real PieSlice::percentage |
|
345 | \qmlproperty real PieSlice::percentage | |
346 | Percentage of the slice compared to the sum of all slices in the series. |
|
346 | Percentage of the slice compared to the sum of all slices in the series. | |
347 | The actual value ranges from 0.0 to 1.0. |
|
347 | The actual value ranges from 0.0 to 1.0. | |
348 | Updated automatically once the slice is added to the series. |
|
348 | Updated automatically once the slice is added to the series. | |
349 | */ |
|
349 | */ | |
350 |
|
350 | |||
351 | /*! |
|
351 | /*! | |
352 | \fn void QPieSlice::percentageChanged() |
|
352 | \fn void QPieSlice::percentageChanged() | |
353 | This signal is emitted when the percentage of the slice has changed. |
|
353 | This signal is emitted when the percentage of the slice has changed. | |
354 | \sa percentage |
|
354 | \sa percentage | |
355 | */ |
|
355 | */ | |
356 | /*! |
|
356 | /*! | |
357 |
\qmlsignal void PieSlice:: |
|
357 | \qmlsignal void PieSlice::onPercentageChanged() | |
358 | This signal is emitted when the percentage of the slice has changed. |
|
358 | This signal is emitted when the percentage of the slice has changed. | |
359 | \sa percentage |
|
359 | \sa percentage | |
360 | */ |
|
360 | */ | |
361 |
|
361 | |||
362 | /*! |
|
362 | /*! | |
363 | \property QPieSlice::startAngle |
|
363 | \property QPieSlice::startAngle | |
364 | Defines the starting angle of this slice in the series it belongs to. |
|
364 | Defines the starting angle of this slice in the series it belongs to. | |
365 | Full pie is 360 degrees where 0 degrees is at 12 a'clock. |
|
365 | Full pie is 360 degrees where 0 degrees is at 12 a'clock. | |
366 | Updated automatically once the slice is added to the series. |
|
366 | Updated automatically once the slice is added to the series. | |
367 | */ |
|
367 | */ | |
368 | /*! |
|
368 | /*! | |
369 | \qmlproperty real PieSlice::startAngle |
|
369 | \qmlproperty real PieSlice::startAngle | |
370 | Defines the starting angle of this slice in the series it belongs to. |
|
370 | Defines the starting angle of this slice in the series it belongs to. | |
371 | Full pie is 360 degrees where 0 degrees is at 12 a'clock. |
|
371 | Full pie is 360 degrees where 0 degrees is at 12 a'clock. | |
372 | Updated automatically once the slice is added to the series. |
|
372 | Updated automatically once the slice is added to the series. | |
373 | */ |
|
373 | */ | |
374 |
|
374 | |||
375 | /*! |
|
375 | /*! | |
376 | \fn void QPieSlice::startAngleChanged() |
|
376 | \fn void QPieSlice::startAngleChanged() | |
377 | This signal is emitted when the starting angle f the slice has changed. |
|
377 | This signal is emitted when the starting angle f the slice has changed. | |
378 | \sa startAngle |
|
378 | \sa startAngle | |
379 | */ |
|
379 | */ | |
380 | /*! |
|
380 | /*! | |
381 |
\qmlsignal PieSlice:: |
|
381 | \qmlsignal PieSlice::onStartAngleChanged() | |
382 | This signal is emitted when the starting angle f the slice has changed. |
|
382 | This signal is emitted when the starting angle f the slice has changed. | |
383 | \sa startAngle |
|
383 | \sa startAngle | |
384 | */ |
|
384 | */ | |
385 |
|
385 | |||
386 | /*! |
|
386 | /*! | |
387 | \property QPieSlice::angleSpan |
|
387 | \property QPieSlice::angleSpan | |
388 | Span of the slice in degrees. |
|
388 | Span of the slice in degrees. | |
389 | Full pie is 360 degrees where 0 degrees is at 12 a'clock. |
|
389 | Full pie is 360 degrees where 0 degrees is at 12 a'clock. | |
390 | Updated automatically once the slice is added to the series. |
|
390 | Updated automatically once the slice is added to the series. | |
391 | */ |
|
391 | */ | |
392 | /*! |
|
392 | /*! | |
393 | \qmlproperty real PieSlice::angleSpan |
|
393 | \qmlproperty real PieSlice::angleSpan | |
394 | Span of the slice in degrees. |
|
394 | Span of the slice in degrees. | |
395 | Full pie is 360 degrees where 0 degrees is at 12 a'clock. |
|
395 | Full pie is 360 degrees where 0 degrees is at 12 a'clock. | |
396 | Updated automatically once the slice is added to the series. |
|
396 | Updated automatically once the slice is added to the series. | |
397 | */ |
|
397 | */ | |
398 |
|
398 | |||
399 | /*! |
|
399 | /*! | |
400 | \fn void QPieSlice::angleSpanChanged() |
|
400 | \fn void QPieSlice::angleSpanChanged() | |
401 | This signal is emitted when the angle span of the slice has changed. |
|
401 | This signal is emitted when the angle span of the slice has changed. | |
402 | \sa angleSpan |
|
402 | \sa angleSpan | |
403 | */ |
|
403 | */ | |
404 | /*! |
|
404 | /*! | |
405 |
\qmlsignal PieSlice:: |
|
405 | \qmlsignal PieSlice::onAngleSpanChanged() | |
406 | This signal is emitted when the angle span of the slice has changed. |
|
406 | This signal is emitted when the angle span of the slice has changed. | |
407 | \sa angleSpan |
|
407 | \sa angleSpan | |
408 | */ |
|
408 | */ | |
409 |
|
409 | |||
410 | /*! |
|
410 | /*! | |
411 | \fn void QPieSlice::clicked() |
|
411 | \fn void QPieSlice::clicked() | |
412 | This signal is emitted when user has clicked the slice. |
|
412 | This signal is emitted when user has clicked the slice. | |
413 | \sa QPieSeries::clicked() |
|
413 | \sa QPieSeries::clicked() | |
414 | */ |
|
414 | */ | |
415 | /*! |
|
415 | /*! | |
416 | \qmlsignal PieSlice::onClicked() |
|
416 | \qmlsignal PieSlice::onClicked() | |
417 | This signal is emitted when user has clicked the slice. |
|
417 | This signal is emitted when user has clicked the slice. | |
418 | */ |
|
418 | */ | |
419 |
|
419 | |||
420 | /*! |
|
420 | /*! | |
421 | \fn void QPieSlice::hovered(bool state) |
|
421 | \fn void QPieSlice::hovered(bool state) | |
422 | This signal is emitted when user has hovered over or away from the slice. |
|
422 | This signal is emitted when user has hovered over or away from the slice. | |
423 | \a state is true when user has hovered over the slice and false when hover has moved away from the slice. |
|
423 | \a state is true when user has hovered over the slice and false when hover has moved away from the slice. | |
424 | \sa QPieSeries::hovered() |
|
424 | \sa QPieSeries::hovered() | |
425 | */ |
|
425 | */ | |
426 | /*! |
|
426 | /*! | |
427 | \qmlsignal PieSlice::onHovered(bool state) |
|
427 | \qmlsignal PieSlice::onHovered(bool state) | |
428 | This signal is emitted when user has hovered over or away from the slice. |
|
428 | This signal is emitted when user has hovered over or away from the slice. | |
429 | \a state is true when user has hovered over the slice and false when hover has moved away from the slice. |
|
429 | \a state is true when user has hovered over the slice and false when hover has moved away from the slice. | |
430 | */ |
|
430 | */ | |
431 |
|
431 | |||
432 | /*! |
|
432 | /*! | |
433 | Constructs an empty slice with a \a parent. |
|
433 | Constructs an empty slice with a \a parent. | |
434 | \sa QPieSeries::append(), QPieSeries::insert() |
|
434 | \sa QPieSeries::append(), QPieSeries::insert() | |
435 | */ |
|
435 | */ | |
436 | QPieSlice::QPieSlice(QObject *parent) |
|
436 | QPieSlice::QPieSlice(QObject *parent) | |
437 | :QObject(parent), |
|
437 | :QObject(parent), | |
438 | d_ptr(new QPieSlicePrivate(this)) |
|
438 | d_ptr(new QPieSlicePrivate(this)) | |
439 | { |
|
439 | { | |
440 |
|
440 | |||
441 | } |
|
441 | } | |
442 |
|
442 | |||
443 | /*! |
|
443 | /*! | |
444 | Constructs an empty slice with given \a value, \a label and a \a parent. |
|
444 | Constructs an empty slice with given \a value, \a label and a \a parent. | |
445 | \sa QPieSeries::append(), QPieSeries::insert() |
|
445 | \sa QPieSeries::append(), QPieSeries::insert() | |
446 | */ |
|
446 | */ | |
447 | QPieSlice::QPieSlice(QString label, qreal value, QObject *parent) |
|
447 | QPieSlice::QPieSlice(QString label, qreal value, QObject *parent) | |
448 | :QObject(parent), |
|
448 | :QObject(parent), | |
449 | d_ptr(new QPieSlicePrivate(this)) |
|
449 | d_ptr(new QPieSlicePrivate(this)) | |
450 | { |
|
450 | { | |
451 | setValue(value); |
|
451 | setValue(value); | |
452 | setLabel(label); |
|
452 | setLabel(label); | |
453 | } |
|
453 | } | |
454 |
|
454 | |||
455 | /*! |
|
455 | /*! | |
456 | Destroys the slice. |
|
456 | Destroys the slice. | |
457 | User should not delete the slice if it has been added to the series. |
|
457 | User should not delete the slice if it has been added to the series. | |
458 | */ |
|
458 | */ | |
459 | QPieSlice::~QPieSlice() |
|
459 | QPieSlice::~QPieSlice() | |
460 | { |
|
460 | { | |
461 |
|
461 | |||
462 | } |
|
462 | } | |
463 |
|
463 | |||
464 | void QPieSlice::setLabel(QString label) |
|
464 | void QPieSlice::setLabel(QString label) | |
465 | { |
|
465 | { | |
466 | if (d_ptr->m_data.m_labelText != label) { |
|
466 | if (d_ptr->m_data.m_labelText != label) { | |
467 | d_ptr->m_data.m_labelText = label; |
|
467 | d_ptr->m_data.m_labelText = label; | |
468 | emit labelChanged(); |
|
468 | emit labelChanged(); | |
469 | } |
|
469 | } | |
470 | } |
|
470 | } | |
471 |
|
471 | |||
472 | QString QPieSlice::label() const |
|
472 | QString QPieSlice::label() const | |
473 | { |
|
473 | { | |
474 | return d_ptr->m_data.m_labelText; |
|
474 | return d_ptr->m_data.m_labelText; | |
475 | } |
|
475 | } | |
476 |
|
476 | |||
477 | void QPieSlice::setValue(qreal value) |
|
477 | void QPieSlice::setValue(qreal value) | |
478 | { |
|
478 | { | |
479 | value = qAbs(value); // negative values not allowed |
|
479 | value = qAbs(value); // negative values not allowed | |
480 | if (!qFuzzyIsNull(d_ptr->m_data.m_value - value)) { |
|
480 | if (!qFuzzyIsNull(d_ptr->m_data.m_value - value)) { | |
481 | d_ptr->m_data.m_value = value; |
|
481 | d_ptr->m_data.m_value = value; | |
482 | emit valueChanged(); |
|
482 | emit valueChanged(); | |
483 | } |
|
483 | } | |
484 | } |
|
484 | } | |
485 |
|
485 | |||
486 | qreal QPieSlice::value() const |
|
486 | qreal QPieSlice::value() const | |
487 | { |
|
487 | { | |
488 | return d_ptr->m_data.m_value; |
|
488 | return d_ptr->m_data.m_value; | |
489 | } |
|
489 | } | |
490 |
|
490 | |||
491 | void QPieSlice::setLabelVisible(bool visible) |
|
491 | void QPieSlice::setLabelVisible(bool visible) | |
492 | { |
|
492 | { | |
493 | if (d_ptr->m_data.m_isLabelVisible != visible) { |
|
493 | if (d_ptr->m_data.m_isLabelVisible != visible) { | |
494 | d_ptr->m_data.m_isLabelVisible = visible; |
|
494 | d_ptr->m_data.m_isLabelVisible = visible; | |
495 | emit labelVisibleChanged(); |
|
495 | emit labelVisibleChanged(); | |
496 | } |
|
496 | } | |
497 | } |
|
497 | } | |
498 |
|
498 | |||
499 | bool QPieSlice::isLabelVisible() const |
|
499 | bool QPieSlice::isLabelVisible() const | |
500 | { |
|
500 | { | |
501 | return d_ptr->m_data.m_isLabelVisible; |
|
501 | return d_ptr->m_data.m_isLabelVisible; | |
502 | } |
|
502 | } | |
503 |
|
503 | |||
504 | void QPieSlice::setExploded(bool exploded) |
|
504 | void QPieSlice::setExploded(bool exploded) | |
505 | { |
|
505 | { | |
506 | if (d_ptr->m_data.m_isExploded != exploded) { |
|
506 | if (d_ptr->m_data.m_isExploded != exploded) { | |
507 | d_ptr->m_data.m_isExploded = exploded; |
|
507 | d_ptr->m_data.m_isExploded = exploded; | |
508 | emit d_ptr->explodedChanged(); |
|
508 | emit d_ptr->explodedChanged(); | |
509 | } |
|
509 | } | |
510 | } |
|
510 | } | |
511 |
|
511 | |||
512 | QPieSlice::LabelPosition QPieSlice::labelPosition() |
|
512 | QPieSlice::LabelPosition QPieSlice::labelPosition() | |
513 | { |
|
513 | { | |
514 | return d_ptr->m_data.m_labelPosition; |
|
514 | return d_ptr->m_data.m_labelPosition; | |
515 | } |
|
515 | } | |
516 |
|
516 | |||
517 | void QPieSlice::setLabelPosition(LabelPosition position) |
|
517 | void QPieSlice::setLabelPosition(LabelPosition position) | |
518 | { |
|
518 | { | |
519 | if (d_ptr->m_data.m_labelPosition != position) { |
|
519 | if (d_ptr->m_data.m_labelPosition != position) { | |
520 | d_ptr->m_data.m_labelPosition = position; |
|
520 | d_ptr->m_data.m_labelPosition = position; | |
521 | emit d_ptr->labelPositionChanged(); |
|
521 | emit d_ptr->labelPositionChanged(); | |
522 | } |
|
522 | } | |
523 | } |
|
523 | } | |
524 |
|
524 | |||
525 | bool QPieSlice::isExploded() const |
|
525 | bool QPieSlice::isExploded() const | |
526 | { |
|
526 | { | |
527 | return d_ptr->m_data.m_isExploded; |
|
527 | return d_ptr->m_data.m_isExploded; | |
528 | } |
|
528 | } | |
529 |
|
529 | |||
530 | void QPieSlice::setPen(const QPen &pen) |
|
530 | void QPieSlice::setPen(const QPen &pen) | |
531 | { |
|
531 | { | |
532 | d_ptr->setPen(pen, false); |
|
532 | d_ptr->setPen(pen, false); | |
533 | } |
|
533 | } | |
534 |
|
534 | |||
535 | QPen QPieSlice::pen() const |
|
535 | QPen QPieSlice::pen() const | |
536 | { |
|
536 | { | |
537 | return d_ptr->m_data.m_slicePen; |
|
537 | return d_ptr->m_data.m_slicePen; | |
538 | } |
|
538 | } | |
539 |
|
539 | |||
540 | QColor QPieSlice::borderColor() |
|
540 | QColor QPieSlice::borderColor() | |
541 | { |
|
541 | { | |
542 | return pen().color(); |
|
542 | return pen().color(); | |
543 | } |
|
543 | } | |
544 |
|
544 | |||
545 | void QPieSlice::setBorderColor(QColor color) |
|
545 | void QPieSlice::setBorderColor(QColor color) | |
546 | { |
|
546 | { | |
547 | QPen p = pen(); |
|
547 | QPen p = pen(); | |
548 | if (color != p.color()) { |
|
548 | if (color != p.color()) { | |
549 | p.setColor(color); |
|
549 | p.setColor(color); | |
550 | setPen(p); |
|
550 | setPen(p); | |
551 | } |
|
551 | } | |
552 | } |
|
552 | } | |
553 |
|
553 | |||
554 | int QPieSlice::borderWidth() |
|
554 | int QPieSlice::borderWidth() | |
555 | { |
|
555 | { | |
556 | return pen().width(); |
|
556 | return pen().width(); | |
557 | } |
|
557 | } | |
558 |
|
558 | |||
559 | void QPieSlice::setBorderWidth(int width) |
|
559 | void QPieSlice::setBorderWidth(int width) | |
560 | { |
|
560 | { | |
561 | QPen p = pen(); |
|
561 | QPen p = pen(); | |
562 | if (width != p.width()) { |
|
562 | if (width != p.width()) { | |
563 | p.setWidth(width); |
|
563 | p.setWidth(width); | |
564 | setPen(p); |
|
564 | setPen(p); | |
565 | } |
|
565 | } | |
566 | } |
|
566 | } | |
567 |
|
567 | |||
568 | void QPieSlice::setBrush(const QBrush &brush) |
|
568 | void QPieSlice::setBrush(const QBrush &brush) | |
569 | { |
|
569 | { | |
570 | d_ptr->setBrush(brush, false); |
|
570 | d_ptr->setBrush(brush, false); | |
571 | } |
|
571 | } | |
572 |
|
572 | |||
573 | QBrush QPieSlice::brush() const |
|
573 | QBrush QPieSlice::brush() const | |
574 | { |
|
574 | { | |
575 | return d_ptr->m_data.m_sliceBrush; |
|
575 | return d_ptr->m_data.m_sliceBrush; | |
576 | } |
|
576 | } | |
577 |
|
577 | |||
578 | QColor QPieSlice::color() |
|
578 | QColor QPieSlice::color() | |
579 | { |
|
579 | { | |
580 | return brush().color(); |
|
580 | return brush().color(); | |
581 | } |
|
581 | } | |
582 |
|
582 | |||
583 | void QPieSlice::setColor(QColor color) |
|
583 | void QPieSlice::setColor(QColor color) | |
584 | { |
|
584 | { | |
585 | QBrush b = brush(); |
|
585 | QBrush b = brush(); | |
586 | if (color != b.color()) { |
|
586 | if (color != b.color()) { | |
587 | b.setColor(color); |
|
587 | b.setColor(color); | |
588 | setBrush(b); |
|
588 | setBrush(b); | |
589 | } |
|
589 | } | |
590 | } |
|
590 | } | |
591 |
|
591 | |||
592 | void QPieSlice::setLabelBrush(const QBrush &brush) |
|
592 | void QPieSlice::setLabelBrush(const QBrush &brush) | |
593 | { |
|
593 | { | |
594 | d_ptr->setLabelBrush(brush, false); |
|
594 | d_ptr->setLabelBrush(brush, false); | |
595 | } |
|
595 | } | |
596 |
|
596 | |||
597 | QBrush QPieSlice::labelBrush() const |
|
597 | QBrush QPieSlice::labelBrush() const | |
598 | { |
|
598 | { | |
599 | return d_ptr->m_data.m_labelBrush; |
|
599 | return d_ptr->m_data.m_labelBrush; | |
600 | } |
|
600 | } | |
601 |
|
601 | |||
602 | QColor QPieSlice::labelColor() |
|
602 | QColor QPieSlice::labelColor() | |
603 | { |
|
603 | { | |
604 | return labelBrush().color(); |
|
604 | return labelBrush().color(); | |
605 | } |
|
605 | } | |
606 |
|
606 | |||
607 | void QPieSlice::setLabelColor(QColor color) |
|
607 | void QPieSlice::setLabelColor(QColor color) | |
608 | { |
|
608 | { | |
609 | QBrush b = labelBrush(); |
|
609 | QBrush b = labelBrush(); | |
610 | if (color != b.color()) { |
|
610 | if (color != b.color()) { | |
611 | b.setColor(color); |
|
611 | b.setColor(color); | |
612 | setLabelBrush(b); |
|
612 | setLabelBrush(b); | |
613 | } |
|
613 | } | |
614 | } |
|
614 | } | |
615 |
|
615 | |||
616 | void QPieSlice::setLabelFont(const QFont &font) |
|
616 | void QPieSlice::setLabelFont(const QFont &font) | |
617 | { |
|
617 | { | |
618 | d_ptr->setLabelFont(font, false); |
|
618 | d_ptr->setLabelFont(font, false); | |
619 | } |
|
619 | } | |
620 |
|
620 | |||
621 | QFont QPieSlice::labelFont() const |
|
621 | QFont QPieSlice::labelFont() const | |
622 | { |
|
622 | { | |
623 | return d_ptr->m_data.m_labelFont; |
|
623 | return d_ptr->m_data.m_labelFont; | |
624 | } |
|
624 | } | |
625 |
|
625 | |||
626 | void QPieSlice::setLabelArmLengthFactor(qreal factor) |
|
626 | void QPieSlice::setLabelArmLengthFactor(qreal factor) | |
627 | { |
|
627 | { | |
628 | if (!qFuzzyIsNull(d_ptr->m_data.m_labelArmLengthFactor - factor)) { |
|
628 | if (!qFuzzyIsNull(d_ptr->m_data.m_labelArmLengthFactor - factor)) { | |
629 | d_ptr->m_data.m_labelArmLengthFactor = factor; |
|
629 | d_ptr->m_data.m_labelArmLengthFactor = factor; | |
630 | emit d_ptr->labelArmLengthFactorChanged(); |
|
630 | emit d_ptr->labelArmLengthFactorChanged(); | |
631 | } |
|
631 | } | |
632 | } |
|
632 | } | |
633 |
|
633 | |||
634 | qreal QPieSlice::labelArmLengthFactor() const |
|
634 | qreal QPieSlice::labelArmLengthFactor() const | |
635 | { |
|
635 | { | |
636 | return d_ptr->m_data.m_labelArmLengthFactor; |
|
636 | return d_ptr->m_data.m_labelArmLengthFactor; | |
637 | } |
|
637 | } | |
638 |
|
638 | |||
639 | void QPieSlice::setExplodeDistanceFactor(qreal factor) |
|
639 | void QPieSlice::setExplodeDistanceFactor(qreal factor) | |
640 | { |
|
640 | { | |
641 | if (!qFuzzyIsNull(d_ptr->m_data.m_explodeDistanceFactor - factor)) { |
|
641 | if (!qFuzzyIsNull(d_ptr->m_data.m_explodeDistanceFactor - factor)) { | |
642 | d_ptr->m_data.m_explodeDistanceFactor = factor; |
|
642 | d_ptr->m_data.m_explodeDistanceFactor = factor; | |
643 | emit d_ptr->explodeDistanceFactorChanged(); |
|
643 | emit d_ptr->explodeDistanceFactorChanged(); | |
644 | } |
|
644 | } | |
645 | } |
|
645 | } | |
646 |
|
646 | |||
647 | qreal QPieSlice::explodeDistanceFactor() const |
|
647 | qreal QPieSlice::explodeDistanceFactor() const | |
648 | { |
|
648 | { | |
649 | return d_ptr->m_data.m_explodeDistanceFactor; |
|
649 | return d_ptr->m_data.m_explodeDistanceFactor; | |
650 | } |
|
650 | } | |
651 |
|
651 | |||
652 | qreal QPieSlice::percentage() const |
|
652 | qreal QPieSlice::percentage() const | |
653 | { |
|
653 | { | |
654 | return d_ptr->m_data.m_percentage; |
|
654 | return d_ptr->m_data.m_percentage; | |
655 | } |
|
655 | } | |
656 |
|
656 | |||
657 | qreal QPieSlice::startAngle() const |
|
657 | qreal QPieSlice::startAngle() const | |
658 | { |
|
658 | { | |
659 | return d_ptr->m_data.m_startAngle; |
|
659 | return d_ptr->m_data.m_startAngle; | |
660 | } |
|
660 | } | |
661 |
|
661 | |||
662 | qreal QPieSlice::angleSpan() const |
|
662 | qreal QPieSlice::angleSpan() const | |
663 | { |
|
663 | { | |
664 | return d_ptr->m_data.m_angleSpan; |
|
664 | return d_ptr->m_data.m_angleSpan; | |
665 | } |
|
665 | } | |
666 |
|
666 | |||
667 | /*! |
|
667 | /*! | |
668 | Returns the series that this slice belongs to. |
|
668 | Returns the series that this slice belongs to. | |
669 |
|
669 | |||
670 | \sa QPieSeries::append() |
|
670 | \sa QPieSeries::append() | |
671 | */ |
|
671 | */ | |
672 | QPieSeries *QPieSlice::series() const |
|
672 | QPieSeries *QPieSlice::series() const | |
673 | { |
|
673 | { | |
674 | return d_ptr->m_series; |
|
674 | return d_ptr->m_series; | |
675 | } |
|
675 | } | |
676 |
|
676 | |||
677 | QPieSlicePrivate::QPieSlicePrivate(QPieSlice *parent) |
|
677 | QPieSlicePrivate::QPieSlicePrivate(QPieSlice *parent) | |
678 | :QObject(parent), |
|
678 | :QObject(parent), | |
679 | q_ptr(parent), |
|
679 | q_ptr(parent), | |
680 | m_series(0) |
|
680 | m_series(0) | |
681 | { |
|
681 | { | |
682 |
|
682 | |||
683 | } |
|
683 | } | |
684 |
|
684 | |||
685 | QPieSlicePrivate::~QPieSlicePrivate() |
|
685 | QPieSlicePrivate::~QPieSlicePrivate() | |
686 | { |
|
686 | { | |
687 |
|
687 | |||
688 | } |
|
688 | } | |
689 |
|
689 | |||
690 | QPieSlicePrivate *QPieSlicePrivate::fromSlice(QPieSlice *slice) |
|
690 | QPieSlicePrivate *QPieSlicePrivate::fromSlice(QPieSlice *slice) | |
691 | { |
|
691 | { | |
692 | return slice->d_func(); |
|
692 | return slice->d_func(); | |
693 | } |
|
693 | } | |
694 |
|
694 | |||
695 | void QPieSlicePrivate::setPen(const QPen &pen, bool themed) |
|
695 | void QPieSlicePrivate::setPen(const QPen &pen, bool themed) | |
696 | { |
|
696 | { | |
697 | if (m_data.m_slicePen != pen) { |
|
697 | if (m_data.m_slicePen != pen) { | |
698 |
|
698 | |||
699 | QPen oldPen = m_data.m_slicePen; |
|
699 | QPen oldPen = m_data.m_slicePen; | |
700 |
|
700 | |||
701 | m_data.m_slicePen = pen; |
|
701 | m_data.m_slicePen = pen; | |
702 | m_data.m_slicePen.setThemed(themed); |
|
702 | m_data.m_slicePen.setThemed(themed); | |
703 |
|
703 | |||
704 | emit q_ptr->penChanged(); |
|
704 | emit q_ptr->penChanged(); | |
705 | if (oldPen.color() != pen.color()) |
|
705 | if (oldPen.color() != pen.color()) | |
706 | emit q_ptr->borderColorChanged(); |
|
706 | emit q_ptr->borderColorChanged(); | |
707 | if (oldPen.width() != pen.width()) |
|
707 | if (oldPen.width() != pen.width()) | |
708 | emit q_ptr->borderWidthChanged(); |
|
708 | emit q_ptr->borderWidthChanged(); | |
709 | } |
|
709 | } | |
710 | } |
|
710 | } | |
711 |
|
711 | |||
712 | void QPieSlicePrivate::setBrush(const QBrush &brush, bool themed) |
|
712 | void QPieSlicePrivate::setBrush(const QBrush &brush, bool themed) | |
713 | { |
|
713 | { | |
714 | if (m_data.m_sliceBrush != brush) { |
|
714 | if (m_data.m_sliceBrush != brush) { | |
715 |
|
715 | |||
716 | QBrush oldBrush = m_data.m_sliceBrush; |
|
716 | QBrush oldBrush = m_data.m_sliceBrush; | |
717 |
|
717 | |||
718 | m_data.m_sliceBrush = brush; |
|
718 | m_data.m_sliceBrush = brush; | |
719 | m_data.m_sliceBrush.setThemed(themed); |
|
719 | m_data.m_sliceBrush.setThemed(themed); | |
720 |
|
720 | |||
721 | emit q_ptr->brushChanged(); |
|
721 | emit q_ptr->brushChanged(); | |
722 | if (oldBrush.color() != brush.color()) |
|
722 | if (oldBrush.color() != brush.color()) | |
723 | emit q_ptr->colorChanged(); |
|
723 | emit q_ptr->colorChanged(); | |
724 | } |
|
724 | } | |
725 | } |
|
725 | } | |
726 |
|
726 | |||
727 | void QPieSlicePrivate::setLabelBrush(const QBrush &brush, bool themed) |
|
727 | void QPieSlicePrivate::setLabelBrush(const QBrush &brush, bool themed) | |
728 | { |
|
728 | { | |
729 | if (m_data.m_labelBrush != brush) { |
|
729 | if (m_data.m_labelBrush != brush) { | |
730 |
|
730 | |||
731 | QBrush oldBrush = m_data.m_labelBrush; |
|
731 | QBrush oldBrush = m_data.m_labelBrush; | |
732 |
|
732 | |||
733 | m_data.m_labelBrush = brush; |
|
733 | m_data.m_labelBrush = brush; | |
734 | m_data.m_labelBrush.setThemed(themed); |
|
734 | m_data.m_labelBrush.setThemed(themed); | |
735 |
|
735 | |||
736 | emit q_ptr->labelBrushChanged(); |
|
736 | emit q_ptr->labelBrushChanged(); | |
737 | if (oldBrush.color() != brush.color()) |
|
737 | if (oldBrush.color() != brush.color()) | |
738 | emit q_ptr->labelColorChanged(); |
|
738 | emit q_ptr->labelColorChanged(); | |
739 | } |
|
739 | } | |
740 | } |
|
740 | } | |
741 |
|
741 | |||
742 | void QPieSlicePrivate::setLabelFont(const QFont &font, bool themed) |
|
742 | void QPieSlicePrivate::setLabelFont(const QFont &font, bool themed) | |
743 | { |
|
743 | { | |
744 | if (m_data.m_labelFont != font) { |
|
744 | if (m_data.m_labelFont != font) { | |
745 | m_data.m_labelFont = font; |
|
745 | m_data.m_labelFont = font; | |
746 | m_data.m_labelFont.setThemed(themed); |
|
746 | m_data.m_labelFont.setThemed(themed); | |
747 | emit q_ptr->labelFontChanged(); |
|
747 | emit q_ptr->labelFontChanged(); | |
748 | } |
|
748 | } | |
749 | } |
|
749 | } | |
750 |
|
750 | |||
751 | void QPieSlicePrivate::setPercentage(qreal percentage) |
|
751 | void QPieSlicePrivate::setPercentage(qreal percentage) | |
752 | { |
|
752 | { | |
753 | if (!qFuzzyIsNull(m_data.m_percentage - percentage)) { |
|
753 | if (!qFuzzyIsNull(m_data.m_percentage - percentage)) { | |
754 | m_data.m_percentage = percentage; |
|
754 | m_data.m_percentage = percentage; | |
755 | emit q_ptr->percentageChanged(); |
|
755 | emit q_ptr->percentageChanged(); | |
756 | } |
|
756 | } | |
757 | } |
|
757 | } | |
758 |
|
758 | |||
759 | void QPieSlicePrivate::setStartAngle(qreal angle) |
|
759 | void QPieSlicePrivate::setStartAngle(qreal angle) | |
760 | { |
|
760 | { | |
761 | if (!qFuzzyIsNull(m_data.m_startAngle - angle)) { |
|
761 | if (!qFuzzyIsNull(m_data.m_startAngle - angle)) { | |
762 | m_data.m_startAngle = angle; |
|
762 | m_data.m_startAngle = angle; | |
763 | emit q_ptr->startAngleChanged(); |
|
763 | emit q_ptr->startAngleChanged(); | |
764 | } |
|
764 | } | |
765 | } |
|
765 | } | |
766 |
|
766 | |||
767 | void QPieSlicePrivate::setAngleSpan(qreal span) |
|
767 | void QPieSlicePrivate::setAngleSpan(qreal span) | |
768 | { |
|
768 | { | |
769 | if (!qFuzzyIsNull(m_data.m_angleSpan - span)) { |
|
769 | if (!qFuzzyIsNull(m_data.m_angleSpan - span)) { | |
770 | m_data.m_angleSpan = span; |
|
770 | m_data.m_angleSpan = span; | |
771 | emit q_ptr->angleSpanChanged(); |
|
771 | emit q_ptr->angleSpanChanged(); | |
772 | } |
|
772 | } | |
773 | } |
|
773 | } | |
774 |
|
774 | |||
775 | QTCOMMERCIALCHART_END_NAMESPACE |
|
775 | QTCOMMERCIALCHART_END_NAMESPACE | |
776 |
|
776 | |||
777 | QTCOMMERCIALCHART_USE_NAMESPACE |
|
777 | QTCOMMERCIALCHART_USE_NAMESPACE | |
778 | #include "moc_qpieslice.cpp" |
|
778 | #include "moc_qpieslice.cpp" | |
779 | #include "moc_qpieslice_p.cpp" |
|
779 | #include "moc_qpieslice_p.cpp" |
@@ -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:: |
|
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:: |
|
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:: |
|
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:: |
|
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 |
General Comments 0
You need to be logged in to leave comments.
Login now