IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)

QXYSeries Class

L'auteur

Liens sociaux

Viadeo Twitter Facebook Share on Google+   

QXYSeries Class

Detailed Description

QXYSeries supports displaying best fit line on a chart. Best fit line is a line through a chart that expresses the relationship between points.

Member Type Documentation

 

enum QXYSeries::PointConfiguration

This enum value describes the particular configuration of a point.

Constant

Value

Description

QXYSeries::PointConfiguration::Color

0

This enum value can be used to change a point's color. If used together with QXYSeries::setPointConfiguration, the configuration's value should be a valid QColor.

QXYSeries::PointConfiguration::Size

1

This enum value can be used to change a point's size. If used together with QXYSeries::setPointConfiguration, the configuration's value should be a number, such as qreal or int.

QXYSeries::PointConfiguration::Visibility

2

This enum value can be used to hide or show the point. If used together with QXYSeries::setPointConfiguration, the configuration's value should be boolean.

QXYSeries::PointConfiguration::LabelVisibility

3

This enum value can be used to hide or show the label of the point. If used together with QXYSeries::setPointConfiguration, the configuration's value should be boolean.

See Also

Property Documentation

 

[since 6.2] bestFitLineColor : QColor

This property holds the color of best fit line.

This property was introduced in Qt 6.2.

Access functions:

  • bestFitLineColor() const

  • void setBestFitLineColor(const &color)

Notifier signal:

See Also

[since 6.2] bestFitLineVisible : bool

This property holds the visibility of the best fit line.

This property is false by default.

This property was introduced in Qt 6.2.

Access functions:

  • bool bestFitLineVisible() const

  • void setBestFitLineVisible(bool visible = true)

Notifier signal:

See Also

color : QColor

This property holds the color of the series.

This is the line (pen) color in case of QLineSeries or QSplineSeries and the fill (brush) color in case of QScatterSeries or QAreaSeries.

Access functions:

  • virtual color() const

  • virtual void setColor(const &color)

Notifier signal:

See Also

See also pen(), brush()

pointLabelsClipping : bool

This property holds the clipping for data point labels.

This property is true by default. The labels on the edge of the plot area are cut when clipping is enabled.

Access functions:

  • bool pointLabelsClipping() const

  • void setPointLabelsClipping(bool enabled = true)

Notifier signal:

See Also

pointLabelsColor : QColor

This property holds the color used for data point labels. By default, the color is the color of the brush defined in theme for labels.

Access functions:

  • pointLabelsColor() const

  • void setPointLabelsColor(const &color)

Notifier signal:

See Also

pointLabelsFont : QFont

This property holds the font used for data point labels.

Access functions:

  • pointLabelsFont() const

  • void setPointLabelsFont(const &font)

Notifier signal:

See Also

pointLabelsFormat : QString

This property holds the format used for showing labels with data points.

QXYSeries supports the following format tags:

@xPoint

The x-coordinate of the data point.

@yPoint

The y-coordinate of the data point.

For example, the following usage of the format tags would produce labels that display the data point shown inside brackets separated by a comma (x, y):

 
Sélectionnez
series->setPointLabelsFormat("(@xPoint, @yPoint)");

By default, the labels' format is set to @xPoint, @yPoint. The labels are shown on the plot area, and the labels on the edge of the plot area are cut. If the points are close to each other, the labels may overlap.

Access functions:

  • pointLabelsFormat() const

  • void setPointLabelsFormat(const &format)

Notifier signal:

See Also

pointLabelsVisible : bool

This property holds the visibility of data point labels.

This property is false by default.

Access functions:

  • bool pointLabelsVisible() const

  • void setPointLabelsVisible(bool visible = true)

Notifier signal:

See Also

pointsVisible : bool

This property holds whether the data points are visible and should be drawn.

Access functions:

  • bool pointsVisible() const

  • void setPointsVisible(bool visible = true)

[since 6.2] selectedColor : QColor

This property holds the color of the selected points.

This is the fill (brush) color of points marked as selected. If not specified, value of QXYSeries::color is used as default.

This property was introduced in Qt 6.2.

Access functions:

  • virtual color() const

  • void setSelectedColor(const &color)

Notifier signal:

  • void selectedColorChanged(const &color)

See Also

See also color

Member Function Documentation

 

[virtual] QXYSeries::~QXYSeries()

Deletes the series. Series added to QChart instances are owned by them, and are deleted when the QChart instances are deleted.

void QXYSeries::append(qreal x, qreal y)

Adds the data point with the coordinates x and y to the series.

