qscatterseries.cpp
118 lines
| 2.8 KiB
| text/x-c
|
CppLexer
Jani Honkonen
|
r794 | /**************************************************************************** | ||
** | ||||
** Copyright (C) 2012 Digia Plc | ||||
** All rights reserved. | ||||
** For any questions to Digia, please use contact form at http://qt.digia.com | ||||
** | ||||
** This file is part of the Qt Commercial Charts Add-on. | ||||
** | ||||
** $QT_BEGIN_LICENSE$ | ||||
** Licensees holding valid Qt Commercial licenses may use this file in | ||||
** accordance with the Qt Commercial License Agreement provided with the | ||||
** Software or, alternatively, in accordance with the terms contained in | ||||
** a written agreement between you and Digia. | ||||
** | ||||
** If you have questions regarding the use of this file, please use | ||||
** contact form at http://qt.digia.com | ||||
** $QT_END_LICENSE$ | ||||
** | ||||
****************************************************************************/ | ||||
Tero Ahola
|
r42 | #include "qscatterseries.h" | ||
#include "qchart.h" | ||||
Tero Ahola
|
r300 | /*! | ||
\class QScatterSeries | ||||
Michal Klocek
|
r481 | \brief The QScatterSeries class is used for making scatter charts. | ||
Tero Ahola
|
r42 | |||
Tero Ahola
|
r300 | \mainclass | ||
Michal Klocek
|
r481 | 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. | ||||
Tero Ahola
|
r300 | |||
Michal Klocek
|
r481 | \image scatterchart.png | ||
Tero Ahola
|
r300 | |||
Michal Klocek
|
r481 | Creating basic scatter chart is simple: | ||
\code | ||||
QScatterSeries* series = new QScatterSeries(); | ||||
Jani Honkonen
|
r796 | series->append(0, 6); | ||
series->append(2, 4); | ||||
Michal Klocek
|
r481 | ... | ||
chartView->addSeries(series); | ||||
\endcode | ||||
Tero Ahola
|
r300 | */ | ||
Tero Ahola
|
r42 | |||
Tero Ahola
|
r261 | /*! | ||
\enum QScatterSeries::MarkerShape | ||||
This enum describes the shape used when rendering marker items. | ||||
\value MarkerShapeCircle | ||||
Michal Klocek
|
r541 | \value MarkerShapeRectangle | ||
Tero Ahola
|
r261 | */ | ||
Tero Ahola
|
r260 | /*! | ||
Tero Ahola
|
r300 | \fn QChartSeriesType QScatterSeries::type() const | ||
\brief Returns QChartSeries::SeriesTypeScatter. | ||||
Michal Klocek
|
r481 | \sa QSeries, QSeriesType | ||
Tero Ahola
|
r300 | */ | ||
Tero Ahola
|
r260 | |||
Tero Ahola
|
r300 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | ||
Tero Ahola
|
r261 | /*! | ||
Constructs a series object which is a child of \a parent. | ||||
*/ | ||||
Tero Ahola
|
r158 | QScatterSeries::QScatterSeries(QObject *parent) : | ||
Michal Klocek
|
r470 | QXYSeries(parent), | ||
Michal Klocek
|
r541 | m_shape(QScatterSeries::MarkerShapeCircle), | ||
Tero Ahola
|
r702 | m_size(15.0) | ||
Tero Ahola
|
r42 | { | ||
} | ||||
Tero Ahola
|
r260 | /*! | ||
Tero Ahola
|
r261 | Destroys the object. Note that adding series to QChart transfers the ownership to the chart. | ||
Tero Ahola
|
r260 | */ | ||
Tero Ahola
|
r158 | QScatterSeries::~QScatterSeries() | ||
Tero Ahola
|
r42 | { | ||
Tero Ahola
|
r48 | } | ||
Tero Ahola
|
r261 | /*! | ||
Tero Ahola
|
r459 | Returns the shape used for drawing markers. | ||
Tero Ahola
|
r261 | */ | ||
Tero Ahola
|
r459 | QScatterSeries::MarkerShape QScatterSeries::shape() const | ||
Tero Ahola
|
r195 | { | ||
Michal Klocek
|
r573 | return m_shape; | ||
Tero Ahola
|
r195 | } | ||
Tero Ahola
|
r261 | /*! | ||
Tero Ahola
|
r300 | Overrides the default shape of the marker items with a user defined \a shape. The default shape | ||
is defined by chart theme setting. | ||||
Tero Ahola
|
r261 | */ | ||
Tero Ahola
|
r358 | void QScatterSeries::setShape(MarkerShape shape) | ||
Tero Ahola
|
r195 | { | ||
sauimone
|
r743 | if (m_shape != shape) { | ||
m_shape = shape; | ||||
Michal Klocek
|
r573 | emit QXYSeries::updated(); | ||
} | ||||
Tero Ahola
|
r195 | } | ||
Tero Ahola
|
r397 | /*! | ||
Returns the size of the marker items. | ||||
*/ | ||||
Tero Ahola
|
r459 | qreal QScatterSeries::size() const | ||
Tero Ahola
|
r397 | { | ||
Michal Klocek
|
r470 | return m_size; | ||
Tero Ahola
|
r397 | } | ||
/*! | ||||
Tero Ahola
|
r814 | Set the \a size of the marker items. The default size is 15. | ||
Tero Ahola
|
r397 | */ | ||
void QScatterSeries::setSize(qreal size) | ||||
{ | ||||
Jani Honkonen
|
r768 | if (!qFuzzyIsNull(m_size - size)) { | ||
sauimone
|
r743 | m_size = size; | ||
Michal Klocek
|
r573 | emit updated(); | ||
} | ||||
Tero Ahola
|
r397 | } | ||
Tero Ahola
|
r42 | QTCOMMERCIALCHART_END_NAMESPACE | ||