##// END OF EJS Templates
Fix series type() docs
Jani Honkonen -
r1345:b13e0c5c83a4
parent child
Show More
@@ -1,289 +1,285
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 QLineSerie instances. Please note terms "upper" and "lower" boundary can be misleading in cases
42 In that case QAreaSeries should be initiated with two QLineSerie 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 /*!
49 /*!
50 \fn virtual QSeriesType QAreaSeries::type() const
51 \brief Returns type of series.
52 \sa QAbstractSeries, QSeriesType
53 */
54
55 /*!
56 \fn QLineSeries* QAreaSeries::upperSeries() const
50 \fn QLineSeries* QAreaSeries::upperSeries() const
57 \brief Returns upperSeries used to define one of area boundaries.
51 \brief Returns upperSeries used to define one of area boundaries.
58 */
52 */
59
53
60 /*!
54 /*!
61 \fn QLineSeries* QAreaSeries::lowerSeries() const
55 \fn QLineSeries* QAreaSeries::lowerSeries() const
62 \brief Returns lowerSeries used to define one of area boundaries. Note if QAreaSeries where counstucted wihtout a\ lowerSeries
56 \brief Returns lowerSeries used to define one of area boundaries. Note if QAreaSeries where counstucted wihtout a\ lowerSeries
63 this function return Null pointer.
57 this function return Null pointer.
64 */
58 */
65
59
66 /*!
60 /*!
67 \fn QPen QAreaSeries::pen() const
61 \fn QPen QAreaSeries::pen() const
68 \brief Returns the pen used to draw line for this series.
62 \brief Returns the pen used to draw line for this series.
69 \sa setPen()
63 \sa setPen()
70 */
64 */
71
65
72 /*!
66 /*!
73 \fn QPen QAreaSeries::brush() const
67 \fn QPen QAreaSeries::brush() const
74 \brief Returns the brush used to draw line for this series.
68 \brief Returns the brush used to draw line for this series.
75 \sa setBrush()
69 \sa setBrush()
76 */
70 */
77
71
78 /*!
72 /*!
79 \fn bool QAreaSeries::pointsVisible() const
73 \fn bool QAreaSeries::pointsVisible() const
80 \brief Returns if the points are drawn for this series.
74 \brief Returns if the points are drawn for this series.
81 \sa setPointsVisible()
75 \sa setPointsVisible()
82 */
76 */
83
77
84 /*!
78 /*!
85 \fn void QAreaSeries::clicked(const QPointF& point)
79 \fn void QAreaSeries::clicked(const QPointF& point)
86 \brief Signal is emitted when user clicks the \a point on area chart.
80 \brief Signal is emitted when user clicks the \a point on area chart.
87 */
81 */
88
82
89 /*!
83 /*!
90 \fn void QAreaSeries::selected()
84 \fn void QAreaSeries::selected()
91
85
92 The signal is emitted if the user selects/deselects the XY series. The logic for maintaining selections should be
86 The signal is emitted if the user selects/deselects the XY series. The logic for maintaining selections should be
93 implemented by the user of QAreaSeries API.
87 implemented by the user of QAreaSeries API.
94 */
88 */
95
89
96 /*!
90 /*!
97 \fn void QAreaSeriesPrivate::updated()
91 \fn void QAreaSeriesPrivate::updated()
98 \brief \internal
92 \brief \internal
99 */
93 */
100
94
101 /*!
95 /*!
102 Constructs area series object which is a child of \a upperSeries. Area will be spanned between \a
96 Constructs area series object which is a child of \a upperSeries. Area will be spanned between \a
103 upperSeries line and \a lowerSeries line. If no \a lowerSeries is passed to constructor, area is specified by axis x (y=0) instead.
97 upperSeries line and \a lowerSeries line. If no \a lowerSeries is passed to constructor, area is specified by axis x (y=0) instead.
104 When series object is added to QChartView or QChart instance ownerships is transferred.
98 When series object is added to QChartView or QChart instance ownerships is transferred.
105 */
99 */
106 QAreaSeries::QAreaSeries(QLineSeries *upperSeries, QLineSeries *lowerSeries)
100 QAreaSeries::QAreaSeries(QLineSeries *upperSeries, QLineSeries *lowerSeries)
107 : QAbstractSeries(*new QAreaSeriesPrivate(upperSeries,lowerSeries,this),upperSeries)
101 : QAbstractSeries(*new QAreaSeriesPrivate(upperSeries,lowerSeries,this),upperSeries)
108 {
102 {
109 }
103 }
110
104
111 /*!
105 /*!
112 Constructs area series object without upper or lower series.
106 Constructs area series object without upper or lower series.
113 */
107 */
114 QAreaSeries::QAreaSeries(QObject *parent)
108 QAreaSeries::QAreaSeries(QObject *parent)
115 : QAbstractSeries(*new QAreaSeriesPrivate(0, 0, this), parent)
109 : QAbstractSeries(*new QAreaSeriesPrivate(0, 0, this), parent)
116 {
110 {
117 }
111 }
118
112
119 /*!
113 /*!
120 Destroys the object. Series added to QChartView or QChart instances are owned by those,
114 Destroys the object. Series added to QChartView or QChart instances are owned by those,
121 and are deleted when mentioned object are destroyed.
115 and are deleted when mentioned object are destroyed.
122 */
116 */
123 QAreaSeries::~QAreaSeries()
117 QAreaSeries::~QAreaSeries()
124 {
118 {
125 }
119 }
126
120
127
121 /*!
122 Returns QChartSeries::SeriesTypeArea.
123 */
128 QAbstractSeries::SeriesType QAreaSeries::type() const
124 QAbstractSeries::SeriesType QAreaSeries::type() const
129 {
125 {
130 return QAbstractSeries::SeriesTypeArea;
126 return QAbstractSeries::SeriesTypeArea;
131 }
127 }
132
128
133 void QAreaSeries::setUpperSeries(QLineSeries* series)
129 void QAreaSeries::setUpperSeries(QLineSeries* series)
134 {
130 {
135 Q_D(QAreaSeries);
131 Q_D(QAreaSeries);
136 d->m_upperSeries = series;
132 d->m_upperSeries = series;
137 }
133 }
138
134
139 QLineSeries* QAreaSeries::upperSeries() const
135 QLineSeries* QAreaSeries::upperSeries() const
140 {
136 {
141 Q_D(const QAreaSeries);
137 Q_D(const QAreaSeries);
142 return d->m_upperSeries;
138 return d->m_upperSeries;
143 }
139 }
144
140
145 void QAreaSeries::setLowerSeries(QLineSeries* series)
141 void QAreaSeries::setLowerSeries(QLineSeries* series)
146 {
142 {
147 Q_D(QAreaSeries);
143 Q_D(QAreaSeries);
148 d->m_lowerSeries = series;
144 d->m_lowerSeries = series;
149 }
145 }
150
146
151 QLineSeries* QAreaSeries::lowerSeries() const
147 QLineSeries* QAreaSeries::lowerSeries() const
152 {
148 {
153 Q_D(const QAreaSeries);
149 Q_D(const QAreaSeries);
154 return d->m_lowerSeries;
150 return d->m_lowerSeries;
155 }
151 }
156
152
157 /*!
153 /*!
158 Sets \a pen used for drawing area outline.
154 Sets \a pen used for drawing area outline.
159 */
155 */
160 void QAreaSeries::setPen(const QPen &pen)
156 void QAreaSeries::setPen(const QPen &pen)
161 {
157 {
162 Q_D(QAreaSeries);
158 Q_D(QAreaSeries);
163 if (d->m_pen != pen) {
159 if (d->m_pen != pen) {
164 d->m_pen = pen;
160 d->m_pen = pen;
165 emit d->updated();
161 emit d->updated();
166 }
162 }
167 }
163 }
168
164
169 QPen QAreaSeries::pen() const
165 QPen QAreaSeries::pen() const
170 {
166 {
171 Q_D(const QAreaSeries);
167 Q_D(const QAreaSeries);
172 return d->m_pen;
168 return d->m_pen;
173 }
169 }
174
170
175 /*!
171 /*!
176 Sets \a brush used for filling the area.
172 Sets \a brush used for filling the area.
177 */
173 */
178 void QAreaSeries::setBrush(const QBrush &brush)
174 void QAreaSeries::setBrush(const QBrush &brush)
179 {
175 {
180 Q_D(QAreaSeries);
176 Q_D(QAreaSeries);
181 if (d->m_brush != brush) {
177 if (d->m_brush != brush) {
182 d->m_brush = brush;
178 d->m_brush = brush;
183 emit d->updated();
179 emit d->updated();
184 }
180 }
185 }
181 }
186
182
187 QBrush QAreaSeries::brush() const
183 QBrush QAreaSeries::brush() const
188 {
184 {
189 Q_D(const QAreaSeries);
185 Q_D(const QAreaSeries);
190 return d->m_brush;
186 return d->m_brush;
191 }
187 }
192 /*!
188 /*!
193 Sets if data points are \a visible and should be drawn on line.
189 Sets if data points are \a visible and should be drawn on line.
194 */
190 */
195 void QAreaSeries::setPointsVisible(bool visible)
191 void QAreaSeries::setPointsVisible(bool visible)
196 {
192 {
197 Q_D(QAreaSeries);
193 Q_D(QAreaSeries);
198 if (d->m_pointsVisible != visible) {
194 if (d->m_pointsVisible != visible) {
199 d->m_pointsVisible = visible;
195 d->m_pointsVisible = visible;
200 emit d->updated();
196 emit d->updated();
201 }
197 }
202 }
198 }
203
199
204 bool QAreaSeries::pointsVisible() const
200 bool QAreaSeries::pointsVisible() const
205 {
201 {
206 Q_D(const QAreaSeries);
202 Q_D(const QAreaSeries);
207 return d->m_pointsVisible;
203 return d->m_pointsVisible;
208 }
204 }
209
205
210 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
206 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
211
207
212 QAreaSeriesPrivate::QAreaSeriesPrivate(QLineSeries *upperSeries, QLineSeries *lowerSeries,QAreaSeries* q) :
208 QAreaSeriesPrivate::QAreaSeriesPrivate(QLineSeries *upperSeries, QLineSeries *lowerSeries,QAreaSeries* q) :
213 QAbstractSeriesPrivate(q),
209 QAbstractSeriesPrivate(q),
214 m_upperSeries(upperSeries),
210 m_upperSeries(upperSeries),
215 m_lowerSeries(lowerSeries),
211 m_lowerSeries(lowerSeries),
216 m_pointsVisible(false)
212 m_pointsVisible(false)
217 {
213 {
218 }
214 }
219
215
220 void QAreaSeriesPrivate::scaleDomain(Domain& domain)
216 void QAreaSeriesPrivate::scaleDomain(Domain& domain)
221 {
217 {
222 Q_Q(QAreaSeries);
218 Q_Q(QAreaSeries);
223
219
224 qreal minX(domain.minX());
220 qreal minX(domain.minX());
225 qreal minY(domain.minY());
221 qreal minY(domain.minY());
226 qreal maxX(domain.maxX());
222 qreal maxX(domain.maxX());
227 qreal maxY(domain.maxY());
223 qreal maxY(domain.maxY());
228 int tickXCount(domain.tickXCount());
224 int tickXCount(domain.tickXCount());
229 int tickYCount(domain.tickYCount());
225 int tickYCount(domain.tickYCount());
230
226
231 QLineSeries* upperSeries = q->upperSeries();
227 QLineSeries* upperSeries = q->upperSeries();
232 QLineSeries* lowerSeries = q->lowerSeries();
228 QLineSeries* lowerSeries = q->lowerSeries();
233
229
234 const QList<QPointF>& points = upperSeries->points();
230 const QList<QPointF>& points = upperSeries->points();
235
231
236 for (int i = 0; i < points.count(); i++)
232 for (int i = 0; i < points.count(); i++)
237 {
233 {
238 qreal x = points[i].x();
234 qreal x = points[i].x();
239 qreal y = points[i].y();
235 qreal y = points[i].y();
240 minX = qMin(minX, x);
236 minX = qMin(minX, x);
241 minY = qMin(minY, y);
237 minY = qMin(minY, y);
242 maxX = qMax(maxX, x);
238 maxX = qMax(maxX, x);
243 maxY = qMax(maxY, y);
239 maxY = qMax(maxY, y);
244 }
240 }
245 if(lowerSeries) {
241 if(lowerSeries) {
246
242
247 const QList<QPointF>& points = lowerSeries->points();
243 const QList<QPointF>& points = lowerSeries->points();
248
244
249 for (int i = 0; i < points.count(); i++)
245 for (int i = 0; i < points.count(); i++)
250 {
246 {
251 qreal x = points[i].x();
247 qreal x = points[i].x();
252 qreal y = points[i].y();
248 qreal y = points[i].y();
253 minX = qMin(minX, x);
249 minX = qMin(minX, x);
254 minY = qMin(minY, y);
250 minY = qMin(minY, y);
255 maxX = qMax(maxX, x);
251 maxX = qMax(maxX, x);
256 maxY = qMax(maxY, y);
252 maxY = qMax(maxY, y);
257 }}
253 }}
258
254
259 domain.setRange(minX,maxX,minY,maxY,tickXCount,tickYCount);
255 domain.setRange(minX,maxX,minY,maxY,tickXCount,tickYCount);
260 }
256 }
261
257
262 Chart* QAreaSeriesPrivate::createGraphics(ChartPresenter* presenter)
258 Chart* QAreaSeriesPrivate::createGraphics(ChartPresenter* presenter)
263 {
259 {
264 Q_Q(QAreaSeries);
260 Q_Q(QAreaSeries);
265
261
266 AreaChartItem* area = new AreaChartItem(q,presenter);
262 AreaChartItem* area = new AreaChartItem(q,presenter);
267 if(presenter->animationOptions().testFlag(QChart::SeriesAnimations)) {
263 if(presenter->animationOptions().testFlag(QChart::SeriesAnimations)) {
268 area->upperLineItem()->setAnimator(presenter->animator());
264 area->upperLineItem()->setAnimator(presenter->animator());
269 area->upperLineItem()->setAnimation(new XYAnimation(area->upperLineItem()));
265 area->upperLineItem()->setAnimation(new XYAnimation(area->upperLineItem()));
270 if(q->lowerSeries()) {
266 if(q->lowerSeries()) {
271 area->lowerLineItem()->setAnimator(presenter->animator());
267 area->lowerLineItem()->setAnimator(presenter->animator());
272 area->lowerLineItem()->setAnimation(new XYAnimation(area->lowerLineItem()));
268 area->lowerLineItem()->setAnimation(new XYAnimation(area->lowerLineItem()));
273 }
269 }
274 }
270 }
275 presenter->chartTheme()->decorate(q, presenter->dataSet()->seriesIndex(q));
271 presenter->chartTheme()->decorate(q, presenter->dataSet()->seriesIndex(q));
276 return area;
272 return area;
277 }
273 }
278
274
279 QList<LegendMarker*> QAreaSeriesPrivate::createLegendMarker(QLegend* legend)
275 QList<LegendMarker*> QAreaSeriesPrivate::createLegendMarker(QLegend* legend)
280 {
276 {
281 Q_Q(QAreaSeries);
277 Q_Q(QAreaSeries);
282 QList<LegendMarker*> list;
278 QList<LegendMarker*> list;
283 return list << new AreaLegendMarker(q,legend);
279 return list << new AreaLegendMarker(q,legend);
284 }
280 }
285
281
286 #include "moc_qareaseries.cpp"
282 #include "moc_qareaseries.cpp"
287 #include "moc_qareaseries_p.cpp"
283 #include "moc_qareaseries_p.cpp"
288
284
289 QTCOMMERCIALCHART_END_NAMESPACE
285 QTCOMMERCIALCHART_END_NAMESPACE
@@ -1,108 +1,105
1 /****************************************************************************
1 /****************************************************************************
2 **
2 **
3 ** Copyright (C) 2012 Digia Plc
3 ** Copyright (C) 2012 Digia Plc
4 ** All rights reserved.
4 ** All rights reserved.
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 **
6 **
7 ** This file is part of the Qt Commercial Charts Add-on.
7 ** This file is part of the Qt Commercial Charts Add-on.
8 **
8 **
9 ** $QT_BEGIN_LICENSE$
9 ** $QT_BEGIN_LICENSE$
10 ** Licensees holding valid Qt Commercial licenses may use this file in
10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 ** accordance with the Qt Commercial License Agreement provided with the
11 ** accordance with the Qt Commercial License Agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia.
13 ** a written agreement between you and Digia.
14 **
14 **
15 ** If you have questions regarding the use of this file, please use
15 ** If you have questions regarding the use of this file, please use
16 ** contact form at http://qt.digia.com
16 ** contact form at http://qt.digia.com
17 ** $QT_END_LICENSE$
17 ** $QT_END_LICENSE$
18 **
18 **
19 ****************************************************************************/
19 ****************************************************************************/
20
20
21 #include "qgroupedbarseries.h"
21 #include "qgroupedbarseries.h"
22 #include "qgroupedbarseries_p.h"
22 #include "qgroupedbarseries_p.h"
23 #include "groupedbarchartitem_p.h"
23 #include "groupedbarchartitem_p.h"
24 #include "chartdataset_p.h"
24 #include "chartdataset_p.h"
25 #include "charttheme_p.h"
25 #include "charttheme_p.h"
26 #include "chartanimator_p.h"
26 #include "chartanimator_p.h"
27
27
28 QTCOMMERCIALCHART_BEGIN_NAMESPACE
28 QTCOMMERCIALCHART_BEGIN_NAMESPACE
29
29
30 /*!
30 /*!
31 \class QGroupedBarSeries
31 \class QGroupedBarSeries
32 \brief part of QtCommercial chart API.
32 \brief part of QtCommercial chart API.
33 \mainclass
33 \mainclass
34
34
35 QGroupedBarSeries represents a series of data shown as bars. The purpose of this class is to draw bars
35 QGroupedBarSeries represents a series of data shown as bars. The purpose of this class is to draw bars
36 as groups, where bars in same category are grouped next to each other. QGroupedBarSeries groups the data
36 as groups, where bars in same category are grouped next to each other. QGroupedBarSeries groups the data
37 from sets to categories, which are defined by a QStringList.
37 from sets to categories, which are defined by a QStringList.
38
38
39 See the \l {GroupedbarChart Example} {grouped bar chart example} to learn how to create a grouped bar chart.
39 See the \l {GroupedbarChart Example} {grouped bar chart example} to learn how to create a grouped bar chart.
40 \image examples_groupedbarchart.png
40 \image examples_groupedbarchart.png
41
41
42 \sa QBarSet, QPercentBarSeries, QBarSeries, QStackedBarSeries
42 \sa QBarSet, QPercentBarSeries, QBarSeries, QStackedBarSeries
43 */
43 */
44
44
45 /*!
45 /*!
46 \fn virtual QSeriesType QGroupedBarSeries::type() const
47 \brief Returns type of series.
48 \sa QAbstractSeries, QSeriesType
49 */
50
51 /*!
52 Constructs empty QGroupedBarSeries.
46 Constructs empty QGroupedBarSeries.
53 QGroupedBarSeries is QObject which is a child of a \a parent.
47 QGroupedBarSeries is QObject which is a child of a \a parent.
54 */
48 */
55 QGroupedBarSeries::QGroupedBarSeries(QObject *parent)
49 QGroupedBarSeries::QGroupedBarSeries(QObject *parent)
56 : QBarSeries(*new QGroupedBarSeriesPrivate(this), parent)
50 : QBarSeries(*new QGroupedBarSeriesPrivate(this), parent)
57 {
51 {
58 }
52 }
59
53
54 /*!
55 Returns QChartSeries::SeriesTypeGroupedBar.
56 */
60 QAbstractSeries::SeriesType QGroupedBarSeries::type() const
57 QAbstractSeries::SeriesType QGroupedBarSeries::type() const
61 {
58 {
62 return QAbstractSeries::SeriesTypeGroupedBar;
59 return QAbstractSeries::SeriesTypeGroupedBar;
63 }
60 }
64
61
65 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
62 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
66
63
67 QGroupedBarSeriesPrivate::QGroupedBarSeriesPrivate(QGroupedBarSeries *q) : QBarSeriesPrivate(q)
64 QGroupedBarSeriesPrivate::QGroupedBarSeriesPrivate(QGroupedBarSeries *q) : QBarSeriesPrivate(q)
68 {
65 {
69
66
70 }
67 }
71
68
72 void QGroupedBarSeriesPrivate::scaleDomain(Domain& domain)
69 void QGroupedBarSeriesPrivate::scaleDomain(Domain& domain)
73 {
70 {
74 qreal minX(domain.minX());
71 qreal minX(domain.minX());
75 qreal minY(domain.minY());
72 qreal minY(domain.minY());
76 qreal maxX(domain.maxX());
73 qreal maxX(domain.maxX());
77 qreal maxY(domain.maxY());
74 qreal maxY(domain.maxY());
78 int tickXCount(domain.tickXCount());
75 int tickXCount(domain.tickXCount());
79 int tickYCount(domain.tickYCount());
76 int tickYCount(domain.tickYCount());
80
77
81 qreal x = categoryCount();
78 qreal x = categoryCount();
82 qreal y = max();
79 qreal y = max();
83 minX = qMin(minX, x) - 0.5;
80 minX = qMin(minX, x) - 0.5;
84 minY = qMin(minY, y);
81 minY = qMin(minY, y);
85 maxX = qMax(maxX, x) - 0.5;
82 maxX = qMax(maxX, x) - 0.5;
86 maxY = qMax(maxY, y);
83 maxY = qMax(maxY, y);
87 tickXCount = x+1;
84 tickXCount = x+1;
88
85
89 domain.setRange(minX,maxX,minY,maxY,tickXCount,tickYCount);
86 domain.setRange(minX,maxX,minY,maxY,tickXCount,tickYCount);
90 }
87 }
91
88
92
89
93 Chart* QGroupedBarSeriesPrivate::createGraphics(ChartPresenter* presenter)
90 Chart* QGroupedBarSeriesPrivate::createGraphics(ChartPresenter* presenter)
94 {
91 {
95 Q_Q(QGroupedBarSeries);
92 Q_Q(QGroupedBarSeries);
96
93
97 GroupedBarChartItem* bar = new GroupedBarChartItem(q,presenter);
94 GroupedBarChartItem* bar = new GroupedBarChartItem(q,presenter);
98 if(presenter->animationOptions().testFlag(QChart::SeriesAnimations)) {
95 if(presenter->animationOptions().testFlag(QChart::SeriesAnimations)) {
99 presenter->animator()->addAnimation(bar);
96 presenter->animator()->addAnimation(bar);
100 }
97 }
101 presenter->chartTheme()->decorate(q, presenter->dataSet()->seriesIndex(q));
98 presenter->chartTheme()->decorate(q, presenter->dataSet()->seriesIndex(q));
102 return bar;
99 return bar;
103 }
100 }
104
101
105 #include "moc_qgroupedbarseries.cpp"
102 #include "moc_qgroupedbarseries.cpp"
106
103
107 QTCOMMERCIALCHART_END_NAMESPACE
104 QTCOMMERCIALCHART_END_NAMESPACE
108
105
@@ -1,107 +1,104
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 "qpercentbarseries.h"
21 #include "qpercentbarseries.h"
22 #include "qpercentbarseries_p.h"
22 #include "qpercentbarseries_p.h"
23 #include "percentbarchartitem_p.h"
23 #include "percentbarchartitem_p.h"
24 #include "chartdataset_p.h"
24 #include "chartdataset_p.h"
25 #include "charttheme_p.h"
25 #include "charttheme_p.h"
26 #include "chartanimator_p.h"
26 #include "chartanimator_p.h"
27
27
28 QTCOMMERCIALCHART_BEGIN_NAMESPACE
28 QTCOMMERCIALCHART_BEGIN_NAMESPACE
29
29
30 /*!
30 /*!
31 \class QPercentBarSeries
31 \class QPercentBarSeries
32 \brief part of QtCommercial chart API.
32 \brief part of QtCommercial chart API.
33 \mainclass
33 \mainclass
34
34
35 QPercentBarSeries represents a series of data shown as bars. The purpose of this class is to draw bars
35 QPercentBarSeries represents a series of data shown as bars. The purpose of this class is to draw bars
36 as stacks, where each bar is shown as percentage of all bars in that category.
36 as stacks, where each bar is shown as percentage of all bars in that category.
37 QPercentBarSeries groups the data from sets to categories, which are defined by a QStringList.
37 QPercentBarSeries groups the data from sets to categories, which are defined by a QStringList.
38
38
39 See the \l {PercentbarChart Example} {percent bar chart example} to learn how to create a percent bar chart.
39 See the \l {PercentbarChart Example} {percent bar chart example} to learn how to create a percent bar chart.
40 \image examples_percentbarchart.png
40 \image examples_percentbarchart.png
41
41
42 \sa QBarSet, QStackedBarSeries, QBarSeries
42 \sa QBarSet, QStackedBarSeries, QBarSeries
43 */
43 */
44
44
45 /*!
45 /*!
46 \fn virtual QSeriesType QPercentBarSeries::type() const
47 \brief Returns type of series.
48 \sa QAbstractSeries, QSeriesType
49 */
50
51 /*!
52 Constructs empty QPercentBarSeries.
46 Constructs empty QPercentBarSeries.
53 QPercentBarSeries is QObject which is a child of a \a parent.
47 QPercentBarSeries is QObject which is a child of a \a parent.
54 */
48 */
55 QPercentBarSeries::QPercentBarSeries(QObject *parent)
49 QPercentBarSeries::QPercentBarSeries(QObject *parent)
56 : QBarSeries(*new QPercentBarSeriesPrivate(this), parent)
50 : QBarSeries(*new QPercentBarSeriesPrivate(this), parent)
57 {
51 {
58 }
52 }
59
53
54 /*!
55 Returns QChartSeries::SeriesTypePercentBar.
56 */
60 QAbstractSeries::SeriesType QPercentBarSeries::type() const
57 QAbstractSeries::SeriesType QPercentBarSeries::type() const
61 {
58 {
62 return QAbstractSeries::SeriesTypePercentBar;
59 return QAbstractSeries::SeriesTypePercentBar;
63 }
60 }
64
61
65 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
62 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
66
63
67 QPercentBarSeriesPrivate::QPercentBarSeriesPrivate(QPercentBarSeries *q) : QBarSeriesPrivate(q)
64 QPercentBarSeriesPrivate::QPercentBarSeriesPrivate(QPercentBarSeries *q) : QBarSeriesPrivate(q)
68 {
65 {
69
66
70 }
67 }
71
68
72 void QPercentBarSeriesPrivate::scaleDomain(Domain& domain)
69 void QPercentBarSeriesPrivate::scaleDomain(Domain& domain)
73 {
70 {
74 qreal minX(domain.minX());
71 qreal minX(domain.minX());
75 qreal minY(domain.minY());
72 qreal minY(domain.minY());
76 qreal maxX(domain.maxX());
73 qreal maxX(domain.maxX());
77 qreal maxY(domain.maxY());
74 qreal maxY(domain.maxY());
78 int tickXCount(domain.tickXCount());
75 int tickXCount(domain.tickXCount());
79 int tickYCount(domain.tickYCount());
76 int tickYCount(domain.tickYCount());
80
77
81 qreal x = categoryCount();
78 qreal x = categoryCount();
82 minX = qMin(minX, x) - 0.5;
79 minX = qMin(minX, x) - 0.5;
83 maxX = qMax(maxX, x) - 0.5;
80 maxX = qMax(maxX, x) - 0.5;
84 minY = 0;
81 minY = 0;
85 maxY = 100;
82 maxY = 100;
86 tickXCount = x+1;
83 tickXCount = x+1;
87
84
88 domain.setRange(minX,maxX,minY,maxY,tickXCount,tickYCount);
85 domain.setRange(minX,maxX,minY,maxY,tickXCount,tickYCount);
89 }
86 }
90
87
91
88
92 Chart* QPercentBarSeriesPrivate::createGraphics(ChartPresenter* presenter)
89 Chart* QPercentBarSeriesPrivate::createGraphics(ChartPresenter* presenter)
93 {
90 {
94 Q_Q(QPercentBarSeries);
91 Q_Q(QPercentBarSeries);
95
92
96 PercentBarChartItem* bar = new PercentBarChartItem(q,presenter);
93 PercentBarChartItem* bar = new PercentBarChartItem(q,presenter);
97 if(presenter->animationOptions().testFlag(QChart::SeriesAnimations)) {
94 if(presenter->animationOptions().testFlag(QChart::SeriesAnimations)) {
98 presenter->animator()->addAnimation(bar);
95 presenter->animator()->addAnimation(bar);
99 }
96 }
100 presenter->chartTheme()->decorate(q, presenter->dataSet()->seriesIndex(q));
97 presenter->chartTheme()->decorate(q, presenter->dataSet()->seriesIndex(q));
101 return bar;
98 return bar;
102 }
99 }
103
100
104 #include "moc_qpercentbarseries.cpp"
101 #include "moc_qpercentbarseries.cpp"
105
102
106 QTCOMMERCIALCHART_END_NAMESPACE
103 QTCOMMERCIALCHART_END_NAMESPACE
107
104
@@ -1,108 +1,105
1 /****************************************************************************
1 /****************************************************************************
2 **
2 **
3 ** Copyright (C) 2012 Digia Plc
3 ** Copyright (C) 2012 Digia Plc
4 ** All rights reserved.
4 ** All rights reserved.
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 **
6 **
7 ** This file is part of the Qt Commercial Charts Add-on.
7 ** This file is part of the Qt Commercial Charts Add-on.
8 **
8 **
9 ** $QT_BEGIN_LICENSE$
9 ** $QT_BEGIN_LICENSE$
10 ** Licensees holding valid Qt Commercial licenses may use this file in
10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 ** accordance with the Qt Commercial License Agreement provided with the
11 ** accordance with the Qt Commercial License Agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia.
13 ** a written agreement between you and Digia.
14 **
14 **
15 ** If you have questions regarding the use of this file, please use
15 ** If you have questions regarding the use of this file, please use
16 ** contact form at http://qt.digia.com
16 ** contact form at http://qt.digia.com
17 ** $QT_END_LICENSE$
17 ** $QT_END_LICENSE$
18 **
18 **
19 ****************************************************************************/
19 ****************************************************************************/
20
20
21 #include "qstackedbarseries.h"
21 #include "qstackedbarseries.h"
22 #include "qstackedbarseries_p.h"
22 #include "qstackedbarseries_p.h"
23 #include "stackedbarchartitem_p.h"
23 #include "stackedbarchartitem_p.h"
24 #include "chartdataset_p.h"
24 #include "chartdataset_p.h"
25 #include "charttheme_p.h"
25 #include "charttheme_p.h"
26 #include "chartanimator_p.h"
26 #include "chartanimator_p.h"
27
27
28 QTCOMMERCIALCHART_BEGIN_NAMESPACE
28 QTCOMMERCIALCHART_BEGIN_NAMESPACE
29
29
30 /*!
30 /*!
31 \class QStackedBarSeries
31 \class QStackedBarSeries
32 \brief part of QtCommercial chart API.
32 \brief part of QtCommercial chart API.
33 \mainclass
33 \mainclass
34
34
35 QStackedBarSeries represents a series of data shown as bars. The purpose of this class is to draw bars
35 QStackedBarSeries represents a series of data shown as bars. The purpose of this class is to draw bars
36 as stacks, where bars in same category are stacked on top of each other.
36 as stacks, where bars in same category are stacked on top of each other.
37 QStackedBarSeries groups the data from sets to categories, which are defined by QStringList.
37 QStackedBarSeries groups the data from sets to categories, which are defined by QStringList.
38
38
39 See the \l {StackedbarChart Example} {stacked bar chart example} to learn how to create a stacked bar chart.
39 See the \l {StackedbarChart Example} {stacked bar chart example} to learn how to create a stacked bar chart.
40 \image examples_stackedbarchart.png
40 \image examples_stackedbarchart.png
41
41
42 \sa QBarSet, QPercentBarSeries, QBarSeries
42 \sa QBarSet, QPercentBarSeries, QBarSeries
43 */
43 */
44
44
45 /*!
45 /*!
46 \fn virtual QSeriesType QStackedBarSeries::type() const
47 \brief Returns type of series.
48 \sa QAbstractSeries, QSeriesType
49 */
50
51 /*!
52 Constructs empty QStackedBarSeries.
46 Constructs empty QStackedBarSeries.
53 QStackedBarSeries is QObject which is a child of a \a parent.
47 QStackedBarSeries is QObject which is a child of a \a parent.
54 */
48 */
55 QStackedBarSeries::QStackedBarSeries(QObject *parent)
49 QStackedBarSeries::QStackedBarSeries(QObject *parent)
56 : QBarSeries(*new QStackedBarSeriesPrivate(this), parent)
50 : QBarSeries(*new QStackedBarSeriesPrivate(this), parent)
57 {
51 {
58 }
52 }
59
53
54 /*!
55 Returns QChartSeries::SeriesTypeStackedBar.
56 */
60 QAbstractSeries::SeriesType QStackedBarSeries::type() const
57 QAbstractSeries::SeriesType QStackedBarSeries::type() const
61 {
58 {
62 return QAbstractSeries::SeriesTypeStackedBar;
59 return QAbstractSeries::SeriesTypeStackedBar;
63 }
60 }
64
61
65 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
62 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
66
63
67 QStackedBarSeriesPrivate::QStackedBarSeriesPrivate(QStackedBarSeries *q) : QBarSeriesPrivate(q)
64 QStackedBarSeriesPrivate::QStackedBarSeriesPrivate(QStackedBarSeries *q) : QBarSeriesPrivate(q)
68 {
65 {
69
66
70 }
67 }
71
68
72 void QStackedBarSeriesPrivate::scaleDomain(Domain& domain)
69 void QStackedBarSeriesPrivate::scaleDomain(Domain& domain)
73 {
70 {
74 qreal minX(domain.minX());
71 qreal minX(domain.minX());
75 qreal minY(domain.minY());
72 qreal minY(domain.minY());
76 qreal maxX(domain.maxX());
73 qreal maxX(domain.maxX());
77 qreal maxY(domain.maxY());
74 qreal maxY(domain.maxY());
78 int tickXCount(domain.tickXCount());
75 int tickXCount(domain.tickXCount());
79 int tickYCount(domain.tickYCount());
76 int tickYCount(domain.tickYCount());
80
77
81 qreal x = categoryCount();
78 qreal x = categoryCount();
82 qreal y = maxCategorySum();
79 qreal y = maxCategorySum();
83 minX = qMin(minX, x) - 0.5;
80 minX = qMin(minX, x) - 0.5;
84 minY = qMin(minY, y);
81 minY = qMin(minY, y);
85 maxX = qMax(maxX, x) - 0.5;
82 maxX = qMax(maxX, x) - 0.5;
86 maxY = qMax(maxY, y);
83 maxY = qMax(maxY, y);
87 tickXCount = x+1;
84 tickXCount = x+1;
88
85
89 domain.setRange(minX,maxX,minY,maxY,tickXCount,tickYCount);
86 domain.setRange(minX,maxX,minY,maxY,tickXCount,tickYCount);
90 }
87 }
91
88
92
89
93 Chart* QStackedBarSeriesPrivate::createGraphics(ChartPresenter* presenter)
90 Chart* QStackedBarSeriesPrivate::createGraphics(ChartPresenter* presenter)
94 {
91 {
95 Q_Q(QStackedBarSeries);
92 Q_Q(QStackedBarSeries);
96
93
97 StackedBarChartItem* bar = new StackedBarChartItem(q,presenter);
94 StackedBarChartItem* bar = new StackedBarChartItem(q,presenter);
98 if(presenter->animationOptions().testFlag(QChart::SeriesAnimations)) {
95 if(presenter->animationOptions().testFlag(QChart::SeriesAnimations)) {
99 presenter->animator()->addAnimation(bar);
96 presenter->animator()->addAnimation(bar);
100 }
97 }
101 presenter->chartTheme()->decorate(q, presenter->dataSet()->seriesIndex(q));
98 presenter->chartTheme()->decorate(q, presenter->dataSet()->seriesIndex(q));
102 return bar;
99 return bar;
103 }
100 }
104
101
105 #include "moc_qstackedbarseries.cpp"
102 #include "moc_qstackedbarseries.cpp"
106
103
107 QTCOMMERCIALCHART_END_NAMESPACE
104 QTCOMMERCIALCHART_END_NAMESPACE
108
105
General Comments 0
You need to be logged in to leave comments. Login now