diff options
author | Arseniy Movshev <dodoradio@outlook.com> | 2023-06-02 16:42:42 +0100 |
---|---|---|
committer | Arseniy Movshev <dodoradio@outlook.com> | 2023-06-02 17:12:18 +0100 |
commit | e28f53101fb034e0b29b406914f2fa9688d64bb0 (patch) | |
tree | 45af1ad064495fe10e2b532eebfeab97d2d06ea5 /src | |
parent | fa77cef96f5bbb49afad287fc85215bedc864ce7 (diff) |
bar graph: tweak anchors to make sure that labels text is never clipped
Diffstat (limited to '')
-rw-r--r-- | src/graphs/BarGraph.qml | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/src/graphs/BarGraph.qml b/src/graphs/BarGraph.qml index f5de55f..3f40130 100644 --- a/src/graphs/BarGraph.qml +++ b/src/graphs/BarGraph.qml @@ -33,7 +33,7 @@ Item { } Item { // labels column id: markerParent - width: parent.width/8 + width: childrenRect.width height: parent.height anchors { left: parent.left @@ -43,8 +43,9 @@ Item { Repeater { model: barGraph.divisionsCount delegate: Label { - anchors.left: parent.left - text: barGraph.divisionsInterval*index + width: implicitWidth + property var value: barGraph.divisionsInterval*index + text: value > 1000 ? value/1000 + "k" : value font.pixelSize: Dims.w(5) y: parent.height - parent.height*barGraph.divisionsInterval*index/barGraph.maxValue - height/2 verticalAlignment: Text.AlignVCenter @@ -54,14 +55,14 @@ Item { Row { // bars id: barsRow anchors { - horizontalCenter: parent.horizontalCenter + left: markerParent.right top: parent.top bottom: labelsRow.top } Repeater { id: barsRepeater delegate: Item { //this contains the graph column and positions it correctly - width: barGraph.width/8 + width: (barGraph.width-markerParent.width)/barGraph.valuesArr.length height: parent.height Rectangle { id: bar @@ -77,7 +78,7 @@ Item { } Row { //labels row id: labelsRow - height: Dims.w(5) + width: childrenRect.height anchors { bottom: parent.bottom left: barsRow.left @@ -86,7 +87,7 @@ Item { Repeater { id: labelsRepeater delegate: Label { - width: barGraph.width/8 + width: (barGraph.width-markerParent.width)/barGraph.valuesArr.length id: dowLabel // anchors.horizontalCenter: parent.horizontalCenter horizontalAlignment: Text.AlignHCenter |