##// END OF EJS Templates
Fix point label position for QXYSeries...
Titta Heikkala -
r2696:85326bf48cb4
parent child
Show More
@@ -374,7 +374,7 void LineChartItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *opt
374 }
374 }
375
375
376 if (m_pointLabelsVisible)
376 if (m_pointLabelsVisible)
377 m_series->d_func()->drawSeriesPointLabels(painter, m_points);
377 m_series->d_func()->drawSeriesPointLabels(painter, m_points, m_linePen.width() / 2);
378
378
379 painter->restore();
379 painter->restore();
380
380
@@ -178,8 +178,11 void ScatterChartItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *
178 painter->save();
178 painter->save();
179 painter->setClipRect(clipRect);
179 painter->setClipRect(clipRect);
180
180
181 if (m_pointLabelsVisible)
181 if (m_pointLabelsVisible) {
182 m_series->d_func()->drawSeriesPointLabels(painter, m_points);
182 m_series->d_func()->drawSeriesPointLabels(painter, m_points,
183 m_series->markerSize() / 2
184 + m_series->pen().width());
185 }
183
186
184 painter->restore();
187 painter->restore();
185 }
188 }
@@ -457,7 +457,7 void SplineChartItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *o
457 }
457 }
458
458
459 if (m_pointLabelsVisible)
459 if (m_pointLabelsVisible)
460 m_series->d_func()->drawSeriesPointLabels(painter, m_points);
460 m_series->d_func()->drawSeriesPointLabels(painter, m_points, m_linePen.width() / 2);
461
461
462 painter->restore();
462 painter->restore();
463 }
463 }
@@ -772,11 +772,12 void QXYSeriesPrivate::initializeAnimations(QtCommercialChart::QChart::Animation
772 QAbstractSeriesPrivate::initializeAnimations(options);
772 QAbstractSeriesPrivate::initializeAnimations(options);
773 }
773 }
774
774
775 void QXYSeriesPrivate::drawSeriesPointLabels(QPainter *painter, const QVector<QPointF> &points)
775 void QXYSeriesPrivate::drawSeriesPointLabels(QPainter *painter, const QVector<QPointF> &points,
776 const int offset)
776 {
777 {
777 static const QString xPointTag(QLatin1String("@xPoint"));
778 static const QString xPointTag(QLatin1String("@xPoint"));
778 static const QString yPointTag(QLatin1String("@yPoint"));
779 static const QString yPointTag(QLatin1String("@yPoint"));
779 const int labelOffset = 2;
780 const int labelOffset = offset + 2;
780
781
781 painter->setFont(m_pointLabelsFont);
782 painter->setFont(m_pointLabelsFont);
782 painter->setPen(QPen(m_pointLabelsColor));
783 painter->setPen(QPen(m_pointLabelsColor));
@@ -791,7 +792,7 void QXYSeriesPrivate::drawSeriesPointLabels(QPainter *painter, const QVector<QP
791 int pointLabelWidth = fm.width(pointLabel);
792 int pointLabelWidth = fm.width(pointLabel);
792 QPointF position(points.at(i));
793 QPointF position(points.at(i));
793 position.setX(position.x() - pointLabelWidth / 2);
794 position.setX(position.x() - pointLabelWidth / 2);
794 position.setY(position.y() - painter->pen().width() / 2 - labelOffset);
795 position.setY(position.y() - labelOffset);
795
796
796 painter->drawText(position, pointLabel);
797 painter->drawText(position, pointLabel);
797 }
798 }
@@ -53,7 +53,8 public:
53 QAbstractAxis::AxisType defaultAxisType(Qt::Orientation orientation) const;
53 QAbstractAxis::AxisType defaultAxisType(Qt::Orientation orientation) const;
54 QAbstractAxis* createDefaultAxis(Qt::Orientation orientation) const;
54 QAbstractAxis* createDefaultAxis(Qt::Orientation orientation) const;
55
55
56 void drawSeriesPointLabels(QPainter *painter, const QVector<QPointF> &points);
56 void drawSeriesPointLabels(QPainter *painter, const QVector<QPointF> &points,
57 const int offset = 0);
57
58
58 Q_SIGNALS:
59 Q_SIGNALS:
59 void updated();
60 void updated();
General Comments 0
You need to be logged in to leave comments. Login now