##// END OF EJS Templates
Fix pie chart label truncation...
Titta Heikkala -
r2646:a54f42bb13ad
parent child
Show More
@@ -135,7 +135,6 void PieSliceItem::updateGeometry()
135
135
136 if (m_data.m_isLabelVisible) {
136 if (m_data.m_isLabelVisible) {
137 // text rect
137 // text rect
138 QFontMetricsF fm(m_data.m_labelFont);
139 m_labelTextRect = ChartPresenter::textBoundingRect(m_data.m_labelFont,
138 m_labelTextRect = ChartPresenter::textBoundingRect(m_data.m_labelFont,
140 m_data.m_labelText,
139 m_data.m_labelText,
141 0);
140 0);
@@ -162,16 +161,14 void PieSliceItem::updateGeometry()
162 if (m_labelTextRect.right() > parentItem()->boundingRect().right())
161 if (m_labelTextRect.right() > parentItem()->boundingRect().right())
163 m_labelTextRect.setRight(parentItem()->boundingRect().right());
162 m_labelTextRect.setRight(parentItem()->boundingRect().right());
164
163
165 if (fm.width(m_data.m_labelText) > m_labelTextRect.width()) {
164 label = ChartPresenter::truncatedText(m_data.m_labelFont, m_data.m_labelText,
166 label = ChartPresenter::truncatedText(m_data.m_labelFont, m_data.m_labelText,
165 qreal(0.0), m_labelTextRect.width(),
167 qreal(0.0), m_labelTextRect.width(),
166 m_labelTextRect.height(), m_labelTextRect);
168 m_labelTextRect.height(), m_labelTextRect);
167 m_labelArmPath = labelArmPath(armStart, centerAngle,
169 m_labelArmPath = labelArmPath(armStart, centerAngle,
168 m_data.m_radius * m_data.m_labelArmLengthFactor,
170 m_data.m_radius * m_data.m_labelArmLengthFactor,
169 m_labelTextRect.width(), &labelTextStart);
171 m_labelTextRect.width(), &labelTextStart);
170 m_labelTextRect.moveBottomLeft(labelTextStart);
172
171
173 m_labelTextRect.moveBottomLeft(labelTextStart);
174 }
175 m_labelItem->setTextWidth(m_labelTextRect.width()
172 m_labelItem->setTextWidth(m_labelTextRect.width()
176 + m_labelItem->document()->documentMargin());
173 + m_labelItem->document()->documentMargin());
177 m_labelItem->setHtml(label);
174 m_labelItem->setHtml(label);
@@ -193,7 +190,7 void PieSliceItem::updateGeometry()
193 textCenter = m_data.m_center + offset(centerAngle, m_data.m_radius / 2);
190 textCenter = m_data.m_center + offset(centerAngle, m_data.m_radius / 2);
194 }
191 }
195 m_labelItem->setPos(textCenter.x() - m_labelItem->boundingRect().width() / 2,
192 m_labelItem->setPos(textCenter.x() - m_labelItem->boundingRect().width() / 2,
196 textCenter.y() - fm.height() / 2);
193 textCenter.y() - m_labelTextRect.height() / 2);
197
194
198 QPointF labelCenter = m_labelItem->boundingRect().center();
195 QPointF labelCenter = m_labelItem->boundingRect().center();
199 m_labelItem->setTransformOriginPoint(labelCenter);
196 m_labelItem->setTransformOriginPoint(labelCenter);
General Comments 0
You need to be logged in to leave comments. Login now