##// END OF EJS Templates
Fixes after merge
Michal Klocek -
r683:ef336a9288eb
parent child
Show More
@@ -19,13 +19,6 BarAnimation::~BarAnimation()
19 {
19 {
20 }
20 }
21
21
22 void BarAnimation::updateValues(const QVector<QRectF>& layout)
23 {
24 // TODO?:
25 // qDebug() << "BarAnimation::updateValues" << layout.count();
26 }
27
28
29 QVariant BarAnimation::interpolated(const QVariant &from, const QVariant &to, qreal progress) const
22 QVariant BarAnimation::interpolated(const QVariant &from, const QVariant &to, qreal progress) const
30 {
23 {
31 QVector<QRectF> startVector = qVariantValue<QVector<QRectF> > (from);
24 QVector<QRectF> startVector = qVariantValue<QVector<QRectF> > (from);
@@ -18,8 +18,6 public:
18 BarAnimation(BarChartItem *item);
18 BarAnimation(BarChartItem *item);
19 ~BarAnimation();
19 ~BarAnimation();
20
20
21 void updateValues(const QVector<QRectF>& layout);
22
23 public: // from QVariantAnimation
21 public: // from QVariantAnimation
24 virtual QVariant interpolated (const QVariant & from, const QVariant & to, qreal progress ) const;
22 virtual QVariant interpolated (const QVariant & from, const QVariant & to, qreal progress ) const;
25 virtual void updateCurrentValue (const QVariant & value );
23 virtual void updateCurrentValue (const QVariant & value );
@@ -188,29 +188,26 QVector<QRectF> BarChartItem::calculateLayout()
188 QVector<QRectF> layout;
188 QVector<QRectF> layout;
189
189
190 // Use temporary qreals for accurancy (we might get some compiler warnings... :)
190 // Use temporary qreals for accurancy (we might get some compiler warnings... :)
191 int categoryCount = mSeries->categoryCount();
191 qreal categoryCount = mSeries->categoryCount();
192 int setCount = mSeries->barsetCount();
192 qreal setCount = mSeries->barsetCount();
193
193
194 // qreal tW = mWidth;
195 // qreal tH = mHeight;
196 qreal width = geometry().width();
194 qreal width = geometry().width();
197 qreal height = geometry().height();
195 qreal height = geometry().height();
198
196
199 qreal tM = mSeries->max();
197 qreal max = mSeries->max();
200
198
201 // Domain:
199 // Domain:
202 if (mDomainMaxY > tM) {
200 if (mDomainMaxY > max) {
203 tM = mDomainMaxY;
201 max = mDomainMaxY;
204 }
202 }
205
203
206 qreal scale = (height/tM);
204 qreal scale = (height/max);
207 qreal tC = categoryCount + 1;
205 qreal categoryWidth = width/categoryCount;
208 qreal categoryWidth = width/tC;
209 qreal barWidth = categoryWidth / (setCount+1);
206 qreal barWidth = categoryWidth / (setCount+1);
210
207
211 int itemIndex(0);
208 int itemIndex(0);
212 for (int category=0; category < categoryCount; category++) {
209 for (int category=0; category < categoryCount; category++) {
213 qreal xPos = categoryWidth * category + categoryWidth /2 + barWidth/2;
210 qreal xPos = categoryWidth * category + barWidth/2;
214 qreal yPos = height;
211 qreal yPos = height;
215 for (int set = 0; set < setCount; set++) {
212 for (int set = 0; set < setCount; set++) {
216 qreal barHeight = mSeries->valueAt(set,category) * scale;
213 qreal barHeight = mSeries->valueAt(set,category) * scale;
@@ -233,7 +230,7 QVector<QRectF> BarChartItem::calculateLayout()
233 // Position floating values
230 // Position floating values
234 itemIndex = 0;
231 itemIndex = 0;
235 for (int category=0; category < mSeries->categoryCount(); category++) {
232 for (int category=0; category < mSeries->categoryCount(); category++) {
236 qreal xPos = categoryWidth * category + categoryWidth/2 + barWidth;
233 qreal xPos = categoryWidth * category + barWidth;
237 qreal yPos = height;
234 qreal yPos = height;
238 for (int set=0; set < mSeries->barsetCount(); set++) {
235 for (int set=0; set < mSeries->barsetCount(); set++) {
239 qreal barHeight = mSeries->valueAt(set,category) * scale;
236 qreal barHeight = mSeries->valueAt(set,category) * scale;
@@ -50,8 +50,8 signals:
50 void rangeYChanged(qreal min, qreal max, int tickYCount);
50 void rangeYChanged(qreal min, qreal max, int tickYCount);
51
51
52 public slots:
52 public slots:
53 void handleAxisXChanged(qreal min,qreal max,int tickXCount,QChartAxis::LabelsSelection mode);
53 void handleAxisXChanged(qreal min,qreal max,int tickXCount = 5,QChartAxis::LabelsSelection mode = QChartAxis::NativeLabelsSelection);
54 void handleAxisYChanged(qreal min,qreal max,int tickYCount,QChartAxis::LabelsSelection mode);
54 void handleAxisYChanged(qreal min,qreal max,int tickYCount = 5,QChartAxis::LabelsSelection mode = QChartAxis::NativeLabelsSelection);
55
55
56 private:
56 private:
57 void niceNumbers(qreal &min, qreal &max, int &ticksCount);
57 void niceNumbers(qreal &min, qreal &max, int &ticksCount);
@@ -1,5 +1,6
1 #include <QtTest/QtTest>
1 #include <QtTest/QtTest>
2 #include <private/domain_p.h>
2 #include <private/domain_p.h>
3 #include <qchartaxis.h>
3
4
4 QTCOMMERCIALCHART_USE_NAMESPACE
5 QTCOMMERCIALCHART_USE_NAMESPACE
5
6
@@ -95,7 +96,7 void tst_Domain::handleAxisRangeXChanged()
95 QSignalSpy spy1(&domain, SIGNAL(rangeXChanged(qreal, qreal)));
96 QSignalSpy spy1(&domain, SIGNAL(rangeXChanged(qreal, qreal)));
96 QSignalSpy spy2(&domain, SIGNAL(rangeYChanged(qreal, qreal)));
97 QSignalSpy spy2(&domain, SIGNAL(rangeYChanged(qreal, qreal)));
97
98
98 domain.handleAxisRangeXChanged(min, max);
99 domain.handleAxisXChanged(min, max);
99
100
100 QList<QVariant> arg0 = spy0.first();
101 QList<QVariant> arg0 = spy0.first();
101 QVERIFY(arg0.at(0).toReal() == min);
102 QVERIFY(arg0.at(0).toReal() == min);
@@ -132,7 +133,7 void tst_Domain::handleAxisRangeYChanged()
132 QSignalSpy spy1(&domain, SIGNAL(rangeXChanged(qreal, qreal)));
133 QSignalSpy spy1(&domain, SIGNAL(rangeXChanged(qreal, qreal)));
133 QSignalSpy spy2(&domain, SIGNAL(rangeYChanged(qreal, qreal)));
134 QSignalSpy spy2(&domain, SIGNAL(rangeYChanged(qreal, qreal)));
134
135
135 domain.handleAxisRangeYChanged(min, max);
136 domain.handleAxisYChanged(min, max,5);
136
137
137 QList<QVariant> arg0 = spy0.first();
138 QList<QVariant> arg0 = spy0.first();
138 QVERIFY(arg0.at(2).toReal() == min);
139 QVERIFY(arg0.at(2).toReal() == min);
General Comments 0
You need to be logged in to leave comments. Login now