void QXYSeries::append(const QPointF &point)

This is an overloaded function.

Adds the data point point to the series.

void QXYSeries::append(const QList<QPointF> &points)

This is an overloaded function.

Adds the list of data points specified by points to the series.

const QPointF &QXYSeries::at(int index) const

Returns the data point at the position specified by index in the internal series of points.

void QXYSeries::bestFitLineColorChanged(const QColor &color)

This signal is emitted when the color used for the best fit line changes to color.

Notifier signal for property bestFitLineColor.

[since 6.2] QPair<qreal, qreal> QXYSeries::bestFitLineEquation(bool &ok) const

Returns a pair of numbers where the first number is a slope factor and the second number is intercept of a linear function for a best fit line.

Those factors are calculated using Least Squares Method based on points passed to the series.

Parameter ok is used to report a failure by setting its value to false and to report a success by setting its value to true.

This function was introduced in Qt 6.2.

See Also

void QXYSeries::bestFitLineVisibilityChanged(bool visible)

This signal is emitted when the visibility of the best fit line changes to visible.

Notifier signal for property bestFitLineVisible.

QBrush QXYSeries::brush() const

Returns the brush used to fill the data points for the series.

See Also

See also setBrush()

void QXYSeries::clear()

Removes all points from the series.

See Also

See also pointsRemoved()

[since 6.2] void QXYSeries::clearPointConfiguration(const int index)

Removes the configuration of a point located at index and restores the default look derived from the series' settings.

It doesn't affect the configuration of other points.

This function was introduced in Qt 6.2.

See Also

[since 6.2] void QXYSeries::clearPointConfiguration(const int index, const QXYSeries::PointConfiguration key)

Removes the configuration property identified by key from the point at index and restores the default look derived from the series' settings.

Removes the configuration type, such as color or size, specified by key from the point at index with configuration customizations, allowing that configuration property to be rendered as the default specified in the series' properties.

It doesn't affect the configuration of other points.

This function was introduced in Qt 6.2.

See Also

[since 6.2] void QXYSeries::clearPointsConfiguration()

Removes the configuration of all points in the series and restores the default look derived from the series' settings.

This function was introduced in Qt 6.2.

See Also

[since 6.2] void QXYSeries::clearPointsConfiguration(const QXYSeries::PointConfiguration key)

Removes the configuration property identified by key from all points and restores the default look derived from the series' settings.

Removes the configuration type, such as color or size, specified by key from all points with configuration customizations, allowing that configuration property to be rendered as the default specified in the series properties.

This function was introduced in Qt 6.2.

See Also

void QXYSeries::clicked(const QPointF &point)

This signal is emitted when the user triggers a mouse event by clicking the point point in the chart.

See Also

See also pressed(), released(), doubleClicked()

[since 6.2] void QXYSeries::colorBy(const QList<qreal> &sourceData, const QLinearGradient &gradient = QLinearGradient())

Sets the points' color according to a passed list of values. Values from sourceData are sorted and mapped to the gradient.

If the series has a QColorAxis attached, then a gradient from the axis is going to be used.

This function was introduced in Qt 6.2.

See Also

void QXYSeries::colorChanged(QColor color)

This signal is emitted when the line (pen) color changes to color.

Notifier signal for property color.

int QXYSeries::count() const

Returns the number of data points in a series.

[since 6.2] void QXYSeries::deselectAllPoints()

Deselects all points in the series.

Emits QXYSeries::selectedPointsChanged

This function was introduced in Qt 6.2.

See Also

See also setPointSelected()

[since 6.2] void QXYSeries::deselectPoint(int index)

Deselects point at given index.

Emits QXYSeries::selectedPointsChanged

This function was introduced in Qt 6.2.

See Also

See also setPointSelected()

[since 6.2] void QXYSeries::deselectPoints(const QList<int> &indexes)

Marks multiple points passed in a indexes list as deselected.

Emits QXYSeries::selectedPointsChanged

This function was introduced in Qt 6.2.

See Also

See also setPointSelected()

void QXYSeries::doubleClicked(const QPointF &point)

This signal is emitted when the user double-clicks the data point point in the chart. The point is the point where the first press was triggered.

See Also

See also pressed(), released(), clicked()

void QXYSeries::hovered(const QPointF &point, bool state)

This signal is emitted when a mouse is hovered over the point point in the chart. When the mouse moves over the point, state turns true, and when the mouse moves away again, it turns false.

void QXYSeries::insert(int index, const QPointF &point)

Inserts the data point point in the series at the position specified by index.

