Added horizontal legend for a small number of series on the chart
This commit is contained in:
@@ -71,11 +71,12 @@ ColumnLayout {
|
|||||||
id: legendDelegate
|
id: legendDelegate
|
||||||
|
|
||||||
RowLayout {
|
RowLayout {
|
||||||
width: ListView.view.width
|
width: ListView.view ? ListView.view.width : 200
|
||||||
height: 60
|
height: 60
|
||||||
|
|
||||||
property Controls.ChartView chartItem: undefined
|
property Controls.ChartView chartItem: undefined
|
||||||
property color seriesColor: "black"
|
property color seriesColor: "black"
|
||||||
|
property bool horizontal: true
|
||||||
|
|
||||||
Controls.CheckBox {
|
Controls.CheckBox {
|
||||||
id: checkSeries
|
id: checkSeries
|
||||||
@@ -87,7 +88,7 @@ ColumnLayout {
|
|||||||
chartItem.series(modelData).color = "transparent"
|
chartItem.series(modelData).color = "transparent"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: !horizontal
|
||||||
}
|
}
|
||||||
|
|
||||||
Rectangle {
|
Rectangle {
|
||||||
@@ -99,7 +100,8 @@ ColumnLayout {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Component.onCompleted: {
|
Component.onCompleted: {
|
||||||
chartItem = ListView.view.chartItem
|
chartItem = ListView.view ? ListView.view.chartItem : parent.chartItem
|
||||||
|
horizontal = !ListView.view
|
||||||
seriesColor = chartItem.series(modelData).color
|
seriesColor = chartItem.series(modelData).color
|
||||||
checkSeries.text = chartItem.series(modelData).name
|
checkSeries.text = chartItem.series(modelData).name
|
||||||
}
|
}
|
||||||
@@ -114,6 +116,7 @@ ColumnLayout {
|
|||||||
property string yLabel: ""
|
property string yLabel: ""
|
||||||
property Controls.ChartView chart: chartView
|
property Controls.ChartView chart: chartView
|
||||||
property int seriesCount: 0
|
property int seriesCount: 0
|
||||||
|
property bool horizontalLegend: true
|
||||||
|
|
||||||
ColumnLayout {
|
ColumnLayout {
|
||||||
spacing: -20
|
spacing: -20
|
||||||
@@ -140,6 +143,21 @@ ColumnLayout {
|
|||||||
Layout.bottomMargin: 10
|
Layout.bottomMargin: 10
|
||||||
}
|
}
|
||||||
|
|
||||||
|
RowLayout {
|
||||||
|
visible: horizontalLegend
|
||||||
|
spacing: 20
|
||||||
|
|
||||||
|
property Controls.ChartView chartItem: chart
|
||||||
|
|
||||||
|
Repeater {
|
||||||
|
model: seriesCount
|
||||||
|
delegate: legendDelegate
|
||||||
|
}
|
||||||
|
|
||||||
|
Layout.topMargin: 20
|
||||||
|
Layout.leftMargin: 20
|
||||||
|
}
|
||||||
|
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
Layout.fillHeight: true
|
Layout.fillHeight: true
|
||||||
}
|
}
|
||||||
@@ -148,10 +166,11 @@ ColumnLayout {
|
|||||||
clip: true
|
clip: true
|
||||||
model: seriesCount
|
model: seriesCount
|
||||||
delegate: legendDelegate
|
delegate: legendDelegate
|
||||||
|
visible: !horizontalLegend
|
||||||
|
|
||||||
property Controls.ChartView chartItem: chart
|
property Controls.ChartView chartItem: chart
|
||||||
|
|
||||||
Layout.preferredWidth: 300
|
Layout.preferredWidth: 180
|
||||||
Layout.fillHeight: true
|
Layout.fillHeight: true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -232,6 +251,7 @@ ColumnLayout {
|
|||||||
Component.onCompleted: {
|
Component.onCompleted: {
|
||||||
item.xLabel = Qt.binding(function() { return qsTr("Time, s") })
|
item.xLabel = Qt.binding(function() { return qsTr("Time, s") })
|
||||||
item.yLabel = Qt.binding(function() { return qsTr("Voltage, V") })
|
item.yLabel = Qt.binding(function() { return qsTr("Voltage, V") })
|
||||||
|
item.horizontalLegend = false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user