##// END OF EJS Templates
minor. formating
Michal Klocek -
r420:ad444fe37cf4
parent child
Show More
@@ -1,404 +1,403
1 #include "chartdataset_p.h"
1 #include "chartdataset_p.h"
2 #include "qchartaxis.h"
2 #include "qchartaxis.h"
3 //series
3 //series
4 #include "qlineseries.h"
4 #include "qlineseries.h"
5 #include "qbarseries.h"
5 #include "qbarseries.h"
6 #include "qstackedbarseries.h"
6 #include "qstackedbarseries.h"
7 #include "qpercentbarseries.h"
7 #include "qpercentbarseries.h"
8 #include "qpieseries.h"
8 #include "qpieseries.h"
9 #include "qscatterseries.h"
9 #include "qscatterseries.h"
10
10
11 QTCOMMERCIALCHART_BEGIN_NAMESPACE
11 QTCOMMERCIALCHART_BEGIN_NAMESPACE
12
12
13 ChartDataSet::ChartDataSet(QObject *parent):QObject(parent),
13 ChartDataSet::ChartDataSet(QObject *parent):QObject(parent),
14 m_axisX(new QChartAxis(this)),
14 m_axisX(new QChartAxis(this)),
15 m_axisY(new QChartAxis(this)),
15 m_axisY(new QChartAxis(this)),
16 m_domainIndex(0),
16 m_domainIndex(0),
17 m_axisXInitialized(false)
17 m_axisXInitialized(false)
18 {
18 {
19 }
19 }
20
20
21 ChartDataSet::~ChartDataSet()
21 ChartDataSet::~ChartDataSet()
22 {
22 {
23 // TODO Auto-generated destructor stub
23 // TODO Auto-generated destructor stub
24 }
24 }
25
25
26 const Domain ChartDataSet::domain(QChartAxis *axisY) const
26 const Domain ChartDataSet::domain(QChartAxis *axisY) const
27 {
27 {
28 int i = m_domainMap.count(axisY);
28 int i = m_domainMap.count(axisY);
29 if(i == 0){
29 if(i == 0) {
30 return Domain();
30 return Domain();
31 }
31 }
32 i = i - m_domainIndex -1;
32 i = i - m_domainIndex -1;
33 return m_domainMap.values(axisY).at(i);
33 return m_domainMap.values(axisY).at(i);
34 }
34 }
35
35
36 void ChartDataSet::addSeries(QSeries* series, QChartAxis *axisY)
36 void ChartDataSet::addSeries(QSeries* series, QChartAxis *axisY)
37 {
37 {
38 // TODO: we should check the series not already added
38 // TODO: we should check the series not already added
39
39
40 series->setParent(this); // take ownership
40 series->setParent(this);// take ownership
41 clearDomains();
41 clearDomains();
42
42
43 if(axisY==0) axisY = m_axisY;
43 if(axisY==0) axisY = m_axisY;
44 axisY->setParent(this); // take ownership
44 axisY->setParent(this);// take ownership
45
45
46 QList<QSeries*> seriesList = m_seriesMap.values(axisY);
46 QList<QSeries*> seriesList = m_seriesMap.values(axisY);
47
47
48 QList<Domain> domainList = m_domainMap.values(axisY);
48 QList<Domain> domainList = m_domainMap.values(axisY);
49
49
50 Q_ASSERT(domainList.size()<=1);
50 Q_ASSERT(domainList.size()<=1);
51
51
52 Domain domain;
52 Domain domain;
53
53
54 if(domainList.size()>0) domain = domainList.at(0);
54 if(domainList.size()>0) domain = domainList.at(0);
55
55
56 switch(series->type())
56 switch(series->type())
57 {
57 {
58 case QSeries::SeriesTypeLine: {
58 case QSeries::SeriesTypeLine: {
59
59
60 QLineSeries* xyseries = static_cast<QLineSeries*>(series);
60 QLineSeries* xyseries = static_cast<QLineSeries*>(series);
61
61
62 for (int i = 0; i < xyseries->count(); i++)
62 for (int i = 0; i < xyseries->count(); i++)
63 {
63 {
64 qreal x = xyseries->x(i);
64 qreal x = xyseries->x(i);
65 qreal y = xyseries->y(i);
65 qreal y = xyseries->y(i);
66 domain.m_minX = qMin(domain.m_minX,x);
66 domain.m_minX = qMin(domain.m_minX,x);
67 domain.m_minY = qMin(domain.m_minY,y);
67 domain.m_minY = qMin(domain.m_minY,y);
68 domain.m_maxX = qMax(domain.m_maxX,x);
68 domain.m_maxX = qMax(domain.m_maxX,x);
69 domain.m_maxY = qMax(domain.m_maxY,y);
69 domain.m_maxY = qMax(domain.m_maxY,y);
70 }
70 }
71 break;
71 break;
72 }
72 }
73 case QSeries::SeriesTypeBar: {
73 case QSeries::SeriesTypeBar: {
74 qDebug() << "QChartSeries::SeriesTypeBar";
74 qDebug() << "QChartSeries::SeriesTypeBar";
75 QBarSeries* barSeries = static_cast<QBarSeries*>(series);
75 QBarSeries* barSeries = static_cast<QBarSeries*>(series);
76 qreal x = barSeries->categoryCount();
76 qreal x = barSeries->categoryCount();
77 qreal y = barSeries->max();
77 qreal y = barSeries->max();
78 domain.m_minX = qMin(domain.m_minX,x);
78 domain.m_minX = qMin(domain.m_minX,x);
79 domain.m_minY = qMin(domain.m_minY,y);
79 domain.m_minY = qMin(domain.m_minY,y);
80 domain.m_maxX = qMax(domain.m_maxX,x);
80 domain.m_maxX = qMax(domain.m_maxX,x);
81 domain.m_maxY = qMax(domain.m_maxY,y);
81 domain.m_maxY = qMax(domain.m_maxY,y);
82 break;
82 break;
83 }
83 }
84 case QSeries::SeriesTypeStackedBar: {
84 case QSeries::SeriesTypeStackedBar: {
85 qDebug() << "QChartSeries::SeriesTypeStackedBar";
85 qDebug() << "QChartSeries::SeriesTypeStackedBar";
86
86
87 QStackedBarSeries* stackedBarSeries = static_cast<QStackedBarSeries*>(series);
87 QStackedBarSeries* stackedBarSeries = static_cast<QStackedBarSeries*>(series);
88 qreal x = stackedBarSeries->categoryCount();
88 qreal x = stackedBarSeries->categoryCount();
89 qreal y = stackedBarSeries->maxCategorySum();
89 qreal y = stackedBarSeries->maxCategorySum();
90 domain.m_minX = qMin(domain.m_minX,x);
90 domain.m_minX = qMin(domain.m_minX,x);
91 domain.m_minY = qMin(domain.m_minY,y);
91 domain.m_minY = qMin(domain.m_minY,y);
92 domain.m_maxX = qMax(domain.m_maxX,x);
92 domain.m_maxX = qMax(domain.m_maxX,x);
93 domain.m_maxY = qMax(domain.m_maxY,y);
93 domain.m_maxY = qMax(domain.m_maxY,y);
94 break;
94 break;
95 }
95 }
96 case QSeries::SeriesTypePercentBar: {
96 case QSeries::SeriesTypePercentBar: {
97 qDebug() << "QChartSeries::SeriesTypePercentBar";
97 qDebug() << "QChartSeries::SeriesTypePercentBar";
98
98
99 QPercentBarSeries* percentBarSeries = static_cast<QPercentBarSeries*>(series);
99 QPercentBarSeries* percentBarSeries = static_cast<QPercentBarSeries*>(series);
100 qreal x = percentBarSeries->categoryCount();
100 qreal x = percentBarSeries->categoryCount();
101 domain.m_minX = qMin(domain.m_minX,x);
101 domain.m_minX = qMin(domain.m_minX,x);
102 domain.m_minY = 0;
102 domain.m_minY = 0;
103 domain.m_maxX = qMax(domain.m_maxX,x);
103 domain.m_maxX = qMax(domain.m_maxX,x);
104 domain.m_maxY = 100;
104 domain.m_maxY = 100;
105 break;
105 break;
106 }
106 }
107
107
108 case QSeries::SeriesTypePie: {
108 case QSeries::SeriesTypePie: {
109 QPieSeries *pieSeries = static_cast<QPieSeries *>(series);
109 QPieSeries *pieSeries = static_cast<QPieSeries *>(series);
110 // TODO: domain stuff
110 // TODO: domain stuff
111 break;
111 break;
112 }
112 }
113
113
114 case QSeries::SeriesTypeScatter: {
114 case QSeries::SeriesTypeScatter: {
115 QScatterSeries *scatterSeries = qobject_cast<QScatterSeries *>(series);
115 QScatterSeries *scatterSeries = qobject_cast<QScatterSeries *>(series);
116 Q_ASSERT(scatterSeries);
116 Q_ASSERT(scatterSeries);
117 foreach (QPointF point, scatterSeries->data()) {
117 foreach (QPointF point, scatterSeries->data()) {
118 domain.m_minX = qMin(domain.m_minX, point.x());
118 domain.m_minX = qMin(domain.m_minX, point.x());
119 domain.m_maxX = qMax(domain.m_maxX, point.x());
119 domain.m_maxX = qMax(domain.m_maxX, point.x());
120 domain.m_minY = qMin(domain.m_minY, point.y());
120 domain.m_minY = qMin(domain.m_minY, point.y());
121 domain.m_maxY = qMax(domain.m_maxY, point.y());
121 domain.m_maxY = qMax(domain.m_maxY, point.y());
122 }
122 }
123 break;
123 break;
124 }
124 }
125
125
126 default: {
126 default: {
127 qDebug()<<__FUNCTION__<<"type" << series->type()<<"not supported";
127 qDebug()<<__FUNCTION__<<"type" << series->type()<<"not supported";
128 return;
128 return;
129 break;
129 break;
130 }
130 }
131
131
132 }
132 }
133
133
134 if(!m_domainMap.contains(axisY))
134 if(!m_domainMap.contains(axisY))
135 {
135 {
136 emit axisAdded(axisY);
136 emit axisAdded(axisY);
137 QObject::connect(axisY,SIGNAL(rangeChanged(QChartAxis*)),this,SLOT(handleRangeChanged(QChartAxis*)));
137 QObject::connect(axisY,SIGNAL(rangeChanged(QChartAxis*)),this,SLOT(handleRangeChanged(QChartAxis*)));
138 QObject::connect(axisY,SIGNAL(ticksChanged(QChartAxis*)),this,SLOT(handleTickChanged(QChartAxis*)));
138 QObject::connect(axisY,SIGNAL(ticksChanged(QChartAxis*)),this,SLOT(handleTickChanged(QChartAxis*)));
139 }
139 }
140
140
141 if(!m_axisXInitialized)
141 if(!m_axisXInitialized)
142 {
142 {
143 emit axisAdded(axisX());
143 emit axisAdded(axisX());
144 QObject::connect(axisX(),SIGNAL(rangeChanged(QChartAxis*)),this,SLOT(handleRangeChanged(QChartAxis*)));
144 QObject::connect(axisX(),SIGNAL(rangeChanged(QChartAxis*)),this,SLOT(handleRangeChanged(QChartAxis*)));
145 QObject::connect(axisX(),SIGNAL(ticksChanged(QChartAxis*)),this,SLOT(handleTickChanged(QChartAxis*)));
145 QObject::connect(axisX(),SIGNAL(ticksChanged(QChartAxis*)),this,SLOT(handleTickChanged(QChartAxis*)));
146 m_axisXInitialized=true;
146 m_axisXInitialized=true;
147 }
147 }
148
148
149 m_domainMap.replace(axisY,domain);
149 m_domainMap.replace(axisY,domain);
150 m_seriesMap.insert(axisY,series);
150 m_seriesMap.insert(axisY,series);
151 emit seriesAdded(series);
151 emit seriesAdded(series);
152 setDomain(m_domainIndex,axisY);
152 setDomain(m_domainIndex,axisY);
153
153
154 }
154 }
155
155
156 void ChartDataSet::removeSeries(QSeries* series)
156 void ChartDataSet::removeSeries(QSeries* series)
157 {
157 {
158 QList<QChartAxis*> keys = m_seriesMap.uniqueKeys();
158 QList<QChartAxis*> keys = m_seriesMap.uniqueKeys();
159 foreach(QChartAxis* axis , keys) {
159 foreach(QChartAxis* axis , keys) {
160 if(m_seriesMap.contains(axis,series)){
160 if(m_seriesMap.contains(axis,series)) {
161 emit seriesRemoved(series);
161 emit seriesRemoved(series);
162 m_seriesMap.remove(axis,series);
162 m_seriesMap.remove(axis,series);
163 //remove axis if no longer there
163 //remove axis if no longer there
164 if(!m_seriesMap.contains(axis)){
164 if(!m_seriesMap.contains(axis)) {
165 emit axisRemoved(axis);
165 emit axisRemoved(axis);
166 m_domainMap.remove(axis);
166 m_domainMap.remove(axis);
167 if(axis != m_axisY)
167 if(axis != m_axisY)
168 delete axis;
168 delete axis;
169 }
169 }
170 series->setParent(0);
170 series->setParent(0);
171 break;
171 break;
172 }
172 }
173 }
173 }
174 }
174 }
175
175
176 void ChartDataSet::removeAllSeries()
176 void ChartDataSet::removeAllSeries()
177 {
177 {
178 QList<QChartAxis*> keys = m_seriesMap.uniqueKeys();
178 QList<QChartAxis*> keys = m_seriesMap.uniqueKeys();
179 foreach(QChartAxis* axis , keys) {
179 foreach(QChartAxis* axis , keys) {
180 QList<QSeries*> seriesList = m_seriesMap.values(axis);
180 QList<QSeries*> seriesList = m_seriesMap.values(axis);
181 for(int i =0 ; i < seriesList.size();i++ )
181 for(int i =0; i < seriesList.size();i++ )
182 {
182 {
183 emit seriesRemoved(seriesList.at(i));
183 emit seriesRemoved(seriesList.at(i));
184 delete(seriesList.at(i));
184 delete(seriesList.at(i));
185 }
185 }
186 m_seriesMap.remove(axis);
186 m_seriesMap.remove(axis);
187 m_domainMap.remove(axis);
187 m_domainMap.remove(axis);
188 emit axisRemoved(axis);
188 emit axisRemoved(axis);
189 if(axis != m_axisY) delete axis;
189 if(axis != m_axisY) delete axis;
190 }
190 }
191 m_domainIndex=0;
191 m_domainIndex=0;
192 }
192 }
193
193
194 bool ChartDataSet::nextDomain()
194 bool ChartDataSet::nextDomain()
195 {
195 {
196 int limit = (m_domainMap.values().size()/m_domainMap.uniqueKeys().size())-1;
196 int limit = (m_domainMap.values().size()/m_domainMap.uniqueKeys().size())-1;
197
197
198 if (m_domainIndex < limit) {
198 if (m_domainIndex < limit) {
199 m_domainIndex++;
199 m_domainIndex++;
200 setDomain(m_domainIndex);
200 setDomain(m_domainIndex);
201 return true;
201 return true;
202 }
202 }
203 else {
203 else {
204 return false;
204 return false;
205 }
205 }
206 }
206 }
207
207
208 bool ChartDataSet::previousDomain()
208 bool ChartDataSet::previousDomain()
209 {
209 {
210 if (m_domainIndex > 0) {
210 if (m_domainIndex > 0) {
211 m_domainIndex--;
211 m_domainIndex--;
212 setDomain(m_domainIndex);
212 setDomain(m_domainIndex);
213 return true;
213 return true;
214 }
214 }
215 else {
215 else {
216 return false;
216 return false;
217 }
217 }
218 }
218 }
219
219
220 void ChartDataSet::setDomain(int index)
220 void ChartDataSet::setDomain(int index)
221 {
221 {
222 QList<QChartAxis*> domainList = m_domainMap.uniqueKeys();
222 QList<QChartAxis*> domainList = m_domainMap.uniqueKeys();
223
223
224 if(domainList.count()==0) return;
224 if(domainList.count()==0) return;
225
225
226 Domain domain;
226 Domain domain;
227
227
228 foreach (QChartAxis* axis , domainList) {
228 foreach (QChartAxis* axis , domainList) {
229 int i = m_domainMap.count(axis) - index -1;
229 int i = m_domainMap.count(axis) - index -1;
230 Q_ASSERT(i>=0);
230 Q_ASSERT(i>=0);
231 domain = m_domainMap.values(axis).at(i);
231 domain = m_domainMap.values(axis).at(i);
232 QStringList labels = createLabels(axis,domain.m_minY,domain.m_maxY);
232 QStringList labels = createLabels(axis,domain.m_minY,domain.m_maxY);
233 QList<QSeries*> seriesList = m_seriesMap.values(axis);
233 QList<QSeries*> seriesList = m_seriesMap.values(axis);
234 foreach(QSeries* series, seriesList) {
234 foreach(QSeries* series, seriesList) {
235 emit seriesDomainChanged(series,domain);
235 emit seriesDomainChanged(series,domain);
236 }
236 }
237 axis->updateRange(domain.m_minY,domain.m_maxY);
237 axis->updateRange(domain.m_minY,domain.m_maxY);
238 emit axisRangeChanged(axis,labels);
238 emit axisRangeChanged(axis,labels);
239
239
240 }
240 }
241
241
242 QStringList labels = createLabels(axisX(),domain.m_minX,domain.m_maxX);
242 QStringList labels = createLabels(axisX(),domain.m_minX,domain.m_maxX);
243 axisX()->updateRange(domain.m_minX,domain.m_maxY);
243 axisX()->updateRange(domain.m_minX,domain.m_maxY);
244 emit axisRangeChanged(axisX(),labels);
244 emit axisRangeChanged(axisX(),labels);
245 }
245 }
246
246
247 void ChartDataSet::setDomain(int index,QChartAxis* axis)
247 void ChartDataSet::setDomain(int index,QChartAxis* axis)
248 {
248 {
249 int i = m_domainMap.count(axis) - index -1;
249 int i = m_domainMap.count(axis) - index -1;
250 Q_ASSERT(i>=0);
250 Q_ASSERT(i>=0);
251 Domain domain = m_domainMap.values(axis).at(i);
251 Domain domain = m_domainMap.values(axis).at(i);
252 {
252 {
253 QStringList labels = createLabels(axis,domain.m_minY,domain.m_maxY);
253 QStringList labels = createLabels(axis,domain.m_minY,domain.m_maxY);
254 QList<QSeries*> seriesList = m_seriesMap.values(axis);
254 QList<QSeries*> seriesList = m_seriesMap.values(axis);
255 foreach(QSeries* series, seriesList) {
255 foreach(QSeries* series, seriesList) {
256 emit seriesDomainChanged(series,domain);
256 emit seriesDomainChanged(series,domain);
257 }
257 }
258 axis->updateRange(domain.m_minY,domain.m_maxY);
258 axis->updateRange(domain.m_minY,domain.m_maxY);
259 emit axisRangeChanged(axis,labels);
259 emit axisRangeChanged(axis,labels);
260 }
260 }
261
261
262 QStringList labels = createLabels(axisX(),domain.m_minX,domain.m_maxX);
262 QStringList labels = createLabels(axisX(),domain.m_minX,domain.m_maxX);
263 axisX()->updateRange(domain.m_minX,domain.m_maxY);
263 axisX()->updateRange(domain.m_minX,domain.m_maxY);
264 emit axisRangeChanged(axisX(),labels);
264 emit axisRangeChanged(axisX(),labels);
265 }
265 }
266
266
267
268 void ChartDataSet::clearDomains(int toIndex)
267 void ChartDataSet::clearDomains(int toIndex)
269 {
268 {
270 Q_ASSERT(toIndex>=0);
269 Q_ASSERT(toIndex>=0);
271
270
272 m_domainIndex = toIndex;
271 m_domainIndex = toIndex;
273
272
274 QList<QChartAxis*> keys = m_domainMap.uniqueKeys();
273 QList<QChartAxis*> keys = m_domainMap.uniqueKeys();
275
274
276 foreach (QChartAxis* key , keys)
275 foreach (QChartAxis* key , keys)
277 {
276 {
278 QList<Domain> domains = m_domainMap.values(key);
277 QList<Domain> domains = m_domainMap.values(key);
279 m_domainMap.remove(key);
278 m_domainMap.remove(key);
280 int i = domains.size() - toIndex - 1;
279 int i = domains.size() - toIndex - 1;
281 while(i--){
280 while(i--) {
282 domains.removeFirst();
281 domains.removeFirst();
283 }
282 }
284 for(int j=domains.size()-1; j>=0 ;j--)
283 for(int j=domains.size()-1; j>=0;j--)
285 m_domainMap.insert(key,domains.at(j));
284 m_domainMap.insert(key,domains.at(j));
286 }
285 }
287 }
286 }
288
287
289 void ChartDataSet::addDomain(const QRectF& rect, const QRectF& viewport)
288 void ChartDataSet::addDomain(const QRectF& rect, const QRectF& viewport)
290 {
289 {
291 Q_ASSERT(rect.isValid());
290 Q_ASSERT(rect.isValid());
292 Q_ASSERT(viewport.isValid());
291 Q_ASSERT(viewport.isValid());
293
292
294 clearDomains(m_domainIndex);
293 clearDomains(m_domainIndex);
295
294
296 QList<QChartAxis*> domainList = m_domainMap.uniqueKeys();
295 QList<QChartAxis*> domainList = m_domainMap.uniqueKeys();
297
296
298 Domain domain;
297 Domain domain;
299
298
300 foreach (QChartAxis* axis , domainList){
299 foreach (QChartAxis* axis , domainList) {
301 domain = m_domainMap.value(axis).subDomain(rect,viewport.width(),viewport.height());
300 domain = m_domainMap.value(axis).subDomain(rect,viewport.width(),viewport.height());
302 m_domainMap.insert(axis,domain);
301 m_domainMap.insert(axis,domain);
303 }
302 }
304
303
305 setDomain(++m_domainIndex);
304 setDomain(++m_domainIndex);
306 }
305 }
307
306
308 QChartAxis* ChartDataSet::axisY(QSeries* series) const
307 QChartAxis* ChartDataSet::axisY(QSeries* series) const
309 {
308 {
310 if(series == 0) return m_axisY;
309 if(series == 0) return m_axisY;
311
310
312 QList<QChartAxis*> keys = m_seriesMap.uniqueKeys();
311 QList<QChartAxis*> keys = m_seriesMap.uniqueKeys();
313
312
314 foreach(QChartAxis* axis , keys) {
313 foreach(QChartAxis* axis , keys) {
315 if(m_seriesMap.contains(axis,series)){
314 if(m_seriesMap.contains(axis,series)) {
316 return axis;
315 return axis;
317 }
316 }
318 }
317 }
319 return 0;
318 return 0;
320 }
319 }
321
320
322 QStringList ChartDataSet::createLabels(QChartAxis* axis,qreal min, qreal max)
321 QStringList ChartDataSet::createLabels(QChartAxis* axis,qreal min, qreal max)
323 {
322 {
324 Q_ASSERT(max>=min);
323 Q_ASSERT(max>=min);
325
324
326 QStringList labels;
325 QStringList labels;
327
326
328 int ticks = axis->ticksCount()-1;
327 int ticks = axis->ticksCount()-1;
329
328
330 for(int i=0; i<= ticks; i++){
329 for(int i=0; i<= ticks; i++) {
331 qreal value = min + (i * (max - min)/ ticks);
330 qreal value = min + (i * (max - min)/ ticks);
332 QString label = axis->axisTickLabel(value);
331 QString label = axis->axisTickLabel(value);
333 if(label.isEmpty()){
332 if(label.isEmpty()) {
334 labels << QString::number(value);
333 labels << QString::number(value);
335 }else{
334 }
335 else {
336 labels << label;
336 labels << label;
337 }
337 }
338 }
338 }
339 return labels;
339 return labels;
340 }
340 }
341
341
342
343 void ChartDataSet::handleRangeChanged(QChartAxis* axis)
342 void ChartDataSet::handleRangeChanged(QChartAxis* axis)
344 {
343 {
345 qreal min = axis->min();
344 qreal min = axis->min();
346 qreal max = axis->max();
345 qreal max = axis->max();
347
346
348 if(axis==axisX()) {
347 if(axis==axisX()) {
349
348
350 m_domainIndex=0;
349 m_domainIndex=0;
351
350
352 clearDomains(m_domainIndex);
351 clearDomains(m_domainIndex);
353
352
354 QList<QChartAxis*> domainList = m_domainMap.uniqueKeys();
353 QList<QChartAxis*> domainList = m_domainMap.uniqueKeys();
355
354
356 foreach (QChartAxis* axis , domainList) {
355 foreach (QChartAxis* axis , domainList) {
357
356
358 Q_ASSERT(m_domainMap.values(axis).size()==1);
357 Q_ASSERT(m_domainMap.values(axis).size()==1);
359
358
360 Domain domain = m_domainMap.value(axis);
359 Domain domain = m_domainMap.value(axis);
361 domain.m_minX=min;
360 domain.m_minX=min;
362 domain.m_maxX=max;
361 domain.m_maxX=max;
363 m_domainMap.replace(axis,domain);
362 m_domainMap.replace(axis,domain);
364 }
363 }
365
364
366 setDomain(m_domainIndex);
365 setDomain(m_domainIndex);
367
366
368 }
367 }
369 else {
368 else {
370
369
371 QList<Domain> domains = m_domainMap.values(axis);
370 QList<Domain> domains = m_domainMap.values(axis);
372 m_domainMap.remove(axis);
371 m_domainMap.remove(axis);
373
372
374 for(int i=0;i<domains.size();i++)
373 for(int i=0;i<domains.size();i++)
375 {
374 {
376 domains[i].m_minY=min;
375 domains[i].m_minY=min;
377 domains[i].m_maxY=max;
376 domains[i].m_maxY=max;
378 }
377 }
379
378
380 for(int j=domains.size()-1; j>=0;j--)
379 for(int j=domains.size()-1; j>=0;j--)
381 m_domainMap.insert(axis,domains.at(j));
380 m_domainMap.insert(axis,domains.at(j));
382
381
383 setDomain(m_domainIndex,axis);
382 setDomain(m_domainIndex,axis);
384 }
383 }
385
384
386
387 }
385 }
388
386
389 void ChartDataSet::handleTickChanged(QChartAxis* axis)
387 void ChartDataSet::handleTickChanged(QChartAxis* axis)
390 {
388 {
391 if(axis==axisX()){
389 if(axis==axisX()) {
392 Domain domain = m_domainMap.value(axisY());
390 Domain domain = m_domainMap.value(axisY());
393 QStringList labels = createLabels(axis,domain.m_minX,domain.m_maxX);
391 QStringList labels = createLabels(axis,domain.m_minX,domain.m_maxX);
394 emit axisRangeChanged(axis,labels);
392 emit axisRangeChanged(axis,labels);
395 }else{
393 }
394 else {
396 Domain domain = m_domainMap.value(axis);
395 Domain domain = m_domainMap.value(axis);
397 QStringList labels = createLabels(axis,domain.m_minY,domain.m_maxY);
396 QStringList labels = createLabels(axis,domain.m_minY,domain.m_maxY);
398 emit axisRangeChanged(axis,labels);
397 emit axisRangeChanged(axis,labels);
399 }
398 }
400 }
399 }
401
400
402 #include "moc_chartdataset_p.cpp"
401 #include "moc_chartdataset_p.cpp"
403
402
404 QTCOMMERCIALCHART_END_NAMESPACE
403 QTCOMMERCIALCHART_END_NAMESPACE
General Comments 0
You need to be logged in to leave comments. Login now