diff --git a/doc/src/classes.qdoc b/doc/src/classes.qdoc index 11f9e79..19c614b 100644 --- a/doc/src/classes.qdoc +++ b/doc/src/classes.qdoc @@ -29,6 +29,7 @@
  • QSeries
  • QSplineSeries
  • QStackedBarSeries
  • +
  • QXYSeries
  • diff --git a/src/qchart.cpp b/src/qchart.cpp index 6d6cb07..83d187d 100644 --- a/src/qchart.cpp +++ b/src/qchart.cpp @@ -112,7 +112,7 @@ void QChart::setChartBackgroundPen(const QPen& pen) } /*! - Sets the chart \a title. The description text that is rendered above the chart. + Sets the chart \a title. The description text that is drawn above the chart. */ void QChart::setChartTitle(const QString& title) { @@ -121,7 +121,7 @@ void QChart::setChartTitle(const QString& title) } /*! - Gets the chart \a title. The description text that is rendered above the chart. + Returns the chart title. The description text that is drawn above the chart. */ QString QChart::chartTitle() const { diff --git a/src/qchartview.cpp b/src/qchartview.cpp index 8890c0b..1ee6fb6 100644 --- a/src/qchartview.cpp +++ b/src/qchartview.cpp @@ -134,7 +134,7 @@ int QChartView::margin() const } /*! - Sets the chart \a title. A description text that is rendered above the chart. + Sets the chart \a title. A description text that is drawn above the chart. */ void QChartView::setChartTitle(const QString& title) { @@ -142,7 +142,7 @@ void QChartView::setChartTitle(const QString& title) } /*! - Returns the chart's title. A description text that is rendered above the chart. + Returns the chart's title. A description text that is drawn above the chart. */ QString QChartView::chartTitle() const { diff --git a/src/scatterseries/qscatterseries.cpp b/src/scatterseries/qscatterseries.cpp index 76c3e6c..a2a3c9a 100644 --- a/src/scatterseries/qscatterseries.cpp +++ b/src/scatterseries/qscatterseries.cpp @@ -3,25 +3,23 @@ /*! \class QScatterSeries - \brief QtCommercial Chart series API for showing scatter series. + \brief The QScatterSeries class is used for making scatter charts. \mainclass - Example on how to create a chart with scatter series: - \snippet ../example/scatter/main.cpp 1 + The scatter data is displayed as a collection of points on the chart. Each point determines the position on the horizontal axis + and the vertical axis. - The example code would result the following: + \image scatterchart.png - \image scatter_example1.jpg - - To customize the graphical representation of the series, you can modify pen, brush, shape and - size of the marker items. For example: - - \snippet ../example/scatter/main.cpp 3 - - Would present your scatter markers as big rectangles with opaque, uglyish green outlines and - opaque red filling instead of the beatiful markers defined by the chart's theme: - \image scatter_example_custom.jpg + Creating basic scatter chart is simple: + \code + QScatterSeries* series = new QScatterSeries(); + series->add(0, 6); + series->add(2, 4); + ... + chartView->addSeries(series); + \endcode */ /*! @@ -41,13 +39,12 @@ /*! \fn QChartSeriesType QScatterSeries::type() const \brief Returns QChartSeries::SeriesTypeScatter. + \sa QSeries, QSeriesType */ /*! - \fn void QScatterSeries::clicked(QPointF coordinate) - User clicked the scatter series. Note that the \a coordinate is the chart coordinate that the - click occurred on; not necessarily a data point coordinate. To find the corresponding (closest) - data point you can use closestPoint(). + \fn void QScatterSeries::clicked(const QPointF& point) + \brief Signal is emitted when user clicks the \a point on scatter chart. */ QTCOMMERCIALCHART_BEGIN_NAMESPACE @@ -69,101 +66,6 @@ QScatterSeries::~QScatterSeries() { } - - -/*! - Stream operator for adding a data point with \a value to the series. - \sa add() - - For example: - \snippet ../example/scatter/main.cpp 2 -*/ - - -/*! - Stream operator for adding a list of points to the series. - \sa add() -*/ - - -/*! - Replaces the data of the series with the given list of data \a points. -*/ - - -/*! - Returns the current list of data points of the series. -*/ - -/*! - Replaces the point at \a index with \a newPoint. Returns true if \a index is a valid position - in the series data, false otherwise. -*/ - - -/*! - Remove the data point at \a index. Returns true if a point was removed, false if the point - at \a index does not exist on the series. -*/ - - -/*! - Remove all occurrences of \a point from the series and returns the number of points removed. -*/ - - -/*! - Remove all data points from the series. -*/ - -/*! - Returns the index of the data point that is closest to \a coordinate. If several data points - are at the same distance from the \a coordinate, returns the last one. If no points exist, - returns -1. - -int QScatterSeries::closestPoint(QPointF coordinate) -{ - qreal distance(-1); - int pointIndex(-1); - for (int i(0); i < d->m_data.count(); i++) { - QPointF dataPoint = d->m_data.at(i); - QPointF difference = dataPoint - coordinate; - if (i == 0 || difference.manhattanLength() <= distance) { - distance = difference.manhattanLength(); - pointIndex = i; - } - } - return pointIndex; -} -*/ - -/*! - Returns the pen used for drawing markers. -*/ - - -/*! - Overrides the default pen used for drawing a marker item with a user defined \a pen. The - default pen is defined by chart theme setting. - - \sa setBrush() - \sa QChart::setChartTheme() -*/ - - -/*! - Returns the brush used for drawing markers. -*/ - - -/*! - Overrides the default brush of the marker items with a user defined \a brush. The default brush - is defined by chart theme setting. - - \sa setPen() - \sa QChart::setChartTheme() -*/ - /*! Returns the shape used for drawing markers. */ diff --git a/src/scatterseries/qscatterseries.h b/src/scatterseries/qscatterseries.h index 9f3eb3f..57f4a24 100644 --- a/src/scatterseries/qscatterseries.h +++ b/src/scatterseries/qscatterseries.h @@ -34,15 +34,13 @@ public: // from QChartSeries QSeriesType type() const { return QSeries::SeriesTypeScatter; } public: - //int closestPoint(QPointF coordinate); - MarkerShape shape() const; void setShape(MarkerShape shape); qreal size() const; void setSize(qreal size); signals: - void clicked(QPointF coordinate); + void clicked(const QPointF& point); private: MarkerShape m_shape; diff --git a/src/xychart/qxyseries.cpp b/src/xychart/qxyseries.cpp index f53a275..e46f709 100644 --- a/src/xychart/qxyseries.cpp +++ b/src/xychart/qxyseries.cpp @@ -8,12 +8,6 @@ QTCOMMERCIALCHART_BEGIN_NAMESPACE */ /*! - \fn virtual QSeriesType QXYSeries::type() const - \brief Returns type of series. - \sa QSeries, QSeriesType -*/ - -/*! \fn QPen QXYSeries::pen() const \brief Returns pen used to draw points for series. \sa setPen() @@ -81,6 +75,17 @@ void QXYSeries::add(const QPointF& point) } /*! + This is an overloaded function. + Adds list of data \a points to the series. Points are connected with lines on the chart. + */ +void QXYSeries::add(const QList points) +{ + foreach(const QPointF& point , points) { + add(point.x(),point.y()); + } +} + +/*! Modifies \a y value for given \a x a value. */ void QXYSeries::replace(qreal x,qreal y) @@ -120,9 +125,9 @@ void QXYSeries::remove(const QPointF& point) } /*! - Clears all the data. + Removes all data points from the series. */ -void QXYSeries::clear() +void QXYSeries::removeAll() { m_x.clear(); m_y.clear(); @@ -156,7 +161,9 @@ int QXYSeries::count() const } /*! - Sets \a pen used for drawing points on the chart. + Sets \a pen used for drawing points on the chart. If the pen is not defined, the + pen from chart theme is used. + \sa QChart::setChartTheme() */ void QXYSeries::setPen(const QPen& pen) { @@ -167,7 +174,9 @@ void QXYSeries::setPen(const QPen& pen) } /*! - Sets \a brush used for drawing points on the chart. + Sets \a brush used for drawing points on the chart. If the brush is not defined, brush + from chart theme setting is used. + \sa QChart::setChartTheme() */ void QXYSeries::setBrush(const QBrush& brush) @@ -191,6 +200,18 @@ QXYSeries& QXYSeries::operator<< (const QPointF &point) } +/*! + Stream operator for adding a list of \a points to the series. + \sa add() +*/ + +QXYSeries& QXYSeries::operator<< (const QList points) +{ + add(points); + return *this; +} + + #include "moc_qxyseries.cpp" QTCOMMERCIALCHART_END_NAMESPACE diff --git a/src/xychart/qxyseries.h b/src/xychart/qxyseries.h index 34bb244..f665038 100644 --- a/src/xychart/qxyseries.h +++ b/src/xychart/qxyseries.h @@ -19,24 +19,19 @@ protected: public: void add(qreal x, qreal y); void add(const QPointF& point); + void add(const QList points); void replace(qreal x,qreal y); void replace(const QPointF& point); void remove(qreal x); void remove(const QPointF& point); - void clear(); + void removeAll(); int count() const; qreal x(int pos) const; qreal y(int pos) const; QXYSeries& operator << (const QPointF &point); - /* - void add(QList points); - void setData(QList points); - QScatterSeries& operator << (const QPointF &value); - QScatterSeries& operator << (QList points); - int removeAll(QPointF point); - */ + QXYSeries& operator << (const QList points); void setPen(const QPen& pen); QPen pen() const {return m_pen;}