我将一个列表绘制成线系列图。列表长度可能在4000左右
import QtQuick 2.9
import QtQuick.Window 2.2
import QtCharts 2.0
import QtQuick.Controls 2.15
Window {
visible: true
width: 640
height: 480
title: qsTr("ADC Chart")
ChartView {
id: chart
anchors.fill: parent
theme: ChartView.ChartThemeBrownSand
antialiasing: true
Component.onCompleted: {
line.clear();
for (let i = 0; i < r_manager.ADC1y.length; ++i) {
line.append(i, r_manager.ADC1y[i]);
}
}
LineSeries {
id: line
name: "ADC1"
axisX: ValueAxis {
titleText: "Sample"
min: 0
max: r_manager.ADC1y.length
}
axisY: ValueAxis {
titleText: "ADC"
min: -400
max: 400
}
}
}
}
以下示例演示了如何使用
Colorize
组件将绿色更改为红色。
import QtQuick
import QtQuick.Controls
import Qt5Compat.GraphicalEffects
Page {
background: Rectangle { color: "#848895" }
title: "Colorize Demo"
Image {
id: chart
source: "https://stephenquan.github.io/images/qt/madewithqt.png"
}
Item {
width: chart.width
height: slider.value
clip: true
Colorize {
width: chart.width
height: chart.height
source: chart
hue: 0.0
saturation: 1.0
lightness: 0.0
}
}
Slider {
id: slider
from: 0
to: chart.height
orientation: Qt.Vertical
rotation: 180
Component.onCompleted: value = 155
}
}
您可以在线尝试!