##// 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 qreal xPos = 0;
245 qreal xPos = 0;
246 qreal yPos = m_layout.at(i).center().y() - label->boundingRect().center().y();
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 if (m_series->labelsPosition() == QAbstractBarSeries::LabelsCenter)
249 if (m_series->labelsPosition() == QAbstractBarSeries::LabelsCenter)
249 xPos = m_layout.at(i).center().x() - label->boundingRect().center().x();
250 xPos = m_layout.at(i).center().x() - label->boundingRect().center().x();
250 else if (m_series->labelsPosition() == QAbstractBarSeries::LabelsInsideEnd)
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 else if (m_series->labelsPosition() == QAbstractBarSeries::LabelsInsideBase)
253 else if (m_series->labelsPosition() == QAbstractBarSeries::LabelsInsideBase)
253 xPos = m_layout.at(i).left();
254 xPos = m_layout.at(i).left() + offset;
254 else if (m_series->labelsPosition() == QAbstractBarSeries::LabelsOutsideEnd)
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 label->setPos(xPos, yPos);
258 label->setPos(xPos, yPos);
258 label->setZValue(zValue() + 1);
259 label->setZValue(zValue() + 1);
@@ -105,14 +105,15 void BarChartItem::positionLabels()
105 qreal xPos = m_layout.at(i).center().x() - label->boundingRect().center().x();
105 qreal xPos = m_layout.at(i).center().x() - label->boundingRect().center().x();
106 qreal yPos = 0;
106 qreal yPos = 0;
107
107
108 int offset = m_bars.at(i)->pen().width() / 2 + 2;
108 if (m_series->labelsPosition() == QAbstractBarSeries::LabelsCenter)
109 if (m_series->labelsPosition() == QAbstractBarSeries::LabelsCenter)
109 yPos = m_layout.at(i).center().y() - label->boundingRect().center().y();
110 yPos = m_layout.at(i).center().y() - label->boundingRect().center().y();
110 else if (m_series->labelsPosition() == QAbstractBarSeries::LabelsInsideEnd)
111 else if (m_series->labelsPosition() == QAbstractBarSeries::LabelsInsideEnd)
111 yPos = m_layout.at(i).top();
112 yPos = m_layout.at(i).top() - offset;
112 else if (m_series->labelsPosition() == QAbstractBarSeries::LabelsInsideBase)
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 else if (m_series->labelsPosition() == QAbstractBarSeries::LabelsOutsideEnd)
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 label->setPos(xPos, yPos);
118 label->setPos(xPos, yPos);
118 label->setZValue(zValue() + 1);
119 label->setZValue(zValue() + 1);
@@ -152,14 +152,15 void PercentBarChartItem::positionLabels()
152 qreal xPos = m_layout.at(i).center().x() - label->boundingRect().center().x();
152 qreal xPos = m_layout.at(i).center().x() - label->boundingRect().center().x();
153 qreal yPos = 0;
153 qreal yPos = 0;
154
154
155 int offset = m_bars.at(i)->pen().width() / 2 + 2;
155 if (m_series->labelsPosition() == QAbstractBarSeries::LabelsCenter)
156 if (m_series->labelsPosition() == QAbstractBarSeries::LabelsCenter)
156 yPos = m_layout.at(i).center().y() - label->boundingRect().center().y();
157 yPos = m_layout.at(i).center().y() - label->boundingRect().center().y();
157 else if (m_series->labelsPosition() == QAbstractBarSeries::LabelsInsideEnd)
158 else if (m_series->labelsPosition() == QAbstractBarSeries::LabelsInsideEnd)
158 yPos = m_layout.at(i).top();
159 yPos = m_layout.at(i).top() - offset;
159 else if (m_series->labelsPosition() == QAbstractBarSeries::LabelsInsideBase)
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 else if (m_series->labelsPosition() == QAbstractBarSeries::LabelsOutsideEnd)
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 label->setPos(xPos, yPos);
165 label->setPos(xPos, yPos);
165 label->setZValue(zValue() + 1);
166 label->setZValue(zValue() + 1);
@@ -117,14 +117,15 void StackedBarChartItem::positionLabels()
117 qreal xPos = m_layout.at(i).center().x() - label->boundingRect().center().x();
117 qreal xPos = m_layout.at(i).center().x() - label->boundingRect().center().x();
118 qreal yPos = 0;
118 qreal yPos = 0;
119
119
120 int offset = m_bars.at(i)->pen().width() / 2 + 2;
120 if (m_series->labelsPosition() == QAbstractBarSeries::LabelsCenter)
121 if (m_series->labelsPosition() == QAbstractBarSeries::LabelsCenter)
121 yPos = m_layout.at(i).center().y() - label->boundingRect().center().y();
122 yPos = m_layout.at(i).center().y() - label->boundingRect().center().y();
122 else if (m_series->labelsPosition() == QAbstractBarSeries::LabelsInsideEnd)
123 else if (m_series->labelsPosition() == QAbstractBarSeries::LabelsInsideEnd)
123 yPos = m_layout.at(i).top();
124 yPos = m_layout.at(i).top() - offset;
124 else if (m_series->labelsPosition() == QAbstractBarSeries::LabelsInsideBase)
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 else if (m_series->labelsPosition() == QAbstractBarSeries::LabelsOutsideEnd)
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 label->setPos(xPos, yPos);
130 label->setPos(xPos, yPos);
130 label->setZValue(zValue() + 1);
131 label->setZValue(zValue() + 1);
General Comments 0
You need to be logged in to leave comments. Login now