Update energy charts and fix y value texts
This commit is contained in:
parent
f2229ba321
commit
120e6d2907
@ -247,7 +247,7 @@ StatsBase {
|
||||
anchors.fill: parent
|
||||
|
||||
backgroundColor: "transparent"
|
||||
// margins.left: 0
|
||||
margins.left: Math.max(Style.smallMargins * 2, valueLabelMetrics.width + Style.smallMargins * 2)
|
||||
margins.right: 0
|
||||
margins.top: 0
|
||||
margins.bottom: Style.smallIconSize + Style.margins
|
||||
@ -291,12 +291,18 @@ StatsBase {
|
||||
Behavior on opacity { NumberAnimation {}}
|
||||
}
|
||||
|
||||
TextMetrics {
|
||||
id: valueLabelMetrics
|
||||
font: Style.extraSmallFont
|
||||
text: (valueAxis.max).toFixed(1) + "kWh"
|
||||
}
|
||||
|
||||
Item {
|
||||
id: labelsLayout
|
||||
x: Style.smallMargins
|
||||
y: chartView.plotArea.y
|
||||
height: chartView.plotArea.height
|
||||
width: chartView.plotArea.x - x
|
||||
width: Math.max(0, chartView.margins.left - Style.smallMargins)
|
||||
Repeater {
|
||||
model: valueAxis.tickCount
|
||||
delegate: Label {
|
||||
@ -484,7 +490,7 @@ StatsBase {
|
||||
}
|
||||
|
||||
property int wheelDelta: 0
|
||||
onWheel: {
|
||||
onWheel: (wheel) => {
|
||||
wheelDelta += wheel.pixelDelta.x
|
||||
var slotWidth = mouseArea.width / d.config.count
|
||||
while (wheelDelta > slotWidth) {
|
||||
|
||||
@ -61,7 +61,7 @@ Item {
|
||||
}
|
||||
}
|
||||
|
||||
onEntriesRemoved: {
|
||||
onEntriesRemoved: (index, count) => {
|
||||
consumptionUpperSeries.removePoints(index, Math.min(count, consumptionUpperSeries.count))
|
||||
zeroSeries.shrink()
|
||||
}
|
||||
@ -227,7 +227,7 @@ Item {
|
||||
anchors.fill: parent
|
||||
|
||||
backgroundColor: "transparent"
|
||||
margins.left: 0
|
||||
margins.left: Math.max(Style.smallMargins * 2, valueLabelMetrics.width + Style.smallMargins * 2)
|
||||
margins.right: 0
|
||||
margins.top: 0
|
||||
margins.bottom: Style.smallIconSize + Style.margins
|
||||
@ -252,6 +252,11 @@ Item {
|
||||
opacity: .5
|
||||
}
|
||||
|
||||
TextMetrics {
|
||||
id: valueLabelMetrics
|
||||
font: Style.extraSmallFont
|
||||
text: ((valueAxis.max) / 1000).toFixed(2) + "kW"
|
||||
}
|
||||
|
||||
ValueAxis {
|
||||
id: valueAxis
|
||||
@ -263,7 +268,6 @@ Item {
|
||||
lineVisible: false
|
||||
titleVisible: false
|
||||
shadesVisible: false
|
||||
// visible: false
|
||||
|
||||
function adjustMax(value) {
|
||||
max = Math.max(max, Math.ceil(value / 100) * 100)
|
||||
@ -275,7 +279,7 @@ Item {
|
||||
x: Style.smallMargins
|
||||
y: chartView.plotArea.y
|
||||
height: chartView.plotArea.height
|
||||
width: chartView.plotArea.x - x
|
||||
width: Math.max(0, chartView.margins.left - Style.smallMargins)
|
||||
Repeater {
|
||||
model: valueAxis.tickCount
|
||||
delegate: Label {
|
||||
@ -692,7 +696,7 @@ Item {
|
||||
d.now = new Date(Math.min(new Date(), new Date(startDatetime.getTime() + timeDelta)))
|
||||
}
|
||||
|
||||
onWheel: {
|
||||
onWheel: (wheel) => {
|
||||
startDatetime = d.now
|
||||
var totalTime = d.endTime.getTime() - d.startTime.getTime()
|
||||
// pixelDelta : timeDelta = width : totalTime
|
||||
|
||||
@ -94,7 +94,7 @@ Item {
|
||||
}
|
||||
|
||||
function selectSeries(series) {
|
||||
if (d.selectedSeries == series) {
|
||||
if (d.selectedSeries === series) {
|
||||
d.selectedSeries = null
|
||||
} else {
|
||||
d.selectedSeries = series
|
||||
@ -147,7 +147,7 @@ Item {
|
||||
acquisitionSeries.lowerSeries = fromStorageUpperSeries
|
||||
}
|
||||
|
||||
onEntriesRemoved: {
|
||||
onEntriesRemoved: (index, count) => {
|
||||
// Note QtCharts crash when calling removePoints() for points that don't exist.
|
||||
// Additionally it may decide to ignore values we add, e.g. if we try to add an Inf or undefined value for whatever reason
|
||||
// So, even though in theory the series should always 1:1 reflect the model, it may not do so in practice and we'll have to make sure not crash here
|
||||
@ -246,7 +246,7 @@ Item {
|
||||
id: chartView
|
||||
anchors.fill: parent
|
||||
backgroundColor: "transparent"
|
||||
margins.left: 0
|
||||
margins.left: Math.max(Style.smallMargins * 2, valueLabelMetrics.width + Style.smallMargins * 2)
|
||||
margins.right: 0
|
||||
margins.bottom: Style.smallIconSize + Style.margins
|
||||
margins.top: 0
|
||||
@ -259,18 +259,24 @@ Item {
|
||||
ActivityIndicator {
|
||||
x: chartView.plotArea.x + (chartView.plotArea.width - width) / 2
|
||||
y: chartView.plotArea.y + (chartView.plotArea.height - height) / 2 + (chartView.plotArea.height / 8)
|
||||
visible: powerBalanceLogs.fetchingData && (powerBalanceLogs.count == 0 || powerBalanceLogs.get(0).timestamp > d.startTime)
|
||||
visible: powerBalanceLogs.fetchingData && (powerBalanceLogs.count === 0 || powerBalanceLogs.get(0).timestamp > d.startTime)
|
||||
opacity: .5
|
||||
}
|
||||
Label {
|
||||
x: chartView.plotArea.x + (chartView.plotArea.width - width) / 2
|
||||
y: chartView.plotArea.y + (chartView.plotArea.height - height) / 2 + (chartView.plotArea.height / 8)
|
||||
text: qsTr("No data available")
|
||||
visible: !powerBalanceLogs.fetchingData && (powerBalanceLogs.count == 0 || powerBalanceLogs.get(0).timestamp > d.now)
|
||||
visible: !powerBalanceLogs.fetchingData && (powerBalanceLogs.count === 0 || powerBalanceLogs.get(0).timestamp > d.now)
|
||||
font: Style.smallFont
|
||||
opacity: .5
|
||||
}
|
||||
|
||||
TextMetrics {
|
||||
id: valueLabelMetrics
|
||||
font: Style.extraSmallFont
|
||||
text: ((valueAxis.max) / 1000).toFixed(2) + "kW"
|
||||
}
|
||||
|
||||
ValueAxis {
|
||||
id: valueAxis
|
||||
min: 0
|
||||
@ -282,12 +288,13 @@ Item {
|
||||
titleVisible: false
|
||||
shadesVisible: false
|
||||
}
|
||||
|
||||
Item {
|
||||
id: labelsLayout
|
||||
x: Style.smallMargins
|
||||
y: chartView.plotArea.y
|
||||
height: chartView.plotArea.height
|
||||
width: chartView.plotArea.x - x
|
||||
width: Math.max(0, chartView.margins.left - Style.smallMargins)
|
||||
Repeater {
|
||||
model: valueAxis.tickCount
|
||||
delegate: Label {
|
||||
@ -353,9 +360,9 @@ Item {
|
||||
XYPoint { x: dateTimeAxis.min.getTime(); y: 0 }
|
||||
XYPoint { x: dateTimeAxis.max.getTime(); y: 0 }
|
||||
function ensureValue(timestamp) {
|
||||
if (count == 0) {
|
||||
if (count === 0) {
|
||||
append(timestamp, 0)
|
||||
} else if (count == 1) {
|
||||
} else if (count === 1) {
|
||||
if (timestamp.getTime() < at(0).x) {
|
||||
insert(0, timestamp, 0)
|
||||
} else {
|
||||
@ -813,7 +820,7 @@ Item {
|
||||
d.now = new Date(Math.min(new Date(), new Date(startDatetime.getTime() + timeDelta)))
|
||||
}
|
||||
|
||||
onWheel: {
|
||||
onWheel: (wheel) => {
|
||||
startDatetime = d.now
|
||||
var totalTime = d.endTime.getTime() - d.startTime.getTime()
|
||||
// pixelDelta : timeDelta = width : totalTime
|
||||
@ -966,4 +973,3 @@ Item {
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@ -242,7 +242,7 @@ StatsBase {
|
||||
legend.font: Style.extraSmallFont
|
||||
legend.labelColor: Style.foregroundColor
|
||||
|
||||
// margins.left: 0
|
||||
margins.left: Math.max(Style.smallMargins * 2, valueLabelMetrics.width + Style.smallMargins * 2)
|
||||
margins.right: 0
|
||||
margins.bottom: Style.smallIconSize + Style.margins
|
||||
margins.top: 0
|
||||
@ -263,12 +263,18 @@ StatsBase {
|
||||
Behavior on opacity { NumberAnimation {}}
|
||||
}
|
||||
|
||||
TextMetrics {
|
||||
id: valueLabelMetrics
|
||||
font: Style.extraSmallFont
|
||||
text: (valueAxis.max).toFixed(1) + "kWh"
|
||||
}
|
||||
|
||||
Item {
|
||||
id: labelsLayout
|
||||
x: Style.smallMargins
|
||||
y: chartView.plotArea.y
|
||||
height: chartView.plotArea.height
|
||||
width: chartView.plotArea.x - x
|
||||
width: Math.max(0, chartView.margins.left - Style.smallMargins)
|
||||
|
||||
Repeater {
|
||||
model: valueAxis.tickCount
|
||||
@ -615,7 +621,7 @@ StatsBase {
|
||||
}
|
||||
|
||||
property int wheelDelta: 0
|
||||
onWheel: {
|
||||
onWheel: (wheel) => {
|
||||
wheelDelta += wheel.pixelDelta.x
|
||||
var slotWidth = mouseArea.width / d.config.count
|
||||
while (wheelDelta > slotWidth) {
|
||||
|
||||
@ -110,7 +110,7 @@ Item {
|
||||
}
|
||||
}
|
||||
|
||||
onEntriesRemoved: {
|
||||
onEntriesRemoved: (index, count) => {
|
||||
acquisitionUpperSeries.removePoints(index, count)
|
||||
storageUpperSeries.removePoints(index, count)
|
||||
selfProductionUpperSeries.removePoints(index, count)
|
||||
@ -194,7 +194,7 @@ Item {
|
||||
id: chartView
|
||||
anchors.fill: parent
|
||||
backgroundColor: "transparent"
|
||||
margins.left: 0
|
||||
margins.left: Math.max(Style.smallMargins * 2, valueLabelMetrics.width + Style.smallMargins * 2)
|
||||
margins.right: 0
|
||||
margins.bottom: 0
|
||||
margins.top: 0
|
||||
@ -218,6 +218,12 @@ Item {
|
||||
opacity: .5
|
||||
}
|
||||
|
||||
TextMetrics {
|
||||
id: valueLabelMetrics
|
||||
font: Style.extraSmallFont
|
||||
text: ((valueAxis.max) / 1000).toFixed(2) + "kW"
|
||||
}
|
||||
|
||||
ValueAxis {
|
||||
id: valueAxis
|
||||
min: 0
|
||||
@ -237,7 +243,7 @@ Item {
|
||||
x: Style.smallMargins
|
||||
y: chartView.plotArea.y
|
||||
height: chartView.plotArea.height
|
||||
width: chartView.plotArea.x - x
|
||||
width: Math.max(0, chartView.margins.left - Style.smallMargins)
|
||||
Repeater {
|
||||
model: valueAxis.tickCount
|
||||
delegate: Label {
|
||||
@ -502,7 +508,7 @@ Item {
|
||||
d.now = new Date(Math.min(new Date(), new Date(startDatetime.getTime() + timeDelta)))
|
||||
}
|
||||
|
||||
onWheel: {
|
||||
onWheel: (wheel) => {
|
||||
startDatetime = d.now
|
||||
var totalTime = d.endTime.getTime() - d.startTime.getTime()
|
||||
// pixelDelta : timeDelta = width : totalTime
|
||||
@ -630,4 +636,3 @@ Item {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -111,7 +111,7 @@ Item {
|
||||
}
|
||||
}
|
||||
|
||||
onEntriesRemoved: {
|
||||
onEntriesRemoved: (index, count) => {
|
||||
acquisitionUpperSeries.removePoints(index, count)
|
||||
storageUpperSeries.removePoints(index, count)
|
||||
selfConsumptionUpperSeries.removePoints(index, count)
|
||||
@ -195,7 +195,7 @@ Item {
|
||||
id: chartView
|
||||
anchors.fill: parent
|
||||
backgroundColor: "transparent"
|
||||
margins.left: 0
|
||||
margins.left: Math.max(Style.smallMargins * 2, valueLabelMetrics.width + Style.smallMargins * 2)
|
||||
margins.right: 0
|
||||
margins.bottom: 0
|
||||
margins.top: 0
|
||||
@ -219,6 +219,12 @@ Item {
|
||||
opacity: .5
|
||||
}
|
||||
|
||||
TextMetrics {
|
||||
id: valueLabelMetrics
|
||||
font: Style.extraSmallFont
|
||||
text: ((valueAxis.max) / 1000).toFixed(2) + "kW"
|
||||
}
|
||||
|
||||
ValueAxis {
|
||||
id: valueAxis
|
||||
min: 0
|
||||
@ -235,7 +241,7 @@ Item {
|
||||
x: Style.smallMargins
|
||||
y: chartView.plotArea.y
|
||||
height: chartView.plotArea.height
|
||||
width: chartView.plotArea.x - x
|
||||
width: Math.max(0, chartView.margins.left - Style.smallMargins)
|
||||
Repeater {
|
||||
model: valueAxis.tickCount
|
||||
delegate: Label {
|
||||
@ -495,7 +501,7 @@ Item {
|
||||
d.now = new Date(Math.min(new Date(), new Date(startDatetime.getTime() + timeDelta)))
|
||||
}
|
||||
|
||||
onWheel: {
|
||||
onWheel: (wheel) => {
|
||||
startDatetime = d.now
|
||||
var totalTime = d.endTime.getTime() - d.startTime.getTime()
|
||||
// pixelDelta : timeDelta = width : totalTime
|
||||
@ -627,4 +633,3 @@ Item {
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user