pragma ComponentBehavior: Bound import QtQuick import "../.." Item { id: root required property Theme theme property var values: [] property var valuesDown: [] property color barColor: theme.ui.accent property color barColorDown: theme.info property real scaleMax: 0 property bool split: false readonly property int shown: Math.max(1, Math.floor(width / 2)) readonly property var slice: tail(values) readonly property var sliceDown: tail(valuesDown) readonly property real maxV: { if (root.scaleMax > 0) return root.scaleMax; let m = 0; for (let i = 0; i < root.slice.length; i++) m = Math.max(m, Number(root.slice[i]) || 0); if (root.split) { for (let j = 0; j < root.sliceDown.length; j++) m = Math.max(m, Number(root.sliceDown[j]) || 0); } return m; } readonly property real budget: root.split ? (root.height - 1) / 2 : root.height function tail(v) { const a = v || []; return a.length > root.shown ? a.slice(a.length - root.shown) : a; } Row { anchors.right: parent.right anchors.bottom: root.split ? parent.verticalCenter : parent.bottom anchors.bottomMargin: root.split ? 1 : 0 height: root.budget spacing: 0 // A count model keeps the bars; each new sample only rebinds their heights. Repeater { model: root.slice.length delegate: Item { id: upBar required property int index width: 2 height: root.budget Rectangle { anchors.bottom: parent.bottom width: parent.width radius: width / 2 height: Math.max(root.split ? 0 : 1, root.budget * (root.maxV > 0 ? Math.min(1, (Number(root.slice[upBar.index]) || 0) / root.maxV) : 0)) color: root.barColor } } } } Row { visible: root.split anchors.right: parent.right anchors.top: parent.verticalCenter anchors.topMargin: 1 height: root.budget spacing: 0 Repeater { model: root.split ? root.sliceDown.length : 0 delegate: Item { id: downBar required property int index width: 2 height: root.budget Rectangle { anchors.top: parent.top width: parent.width radius: width / 2 height: Math.max(0, root.budget * (root.maxV > 0 ? Math.min(1, (Number(root.sliceDown[downBar.index]) || 0) / root.maxV) : 0)) color: root.barColorDown } } } } }