##// END OF EJS Templates
Fix category axis label positioning....
Miikka Heikkinen -
r2446:e5bdddebc98a
parent child
Show More
@@ -136,14 +136,23 void HorizontalAxis::updateGeometry()
136 136 tickItem->setLine(layout[i], axisRect.top(), layout[i], axisRect.top() + labelPadding());
137 137 }
138 138
139 //label in beetwen
140 if(intervalAxis()&& i+1!=layout.size()) {
141 const qreal delta = (layout[i+1] - layout[i])/2;
142 labelItem->setPos(layout[i] + delta - center.x(), labelItem->pos().y());
139 //label in between
140 bool forceHide = false;
141 if (intervalAxis() && (i + 1) != layout.size()) {
142 qreal leftBound = qMax(layout[i], gridRect.left());
143 qreal rightBound = qMin(layout[i + 1], gridRect.right());
144 const qreal delta = rightBound - leftBound;
145 // Hide label in case visible part of the category at the grid edge is too narrow
146 if (delta < boundingRect.width()
147 && (leftBound == gridRect.left() || rightBound == gridRect.right())) {
148 forceHide = true;
149 } else {
150 labelItem->setPos(leftBound + (delta / 2.0) - center.x(), labelItem->pos().y());
151 }
143 152 }
144 153
145 154 //label overlap detection - compensate one pixel for rounding errors
146 if(labelItem->pos().x() < width ||
155 if (labelItem->pos().x() < width || forceHide ||
147 156 labelItem->pos().x() < (axisRect.left() - 1.0) ||
148 157 (labelItem->pos().x() + boundingRect.width() - 1.0) > axisRect.right()){
149 158 labelItem->setVisible(false);
@@ -146,14 +146,23 void VerticalAxis::updateGeometry()
146 146 tickItem->setLine(axisRect.left(), layout[i], axisRect.left() + labelPadding(), layout[i]);
147 147 }
148 148
149 //label in beetwen
150 if(intervalAxis()&& i+1!=layout.size()) {
151 const qreal delta = (layout[i+1] - layout[i])/2;
152 labelItem->setPos(labelItem->pos().x() , layout[i] + delta - center.y());
149 //label in between
150 bool forceHide = false;
151 if (intervalAxis() && (i + 1) != layout.size()) {
152 qreal lowerBound = qMin(layout[i], gridRect.bottom());
153 qreal upperBound = qMax(layout[i + 1], gridRect.top());
154 const qreal delta = lowerBound - upperBound;
155 // Hide label in case visible part of the category at the grid edge is too narrow
156 if (delta < boundingRect.height()
157 && (lowerBound == gridRect.bottom() || upperBound == gridRect.top())) {
158 forceHide = true;
159 } else {
160 labelItem->setPos(labelItem->pos().x() , lowerBound - (delta / 2.0) - center.y());
161 }
153 162 }
154 163
155 164 //label overlap detection - compensate one pixel for rounding errors
156 if (labelItem->pos().y() + boundingRect.height() > height ||
165 if (labelItem->pos().y() + boundingRect.height() > height || forceHide ||
157 166 (labelItem->pos().y() + (boundingRect.height() / 2.0) - 1.0) > axisRect.bottom() ||
158 167 labelItem->pos().y() + (boundingRect.height() / 2.0) < (axisRect.top() - 1.0)) {
159 168 labelItem->setVisible(false);
General Comments 0
You need to be logged in to leave comments. Login now