Basic static plot¶
A Plot needs axes and one or more series. Each series names the axes that map
its data and optionally supplies a name for the legend.
import QtQuick
import QAccelPlot as QAccelPlot
QAccelPlot.Plot {
id: plot
xAxis: QAccelPlot.Axis {
viewportMin: 0
viewportMax: 24
label: "Time of day (h)"
}
yAxis: QAccelPlot.Axis {
viewportMin: 16
viewportMax: 27
label: "Temperature (°C)"
}
QAccelPlot.LineCurve {
name: "Measured"
xAxis: plot.xAxis
yAxis: plot.yAxis
color: "tomato"
lineWidth: 3
Component.onCompleted: setData([
Qt.point(0, 18), Qt.point(6, 19.5),
Qt.point(12, 25), Qt.point(18, 23.5), Qt.point(24, 18)
])
}
QAccelPlot.LineCurve {
name: "Forecast"
xAxis: plot.xAxis
yAxis: plot.yAxis
color: "dodgerblue"
lineWidth: 2
lineStyle: QAccelPlot.DashLine { pattern: [8, 5] }
marker.shape: QAccelPlot.MarkerShape.Diamond
marker.size: 7
}
}
Plot shows a legend entry for every visible series that has one, and one per
category for a series with categories; a heatmap has none, because its color
bar is its key. Set legendVisible: false to hide
the legend, or assign legend to replace it. Plot.legendModel lists every
entry; a LegendModel of your own lists a subset:
QML setData()
suits small or rarely changing data. For large or frequent updates, see
Select the data path.
Complete source: examples/quickstart