@@ -1,345 +1,345 | |||||
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 "chartdataset_p.h" |
|
21 | #include "chartdataset_p.h" | |
22 | #include "qchartaxis.h" |
|
22 | #include "qchartaxis.h" | |
23 | //series |
|
23 | //series | |
24 | #include "qlineseries.h" |
|
24 | #include "qlineseries.h" | |
25 | #include "qareaseries.h" |
|
25 | #include "qareaseries.h" | |
26 | #include "qbarseries.h" |
|
26 | #include "qbarseries.h" | |
27 | #include "qstackedbarseries.h" |
|
27 | #include "qstackedbarseries.h" | |
28 | #include "qpercentbarseries.h" |
|
28 | #include "qpercentbarseries.h" | |
29 | #include "qpieseries.h" |
|
29 | #include "qpieseries.h" | |
30 | #include "qscatterseries.h" |
|
30 | #include "qscatterseries.h" | |
31 | #include "qsplineseries.h" |
|
31 | #include "qsplineseries.h" | |
32 |
|
32 | |||
33 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
33 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
34 |
|
34 | |||
35 | ChartDataSet::ChartDataSet(QObject *parent):QObject(parent), |
|
35 | ChartDataSet::ChartDataSet(QObject *parent):QObject(parent), | |
36 | m_axisX(new QChartAxis(this)), |
|
36 | m_axisX(new QChartAxis(this)), | |
37 | m_axisY(new QChartAxis(this)), |
|
37 | m_axisY(new QChartAxis(this)), | |
38 | m_domainIndex(0), |
|
38 | m_domainIndex(0), | |
39 | m_axisXInitialized(false) |
|
39 | m_axisXInitialized(false) | |
40 | { |
|
40 | { | |
41 | } |
|
41 | } | |
42 |
|
42 | |||
43 | ChartDataSet::~ChartDataSet() |
|
43 | ChartDataSet::~ChartDataSet() | |
44 | { |
|
44 | { | |
45 | } |
|
45 | } | |
46 |
|
46 | |||
47 | void ChartDataSet::addSeries(QSeries* series, QChartAxis *axisY) |
|
47 | void ChartDataSet::addSeries(QSeries* series, QChartAxis *axisY) | |
48 | { |
|
48 | { | |
49 | if(axisY==0) axisY = m_axisY; |
|
49 | if(axisY==0) axisY = m_axisY; | |
50 |
|
50 | |||
51 | QChartAxis* axis = m_seriesAxisMap.value(series); |
|
51 | QChartAxis* axis = m_seriesAxisMap.value(series); | |
52 |
|
52 | |||
53 | if(axis) { |
|
53 | if(axis) { | |
54 | qWarning() << "Can not add series. Series already on the chart"; |
|
54 | qWarning() << "Can not add series. Series already on the chart"; | |
55 | return; |
|
55 | return; | |
56 | } |
|
56 | } | |
57 |
|
57 | |||
58 | if(!series->parent()){ |
|
58 | if(!series->parent()){ | |
59 | series->setParent(this); // take ownership |
|
59 | series->setParent(this); // take ownership | |
60 | }; |
|
60 | }; | |
61 |
|
61 | |||
62 | if(!axisY->parent()){ |
|
62 | if(!axisY->parent()){ | |
63 | axisY->setParent(this); // take ownership |
|
63 | axisY->setParent(this); // take ownership | |
64 | } |
|
64 | } | |
65 |
|
65 | |||
66 | Domain* domain = m_axisDomainMap.value(axisY); |
|
66 | Domain* domain = m_axisDomainMap.value(axisY); | |
67 |
|
67 | |||
68 | if(!domain) { |
|
68 | if(!domain) { | |
69 | domain = new Domain(); |
|
69 | domain = new Domain(axisY); | |
70 | QObject::connect(axisY,SIGNAL(changed(qreal,qreal,int,bool)),domain,SLOT(handleAxisYChanged(qreal,qreal,int,bool))); |
|
70 | QObject::connect(axisY,SIGNAL(changed(qreal,qreal,int,bool)),domain,SLOT(handleAxisYChanged(qreal,qreal,int,bool))); | |
71 | QObject::connect(axisX(),SIGNAL(changed(qreal,qreal,int,bool)),domain,SLOT(handleAxisXChanged(qreal,qreal,int,bool))); |
|
71 | QObject::connect(axisX(),SIGNAL(changed(qreal,qreal,int,bool)),domain,SLOT(handleAxisXChanged(qreal,qreal,int,bool))); | |
72 | QObject::connect(domain,SIGNAL(rangeYChanged(qreal,qreal,int)),axisY,SLOT(handleAxisRangeChanged(qreal,qreal,int))); |
|
72 | QObject::connect(domain,SIGNAL(rangeYChanged(qreal,qreal,int)),axisY,SLOT(handleAxisRangeChanged(qreal,qreal,int))); | |
73 | QObject::connect(domain,SIGNAL(rangeXChanged(qreal,qreal,int)),axisX(),SLOT(handleAxisRangeChanged(qreal,qreal,int))); |
|
73 | QObject::connect(domain,SIGNAL(rangeXChanged(qreal,qreal,int)),axisX(),SLOT(handleAxisRangeChanged(qreal,qreal,int))); | |
74 | //initialize |
|
74 | //initialize | |
75 | m_axisDomainMap.insert(axisY,domain); |
|
75 | m_axisDomainMap.insert(axisY,domain); | |
76 | emit axisAdded(axisY,domain); |
|
76 | emit axisAdded(axisY,domain); | |
77 | } |
|
77 | } | |
78 |
|
78 | |||
79 | if(!m_axisXInitialized){ |
|
79 | if(!m_axisXInitialized){ | |
80 | emit axisAdded(axisX(),domain); |
|
80 | emit axisAdded(axisX(),domain); | |
81 | m_axisXInitialized=true; |
|
81 | m_axisXInitialized=true; | |
82 | } |
|
82 | } | |
83 |
|
83 | |||
84 | calculateDomain(series,domain); |
|
84 | calculateDomain(series,domain); | |
85 |
|
85 | |||
86 | m_seriesAxisMap.insert(series,axisY); |
|
86 | m_seriesAxisMap.insert(series,axisY); | |
87 | emit seriesAdded(series,domain); |
|
87 | emit seriesAdded(series,domain); | |
88 |
|
88 | |||
89 | } |
|
89 | } | |
90 |
|
90 | |||
91 | void ChartDataSet::removeSeries(QSeries* series) |
|
91 | void ChartDataSet::removeSeries(QSeries* series) | |
92 | { |
|
92 | { | |
93 |
|
93 | |||
94 | QChartAxis* axis = m_seriesAxisMap.value(series); |
|
94 | QChartAxis* axis = m_seriesAxisMap.value(series); | |
95 |
|
95 | |||
96 | if(!axis){ |
|
96 | if(!axis){ | |
97 | qWarning()<<"Can not remove series. Series not found on the chart."; |
|
97 | qWarning()<<"Can not remove series. Series not found on the chart."; | |
98 | return; |
|
98 | return; | |
99 | } |
|
99 | } | |
100 | emit seriesRemoved(series); |
|
100 | emit seriesRemoved(series); | |
101 | m_seriesAxisMap.remove(series); |
|
101 | m_seriesAxisMap.remove(series); | |
102 |
|
102 | |||
103 | if(series->parent()==this){ |
|
103 | if(series->parent()==this){ | |
104 | delete series; |
|
104 | delete series; | |
105 | series=0; |
|
105 | series=0; | |
106 | } |
|
106 | } | |
107 |
|
107 | |||
108 | QList<QChartAxis*> axes = m_seriesAxisMap.values(); |
|
108 | QList<QChartAxis*> axes = m_seriesAxisMap.values(); | |
109 |
|
109 | |||
110 | int i = axes.indexOf(axis); |
|
110 | int i = axes.indexOf(axis); | |
111 |
|
111 | |||
112 | if(i==-1){ |
|
112 | if(i==-1){ | |
113 | Domain* domain = m_axisDomainMap.take(axis); |
|
113 | Domain* domain = m_axisDomainMap.take(axis); | |
114 | emit axisRemoved(axis); |
|
114 | emit axisRemoved(axis); | |
115 | if(axis!=axisY()){ |
|
115 | if(axis!=axisY()){ | |
116 | if(axis->parent()==this){ |
|
116 | if(axis->parent()==this){ | |
117 | delete axis; |
|
117 | delete axis; | |
118 | axis=0; |
|
118 | axis=0; | |
119 | } |
|
119 | } | |
120 | } |
|
120 | } | |
121 | delete domain; |
|
121 | delete domain; | |
122 | } |
|
122 | } | |
123 |
|
123 | |||
124 | if(m_seriesAxisMap.values().size()==0) |
|
124 | if(m_seriesAxisMap.values().size()==0) | |
125 | { |
|
125 | { | |
126 | m_axisXInitialized=false; |
|
126 | m_axisXInitialized=false; | |
127 | emit axisRemoved(axisX()); |
|
127 | emit axisRemoved(axisX()); | |
128 | } |
|
128 | } | |
129 | } |
|
129 | } | |
130 |
|
130 | |||
131 | void ChartDataSet::removeAllSeries() |
|
131 | void ChartDataSet::removeAllSeries() | |
132 | { |
|
132 | { | |
133 |
|
133 | |||
134 | QList<QSeries*> series = m_seriesAxisMap.keys(); |
|
134 | QList<QSeries*> series = m_seriesAxisMap.keys(); | |
135 |
|
135 | |||
136 | foreach(QSeries* s , series) { |
|
136 | foreach(QSeries* s , series) { | |
137 | removeSeries(s); |
|
137 | removeSeries(s); | |
138 | } |
|
138 | } | |
139 |
|
139 | |||
140 | Q_ASSERT(m_seriesAxisMap.count()==0); |
|
140 | Q_ASSERT(m_seriesAxisMap.count()==0); | |
141 | Q_ASSERT(m_axisDomainMap.count()==0); |
|
141 | Q_ASSERT(m_axisDomainMap.count()==0); | |
142 |
|
142 | |||
143 | } |
|
143 | } | |
144 |
|
144 | |||
145 | //to be removed with PIMPL |
|
145 | //to be removed with PIMPL | |
146 | void ChartDataSet::calculateDomain(QSeries* series,Domain* domain) |
|
146 | void ChartDataSet::calculateDomain(QSeries* series,Domain* domain) | |
147 | { |
|
147 | { | |
148 | qreal minX(domain->minX()); |
|
148 | qreal minX(domain->minX()); | |
149 | qreal minY(domain->minY()); |
|
149 | qreal minY(domain->minY()); | |
150 | qreal maxX(domain->maxX()); |
|
150 | qreal maxX(domain->maxX()); | |
151 | qreal maxY(domain->maxY()); |
|
151 | qreal maxY(domain->maxY()); | |
152 | int tickXCount(domain->tickXCount()); |
|
152 | int tickXCount(domain->tickXCount()); | |
153 | int tickYCount(domain->tickYCount()); |
|
153 | int tickYCount(domain->tickYCount()); | |
154 |
|
154 | |||
155 |
|
155 | |||
156 | switch(series->type()) |
|
156 | switch(series->type()) | |
157 | { |
|
157 | { | |
158 | case QSeries::SeriesTypeLine: |
|
158 | case QSeries::SeriesTypeLine: | |
159 | case QSeries::SeriesTypeSpline: |
|
159 | case QSeries::SeriesTypeSpline: | |
160 | case QSeries::SeriesTypeScatter: |
|
160 | case QSeries::SeriesTypeScatter: | |
161 | { |
|
161 | { | |
162 |
|
162 | |||
163 | QXYSeries* xySeries = static_cast<QXYSeries*>(series); |
|
163 | QXYSeries* xySeries = static_cast<QXYSeries*>(series); | |
164 |
|
164 | |||
165 | for (int i = 0; i < xySeries->count(); i++) |
|
165 | for (int i = 0; i < xySeries->count(); i++) | |
166 | { |
|
166 | { | |
167 | qreal x = xySeries->x(i); |
|
167 | qreal x = xySeries->x(i); | |
168 | qreal y = xySeries->y(i); |
|
168 | qreal y = xySeries->y(i); | |
169 | minX = qMin(minX, x); |
|
169 | minX = qMin(minX, x); | |
170 | minY = qMin(minY, y); |
|
170 | minY = qMin(minY, y); | |
171 | maxX = qMax(maxX, x); |
|
171 | maxX = qMax(maxX, x); | |
172 | maxY = qMax(maxY, y); |
|
172 | maxY = qMax(maxY, y); | |
173 | } |
|
173 | } | |
174 | break; |
|
174 | break; | |
175 | } |
|
175 | } | |
176 | case QSeries::SeriesTypeArea: { |
|
176 | case QSeries::SeriesTypeArea: { | |
177 |
|
177 | |||
178 | QAreaSeries* areaSeries = static_cast<QAreaSeries*>(series); |
|
178 | QAreaSeries* areaSeries = static_cast<QAreaSeries*>(series); | |
179 | QLineSeries* upperSeries = areaSeries->upperSeries(); |
|
179 | QLineSeries* upperSeries = areaSeries->upperSeries(); | |
180 | QLineSeries* lowerSeries = areaSeries->lowerSeries(); |
|
180 | QLineSeries* lowerSeries = areaSeries->lowerSeries(); | |
181 |
|
181 | |||
182 | for (int i = 0; i < upperSeries->count(); i++) |
|
182 | for (int i = 0; i < upperSeries->count(); i++) | |
183 | { |
|
183 | { | |
184 | qreal x = upperSeries->x(i); |
|
184 | qreal x = upperSeries->x(i); | |
185 | qreal y = upperSeries->y(i); |
|
185 | qreal y = upperSeries->y(i); | |
186 | minX = qMin(minX, x); |
|
186 | minX = qMin(minX, x); | |
187 | minY = qMin(minY, y); |
|
187 | minY = qMin(minY, y); | |
188 | maxX = qMax(maxX, x); |
|
188 | maxX = qMax(maxX, x); | |
189 | maxY = qMax(maxY, y); |
|
189 | maxY = qMax(maxY, y); | |
190 | } |
|
190 | } | |
191 | if(lowerSeries) { |
|
191 | if(lowerSeries) { | |
192 | for (int i = 0; i < lowerSeries->count(); i++) |
|
192 | for (int i = 0; i < lowerSeries->count(); i++) | |
193 | { |
|
193 | { | |
194 | qreal x = lowerSeries->x(i); |
|
194 | qreal x = lowerSeries->x(i); | |
195 | qreal y = lowerSeries->y(i); |
|
195 | qreal y = lowerSeries->y(i); | |
196 | minX = qMin(minX, x); |
|
196 | minX = qMin(minX, x); | |
197 | minY = qMin(minY, y); |
|
197 | minY = qMin(minY, y); | |
198 | maxX = qMax(maxX, x); |
|
198 | maxX = qMax(maxX, x); | |
199 | maxY = qMax(maxY, y); |
|
199 | maxY = qMax(maxY, y); | |
200 | }} |
|
200 | }} | |
201 | break; |
|
201 | break; | |
202 | } |
|
202 | } | |
203 | case QSeries::SeriesTypeBar: { |
|
203 | case QSeries::SeriesTypeBar: { | |
204 |
|
204 | |||
205 | QBarSeries* barSeries = static_cast<QBarSeries*>(series); |
|
205 | QBarSeries* barSeries = static_cast<QBarSeries*>(series); | |
206 | qreal x = barSeries->categoryCount(); |
|
206 | qreal x = barSeries->categoryCount(); | |
207 | qreal y = barSeries->max(); |
|
207 | qreal y = barSeries->max(); | |
208 | minX = qMin(minX, x); |
|
208 | minX = qMin(minX, x); | |
209 | minY = qMin(minY, y); |
|
209 | minY = qMin(minY, y); | |
210 | maxX = qMax(maxX, x); |
|
210 | maxX = qMax(maxX, x); | |
211 | maxY = qMax(maxY, y); |
|
211 | maxY = qMax(maxY, y); | |
212 | tickXCount = x+1; |
|
212 | tickXCount = x+1; | |
213 | setupCategories(barSeries); |
|
213 | setupCategories(barSeries); | |
214 | break; |
|
214 | break; | |
215 | } |
|
215 | } | |
216 | case QSeries::SeriesTypeStackedBar: { |
|
216 | case QSeries::SeriesTypeStackedBar: { | |
217 |
|
217 | |||
218 | QStackedBarSeries* stackedBarSeries = static_cast<QStackedBarSeries*>(series); |
|
218 | QStackedBarSeries* stackedBarSeries = static_cast<QStackedBarSeries*>(series); | |
219 | qreal x = stackedBarSeries->categoryCount(); |
|
219 | qreal x = stackedBarSeries->categoryCount(); | |
220 | qreal y = stackedBarSeries->maxCategorySum(); |
|
220 | qreal y = stackedBarSeries->maxCategorySum(); | |
221 | minX = qMin(minX, x); |
|
221 | minX = qMin(minX, x); | |
222 | minY = qMin(minY, y); |
|
222 | minY = qMin(minY, y); | |
223 | maxX = qMax(maxX, x); |
|
223 | maxX = qMax(maxX, x); | |
224 | maxY = qMax(maxY, y); |
|
224 | maxY = qMax(maxY, y); | |
225 | tickXCount = x+1; |
|
225 | tickXCount = x+1; | |
226 | setupCategories(stackedBarSeries); |
|
226 | setupCategories(stackedBarSeries); | |
227 | break; |
|
227 | break; | |
228 | } |
|
228 | } | |
229 | case QSeries::SeriesTypePercentBar: { |
|
229 | case QSeries::SeriesTypePercentBar: { | |
230 |
|
230 | |||
231 | QPercentBarSeries* percentBarSeries = static_cast<QPercentBarSeries*>(series); |
|
231 | QPercentBarSeries* percentBarSeries = static_cast<QPercentBarSeries*>(series); | |
232 | qreal x = percentBarSeries->categoryCount(); |
|
232 | qreal x = percentBarSeries->categoryCount(); | |
233 | minX = qMin(minX, x); |
|
233 | minX = qMin(minX, x); | |
234 | maxX = qMax(maxX, x); |
|
234 | maxX = qMax(maxX, x); | |
235 | minY = 0; |
|
235 | minY = 0; | |
236 | maxY = 100; |
|
236 | maxY = 100; | |
237 | setupCategories(percentBarSeries); |
|
237 | setupCategories(percentBarSeries); | |
238 | break; |
|
238 | break; | |
239 | } |
|
239 | } | |
240 |
|
240 | |||
241 | case QSeries::SeriesTypePie: { |
|
241 | case QSeries::SeriesTypePie: { | |
242 | //QPieSeries *pieSeries = static_cast<QPieSeries *>(series); |
|
242 | //QPieSeries *pieSeries = static_cast<QPieSeries *>(series); | |
243 | // TODO: domain stuff |
|
243 | // TODO: domain stuff | |
244 | break; |
|
244 | break; | |
245 | } |
|
245 | } | |
246 |
|
246 | |||
247 |
|
247 | |||
248 | default: { |
|
248 | default: { | |
249 | qDebug()<<__FUNCTION__<<"type" << series->type()<<"not supported"; |
|
249 | qDebug()<<__FUNCTION__<<"type" << series->type()<<"not supported"; | |
250 | return; |
|
250 | return; | |
251 | } |
|
251 | } | |
252 |
|
252 | |||
253 | } |
|
253 | } | |
254 |
|
254 | |||
255 | domain->setRangeX(minX,maxX,tickXCount); |
|
255 | domain->setRangeX(minX,maxX,tickXCount); | |
256 | domain->setRangeY(minY,maxY,tickYCount); |
|
256 | domain->setRangeY(minY,maxY,tickYCount); | |
257 | } |
|
257 | } | |
258 |
|
258 | |||
259 |
|
259 | |||
260 | void ChartDataSet::setupCategories(QBarSeries* series) |
|
260 | void ChartDataSet::setupCategories(QBarSeries* series) | |
261 | { |
|
261 | { | |
262 | QChartAxisCategories* categories = axisX()->categories(); |
|
262 | QChartAxisCategories* categories = axisX()->categories(); | |
263 | categories->clear(); |
|
263 | categories->clear(); | |
264 | categories->insert(series->categories()); |
|
264 | categories->insert(series->categories()); | |
265 | } |
|
265 | } | |
266 |
|
266 | |||
267 | void ChartDataSet::zoomInDomain(const QRectF& rect, const QSizeF& size) |
|
267 | void ChartDataSet::zoomInDomain(const QRectF& rect, const QSizeF& size) | |
268 | { |
|
268 | { | |
269 | QMapIterator<QChartAxis*, Domain*> i(m_axisDomainMap); |
|
269 | QMapIterator<QChartAxis*, Domain*> i(m_axisDomainMap); | |
270 | while (i.hasNext()) { |
|
270 | while (i.hasNext()) { | |
271 | i.next(); |
|
271 | i.next(); | |
272 | i.value()->zoomIn(rect,size); |
|
272 | i.value()->zoomIn(rect,size); | |
273 | } |
|
273 | } | |
274 | } |
|
274 | } | |
275 |
|
275 | |||
276 | void ChartDataSet::zoomOutDomain(const QRectF& rect, const QSizeF& size) |
|
276 | void ChartDataSet::zoomOutDomain(const QRectF& rect, const QSizeF& size) | |
277 | { |
|
277 | { | |
278 | QMapIterator<QChartAxis*, Domain*> i(m_axisDomainMap); |
|
278 | QMapIterator<QChartAxis*, Domain*> i(m_axisDomainMap); | |
279 | while (i.hasNext()) { |
|
279 | while (i.hasNext()) { | |
280 | i.next(); |
|
280 | i.next(); | |
281 | i.value()->zoomOut(rect,size); |
|
281 | i.value()->zoomOut(rect,size); | |
282 | } |
|
282 | } | |
283 | } |
|
283 | } | |
284 |
|
284 | |||
285 | int ChartDataSet::seriesCount(QSeries::QSeriesType type) |
|
285 | int ChartDataSet::seriesCount(QSeries::QSeriesType type) | |
286 | { |
|
286 | { | |
287 | int count=0; |
|
287 | int count=0; | |
288 | QMapIterator<QSeries*, QChartAxis*> i(m_seriesAxisMap); |
|
288 | QMapIterator<QSeries*, QChartAxis*> i(m_seriesAxisMap); | |
289 | while (i.hasNext()) { |
|
289 | while (i.hasNext()) { | |
290 | i.next(); |
|
290 | i.next(); | |
291 | if(i.key()->type()==type) count++; |
|
291 | if(i.key()->type()==type) count++; | |
292 | } |
|
292 | } | |
293 | return count; |
|
293 | return count; | |
294 | } |
|
294 | } | |
295 |
|
295 | |||
296 | int ChartDataSet::seriesIndex(QSeries *series) |
|
296 | int ChartDataSet::seriesIndex(QSeries *series) | |
297 | { |
|
297 | { | |
298 | int count=-1; |
|
298 | int count=-1; | |
299 | QMapIterator<QSeries*, QChartAxis*> i(m_seriesAxisMap); |
|
299 | QMapIterator<QSeries*, QChartAxis*> i(m_seriesAxisMap); | |
300 | while (i.hasNext()) { |
|
300 | while (i.hasNext()) { | |
301 | i.next(); |
|
301 | i.next(); | |
302 | count++; |
|
302 | count++; | |
303 | if (i.key() == series) |
|
303 | if (i.key() == series) | |
304 | return count; |
|
304 | return count; | |
305 | } |
|
305 | } | |
306 | return count; |
|
306 | return count; | |
307 | } |
|
307 | } | |
308 |
|
308 | |||
309 | QChartAxis* ChartDataSet::axisY(QSeries* series) const |
|
309 | QChartAxis* ChartDataSet::axisY(QSeries* series) const | |
310 | { |
|
310 | { | |
311 | if(series == 0) return m_axisY; |
|
311 | if(series == 0) return m_axisY; | |
312 | return m_seriesAxisMap.value(series); |
|
312 | return m_seriesAxisMap.value(series); | |
313 | } |
|
313 | } | |
314 |
|
314 | |||
315 | Domain* ChartDataSet::domain(QSeries* series) const |
|
315 | Domain* ChartDataSet::domain(QSeries* series) const | |
316 | { |
|
316 | { | |
317 | QChartAxis* axis = m_seriesAxisMap.value(series); |
|
317 | QChartAxis* axis = m_seriesAxisMap.value(series); | |
318 | if(axis){ |
|
318 | if(axis){ | |
319 | return m_axisDomainMap.value(axis); |
|
319 | return m_axisDomainMap.value(axis); | |
320 | }else |
|
320 | }else | |
321 | return 0; |
|
321 | return 0; | |
322 | } |
|
322 | } | |
323 |
|
323 | |||
324 | Domain* ChartDataSet::domain(QChartAxis* axis) const |
|
324 | Domain* ChartDataSet::domain(QChartAxis* axis) const | |
325 | { |
|
325 | { | |
326 | if(!axis || axis==axisX()) { |
|
326 | if(!axis || axis==axisX()) { | |
327 | return m_axisDomainMap.value(axisY()); |
|
327 | return m_axisDomainMap.value(axisY()); | |
328 | } |
|
328 | } | |
329 | else { |
|
329 | else { | |
330 | return m_axisDomainMap.value(axis); |
|
330 | return m_axisDomainMap.value(axis); | |
331 | } |
|
331 | } | |
332 | } |
|
332 | } | |
333 |
|
333 | |||
334 | void ChartDataSet::scrollDomain(int dx,int dy,const QSizeF& size) |
|
334 | void ChartDataSet::scrollDomain(int dx,int dy,const QSizeF& size) | |
335 | { |
|
335 | { | |
336 | QMapIterator<QChartAxis*, Domain*> i( m_axisDomainMap); |
|
336 | QMapIterator<QChartAxis*, Domain*> i( m_axisDomainMap); | |
337 | while (i.hasNext()) { |
|
337 | while (i.hasNext()) { | |
338 | i.next(); |
|
338 | i.next(); | |
339 | i.value()->move(dx,dy,size); |
|
339 | i.value()->move(dx,dy,size); | |
340 | } |
|
340 | } | |
341 | } |
|
341 | } | |
342 |
|
342 | |||
343 | #include "moc_chartdataset_p.cpp" |
|
343 | #include "moc_chartdataset_p.cpp" | |
344 |
|
344 | |||
345 | QTCOMMERCIALCHART_END_NAMESPACE |
|
345 | QTCOMMERCIALCHART_END_NAMESPACE |
General Comments 0
You need to be logged in to leave comments.
Login now