默认情况下,在QML Charts LineSeries中标记所有点。我只需要标明具体点,如何实现这一点?
这是我的qml文件(大项目的一部分)。我已经为LineSeries设置了相应的属性来显示点标签,但我只需要显示几个标签而不是完整的点集。 Qml中有没有办法控制它?
import QtQuick 2.7
import QtCharts 2.2
import QtQuick.Layouts 1.3
import aa.ui.backend 1.0
Item {
property DSPBackend backend: analyzer.dsp
property alias titleV: chartV.title
property alias seriesV: lineSeriesV
property alias titleI: chartI.title
property alias seriesI: lineSeriesI
GridLayout {
id: gridSpectrum
anchors.fill: parent
columns: 2
rows: 1
columnSpacing: 0
flow: GridLayout.LeftToRight
ChartView {
id: chartV
Layout.fillWidth: true
Layout.fillHeight: true
/*title: "Spectrum (V-channel)"
titleFont.pixelSize: 10*/
theme: ChartView.ChartThemeBlueCerulean
antialiasing: false
legend.visible: false
legend.font.pointSize: 10
margins.top: 2
margins.left: 2
margins.right: 2
margins.bottom: 4
ValueAxis {
id: axisXV
titleFont.pointSize: 7
labelsFont.pointSize: 7
}
ValueAxis {
id: axisYV
titleFont.pointSize: 7
labelsFont.pointSize: 7
}
LineSeries {
id: lineSeriesV
axisX: axisXV
axisY: axisYV
color: "#66cc00"
name: "V-channel"
pointLabelsFormat: "(@xPoint Hz, @yPoint dB)"
pointLabelsVisible: true
width: 3
useOpenGL: false
}
}
ChartView {
id: chartI
/*title: "Spectrum (I-channel)"
titleFont.pixelSize: 10*/
antialiasing: true
theme: ChartView.ChartThemeBlueCerulean
legend.visible: false
legend.font.pointSize: 10
margins.top: 2
margins.left: 2
margins.right: 2
margins.bottom: 4
Layout.fillWidth: true
Layout.fillHeight: true
ValueAxis {
id: axisXI
titleFont.pointSize: 7
labelsFont.pointSize: 7
}
ValueAxis {
id: axisYI
titleFont.pointSize: 7
labelsFont.pointSize: 7
}
LineSeries {
id: lineSeriesI
axisX: axisXI
axisY: axisYI
color: "#0099ff"
name: "I-channel"
pointLabelsFormat: "(@xPoint Hz, @yPoint dB)"
pointLabelsVisible: true
width: 3
useOpenGL: false
}
}
}
Timer {
id: timerSpectrum
interval: 500
running: true
repeat: true
onTriggered: {
backend.update_spectrum(seriesV, seriesI);
}
}
Component.onCompleted: {
backend.setup_spectrum(axisXV, axisYV, axisXI, axisYI)
}
}
答案 0 :(得分:0)
您可以设置bool属性或返回bool的函数。然后在pointLabelsFormat属性中对其进行评估。
toMap
如果布尔值为false,则将点的标签设置为空字符串。