Allow styling energy colors

This commit is contained in:
Michael Zanetti 2023-03-08 22:15:56 +01:00
parent d8273dd161
commit 745462e848
4 changed files with 58 additions and 50 deletions

View File

@ -87,6 +87,14 @@ Item {
property color rose: "#cd5c95"
property color darkGreen: "#5ccd5e"
property color powerAcquisitionColor: red
property color powerReturnColor: yellow
property color powerConsumptionColor: blue
property color powerSelfProductionConsumptionColor: green
property color powerBatteryChargingColor: purple
property color powerBatteryDischargingColor: orange
property color powerBatteryIdleColor: lime
// Icon/graph colors for various interfaces
property var interfaceColors: {
"temperaturesensor": red,

View File

@ -126,34 +126,34 @@ Item {
if (root.toGrid > 0) {
size = root.toGrid / biggest
drawDottedCurve(ctx, solarPos, gridPos, size, Style.yellow)
drawDottedCurve(ctx, solarPos, gridPos, size, Style.powerReturnColor)
}
if (energyManager.currentPowerProduction < 0 && root.fromProduction) {
size = root.fromProduction / biggest
drawDottedCurve(ctx, solarPos, consumptionPos, size, Style.green)
drawDottedCurve(ctx, solarPos, consumptionPos, size, Style.powerSelfProductionConsumptionColor)
}
if (batteries.count > 0) {
if (energyManager.currentPowerStorage > 0) {
if (energyManager.currentPowerProduction < 0) {
size = Math.abs(energyManager.currentPowerStorage) / biggest
drawDottedCurve(ctx, solarPos, storagePos, size, Style.purple)
drawDottedCurve(ctx, solarPos, storagePos, size, Style.powerBatteryChargingColor)
} else {
size = Math.abs(energyManager.currentPowerStorage) / biggest
drawDottedCurve(ctx, gridPos, storagePos, size, Style.purple)
drawDottedCurve(ctx, gridPos, storagePos, size, Style.powerBatteryChargingColor)
}
}
if (energyManager.currentPowerStorage < 0) {
size = Math.abs(energyManager.currentPowerStorage) / biggest
drawDottedCurve(ctx, storagePos, consumptionPos, size, Style.orange)
drawDottedCurve(ctx, storagePos, consumptionPos, size, Style.powerBatteryDischargingColor)
}
}
if (energyManager.currentPowerAcquisition > 0) {
size = Math.abs(energyManager.currentPowerAcquisition) / biggest
drawDottedCurve(ctx, gridPos, consumptionPos, size, Style.red)
drawDottedCurve(ctx, gridPos, consumptionPos, size, Style.powerAcquisitionColor)
}
ctx.restore();
@ -247,13 +247,13 @@ Item {
holeSize: 0.8
PieSlice {
color: Style.red
color: Style.powerAcquisitionColor
borderColor: color
borderWidth: 0
value: root.fromGrid
}
PieSlice {
color: Style.yellow
color: Style.powerReturnColor
borderColor: color
borderWidth: 0
value: root.toGrid
@ -317,19 +317,19 @@ Item {
holeSize: 0.8
PieSlice {
color: Style.yellow
color: Style.powerReturnColor
borderColor: color
borderWidth: 0
value: root.toGrid
}
PieSlice {
color: Style.purple
color: Style.powerBatteryChargingColor
borderColor: color
borderWidth: 0
value: root.toStorage
}
PieSlice {
color: Style.green
color: Style.powerSelfProductionConsumptionColor
borderColor: color
borderWidth: 0
value: root.fromProduction
@ -390,19 +390,19 @@ Item {
holeSize: 0.8
PieSlice {
color: Style.green
color: Style.powerSelfProductionConsumptionColor
borderColor: color
borderWidth: 0
value: root.fromProduction
}
PieSlice {
color: Style.orange
color: Style.powerBatteryDischargingColor
borderColor: color
borderWidth: 0
value: root.fromStorage
}
PieSlice {
color: Style.red
color: Style.powerAcquisitionColor
borderColor: color
borderWidth: 0
value: root.fromGrid
@ -500,10 +500,10 @@ Item {
PieSlice {
color: energyManager.currentPowerStorage == 0
? Style.lime
? Style.powerBatteryIdleColor
: root.toStorage > 0
? Style.purple
: Style.orange
? Style.powerBatteryChargingColor
: Style.powerBatteryDischargingColor
borderColor: color
borderWidth: 0
value: batteryChart.averageLevel

View File

@ -81,10 +81,10 @@ Item {
target: powerBalanceLogs
onEntriesAddedIdx: {
print("entries added", index, count)
// print("entries added", index, count)
for (var i = 0; i < count; i++) {
var entry = powerBalanceLogs.get(index + i)
print("got entry", entry.timestamp)
// print("got entry", entry.timestamp)
zeroSeries.ensureValue(entry.timestamp)
// For debugging, to see if the other maths line up with the plain production graph
@ -290,7 +290,7 @@ Item {
id: selfProductionConsumptionSeries
axisX: dateTimeAxis
axisY: valueAxis
color: Style.green
color: Style.powerSelfProductionConsumptionColor
// borderWidth: 2
borderColor: color
name: qsTr("From self production")
@ -351,7 +351,7 @@ Item {
id: toStorageSeries
axisX: dateTimeAxis
axisY: valueAxis
color: Style.purple
color: Style.powerBatteryChargingColor
borderWidth: 0
borderColor: color
opacity: d.selectedSeries == null || d.selectedSeries == toStorageSeries ? 1 : 0.3
@ -381,7 +381,7 @@ Item {
id: returnSeries
axisX: dateTimeAxis
axisY: valueAxis
color: Style.yellow
color: Style.powerReturnColor
borderWidth: 0
borderColor: color
name: qsTr("To grid")
@ -412,7 +412,7 @@ Item {
id: fromStorageSeries
axisX: dateTimeAxis
axisY: valueAxis
color: Style.orange
color: Style.powerBatteryDischargingColor
borderWidth: 0
borderColor: color
name: qsTr("From battery")
@ -441,7 +441,7 @@ Item {
id: acquisitionSeries
axisX: dateTimeAxis
axisY: valueAxis
color: Style.red
color: Style.powerAcquisitionColor
borderWidth: 0
borderColor: color
name: qsTr("From grid")
@ -491,7 +491,7 @@ Item {
id: consumptionSeries
axisX: dateTimeAxis
axisY: valueAxis
color: Style.red
color: Style.powerAcquisitionColor
width: 1
name: "Total consumption"
visible: false
@ -563,12 +563,12 @@ Item {
ColorIcon {
name: "power-grid"
size: Style.smallIconSize
color: Style.red
color: Style.powerAcquisitionColor
}
ColorIcon {
name: "arrow-down"
size: Style.smallIconSize
color: Style.red
color: Style.powerAcquisitionColor
}
}
Label {
@ -599,12 +599,12 @@ Item {
ColorIcon {
name: "power-grid"
size: Style.smallIconSize
color: Style.yellow
color: Style.powerReturnColor
}
ColorIcon {
name: "arrow-up"
size: Style.smallIconSize
color: Style.yellow
color: Style.powerReturnColor
}
}
Label {
@ -636,12 +636,12 @@ Item {
ColorIcon {
name: "battery/battery-080"
size: Style.smallIconSize
color: Style.purple
color: Style.powerBatteryChargingColor
}
ColorIcon {
name: "plus"
size: Style.smallIconSize
color: Style.purple
color: Style.powerBatteryChargingColor
}
}
Label {
@ -673,12 +673,12 @@ Item {
ColorIcon {
name: "battery/battery-040"
size: Style.smallIconSize
color: Style.orange
color: Style.powerBatteryDischargingColor
}
ColorIcon {
name: "minus"
size: Style.smallIconSize
color: Style.orange
color: Style.powerBatteryDischargingColor
}
}
Label {
@ -845,7 +845,7 @@ Item {
Rectangle {
width: Style.extraSmallFont.pixelSize
height: width
color: toolTip.entry && toolTip.entry.acquisition >= 0 ? Style.red : Style.yellow
color: toolTip.entry && toolTip.entry.acquisition >= 0 ? Style.powerAcquisitionColor : Style.powerReturnColor
}
Label {
@ -867,7 +867,7 @@ Item {
Rectangle {
width: Style.extraSmallFont.pixelSize
height: width
color: Style.green
color: Style.powerSelfProductionConsumptionColor
}
Label {
@ -890,7 +890,7 @@ Item {
Rectangle {
width: Style.extraSmallFont.pixelSize
height: width
color: toolTip.entry && toolTip.entry.storage > 0 ? Style.purple : Style.orange
color: toolTip.entry && toolTip.entry.storage > 0 ? Style.powerBatteryChargingColor : Style.powerBatteryDischargingColor
}
Label {

View File

@ -299,7 +299,7 @@ StatsBase {
BarSet {
id: consumptionSet
label: qsTr("Consumed")
color: Qt.rgba(Style.blue.r, Style.blue.g, Style.blue.b, opacity)
color: Qt.rgba(Style.powerConsumptionColor.r, Style.powerConsumptionColor.g, Style.powerConsumptionColor.b, opacity)
borderColor: color
borderWidth: 0
property real opacity: d.selectedSet == null || d.selectedSet == consumptionSet ? 1 : 0.3
@ -314,7 +314,7 @@ StatsBase {
BarSet {
id: productionSet
label: qsTr("Produced")
color: Qt.rgba(Style.green.r, Style.green.g, Style.green.b, opacity)
color: Qt.rgba(Style.powerSelfProductionConsumptionColor.r, Style.powerSelfProductionConsumptionColor.g, Style.powerSelfProductionConsumptionColor.b, opacity)
borderColor: color
borderWidth: 0
property real opacity: d.selectedSet == null || d.selectedSet == productionSet ? 1 : 0.3
@ -329,7 +329,7 @@ StatsBase {
BarSet {
id: acquisitionSet
label: qsTr("From grid")
color: Qt.rgba(Style.red.r, Style.red.g, Style.red.b, opacity)
color: Qt.rgba(Style.powerAcquisitionColor.r, Style.powerAcquisitionColor.g, Style.powerAcquisitionColor.b, opacity)
borderColor: color
borderWidth: 0
property real opacity: d.selectedSet == null || d.selectedSet == acquisitionSet ? 1 : 0.3
@ -344,7 +344,7 @@ StatsBase {
BarSet {
id: returnSet
label: qsTr("To grid")
color: Qt.rgba(Style.yellow.r, Style.yellow.g, Style.yellow.b, opacity)
color: Qt.rgba(Style.powerReturnColor.r, Style.powerReturnColor.g, Style.powerReturnColor.b, opacity)
borderColor: color
borderWidth: 0
property real opacity: d.selectedSet == null || d.selectedSet == returnSet ? 1 : 0.3
@ -383,7 +383,7 @@ StatsBase {
ColorIcon {
name: "powersocket"
size: Style.smallIconSize
color: Style.blue
color: Style.powerConsumptionColor
}
Label {
width: parent.parent.width - x
@ -412,7 +412,7 @@ StatsBase {
ColorIcon {
name: "weathericons/weather-clear-day"
size: Style.smallIconSize
color: Style.green
color: Style.powerSelfProductionConsumptionColor
}
Label {
width: parent.parent.width - x
@ -442,12 +442,12 @@ StatsBase {
ColorIcon {
name: "power-grid"
size: Style.smallIconSize
color: Style.red
color: Style.powerAcquisitionColor
}
ColorIcon {
name: "arrow-down"
size: Style.smallIconSize
color: Style.red
color: Style.powerAcquisitionColor
}
}
Label {
@ -477,12 +477,12 @@ StatsBase {
ColorIcon {
name: "power-grid"
size: Style.smallIconSize
color: Style.yellow
color: Style.powerReturnColor
}
ColorIcon {
name: "arrow-up"
size: Style.smallIconSize
color: Style.yellow
color: Style.powerReturnColor
}
}
Label {
@ -651,7 +651,7 @@ StatsBase {
Rectangle {
width: Style.extraSmallFont.pixelSize
height: width
color: Style.blue
color: Style.powerConsumptionColor
}
Label {
text: d.startOffset !== undefined ? qsTr("Consumed: %1 kWh").arg(consumptionSet.at(toolTip.idx).toFixed(2)) : ""
@ -663,7 +663,7 @@ StatsBase {
Rectangle {
width: Style.extraSmallFont.pixelSize
height: width
color: Style.green
color: Style.powerSelfProductionConsumptionColor
}
Label {
text: d.startOffset !== undefined ? qsTr("Produced: %1 kWh").arg(productionSet.at(toolTip.idx).toFixed(2)) : ""
@ -674,7 +674,7 @@ StatsBase {
Rectangle {
width: Style.extraSmallFont.pixelSize
height: width
color: Style.red
color: Style.powerAcquisitionColor
}
Label {
text: d.startOffset !== undefined ? qsTr("From grid: %1 kWh").arg(acquisitionSet.at(toolTip.idx).toFixed(2)) :""
@ -685,7 +685,7 @@ StatsBase {
Rectangle {
width: Style.extraSmallFont.pixelSize
height: width
color: Style.yellow
color: Style.powerReturnColor
}
Label {
text: d.startOffset !== undefined ? qsTr("To grid: %1 kWh").arg(returnSet.at(toolTip.idx).toFixed(2)) : ""