- class QXYSeries#
The
QXYSeries
class is a base class for line, spline, and scatter series. More…Inherited by:
QScatterSeries
,QLineSeries
,QSplineSeries
Synopsis#
Properties#
bestFitLineColorᅟ
- Color of best fit linebestFitLineVisibleᅟ
- Visibility of the best fit linecolorᅟ
- Of the seriespointLabelsClippingᅟ
- Clipping for data point labelspointLabelsColorᅟ
- Color used for data point labels. By default, the color is the color of the brush defined in theme for labelspointLabelsFontᅟ
- Font used for data point labelspointLabelsFormatᅟ
- Format used for showing labels with data pointspointLabelsVisibleᅟ
- Visibility of data point labelspointsVisibleᅟ
- Whether the data points are visible and should be drawnselectedColorᅟ
- Color of the selected points
Methods#
def
append()
def
at()
def
bestFitLinePen()
def
brush()
def
clear()
def
colorBy()
def
count()
def
deselectPoint()
def
deselectPoints()
def
insert()
def
lightMarker()
def
markerSize()
def
pen()
def
points()
def
pointsVector()
def
pointsVisible()
def
remove()
def
removePoints()
def
replace()
def
selectPoint()
def
selectPoints()
def
selectedColor()
def
selectedPoints()
def
setLightMarker()
def
setMarkerSize()
def
sizeBy()
Virtual methods#
def
color()
def
setBrush()
def
setColor()
def
setPen()
Signals#
def
clicked()
def
colorChanged()
def
doubleClicked()
def
hovered()
def
penChanged()
def
pointAdded()
def
pointRemoved()
def
pointReplaced()
def
pointsRemoved()
def
pointsReplaced()
def
pressed()
def
released()
Note
This documentation may contain snippets that were automatically translated from C++ to Python. We always welcome contributions to the snippet translation. If you see an issue with the translation, you can also let us know by creating a ticket on https:/bugreports.qt.io/projects/PYSIDE
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.- class PointConfiguration#
This enum value describes the particular configuration of a point.
Constant
Description
QXYSeries.PointConfiguration.Color
This enum value can be used to change a point’s color. If used together with
setPointConfiguration
, the configuration’s value should be a valid QColor.QXYSeries.PointConfiguration.Size
This enum value can be used to change a point’s size. If used together with
setPointConfiguration
, the configuration’s value should be a number, such asqreal
orint
.QXYSeries.PointConfiguration.Visibility
This enum value can be used to hide or show the point. If used together with
setPointConfiguration
, the configuration’s value should be boolean.QXYSeries.PointConfiguration.LabelVisibility
This enum value can be used to hide or show the label of the point. If used together with
setPointConfiguration
, the configuration’s value should be boolean.QXYSeries.PointConfiguration.LabelFormat
This enum value can be used to set custom label text per-point. If used together with
setPointConfiguration
, the configuration’s value should be a string.Note
If an empty string is set as the LabelFormat, it will be ignored, and the series
pointLabelsFormat
will be used.See also
Note
Properties can be used directly when
from __feature__ import true_property
is used or via accessor functions otherwise.This property holds The color of best fit line..
See also
- Access functions:
- property bestFitLineVisibleᅟ: bool#
This property holds The visibility of the best fit line..
This property is
false
by default.See also
- Access functions:
This property holds The color of the series..
This is the line (pen) color in case of
QLineSeries
orQSplineSeries
and the fill (brush) color in case ofQScatterSeries
orQAreaSeries
.- Access functions:
Signal
colorChanged()
- property 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.See also
- Access functions:
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..
See also
- Access functions:
This property holds The font used for data point labels..
See also
- Access functions:
- property pointLabelsFormatᅟ: str#
This property holds The format used for showing labels with data points..
QXYSeries
supports the following format tags:@index
The index in the series of the data point. [since 6.5]
@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):
series->setPointLabelsFormat("@index: (@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:
- property pointLabelsVisibleᅟ: bool#
This property holds The visibility of data point labels..
This property is
false
by default.See also
- Access functions:
- property pointsVisibleᅟ: bool#
This property holds Whether the data points are visible and should be drawn..
- Access functions:
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
color
is used as default.See also
- Access functions:
This is an overloaded function.
Adds the data point
point
to the series.- append(points)
- Parameters:
points – .list of QPointF
This is an overloaded function.
Adds the list of data points specified by
points
to the series.- append(x, y)
- Parameters:
x – float
y – float
Adds the data point with the coordinates
x
andy
to the series.Returns the data point at the position specified by
index
in the internal series of points.- bestFitLineColor()#
- Return type:
See also
Getter of property
bestFitLineColorᅟ
.This signal is emitted when the color used for the best fit line changes to
color
.Notification signal of property
bestFitLineColorᅟ
.- bestFitLineEquation(ok)#
- Parameters:
ok – bool
- Return type:
.std.pairqreal,qreal
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 tofalse
and to report a success by setting its value totrue
.See also
- bestFitLineVisibilityChanged(visible)#
- Parameters:
visible – bool
This signal is emitted when the visibility of the best fit line changes to
visible
.Notification signal of property
bestFitLineVisibleᅟ
.- bestFitLineVisible()#
- Return type:
bool
See also
Getter of property
bestFitLineVisibleᅟ
.Returns the brush used to fill the data points for the series.
See also
- clear()#
Removes all points from the series.
See also
- clearPointConfiguration(index)#
- Parameters:
index – int
Removes the configuration of a point located at
index
and restores the default look derived from the series’ settings.Note
It doesn’t affect the configuration of other points.
- clearPointConfiguration(index, key)
- Parameters:
index – int
key –
PointConfiguration
Removes the configuration property identified by
key
from the point atindex
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 atindex
with configuration customizations, allowing that configuration property to be rendered as the default specified in the series’ properties.Note
It doesn’t affect the configuration of other points.
- clearPointsConfiguration()#
Removes the configuration of all points in the series and restores the default look derived from the series’ settings.
See also
- clearPointsConfiguration(key)
- Parameters:
key –
PointConfiguration
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 signal is emitted when the user triggers a mouse event by clicking the point
point
in the chart.See also
- color()#
- Return type:
See also
Getter of property
colorᅟ
.- colorBy(sourceData[, gradient=QLinearGradient()])#
- Parameters:
sourceData – .list of qreal
gradient –
QLinearGradient
Sets the points’ color according to a passed list of values. Values from
sourceData
are sorted and mapped to thegradient
.If the series has a
QColorAxis
attached, then a gradient from the axis is going to be used.This signal is emitted when the line (pen) color changes to
color
.Notification signal of property
colorᅟ
.- count()#
- Return type:
int
Returns the number of data points in a series.
- deselectAllPoints()#
Deselects all points in the series.
- deselectPoint(index)#
- Parameters:
index – int
Deselects point at given
index
.- deselectPoints(indexes)#
- Parameters:
indexes – .list of int
Marks multiple points passed in a
indexes
list as deselected.This signal is emitted when the user double-clicks the data point
point
in the chart. Thepoint
is the point where the first press was triggered.See also
This signal is emitted when a mouse is hovered over the point
point
in the chart. When the mouse moves over the point,state
turnstrue
, and when the mouse moves away again, it turnsfalse
.Inserts the data point
point
in the series at the position specified byindex
.See also
- isPointSelected(index)#
- Parameters:
index – int
- Return type:
bool
Returns true if point at given
index
is among selected points and false otherwise.Note
Selected points are drawn using the selected color if it was specified.
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 ofQXYSeries
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.See also
This signal is emitted when the light marker image changes to
lightMarker
.See also
- markerSize()#
- Return type:
float
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.0QLineSeries
has a default of the series pen size * 1.5See also
setMarkerSize()
markerSize
- markerSizeChanged(size)#
- Parameters:
size – float
This signal is emitted when the marker size changes to
size
.Returns the pen used to draw the outline of the data points for the series.
See also
This signal is emitted when the pen changes to
pen
.- pointAdded(index)#
- Parameters:
index – int
This signal is emitted when a point is added at the position specified by
index
.- pointConfiguration(index)#
- Parameters:
index – int
- Return type:
Dictionary with keys of type .QXYSeries.PointConfiguration and values of type QVariant.
Returns a map representing the configuration of a point at
index
.With points configuration you can change various aspects of each point’s look.
See also
- pointLabelsClipping()#
- Return type:
bool
See also
Getter of property
pointLabelsClippingᅟ
.- pointLabelsClippingChanged(clipping)#
- Parameters:
clipping – bool
This signal is emitted when the clipping of the data point labels changes to
clipping
.Notification signal of property
pointLabelsClippingᅟ
.- pointLabelsColor()#
- Return type:
See also
Getter of property
pointLabelsColorᅟ
.This signal is emitted when the color used for data point labels changes to
color
.Notification signal of property
pointLabelsColorᅟ
.- pointLabelsFont()#
- Return type:
See also
Getter of property
pointLabelsFontᅟ
.This signal is emitted when the font used for data point labels changes to
font
.Notification signal of property
pointLabelsFontᅟ
.- pointLabelsFormat()#
- Return type:
str
See also
Getter of property
pointLabelsFormatᅟ
.- pointLabelsFormatChanged(format)#
- Parameters:
format – str
This signal is emitted when the format of data point labels changes to
format
.Notification signal of property
pointLabelsFormatᅟ
.- pointLabelsVisibilityChanged(visible)#
- Parameters:
visible – bool
This signal is emitted when the visibility of the data point labels changes to
visible
.Notification signal of property
pointLabelsVisibleᅟ
.- pointLabelsVisible()#
- Return type:
bool
See also
Getter of property
pointLabelsVisibleᅟ
.- pointRemoved(index)#
- Parameters:
index – int
This signal is emitted when a point is removed from the position specified by
index
.See also
- pointReplaced(index)#
- Parameters:
index – int
This signal is emitted when a point is replaced at the position specified by
index
.See also
Returns the points in the series.
- pointsConfiguration()#
- Return type:
Dictionary with keys of type .int and values of type QXYSeries.PointConfiguration.
Returns a map with points’ indexes as keys and points’ configuration as values.
- pointsConfigurationChanged(configuration)#
- Parameters:
configuration – Dictionary with keys of type .int and values of type QXYSeries.PointConfiguration.
- pointsRemoved(index, count)#
- Parameters:
index – int
count – int
This signal is emitted when the number of points specified by
count
is removed starting at the position specified byindex
.See also
- pointsReplaced()#
This signal is emitted when all points are replaced with other points.
See also
Use
points()
instead. Returns the points in the series.- pointsVisible()#
- Return type:
bool
See also
Getter of property
pointsVisibleᅟ
.This signal is emitted when the user presses the data point
point
in the chart and holds down the mouse button.See also
This signal is emitted when the user releases the mouse press on the data point specified by
point
.See also
Removes the data point
point
from the series.See also
- remove(index)
- Parameters:
index – int
Removes the point at the position specified by
index
from the series.See also
- remove(x, y)
- Parameters:
x – float
y – float
Removes the point that has the coordinates
x
andy
from the series.See also
- removePoints(index, count)#
- Parameters:
index – int
count – int
Removes the number of points specified by
count
from the series starting at the position specified byindex
.See also
Replaces the point specified by
oldPoint
with the one specified bynewPoint
.See also
- replace(oldX, oldY, newX, newY)
- Parameters:
oldX – float
oldY – float
newX – float
newY – float
Replaces the point with the coordinates
oldX
andoldY
with the point with the coordinatesnewX
andnewY
. Does nothing if the old point does not exist.See also
- replace(index, newX, newY)
- Parameters:
index – int
newX – float
newY – float
Replaces the point at the position specified by
index
with the point that has the coordinatesnewX
andnewY
.See also
- replace(index, newPoint)
- Parameters:
index – int
newPoint –
QPointF
Replaces the point at the position specified by
index
with the point specified bynewPoint
.See also
- replace(points)
- Parameters:
points – .list of QPointF
Replaces the current points with the points specified by
points
.Note
This is much faster than replacing data points one by one, or first clearing all data, and then appending the new data. Emits
pointsReplaced()
when the points have been replaced.See also
- selectAllPoints()#
Marks all points in the series as selected,
- selectPoint(index)#
- Parameters:
index – int
Marks point at
index
as selected.- selectPoints(indexes)#
- Parameters:
indexes – .list of int
Marks multiple points passed in a
indexes
list as selected.Notification signal of property
selectedColorᅟ
.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.- selectedPoints()#
- Return type:
.list of int
Returns a list of points indexes marked as selected. Selected points are visible regardless of points visibility.
See also
- selectedPointsChanged()#
This signal is emitted when the points selection changes.
Setter of property
bestFitLineColorᅟ
.- setBestFitLineVisible([visible=true])#
- Parameters:
visible – bool
See also
Setter of property
bestFitLineVisibleᅟ
.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
Setter of property
colorᅟ
.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 withsetPointsVisible(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 ofQXYSeries
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.See also
- setMarkerSize(size)#
- Parameters:
size – float
Sets the
size
of the marker used to render points in the series.The default size is 15.0.
See also
markerSize
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
- setPointConfiguration(index, configuration)#
- Parameters:
index – int
configuration – Dictionary with keys of type .QXYSeries.PointConfiguration and values of type QVariant.
Enables customizing the appearance of a point located at
index
with desiredconfiguration
.With points configuration you can change various aspects of every point’s appearance.
A point’s configuration is represented as a hash map with
pointConfiguration
keys and QVariant values. For example:QLineSeries *series = new QLineSeries(); series->setName("Customized series"); series->setPointsVisible(true); *series << QPointF(0, 6) << QPointF(2, 4) << QPointF(3, 6) << QPointF(7, 4) << QPointF(10, 5) << QPointF(11, 1) << QPointF(13, 3) << QPointF(17, 6) << QPointF(18, 3) << QPointF(20, 2); QChart *chart = new QChart(); chart->addSeries(series); chart->createDefaultAxes(); QHash<QXYSeries::PointConfiguration, QVariant> conf; conf[QXYSeries::PointConfiguration::Color] = QColor(Qt::red); conf[QXYSeries::PointConfiguration::Size] = 8; conf[QXYSeries::PointConfiguration::LabelVisibility] = true; series->setPointConfiguration(4, conf); conf.remove(QXYSeries::PointConfiguration::Color); conf[QXYSeries::PointConfiguration::LabelFormat] = "This Point"; series->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 visibly bigger than the others with a look derived from the series configuration. By default, points don’t have labels, but the point at index 4 has a label thanks to theLabelVisibility
andLabelFormat
configuration values. The point at index 6 has a custom label This Point thanks to theLabelFormat
configuration value. Below is an example of a chart created in this way:- setPointConfiguration(index, key, value)
- Parameters:
index – int
key –
PointConfiguration
value – object
Enables customizing a particular aspect of a point’s configuration.
Note
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
PointConfiguration
to see whatvalue
should be passed for certainkey
.See also
- setPointLabelsClipping([enabled=true])#
- Parameters:
enabled – bool
See also
Setter of property
pointLabelsClippingᅟ
.Setter of property
pointLabelsColorᅟ
.Setter of property
pointLabelsFontᅟ
.- setPointLabelsFormat(format)#
- Parameters:
format – str
See also
Setter of property
pointLabelsFormatᅟ
.- setPointLabelsVisible([visible=true])#
- Parameters:
visible – bool
See also
Setter of property
pointLabelsVisibleᅟ
.- setPointSelected(index, selected)#
- Parameters:
index – int
selected – bool
Marks point at given
index
as either selected or deselected as specified byselected
.Note
Selected points are drawn using the selected color if it was specified. Emits
selectedPointsChanged
See also
- setPointsConfiguration(pointsConfiguration)#
- Parameters:
pointsConfiguration – Dictionary with keys of type .int and values of type QXYSeries.PointConfiguration.
Enables customizing the configuration of multiple points as specified by
pointsConfiguration
.See also
- setPointsVisible([visible=true])#
- Parameters:
visible – bool
See also
Setter of property
pointsVisibleᅟ
.Setter of property
selectedColorᅟ
.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.- sizeBy(sourceData, minSize, maxSize)#
- Parameters:
sourceData – .list of qreal
minSize – float
maxSize – float
Sets the points’ sizes according to a passed list of values. Values from
sourceData
are sorted and mapped to a point size which is betweenminSize
andmaxSize
.Note
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.- toggleSelection(indexes)#
- Parameters:
indexes – .list of int
Changes selection state of points at given
indexes
to the opposite one. Makes