##// END OF EJS Templates
minor. formating
Michal Klocek -
r420:ad444fe37cf4
parent child
Show More
@@ -25,11 +25,11 ChartDataSet::~ChartDataSet()
25 25
26 26 const Domain ChartDataSet::domain(QChartAxis *axisY) const
27 27 {
28 int i = m_domainMap.count(axisY);
29 if(i == 0){
30 return Domain();
31 }
32 i = i - m_domainIndex -1;
28 int i = m_domainMap.count(axisY);
29 if(i == 0) {
30 return Domain();
31 }
32 i = i - m_domainIndex -1;
33 33 return m_domainMap.values(axisY).at(i);
34 34 }
35 35
@@ -37,13 +37,13 void ChartDataSet::addSeries(QSeries* series, QChartAxis *axisY)
37 37 {
38 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 41 clearDomains();
42 42
43 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 48 QList<Domain> domainList = m_domainMap.values(axisY);
49 49
@@ -71,7 +71,7 void ChartDataSet::addSeries(QSeries* series, QChartAxis *axisY)
71 71 break;
72 72 }
73 73 case QSeries::SeriesTypeBar: {
74 qDebug() << "QChartSeries::SeriesTypeBar";
74 qDebug() << "QChartSeries::SeriesTypeBar";
75 75 QBarSeries* barSeries = static_cast<QBarSeries*>(series);
76 76 qreal x = barSeries->categoryCount();
77 77 qreal y = barSeries->max();
@@ -82,7 +82,7 void ChartDataSet::addSeries(QSeries* series, QChartAxis *axisY)
82 82 break;
83 83 }
84 84 case QSeries::SeriesTypeStackedBar: {
85 qDebug() << "QChartSeries::SeriesTypeStackedBar";
85 qDebug() << "QChartSeries::SeriesTypeStackedBar";
86 86
87 87 QStackedBarSeries* stackedBarSeries = static_cast<QStackedBarSeries*>(series);
88 88 qreal x = stackedBarSeries->categoryCount();
@@ -94,7 +94,7 void ChartDataSet::addSeries(QSeries* series, QChartAxis *axisY)
94 94 break;
95 95 }
96 96 case QSeries::SeriesTypePercentBar: {
97 qDebug() << "QChartSeries::SeriesTypePercentBar";
97 qDebug() << "QChartSeries::SeriesTypePercentBar";
98 98
99 99 QPercentBarSeries* percentBarSeries = static_cast<QPercentBarSeries*>(series);
100 100 qreal x = percentBarSeries->categoryCount();
@@ -157,11 +157,11 void ChartDataSet::removeSeries(QSeries* series)
157 157 {
158 158 QList<QChartAxis*> keys = m_seriesMap.uniqueKeys();
159 159 foreach(QChartAxis* axis , keys) {
160 if(m_seriesMap.contains(axis,series)){
160 if(m_seriesMap.contains(axis,series)) {
161 161 emit seriesRemoved(series);
162 162 m_seriesMap.remove(axis,series);
163 163 //remove axis if no longer there
164 if(!m_seriesMap.contains(axis)){
164 if(!m_seriesMap.contains(axis)) {
165 165 emit axisRemoved(axis);
166 166 m_domainMap.remove(axis);
167 167 if(axis != m_axisY)
@@ -178,7 +178,7 void ChartDataSet::removeAllSeries()
178 178 QList<QChartAxis*> keys = m_seriesMap.uniqueKeys();
179 179 foreach(QChartAxis* axis , keys) {
180 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 183 emit seriesRemoved(seriesList.at(i));
184 184 delete(seriesList.at(i));
@@ -187,7 +187,7 void ChartDataSet::removeAllSeries()
187 187 m_domainMap.remove(axis);
188 188 emit axisRemoved(axis);
189 189 if(axis != m_axisY) delete axis;
190 }
190 }
191 191 m_domainIndex=0;
192 192 }
193 193
@@ -250,13 +250,13 void ChartDataSet::setDomain(int index,QChartAxis* axis)
250 250 Q_ASSERT(i>=0);
251 251 Domain domain = m_domainMap.values(axis).at(i);
252 252 {
253 QStringList labels = createLabels(axis,domain.m_minY,domain.m_maxY);
254 QList<QSeries*> seriesList = m_seriesMap.values(axis);
255 foreach(QSeries* series, seriesList) {
256 emit seriesDomainChanged(series,domain);
257 }
258 axis->updateRange(domain.m_minY,domain.m_maxY);
259 emit axisRangeChanged(axis,labels);
253 QStringList labels = createLabels(axis,domain.m_minY,domain.m_maxY);
254 QList<QSeries*> seriesList = m_seriesMap.values(axis);
255 foreach(QSeries* series, seriesList) {
256 emit seriesDomainChanged(series,domain);
257 }
258 axis->updateRange(domain.m_minY,domain.m_maxY);
259 emit axisRangeChanged(axis,labels);
260 260 }
261 261
262 262 QStringList labels = createLabels(axisX(),domain.m_minX,domain.m_maxX);
@@ -264,7 +264,6 void ChartDataSet::setDomain(int index,QChartAxis* axis)
264 264 emit axisRangeChanged(axisX(),labels);
265 265 }
266 266
267
268 267 void ChartDataSet::clearDomains(int toIndex)
269 268 {
270 269 Q_ASSERT(toIndex>=0);
@@ -278,11 +277,11 void ChartDataSet::clearDomains(int toIndex)
278 277 QList<Domain> domains = m_domainMap.values(key);
279 278 m_domainMap.remove(key);
280 279 int i = domains.size() - toIndex - 1;
281 while(i--){
280 while(i--) {
282 281 domains.removeFirst();
283 282 }
284 for(int j=domains.size()-1; j>=0 ;j--)
285 m_domainMap.insert(key,domains.at(j));
283 for(int j=domains.size()-1; j>=0;j--)
284 m_domainMap.insert(key,domains.at(j));
286 285 }
287 286 }
288 287
@@ -297,7 +296,7 void ChartDataSet::addDomain(const QRectF& rect, const QRectF& viewport)
297 296
298 297 Domain domain;
299 298
300 foreach (QChartAxis* axis , domainList){
299 foreach (QChartAxis* axis , domainList) {
301 300 domain = m_domainMap.value(axis).subDomain(rect,viewport.width(),viewport.height());
302 301 m_domainMap.insert(axis,domain);
303 302 }
@@ -312,7 +311,7 QChartAxis* ChartDataSet::axisY(QSeries* series) const
312 311 QList<QChartAxis*> keys = m_seriesMap.uniqueKeys();
313 312
314 313 foreach(QChartAxis* axis , keys) {
315 if(m_seriesMap.contains(axis,series)){
314 if(m_seriesMap.contains(axis,series)) {
316 315 return axis;
317 316 }
318 317 }
@@ -327,19 +326,19 QStringList ChartDataSet::createLabels(QChartAxis* axis,qreal min, qreal max)
327 326
328 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 330 qreal value = min + (i * (max - min)/ ticks);
332 331 QString label = axis->axisTickLabel(value);
333 if(label.isEmpty()){
332 if(label.isEmpty()) {
334 333 labels << QString::number(value);
335 }else{
334 }
335 else {
336 336 labels << label;
337 337 }
338 338 }
339 339 return labels;
340 340 }
341 341
342
343 342 void ChartDataSet::handleRangeChanged(QChartAxis* axis)
344 343 {
345 344 qreal min = axis->min();
@@ -383,16 +382,16 void ChartDataSet::handleRangeChanged(QChartAxis* axis)
383 382 setDomain(m_domainIndex,axis);
384 383 }
385 384
386
387 385 }
388 386
389 387 void ChartDataSet::handleTickChanged(QChartAxis* axis)
390 388 {
391 if(axis==axisX()){
389 if(axis==axisX()) {
392 390 Domain domain = m_domainMap.value(axisY());
393 391 QStringList labels = createLabels(axis,domain.m_minX,domain.m_maxX);
394 392 emit axisRangeChanged(axis,labels);
395 }else{
393 }
394 else {
396 395 Domain domain = m_domainMap.value(axis);
397 396 QStringList labels = createLabels(axis,domain.m_minY,domain.m_maxY);
398 397 emit axisRangeChanged(axis,labels);
General Comments 0
You need to be logged in to leave comments. Login now