Small improvements into Graph example
Use FrameAnimation instead of Timer and double the amount of samples
to make the example smoother.
Change-Id: I6f5bb1414fd7532e16aeb25f886879828ce29854
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
Reviewed-by: Tomi Korpipää <tomi.korpipaa@qt.io>
(cherry picked from commit 75a33aceab
)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
parent
d733885962
commit
e497ff1437
|
@ -15,27 +15,23 @@ Item {
|
|||
anchors.margins: 100
|
||||
|
||||
function newSample(i) {
|
||||
return (Math.sin(i / 100.0 * Math.PI * 2) + 1) * 0.4 + Math.random() * 0.05;
|
||||
return (Math.sin(i / 200.0 * Math.PI * 2) + 1) * 0.4 + Math.random() * 0.05;
|
||||
}
|
||||
|
||||
Component.onCompleted: {
|
||||
for (var i=0; i<100; ++i)
|
||||
for (var i=0; i<graph.offset; ++i)
|
||||
appendSample(newSample(i));
|
||||
}
|
||||
|
||||
property int offset: 100;
|
||||
property int offset: 200
|
||||
}
|
||||
|
||||
Timer {
|
||||
id: timer
|
||||
interval: 500
|
||||
repeat: true
|
||||
FrameAnimation {
|
||||
running: true
|
||||
onTriggered: {
|
||||
graph.removeFirstSample();
|
||||
graph.appendSample(graph.newSample(++graph.offset));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
|
|
Loading…
Reference in New Issue