From ef336a9288eb8e9ec326560290abd6a39539a73f 2012-03-21 14:55:24 From: Michal Klocek Date: 2012-03-21 14:55:24 Subject: [PATCH] Fixes after merge --- diff --git a/src/animations/baranimation.cpp b/src/animations/baranimation.cpp index 4ba119d..afe3294 100644 --- a/src/animations/baranimation.cpp +++ b/src/animations/baranimation.cpp @@ -19,13 +19,6 @@ BarAnimation::~BarAnimation() { } -void BarAnimation::updateValues(const QVector& layout) -{ - // TODO?: -// qDebug() << "BarAnimation::updateValues" << layout.count(); -} - - QVariant BarAnimation::interpolated(const QVariant &from, const QVariant &to, qreal progress) const { QVector startVector = qVariantValue > (from); diff --git a/src/animations/baranimation_p.h b/src/animations/baranimation_p.h index a6c7236..9823557 100644 --- a/src/animations/baranimation_p.h +++ b/src/animations/baranimation_p.h @@ -18,8 +18,6 @@ public: BarAnimation(BarChartItem *item); ~BarAnimation(); - void updateValues(const QVector& layout); - public: // from QVariantAnimation virtual QVariant interpolated (const QVariant & from, const QVariant & to, qreal progress ) const; virtual void updateCurrentValue (const QVariant & value ); diff --git a/src/barchart/barchartitem.cpp b/src/barchart/barchartitem.cpp index 46575fa..072d227 100644 --- a/src/barchart/barchartitem.cpp +++ b/src/barchart/barchartitem.cpp @@ -188,29 +188,26 @@ QVector BarChartItem::calculateLayout() QVector layout; // Use temporary qreals for accurancy (we might get some compiler warnings... :) - int categoryCount = mSeries->categoryCount(); - int setCount = mSeries->barsetCount(); + qreal categoryCount = mSeries->categoryCount(); + qreal setCount = mSeries->barsetCount(); -// qreal tW = mWidth; -// qreal tH = mHeight; qreal width = geometry().width(); qreal height = geometry().height(); - qreal tM = mSeries->max(); + qreal max = mSeries->max(); // Domain: - if (mDomainMaxY > tM) { - tM = mDomainMaxY; + if (mDomainMaxY > max) { + max = mDomainMaxY; } - qreal scale = (height/tM); - qreal tC = categoryCount + 1; - qreal categoryWidth = width/tC; + qreal scale = (height/max); + qreal categoryWidth = width/categoryCount; qreal barWidth = categoryWidth / (setCount+1); int itemIndex(0); for (int category=0; category < categoryCount; category++) { - qreal xPos = categoryWidth * category + categoryWidth /2 + barWidth/2; + qreal xPos = categoryWidth * category + barWidth/2; qreal yPos = height; for (int set = 0; set < setCount; set++) { qreal barHeight = mSeries->valueAt(set,category) * scale; @@ -233,7 +230,7 @@ QVector BarChartItem::calculateLayout() // Position floating values itemIndex = 0; for (int category=0; category < mSeries->categoryCount(); category++) { - qreal xPos = categoryWidth * category + categoryWidth/2 + barWidth; + qreal xPos = categoryWidth * category + barWidth; qreal yPos = height; for (int set=0; set < mSeries->barsetCount(); set++) { qreal barHeight = mSeries->valueAt(set,category) * scale; diff --git a/src/domain_p.h b/src/domain_p.h index 36f1a2d..0a6c1ba 100644 --- a/src/domain_p.h +++ b/src/domain_p.h @@ -50,8 +50,8 @@ signals: void rangeYChanged(qreal min, qreal max, int tickYCount); public slots: - void handleAxisXChanged(qreal min,qreal max,int tickXCount,QChartAxis::LabelsSelection mode); - void handleAxisYChanged(qreal min,qreal max,int tickYCount,QChartAxis::LabelsSelection mode); + void handleAxisXChanged(qreal min,qreal max,int tickXCount = 5,QChartAxis::LabelsSelection mode = QChartAxis::NativeLabelsSelection); + void handleAxisYChanged(qreal min,qreal max,int tickYCount = 5,QChartAxis::LabelsSelection mode = QChartAxis::NativeLabelsSelection); private: void niceNumbers(qreal &min, qreal &max, int &ticksCount); diff --git a/test/auto/domain/tst_domain.cpp b/test/auto/domain/tst_domain.cpp index 1ca3957..238b91c 100644 --- a/test/auto/domain/tst_domain.cpp +++ b/test/auto/domain/tst_domain.cpp @@ -1,5 +1,6 @@ #include #include +#include QTCOMMERCIALCHART_USE_NAMESPACE @@ -95,7 +96,7 @@ void tst_Domain::handleAxisRangeXChanged() QSignalSpy spy1(&domain, SIGNAL(rangeXChanged(qreal, qreal))); QSignalSpy spy2(&domain, SIGNAL(rangeYChanged(qreal, qreal))); - domain.handleAxisRangeXChanged(min, max); + domain.handleAxisXChanged(min, max); QList arg0 = spy0.first(); QVERIFY(arg0.at(0).toReal() == min); @@ -132,7 +133,7 @@ void tst_Domain::handleAxisRangeYChanged() QSignalSpy spy1(&domain, SIGNAL(rangeXChanged(qreal, qreal))); QSignalSpy spy2(&domain, SIGNAL(rangeYChanged(qreal, qreal))); - domain.handleAxisRangeYChanged(min, max); + domain.handleAxisYChanged(min, max,5); QList arg0 = spy0.first(); QVERIFY(arg0.at(2).toReal() == min);