##// END OF EJS Templates
minor. formating
Michal Klocek -
r420:ad444fe37cf4
parent child
Show More
@@ -25,11 +25,11 ChartDataSet::~ChartDataSet()
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
@@ -37,13 +37,13 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
@@ -71,7 +71,7 void ChartDataSet::addSeries(QSeries* series, QChartAxis *axisY)
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();
@@ -82,7 +82,7 void ChartDataSet::addSeries(QSeries* series, QChartAxis *axisY)
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();
@@ -94,7 +94,7 void ChartDataSet::addSeries(QSeries* series, QChartAxis *axisY)
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();
@@ -157,11 +157,11 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)
@@ -178,7 +178,7 void ChartDataSet::removeAllSeries()
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));
@@ -187,7 +187,7 void ChartDataSet::removeAllSeries()
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
@@ -250,13 +250,13 void ChartDataSet::setDomain(int index,QChartAxis* axis)
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);
@@ -264,7 +264,6 void ChartDataSet::setDomain(int index,QChartAxis* axis)
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);
@@ -278,11 +277,11 void ChartDataSet::clearDomains(int toIndex)
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
@@ -297,7 +296,7 void ChartDataSet::addDomain(const QRectF& rect, const QRectF& viewport)
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 }
@@ -312,7 +311,7 QChartAxis* ChartDataSet::axisY(QSeries* series) const
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 }
@@ -327,19 +326,19 QStringList ChartDataSet::createLabels(QChartAxis* axis,qreal min, qreal max)
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();
@@ -383,16 +382,16 void ChartDataSet::handleRangeChanged(QChartAxis* axis)
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);
General Comments 0
You need to be logged in to leave comments. Login now