##// END OF EJS Templates
Fix bar value label position...
Titta Heikkala -
r2697:899dd6266dee
parent child
Show More
@@ -245,14 +245,15 void AbstractBarChartItem::positionLabels()
245 245 qreal xPos = 0;
246 246 qreal yPos = m_layout.at(i).center().y() - label->boundingRect().center().y();
247 247
248 int offset = m_bars.at(i)->pen().width() / 2 + 2;
248 249 if (m_series->labelsPosition() == QAbstractBarSeries::LabelsCenter)
249 250 xPos = m_layout.at(i).center().x() - label->boundingRect().center().x();
250 251 else if (m_series->labelsPosition() == QAbstractBarSeries::LabelsInsideEnd)
251 xPos = m_layout.at(i).right() - label->boundingRect().width();
252 xPos = m_layout.at(i).right() - label->boundingRect().width() - offset;
252 253 else if (m_series->labelsPosition() == QAbstractBarSeries::LabelsInsideBase)
253 xPos = m_layout.at(i).left();
254 xPos = m_layout.at(i).left() + offset;
254 255 else if (m_series->labelsPosition() == QAbstractBarSeries::LabelsOutsideEnd)
255 xPos = m_layout.at(i).right();
256 xPos = m_layout.at(i).right() + offset;
256 257
257 258 label->setPos(xPos, yPos);
258 259 label->setZValue(zValue() + 1);
@@ -105,14 +105,15 void BarChartItem::positionLabels()
105 105 qreal xPos = m_layout.at(i).center().x() - label->boundingRect().center().x();
106 106 qreal yPos = 0;
107 107
108 int offset = m_bars.at(i)->pen().width() / 2 + 2;
108 109 if (m_series->labelsPosition() == QAbstractBarSeries::LabelsCenter)
109 110 yPos = m_layout.at(i).center().y() - label->boundingRect().center().y();
110 111 else if (m_series->labelsPosition() == QAbstractBarSeries::LabelsInsideEnd)
111 yPos = m_layout.at(i).top();
112 yPos = m_layout.at(i).top() - offset;
112 113 else if (m_series->labelsPosition() == QAbstractBarSeries::LabelsInsideBase)
113 yPos = m_layout.at(i).bottom() - label->boundingRect().height();
114 yPos = m_layout.at(i).bottom() - label->boundingRect().height() + offset;
114 115 else if (m_series->labelsPosition() == QAbstractBarSeries::LabelsOutsideEnd)
115 yPos = m_layout.at(i).top() - label->boundingRect().height();
116 yPos = m_layout.at(i).top() - label->boundingRect().height() + offset;
116 117
117 118 label->setPos(xPos, yPos);
118 119 label->setZValue(zValue() + 1);
@@ -152,14 +152,15 void PercentBarChartItem::positionLabels()
152 152 qreal xPos = m_layout.at(i).center().x() - label->boundingRect().center().x();
153 153 qreal yPos = 0;
154 154
155 int offset = m_bars.at(i)->pen().width() / 2 + 2;
155 156 if (m_series->labelsPosition() == QAbstractBarSeries::LabelsCenter)
156 157 yPos = m_layout.at(i).center().y() - label->boundingRect().center().y();
157 158 else if (m_series->labelsPosition() == QAbstractBarSeries::LabelsInsideEnd)
158 yPos = m_layout.at(i).top();
159 yPos = m_layout.at(i).top() - offset;
159 160 else if (m_series->labelsPosition() == QAbstractBarSeries::LabelsInsideBase)
160 yPos = m_layout.at(i).bottom() - label->boundingRect().height();
161 yPos = m_layout.at(i).bottom() - label->boundingRect().height() + offset;
161 162 else if (m_series->labelsPosition() == QAbstractBarSeries::LabelsOutsideEnd)
162 yPos = m_layout.at(i).top() - label->boundingRect().height();
163 yPos = m_layout.at(i).top() - label->boundingRect().height() + offset;
163 164
164 165 label->setPos(xPos, yPos);
165 166 label->setZValue(zValue() + 1);
@@ -117,14 +117,15 void StackedBarChartItem::positionLabels()
117 117 qreal xPos = m_layout.at(i).center().x() - label->boundingRect().center().x();
118 118 qreal yPos = 0;
119 119
120 int offset = m_bars.at(i)->pen().width() / 2 + 2;
120 121 if (m_series->labelsPosition() == QAbstractBarSeries::LabelsCenter)
121 122 yPos = m_layout.at(i).center().y() - label->boundingRect().center().y();
122 123 else if (m_series->labelsPosition() == QAbstractBarSeries::LabelsInsideEnd)
123 yPos = m_layout.at(i).top();
124 yPos = m_layout.at(i).top() - offset;
124 125 else if (m_series->labelsPosition() == QAbstractBarSeries::LabelsInsideBase)
125 yPos = m_layout.at(i).bottom() - label->boundingRect().height();
126 yPos = m_layout.at(i).bottom() - label->boundingRect().height() + offset;
126 127 else if (m_series->labelsPosition() == QAbstractBarSeries::LabelsOutsideEnd)
127 yPos = m_layout.at(i).top() - label->boundingRect().height();
128 yPos = m_layout.at(i).top() - label->boundingRect().height() + offset;
128 129
129 130 label->setPos(xPos, yPos);
130 131 label->setZValue(zValue() + 1);
General Comments 0
You need to be logged in to leave comments. Login now