diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/charts/barchart/abstractbarchartitem.cpp | 16 | ||||
-rw-r--r-- | src/charts/barchart/qabstractbarseries.cpp | 4 |
2 files changed, 12 insertions, 8 deletions
diff --git a/src/charts/barchart/abstractbarchartitem.cpp b/src/charts/barchart/abstractbarchartitem.cpp index 5cae977e..9695a60e 100644 --- a/src/charts/barchart/abstractbarchartitem.cpp +++ b/src/charts/barchart/abstractbarchartitem.cpp @@ -352,15 +352,17 @@ void AbstractBarChartItem::positionLabels() case QAbstractBarSeries::LabelsCenter: xPos = m_layout.at(bar->layoutIndex()).center().x() - center.x(); break; + case QAbstractBarSeries::LabelsOutsideEnd: + xPos = m_layout.at(bar->layoutIndex()).right() + offset + xDiff; + if (xPos + labelRect.width() - offset <= m_rect.right()) + break; + Q_FALLTHROUGH(); case QAbstractBarSeries::LabelsInsideEnd: xPos = m_layout.at(bar->layoutIndex()).right() - labelRect.width() - offset + xDiff; break; case QAbstractBarSeries::LabelsInsideBase: xPos = m_layout.at(bar->layoutIndex()).left() + offset + xDiff; break; - case QAbstractBarSeries::LabelsOutsideEnd: - xPos = m_layout.at(bar->layoutIndex()).right() + offset + xDiff; - break; default: // Invalid position, never comes here break; @@ -473,15 +475,17 @@ void AbstractBarChartItem::positionLabelsVertical() case QAbstractBarSeries::LabelsCenter: yPos = m_layout.at(bar->layoutIndex()).center().y() - center.y(); break; + case QAbstractBarSeries::LabelsOutsideEnd: + yPos = m_layout.at(bar->layoutIndex()).top() - labelRect.height() - offset + yDiff; + if (yPos + offset >= m_rect.y()) + break; + Q_FALLTHROUGH(); case QAbstractBarSeries::LabelsInsideEnd: yPos = m_layout.at(bar->layoutIndex()).top() + offset + yDiff; break; case QAbstractBarSeries::LabelsInsideBase: yPos = m_layout.at(bar->layoutIndex()).bottom() - labelRect.height() - offset + yDiff; break; - case QAbstractBarSeries::LabelsOutsideEnd: - yPos = m_layout.at(bar->layoutIndex()).top() - labelRect.height() - offset + yDiff; - break; default: // Invalid position, never comes here break; diff --git a/src/charts/barchart/qabstractbarseries.cpp b/src/charts/barchart/qabstractbarseries.cpp index 6427365c..7379e8e1 100644 --- a/src/charts/barchart/qabstractbarseries.cpp +++ b/src/charts/barchart/qabstractbarseries.cpp @@ -182,8 +182,8 @@ QT_CHARTS_BEGIN_NAMESPACE \endcode By default, the labels show the value of the bar. For the percent bar series, \e % is added - after the value. The labels are shown on the plot area, whereas labels on the edge of the plot - area are cut. If the bars are close to each other, the labels may overlap. + after the value. The labels are shown on the plot area, if the bars are close to each other, + the labels may overlap. \sa labelsVisible, labelsPosition, labelsPrecision */ |