mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 13:49:12 +02:00
TRying to create a graph :)
This commit is contained in:
parent
851cbb1c46
commit
6d6f0398f5
1 changed files with 35 additions and 2 deletions
|
@ -11,6 +11,7 @@
|
||||||
import QtQuick 2.5
|
import QtQuick 2.5
|
||||||
import QtQuick.Controls 1.4
|
import QtQuick.Controls 1.4
|
||||||
|
|
||||||
|
|
||||||
Column {
|
Column {
|
||||||
spacing: 8
|
spacing: 8
|
||||||
Column {
|
Column {
|
||||||
|
@ -28,12 +29,44 @@ Column {
|
||||||
Label {
|
Label {
|
||||||
text: qsTr(modelData.split(":")[0])
|
text: qsTr(modelData.split(":")[0])
|
||||||
}
|
}
|
||||||
property var value: stats.config[modelData.split(":")[1]]
|
property var value: stats.config[modelData.split(":")[1]]
|
||||||
|
property var valueHistory : new Array()
|
||||||
|
property var valueMax : 1000
|
||||||
|
property var tick : 0
|
||||||
Label {
|
Label {
|
||||||
text: value
|
text: value
|
||||||
horizontalAlignment: AlignRight
|
horizontalAlignment: AlignRight
|
||||||
}
|
}
|
||||||
|
Canvas {
|
||||||
|
id: mycanvas
|
||||||
|
width: 100
|
||||||
|
height: 200
|
||||||
|
onPaint: {
|
||||||
|
tick++;
|
||||||
|
valueHistory.push(value)
|
||||||
|
if (valueHistory.length > 100) {
|
||||||
|
valueHistory.shift();
|
||||||
|
}
|
||||||
|
var ctx = getContext("2d");
|
||||||
|
if (tick % 2) {
|
||||||
|
ctx.fillStyle = Qt.rgba(0, 1, 0, 0.5);
|
||||||
|
} else {
|
||||||
|
ctx.fillStyle = Qt.rgba(0, 0, 0, 0.5);
|
||||||
|
}
|
||||||
|
ctx.fillRect(0, 0, width, height);
|
||||||
|
var widthStep= width / valueHistory.length;
|
||||||
|
ctx.lineWidth="5";
|
||||||
|
ctx.beginPath();
|
||||||
|
ctx.strokeStyle="green"; // Green path
|
||||||
|
ctx.moveTo(0,height);
|
||||||
|
|
||||||
|
for (var i = 0; i < valueHistory.length; i++) {
|
||||||
|
ctx.lineTo(i * widthStep, height * (1 - valueHistory[i] / valueMax) );
|
||||||
|
}
|
||||||
|
ctx.lineTo(width, height);
|
||||||
|
ctx.stroke(); // Draw it
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue