diff --git a/src/linechart/linechartitem.cpp b/src/linechart/linechartitem.cpp index f279a3e..da7c0c5 100644 --- a/src/linechart/linechartitem.cpp +++ b/src/linechart/linechartitem.cpp @@ -374,7 +374,7 @@ void LineChartItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *opt } if (m_pointLabelsVisible) - m_series->d_func()->drawSeriesPointLabels(painter, m_points); + m_series->d_func()->drawSeriesPointLabels(painter, m_points, m_linePen.width() / 2); painter->restore(); diff --git a/src/scatterchart/scatterchartitem.cpp b/src/scatterchart/scatterchartitem.cpp index 238c958..dda32e5 100644 --- a/src/scatterchart/scatterchartitem.cpp +++ b/src/scatterchart/scatterchartitem.cpp @@ -178,8 +178,11 @@ void ScatterChartItem::paint(QPainter *painter, const QStyleOptionGraphicsItem * painter->save(); painter->setClipRect(clipRect); - if (m_pointLabelsVisible) - m_series->d_func()->drawSeriesPointLabels(painter, m_points); + if (m_pointLabelsVisible) { + m_series->d_func()->drawSeriesPointLabels(painter, m_points, + m_series->markerSize() / 2 + + m_series->pen().width()); + } painter->restore(); } diff --git a/src/splinechart/splinechartitem.cpp b/src/splinechart/splinechartitem.cpp index c9d1a52..2b14686 100644 --- a/src/splinechart/splinechartitem.cpp +++ b/src/splinechart/splinechartitem.cpp @@ -457,7 +457,7 @@ void SplineChartItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *o } if (m_pointLabelsVisible) - m_series->d_func()->drawSeriesPointLabels(painter, m_points); + m_series->d_func()->drawSeriesPointLabels(painter, m_points, m_linePen.width() / 2); painter->restore(); } diff --git a/src/xychart/qxyseries.cpp b/src/xychart/qxyseries.cpp index 6c56a7b..448e383 100644 --- a/src/xychart/qxyseries.cpp +++ b/src/xychart/qxyseries.cpp @@ -772,11 +772,12 @@ void QXYSeriesPrivate::initializeAnimations(QtCommercialChart::QChart::Animation QAbstractSeriesPrivate::initializeAnimations(options); } -void QXYSeriesPrivate::drawSeriesPointLabels(QPainter *painter, const QVector &points) +void QXYSeriesPrivate::drawSeriesPointLabels(QPainter *painter, const QVector &points, + const int offset) { static const QString xPointTag(QLatin1String("@xPoint")); static const QString yPointTag(QLatin1String("@yPoint")); - const int labelOffset = 2; + const int labelOffset = offset + 2; painter->setFont(m_pointLabelsFont); painter->setPen(QPen(m_pointLabelsColor)); @@ -791,7 +792,7 @@ void QXYSeriesPrivate::drawSeriesPointLabels(QPainter *painter, const QVectorpen().width() / 2 - labelOffset); + position.setY(position.y() - labelOffset); painter->drawText(position, pointLabel); } diff --git a/src/xychart/qxyseries_p.h b/src/xychart/qxyseries_p.h index 64dec64..996f0f0 100644 --- a/src/xychart/qxyseries_p.h +++ b/src/xychart/qxyseries_p.h @@ -53,7 +53,8 @@ public: QAbstractAxis::AxisType defaultAxisType(Qt::Orientation orientation) const; QAbstractAxis* createDefaultAxis(Qt::Orientation orientation) const; - void drawSeriesPointLabels(QPainter *painter, const QVector &points); + void drawSeriesPointLabels(QPainter *painter, const QVector &points, + const int offset = 0); Q_SIGNALS: void updated();