在本页

XYSeries QML Type

直线、样条曲线和散点数列的基本类型。更多

Import Statement: import QtCharts 2.11
In C++: QXYSeries
Inherits:

AbstractSeries

Inherited By:

LineSeries, ScatterSeries, and SplineSeries

属性

信号

方法

  • void append(real x, real y)
  • point at(int index)
  • void insert(int index, real x, real y)
  • void remove(int index)
  • void remove(real x, real y)
  • void removePoints(int index, int count)
  • void replace(real oldX, real oldY, real newX, real newY)

详细说明

XYSeries 支持在图表上显示最佳拟合线。最佳拟合线是一条穿过图表的线,用于表达点之间的关系。

属性文档

axisAngular : AbstractAxis

极坐标图视图周围绘制的用于系列的角轴。

另请参阅 axisX

axisRadial : AbstractAxis

极坐标图视图内绘制的用于系列的径向轴。

另请参阅 axisY

axisX : AbstractAxis

用于系列的 X 轴。如果不定义 axisX 和axisXTop ,则会为序列创建一个值轴。

另请参阅 axisXTopValueAxis

axisXTop : AbstractAxis

用于系列的 x 轴,绘制在图表视图的顶部。

注意: 只能提供axisX 或 axisXTop,不能同时提供。

另请参阅 axisX

axisY : AbstractAxis

用于序列的 Y 轴。如果不定义 axisY 和axisYRight ,则会为序列创建一个值轴。

另请参阅 axisYRightValueAxis

axisYRight : AbstractAxis

用于系列的 Y 轴,在图表视图中画在右边。

注意: 只能提供axisY 或 axisYRight,不能同时提供。

另请参阅 axisY

bestFitLineColor : color

最佳拟合线的颜色。

另请参见 bestFitLineVisible

bestFitLineVisible : bool

最佳拟合线的可见度。该属性默认为false

color : color

系列的颜色。如果是LineSeriesSplineSeries ,这是线条(笔)的颜色;如果是ScatterSeriesAreaSeries ,这是填充(画笔)的颜色。

pointLabelsClipping : bool

数据点标签的裁剪。该属性默认为true 。启用剪切后,绘图区域边缘的标签将被剪切。

另请参阅 pointLabelsVisible

pointLabelsColor : font

数据点标签的颜色。默认情况下,颜色是标签主题中定义的笔刷颜色。

另请参阅 pointLabelsFormat

pointLabelsFont : font

数据点标签使用的字体。

另请参阅 pointLabelsFormat

pointLabelsFormat : string

用于显示带有数据点的标签的格式。

另请参阅 pointLabelsVisible,pointLabelsFont, 和pointLabelsColor

pointLabelsVisible : bool

数据点标签的可见性。该属性默认为false

另请参阅 pointLabelsFormatpointLabelsClipping

pointsVisible : bool

数据点是否可见,是否应该绘制。

selectedColor : color

选中点的颜色。这是标记为选中点的填充(画笔)颜色。如果未指定,默认值为QXYSeries::color

另请参阅 color

信号文档

clicked(point point)

当用户点击图表中的point 点触发鼠标事件时,就会发出该信号。例如

LineSeries {
    XYPoint { x: 0; y: 0 }
    XYPoint { x: 1.1; y: 2.1 }
    onClicked: console.log("onClicked: " + point.x + ", " + point.y);
}

相应的信号处理程序是onClicked()

注: 相应的处理程序是onClicked

另请参阅 pressed(),released() 和doubleClicked()。

doubleClicked(point point)

当用户双击图表中的数据点point 时,就会发出该信号。point 是触发第一次按压的点。例如

LineSeries {
    XYPoint { x: 0; y: 0 }
    XYPoint { x: 1.1; y: 2.1 }
    onDoubleClicked: console.log("onDoubleClicked: " + point.x + ", " + point.y);
}

相应的信号处理程序是onDoubleClicked()

注: 相应的处理程序是onDoubleClicked

另请参阅 pressed(),released() 和clicked()。

hovered(point point, bool state)

当鼠标悬停在图表中的点point 上时,就会发出该信号。当鼠标移到该点上时,state 变成true ,当鼠标再次移开时,变成false

相应的信号处理程序是onHovered()

注: 相应的处理程序是onHovered

pointAdded(int index)

index 指定的位置添加一个点时会发出该信号。

相应的信号处理程序是onPointAdded()

注: 相应的处理程序是onPointAdded

pointRemoved(int index)

当一个点从index 指定的位置移除时,会发出该信号。

相应的信号处理程序是onPointRemoved()

注: 相应的处理程序是onPointRemoved

pointReplaced(int index)

index 指定的位置上的点被替换时,将发出该信号。

相应的信号处理程序是onPointReplaced()

注: 相应的处理程序是onPointReplaced

pointsRemoved(int index, int count)

当从index 指定的位置开始移除count 指定的点数时,将发出该信号。

相应的信号处理程序是onPointRemoved()

注: 相应的处理程序是onPointsRemoved

pointsReplaced()

当所有点都被其他点替换时,就会发出该信号。

相应的信号处理程序是onPointsReplaced()

注: 相应的处理程序是onPointsReplaced

pressed(point point)

当用户按下图表中的数据点point 并按住鼠标键时,就会发出该信号。例如

LineSeries {
    XYPoint { x: 0; y: 0 }
    XYPoint { x: 1.1; y: 2.1 }
    onPressed: console.log("onPressed: " + point.x + ", " + point.y);
}

相应的信号处理程序是onPressed()

注: 相应的处理程序是onPressed

另请参阅 clicked(),released() 和doubleClicked()。

released(point point)

当用户在point 指定的数据点上松开鼠标时,就会发出该信号。例如

LineSeries {
    XYPoint { x: 0; y: 0 }
    XYPoint { x: 1.1; y: 2.1 }
    onReleased: console.log("onReleased: " + point.x + ", " + point.y);
}

相应的信号处理程序是onReleased()

注: 相应的处理程序是onReleased

另请参阅 pressed(),clicked() 和doubleClicked()。

方法文档

void append(real x, real y)

将坐标为xy 的点添加到序列中。

point at(int index)

返回index 指定位置上的点。如果索引无效,则返回 (0, 0)。

void insert(int index, real x, real y)

将坐标为xy 的点插入数列中index 指定的位置。如果索引为 0 或小于 0,该点将被添加到点列表中。如果索引等于或大于系列中的点数,则将该点追加到点列表中。

void remove(int index)

从序列中删除index 指定位置上的点。

void remove(real x, real y)

从序列中删除坐标为xy 的点。如果该点不存在,则不做任何操作。

void removePoints(int index, int count)

index 指定的位置开始,删除count 指定的数列点。

void replace(real oldX, real oldY, real newX, real newY)

将坐标为oldXoldY 的点替换为坐标为newXnewY 的点。如果旧点不存在,则不起任何作用。

© 2026 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.