##// END OF EJS Templates
Fix int-qreal rounding errors in axislayout calculations...
Miikka Heikkinen -
r2447:ba792163ba0e
parent child
Show More
@@ -60,7 +60,7 QVector<qreal> ChartBarCategoryAxisX::calculateLayout() const
60 60 points.resize(count + 2);
61 61
62 62 for (int i = 0; i < count + 2; ++i)
63 points[i] = offset + (i * delta) + gridRect.left();
63 points[i] = offset + (qreal(i) * delta) + gridRect.left();
64 64
65 65 return points;
66 66 }
@@ -60,7 +60,7 QVector<qreal> ChartBarCategoryAxisY::calculateLayout() const
60 60 points.resize(count + 2);
61 61
62 62 for (int i = 0; i < count + 2; ++i)
63 points[i] = gridRect.bottom() - (i * delta) - offset;
63 points[i] = gridRect.bottom() - (qreal(i) * delta) - offset;
64 64
65 65 return points;
66 66 }
@@ -50,11 +50,9 QVector<qreal> ChartDateTimeAxisX::calculateLayout() const
50 50 QVector<qreal> points;
51 51 points.resize(tickCount);
52 52 const QRectF &gridRect = gridGeometry();
53 const qreal deltaX = gridRect.width() / (tickCount - 1);
54 for (int i = 0; i < tickCount; ++i) {
55 int x = i * deltaX + gridRect.left();
56 points[i] = x;
57 }
53 const qreal deltaX = gridRect.width() / (qreal(tickCount) - 1.0);
54 for (int i = 0; i < tickCount; ++i)
55 points[i] = qreal(i) * deltaX + gridRect.left();
58 56 return points;
59 57 }
60 58
@@ -50,11 +50,9 QVector<qreal> ChartDateTimeAxisY::calculateLayout() const
50 50 QVector<qreal> points;
51 51 points.resize(tickCount);
52 52 const QRectF &gridRect = gridGeometry();
53 const qreal deltaY = gridRect.height() / (tickCount - 1);
54 for (int i = 0; i < tickCount; ++i) {
55 int y = i * -deltaY + gridRect.bottom();
56 points[i] = y;
57 }
53 const qreal deltaY = gridRect.height() / (qreal(tickCount) - 1.0);
54 for (int i = 0; i < tickCount; ++i)
55 points[i] = qreal(i) * -deltaY + gridRect.bottom();
58 56
59 57 return points;
60 58 }
@@ -53,10 +53,9 QVector<qreal> ChartValueAxisX::calculateLayout() const
53 53 points.resize(tickCount);
54 54
55 55 const QRectF &gridRect = gridGeometry();
56 const qreal deltaX = gridRect.width() / (tickCount - 1);
57 for (int i = 0; i < tickCount; ++i) {
58 points[i] = i * deltaX + gridRect.left();
59 }
56 const qreal deltaX = gridRect.width() / (qreal(tickCount) - 1.0);
57 for (int i = 0; i < tickCount; ++i)
58 points[i] = qreal(i) * deltaX + gridRect.left();
60 59 return points;
61 60 }
62 61
@@ -53,10 +53,9 QVector<qreal> ChartValueAxisY::calculateLayout() const
53 53
54 54 const QRectF &gridRect = gridGeometry();
55 55
56 const qreal deltaY = gridRect.height() / (tickCount - 1);
57 for (int i = 0; i < tickCount; ++i) {
58 points[i] = i * -deltaY + gridRect.bottom();
59 }
56 const qreal deltaY = gridRect.height() / (qreal(tickCount) - 1.0);
57 for (int i = 0; i < tickCount; ++i)
58 points[i] = qreal(i) * -deltaY + gridRect.bottom();
60 59
61 60 return points;
62 61 }
General Comments 0
You need to be logged in to leave comments. Login now