diff --git a/src/linechart/linechartitem.cpp b/src/linechart/linechartitem.cpp index 78856fb..5daafc0 100644 --- a/src/linechart/linechartitem.cpp +++ b/src/linechart/linechartitem.cpp @@ -15,6 +15,7 @@ m_dirtyData(false), m_dirtyGeometry(false), m_dirtyDomain(false) { + } QRectF LineChartItem::boundingRect() const @@ -35,7 +36,7 @@ void LineChartItem::addPoints(const QVector& points) const QPointF& point =m_data[i]; QGraphicsRectItem* item = new QGraphicsRectItem(0,0,3,3,this); item->setPos(point.x()-1,point.y()-1);; - if(!m_clipRect.contains(point)) item->setVisible(false); + if(!m_clipRect.contains(point) || !m_series->isPointsVisible()) item->setVisible(false); m_points << item; } } @@ -46,7 +47,7 @@ void LineChartItem::addPoint(const QPointF& point) QGraphicsRectItem* item = new QGraphicsRectItem(0,0,3,3,this); m_clipRect.contains(point); item->setPos(point.x()-1,point.y()-1); - if(!m_clipRect.contains(point)) item->setVisible(false); + if(!m_clipRect.contains(point) || !m_series->isPointsVisible()) item->setVisible(false); m_points << item; } diff --git a/src/linechart/linechartitem_p.h b/src/linechart/linechartitem_p.h index 67e33b0..fcf3eec 100644 --- a/src/linechart/linechartitem_p.h +++ b/src/linechart/linechartitem_p.h @@ -31,6 +31,7 @@ public: virtual void removePoint(const QPointF& point); virtual void setPoint(const QPointF& oldPoint, const QPointF& newPoint); virtual void setPoint(int index,const QPointF& point); + void setPointsVisible(bool visible); void clear(); void clearView(); int count() const { return m_data.size();} diff --git a/src/linechart/qlinechartseries.cpp b/src/linechart/qlinechartseries.cpp index 4d7627b..8ae77c8 100644 --- a/src/linechart/qlinechartseries.cpp +++ b/src/linechart/qlinechartseries.cpp @@ -2,7 +2,8 @@ QTCOMMERCIALCHART_BEGIN_NAMESPACE -QLineChartSeries::QLineChartSeries(QObject* parent):QChartSeries(parent) +QLineChartSeries::QLineChartSeries(QObject* parent):QChartSeries(parent), +m_pointsVisible(false) { } diff --git a/src/linechart/qlinechartseries.h b/src/linechart/qlinechartseries.h index 1be17dd..0d26b8e 100644 --- a/src/linechart/qlinechartseries.h +++ b/src/linechart/qlinechartseries.h @@ -18,8 +18,6 @@ public: public: // from QChartSeries virtual QChartSeriesType type() const { return QChartSeries::SeriesTypeLine;} - -public: int add(qreal x, qreal y); void set(int index,qreal x,qreal y); void clear(); @@ -27,6 +25,9 @@ public: void setPen(const QPen& pen); const QPen& pen() const { return m_pen;} + void pointsVisible(bool visible); + bool isPointsVisible() const {return m_pointsVisible;} + int count() const; qreal x(int pos) const; qreal y(int pos) const; @@ -39,6 +40,7 @@ private: QVector m_x; QVector m_y; QPen m_pen; + bool m_pointsVisible; }; QTCOMMERCIALCHART_END_NAMESPACE