See Also

See also pointAdded()

[since 6.2] bool QXYSeries::isPointSelected(int index)

Returns true if point at given index is among selected points and false otherwise.

Selected points are drawn using the selected color if it was specified.

This function was introduced in Qt 6.2.

See Also

[since 6.2] const QImage &QXYSeries::lightMarker() const

Gets the image used for drawing markers on each point of the series.

The default value is QImage(), meaning no light marker will be painted.

The light markers visualize the data points of this series and as such are an alternative to setPointsVisible(true). Both features can be enabled independently from each other.

Unlike the elements of QScatterSeries the light markers are not represented by QGraphicsItem, but are just painted (no objects created). However, the mouse-event-signals of QXYSeries behave the same way, meaning that you'll get the exact domain value of the point if you click/press/hover the light marker. You'll still get the in between domain value if you click on the line. The light markers are above the line in terms of painting as well as events.

This function was introduced in Qt 6.2.

See Also

[since 6.2] void QXYSeries::lightMarkerChanged(const QImage &lightMarker)

This signal is emitted when the light marker image changes to lightMarker.

This function was introduced in Qt 6.2.

See Also

[since 6.2] qreal QXYSeries::markerSize() const

Gets the size of the marker used to render points in the series.

The default size depends on the specific QXYSeries type. QScatterSeries has a default of 15.0 QLineSeries has a default of the series pen size * 1.5

This function was introduced in Qt 6.2.

See Also

void QXYSeries::markerSizeChanged(qreal size)

This signal is emitted when the marker size changes to size.

QPen QXYSeries::pen() const

Returns the pen used to draw the outline of the data points for the series.

See Also

See also setPen()

void QXYSeries::penChanged(const QPen &pen)

This signal is emitted when the pen changes to pen.

void QXYSeries::pointAdded(int index)

This signal is emitted when a point is added at the position specified by index.

See Also

See also append(), insert()

[since 6.2] QHash<QXYSeries::PointConfiguration, QVariant> QXYSeries::pointConfiguration(const int index) const

Returns a map representing the configuration of a point at index.

With points configuration you can change various aspects of each point's look.

This function was introduced in Qt 6.2.

See Also

void QXYSeries::pointLabelsClippingChanged(bool clipping)

This signal is emitted when the clipping of the data point labels changes to clipping.

Notifier signal for property pointLabelsClipping.

void QXYSeries::pointLabelsColorChanged(const QColor &color)

This signal is emitted when the color used for data point labels changes to color.

Notifier signal for property pointLabelsColor.

void QXYSeries::pointLabelsFontChanged(const QFont &font)

This signal is emitted when the font used for data point labels changes to font.

Notifier signal for property pointLabelsFont.

void QXYSeries::pointLabelsFormatChanged(const QString &format)

This signal is emitted when the format of data point labels changes to format.

Notifier signal for property pointLabelsFormat.

void QXYSeries::pointLabelsVisibilityChanged(bool visible)

This signal is emitted when the visibility of the data point labels changes to visible.

Notifier signal for property pointLabelsVisible.

void QXYSeries::pointRemoved(int index)

This signal is emitted when a point is removed from the position specified by index.

See Also

See also remove()

void QXYSeries::pointReplaced(int index)

This signal is emitted when a point is replaced at the position specified by index.

See Also

See also replace()

QList<QPointF> QXYSeries::points() const

Returns the points in the series.

[since 6.2] QHash<int, QHash<QXYSeries::PointConfiguration, QVariant>> QXYSeries::pointsConfiguration() const

Returns a map with points' indexes as keys and points' configuration as values.

This function was introduced in Qt 6.2.

See Also

void QXYSeries::pointsRemoved(int index, int count)

This signal is emitted when the number of points specified by count is removed starting at the position specified by index.

See Also

See also removePoints(), clear()

void QXYSeries::pointsReplaced()

This signal is emitted when all points are replaced with other points.

See Also

See also replace()

void QXYSeries::pressed(const QPointF &point)

This signal is emitted when the user presses the data point point in the chart and holds down the mouse button.

See Also

See also clicked(), released(), doubleClicked()

void QXYSeries::released(const QPointF &point)

This signal is emitted when the user releases the mouse press on the data point specified by point.

See Also

See also pressed(), clicked(), doubleClicked()

void QXYSeries::remove(qreal x, qreal y)

Removes the point that has the coordinates x and y from the series.

See Also

See also pointRemoved()

void QXYSeries::remove(const QPointF &point)

Removes the data point point from the series.

See Also

