projection: begin the exact-path public epoch
The public tree and its history contain only the listed paths. Earlier projection history remains preserved internally. Source-Sha: 913fde029b935671833254797f0f20f1eb9fabba Policy-Sha: 913fde029b935671833254797f0f20f1eb9fabba Tree-Digest: 180ae530c1058a2a5c89837bdce2d323ae83e669e38590ca72e75b8d92b7262f
This commit is contained in:
commit
67e26be2d9
838 changed files with 157302 additions and 0 deletions
45
desktop/qml/LineGraph.qml
Normal file
45
desktop/qml/LineGraph.qml
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
import QtQuick
|
||||
|
||||
Canvas {
|
||||
id: root
|
||||
property var values: []
|
||||
property real ceiling: 100
|
||||
property color lineColor: Theme.red
|
||||
property color fillColor: Theme.tint(lineColor, 0.12)
|
||||
property bool grid: true
|
||||
|
||||
onValuesChanged: requestPaint()
|
||||
onWidthChanged: requestPaint()
|
||||
onHeightChanged: requestPaint()
|
||||
onCeilingChanged: requestPaint()
|
||||
|
||||
onPaint: {
|
||||
const ctx = getContext("2d")
|
||||
ctx.reset()
|
||||
if (grid) {
|
||||
ctx.strokeStyle = Theme.divider
|
||||
ctx.lineWidth = 1
|
||||
for (let y = 0; y <= 4; ++y) {
|
||||
ctx.beginPath(); ctx.moveTo(0, y * height / 4); ctx.lineTo(width, y * height / 4); ctx.stroke()
|
||||
}
|
||||
}
|
||||
if (!values || values.length < 2) return
|
||||
const top = Math.max(1, ceiling)
|
||||
const step = width / Math.max(1, values.length - 1)
|
||||
ctx.beginPath()
|
||||
for (let i = 0; i < values.length; ++i) {
|
||||
const x = i * step
|
||||
const y = height - Math.min(top, Math.max(0, Number(values[i]))) / top * height
|
||||
if (i === 0) ctx.moveTo(x, y); else ctx.lineTo(x, y)
|
||||
}
|
||||
ctx.lineTo(width, height); ctx.lineTo(0, height); ctx.closePath()
|
||||
ctx.fillStyle = fillColor; ctx.fill()
|
||||
ctx.beginPath()
|
||||
for (let j = 0; j < values.length; ++j) {
|
||||
const x2 = j * step
|
||||
const y2 = height - Math.min(top, Math.max(0, Number(values[j]))) / top * height
|
||||
if (j === 0) ctx.moveTo(x2, y2); else ctx.lineTo(x2, y2)
|
||||
}
|
||||
ctx.strokeStyle = lineColor; ctx.lineWidth = 2; ctx.stroke()
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue