diff --git a/src/barchart/abstractbarchartitem.cpp b/src/barchart/abstractbarchartitem.cpp index 70c647c..8dbc318 100644 --- a/src/barchart/abstractbarchartitem.cpp +++ b/src/barchart/abstractbarchartitem.cpp @@ -245,14 +245,15 @@ void AbstractBarChartItem::positionLabels() qreal xPos = 0; qreal yPos = m_layout.at(i).center().y() - label->boundingRect().center().y(); + int offset = m_bars.at(i)->pen().width() / 2 + 2; if (m_series->labelsPosition() == QAbstractBarSeries::LabelsCenter) xPos = m_layout.at(i).center().x() - label->boundingRect().center().x(); else if (m_series->labelsPosition() == QAbstractBarSeries::LabelsInsideEnd) - xPos = m_layout.at(i).right() - label->boundingRect().width(); + xPos = m_layout.at(i).right() - label->boundingRect().width() - offset; else if (m_series->labelsPosition() == QAbstractBarSeries::LabelsInsideBase) - xPos = m_layout.at(i).left(); + xPos = m_layout.at(i).left() + offset; else if (m_series->labelsPosition() == QAbstractBarSeries::LabelsOutsideEnd) - xPos = m_layout.at(i).right(); + xPos = m_layout.at(i).right() + offset; label->setPos(xPos, yPos); label->setZValue(zValue() + 1); diff --git a/src/barchart/vertical/bar/barchartitem.cpp b/src/barchart/vertical/bar/barchartitem.cpp index eae5be1..9a57325 100644 --- a/src/barchart/vertical/bar/barchartitem.cpp +++ b/src/barchart/vertical/bar/barchartitem.cpp @@ -105,14 +105,15 @@ void BarChartItem::positionLabels() qreal xPos = m_layout.at(i).center().x() - label->boundingRect().center().x(); qreal yPos = 0; + int offset = m_bars.at(i)->pen().width() / 2 + 2; if (m_series->labelsPosition() == QAbstractBarSeries::LabelsCenter) yPos = m_layout.at(i).center().y() - label->boundingRect().center().y(); else if (m_series->labelsPosition() == QAbstractBarSeries::LabelsInsideEnd) - yPos = m_layout.at(i).top(); + yPos = m_layout.at(i).top() - offset; else if (m_series->labelsPosition() == QAbstractBarSeries::LabelsInsideBase) - yPos = m_layout.at(i).bottom() - label->boundingRect().height(); + yPos = m_layout.at(i).bottom() - label->boundingRect().height() + offset; else if (m_series->labelsPosition() == QAbstractBarSeries::LabelsOutsideEnd) - yPos = m_layout.at(i).top() - label->boundingRect().height(); + yPos = m_layout.at(i).top() - label->boundingRect().height() + offset; label->setPos(xPos, yPos); label->setZValue(zValue() + 1); diff --git a/src/barchart/vertical/percent/percentbarchartitem.cpp b/src/barchart/vertical/percent/percentbarchartitem.cpp index b7ec6d5..b4c6283 100644 --- a/src/barchart/vertical/percent/percentbarchartitem.cpp +++ b/src/barchart/vertical/percent/percentbarchartitem.cpp @@ -152,14 +152,15 @@ void PercentBarChartItem::positionLabels() qreal xPos = m_layout.at(i).center().x() - label->boundingRect().center().x(); qreal yPos = 0; + int offset = m_bars.at(i)->pen().width() / 2 + 2; if (m_series->labelsPosition() == QAbstractBarSeries::LabelsCenter) yPos = m_layout.at(i).center().y() - label->boundingRect().center().y(); else if (m_series->labelsPosition() == QAbstractBarSeries::LabelsInsideEnd) - yPos = m_layout.at(i).top(); + yPos = m_layout.at(i).top() - offset; else if (m_series->labelsPosition() == QAbstractBarSeries::LabelsInsideBase) - yPos = m_layout.at(i).bottom() - label->boundingRect().height(); + yPos = m_layout.at(i).bottom() - label->boundingRect().height() + offset; else if (m_series->labelsPosition() == QAbstractBarSeries::LabelsOutsideEnd) - yPos = m_layout.at(i).top() - label->boundingRect().height(); + yPos = m_layout.at(i).top() - label->boundingRect().height() + offset; label->setPos(xPos, yPos); label->setZValue(zValue() + 1); diff --git a/src/barchart/vertical/stacked/stackedbarchartitem.cpp b/src/barchart/vertical/stacked/stackedbarchartitem.cpp index 8232919..72bc650 100644 --- a/src/barchart/vertical/stacked/stackedbarchartitem.cpp +++ b/src/barchart/vertical/stacked/stackedbarchartitem.cpp @@ -117,14 +117,15 @@ void StackedBarChartItem::positionLabels() qreal xPos = m_layout.at(i).center().x() - label->boundingRect().center().x(); qreal yPos = 0; + int offset = m_bars.at(i)->pen().width() / 2 + 2; if (m_series->labelsPosition() == QAbstractBarSeries::LabelsCenter) yPos = m_layout.at(i).center().y() - label->boundingRect().center().y(); else if (m_series->labelsPosition() == QAbstractBarSeries::LabelsInsideEnd) - yPos = m_layout.at(i).top(); + yPos = m_layout.at(i).top() - offset; else if (m_series->labelsPosition() == QAbstractBarSeries::LabelsInsideBase) - yPos = m_layout.at(i).bottom() - label->boundingRect().height(); + yPos = m_layout.at(i).bottom() - label->boundingRect().height() + offset; else if (m_series->labelsPosition() == QAbstractBarSeries::LabelsOutsideEnd) - yPos = m_layout.at(i).top() - label->boundingRect().height(); + yPos = m_layout.at(i).top() - label->boundingRect().height() + offset; label->setPos(xPos, yPos); label->setZValue(zValue() + 1);