See also pointRemoved()

void QXYSeries::remove(int index)

Removes the point at the position specified by index from the series.

See Also

See also pointRemoved()

void QXYSeries::removePoints(int index, int count)

Removes the number of points specified by count from the series starting at the position specified by index.

See Also

See also pointsRemoved()

void QXYSeries::replace(qreal oldX, qreal oldY, qreal newX, qreal newY)

Replaces the point with the coordinates oldX and oldY with the point with the coordinates newX and newY. Does nothing if the old point does not exist.

See Also

See also pointReplaced()

void QXYSeries::replace(const QPointF &oldPoint, const QPointF &newPoint)

Replaces the point specified by oldPoint with the one specified by newPoint.

See Also

See also pointReplaced()

void QXYSeries::replace(int index, qreal newX, qreal newY)

Replaces the point at the position specified by index with the point that has the coordinates newX and newY.

See Also

See also pointReplaced()

void QXYSeries::replace(int index, const QPointF &newPoint)

Replaces the point at the position specified by index with the point specified by newPoint.

See Also

See also pointReplaced()

void QXYSeries::replace(const QList<QPointF> &points)

Replaces the current points with the points specified by points.

This is much faster than replacing data points one by one, or first clearing all data, and then appending the new data. Emits QXYSeries::pointsReplaced() when the points have been replaced.

See Also

See also pointsReplaced()

[since 6.2] void QXYSeries::selectAllPoints()

Marks all points in the series as selected,

Emits QXYSeries::selectedPointsChanged

This function was introduced in Qt 6.2.

See Also

See also setPointSelected()

[since 6.2] void QXYSeries::selectPoint(int index)

Marks point at index as selected.

Emits QXYSeries::selectedPointsChanged

This function was introduced in Qt 6.2.

See Also

See also setPointSelected()

[since 6.2] void QXYSeries::selectPoints(const QList<int> &indexes)

Marks multiple points passed in a indexes list as selected.

Emits QXYSeries::selectedPointsChanged

This function was introduced in Qt 6.2.

See Also

See also setPointSelected()

[since 6.2] const QImage &QXYSeries::selectedLightMarker() const

Returns the image used for drawing markers on selected series' points.

The default value is QImage(), meaning usual lightMarker() will be painted.

This is equivalent to selectedColor if you prefer light markers over normal points, but still want to distinguish selected points.

This function was introduced in Qt 6.2.

See Also

[since 6.2] QList<int> QXYSeries::selectedPoints() const

Returns a list of points indexes marked as selected. Selected points are visible regardless of points visibility.

This function was introduced in Qt 6.2.

See Also

[virtual] void QXYSeries::setBrush(const QBrush &brush)

Sets the brush used for drawing points on the chart to brush. If the brush is not defined, the brush from the chart theme setting is used.

See Also

See also brush(), QChart::setTheme()

[since 6.2] void QXYSeries::setLightMarker(const QImage &lightMarker)

Sets the image used for drawing markers on each point of the series as the value of lightMarker.

The default value is a default-QImage() (QImage::isNull() == true), meaning no light marker will be painted. You can reset back to default (disabled) by calling this function with a null QImage (QImage()).

The light markers visualize the data points of this series and as such are an alternative to setPointsVisible(true). If a light marker is set with this method, visible points as set with setPointsVisible(true) are not displayed.

Unlike the elements of QScatterSeries the light markers are not represented by QGraphicsItem, but are just painted (no objects created). However, the mouse-event-signals of QXYSeries behave the same way, meaning that you'll get the exact domain value of the point if you click/press/hover the light marker. You'll still get the in between domain value if you click on the line. The light markers are above the line in terms of painting as well as events.

This function was introduced in Qt 6.2.

See Also

[since 6.2] void QXYSeries::setMarkerSize(qreal size)

Sets the size of the marker used to render points in the series.

The default size is 15.0.

This function was introduced in Qt 6.2.

See Also

[virtual] void QXYSeries::setPen(const QPen &pen)

Sets the pen used for drawing points on the chart to pen. If the pen is not defined, the pen from the chart theme is used.

See Also

See also pen(), QChart::setTheme()

[since 6.2] void QXYSeries::setPointConfiguration(const int index, const QHash<QXYSeries::PointConfiguration, QVariant> &configuration)

Enables customizing the appearance of a point located at index with desired configuration.

With points configuration you can change various aspects of every point's appearance.

A point's configuration is represented as a hash map with QXYSeries::pointConfiguration keys and QVariant values. For example:

 
Sélectionnez
QLineSeries *series = new QLineSeries();
series-&gt;setName("Customized serie");
series-&gt;setPointsVisible(true);

*series &lt;&lt; QPointF(0, 6) &lt;&lt; QPointF(2, 4) &lt;&lt; QPointF(3, 6) &lt;&lt; QPointF(7, 4) &lt;&lt; QPointF(10, 5)
        &lt;&lt; QPointF(11, 1) &lt;&lt; QPointF(13, 3) &lt;&lt; QPointF(17, 6) &lt;&lt; QPointF(18, 3)
        &lt;&lt; QPointF(20, 2);

QChart *chart = new QChart();
chart-&gt;addSeries(series);
chart-&gt;createDefaultAxes();

QHash&lt;QXYSeries::PointConfiguration, QVariant&gt; conf;
conf[QXYSeries::PointConfiguration::Color] = QColor(Qt::red);
conf[QXYSeries::PointConfiguration::Size] = 8;
conf[QXYSeries::PointConfiguration::LabelVisibility] = true;

series-&gt;setPointConfiguration(4, conf);

conf.remove(QXYSeries::PointConfiguration::LabelVisibility);
series-&gt;setPointConfiguration(6, conf);

In this example, you can see a default QLineSeries with 10 points and with changed configuration of two points. Both changed points are red and visibly bigger than the others with a look derived from series. By default, points don't have labels, but the point at index 4 has the label thanks to the QXYSeries::PointConfiguration::LabelVisibility configuration value. Below is an example of a chart created in this way:

Image non disponible

This function was introduced in Qt 6.2.

See Also

[since 6.2] void QXYSeries::setPointConfiguration(const int index, const QXYSeries::PointConfiguration key, const QVariant &value)

Enables customizing a particular aspect of a point's configuration.

Points configuration concept provides a flexible way to configure various aspects of a point's appearance. Thus, values need to have an elastic type such as QVariant. See QXYSeries::PointConfiguration to see what value should be passed for certain key.

This function was introduced in Qt 6.2.

See Also

See also pointsConfiguration()

[since 6.2] void QXYSeries::setPointSelected(int index, bool selected)

Marks point at given index as either selected or deselected as specified by selected.

Selected points are drawn using the selected color if it was specified. Emits QXYSeries::selectedPointsChanged

This function was introduced in Qt 6.2.

See Also

See also isPointSelected(), setPointSelected(), setSelectedColor()

[since 6.2] void QXYSeries::setPointsConfiguration(const QHash<int, QHash<QXYSeries::PointConfiguration, QVariant>> &pointsConfiguration)

Enables customizing the configuration of multiple points as specified by pointsConfiguration.

This function was introduced in Qt 6.2.

See Also

See also pointsConfiguration()

[since 6.2] void QXYSeries::setSelectedLightMarker(const QImage &selectedLightMarker)

Sets the image used for drawing markers on selected series's points to selectedLightMarker.

The default value is QImage(), meaning usual lightMarker() will be painted.

This is an equivalent for selectedColor if you prefer light markers over normal points, but still want to distinguish selected points.

This function was introduced in Qt 6.2.

See Also

[since 6.2] void QXYSeries::sizeBy(const QList<qreal> &sourceData, const qreal minSize, const qreal maxSize)

Sets the points' sizes according to a passed list of values. Values from sourceData are sorted and mapped to a point size which is between minSize and maxSize.

If sourceData length is smaller than number of points in the series, then size of the points at the end of the series will stay the same.

This function was introduced in Qt 6.2.

See Also

[since 6.2] void QXYSeries::toggleSelection(const QList<int> &indexes)

Changes selection state of points at given indexes to the opposite one. Makes

Emits QXYSeries::selectedPointsChanged

This function was introduced in Qt 6.2.

See Also

See also setPointSelected()

QXYSeries &QXYSeries::operator<<(const QPointF &point)

Stream operator for adding the data point point to the series.

See Also

See also append()

QXYSeries &QXYSeries::operator<<(const QList<QPointF> &points)

Stream operator for adding the list of data points specified by points to the series.

See Also

See also append()

Obsolete Members for QXYSeries

The following members of class QXYSeries are deprecated. We strongly advise against using them in new code.

Obsolete Member Function Documentation

 
QList<QPointF> QXYSeries::pointsVector() const

This function is deprecated. We strongly advise against using it in new code.

Use points() instead. Returns the points in the series.

Vous avez aimé ce tutoriel ? Alors partagez-le en cliquant sur les boutons suivants : Viadeo Twitter Facebook Share on Google+