fix(energy-pie): represent indeterminate shares and preserve prepared styling
Tests / test (push) Successful in 50s

This commit is contained in:
dh
2026-10-06 17:40:42 +00:00
parent c5f924bd19
commit 5b6125d086
10 changed files with 241 additions and 27 deletions
+10 -9
View File
@@ -82,16 +82,17 @@ final class EnergyChartCalculator
* Einspeisung: float,
* Netzbezug: float,
* Hausverbrauch: float,
* Eigenverbrauch: float,
* Eigenverbrauchsquote: float,
* Autarkiegrad: float
* Eigenverbrauch: float|null,
* Eigenverbrauchsquote: float|null,
* Autarkiegrad: float|null
* }
*/
public static function metrics(
float $production,
float $feedIn,
float $grid,
?float $consumption = null
?float $consumption = null,
bool $sharesAvailable = true
): array {
$production = max(0.0, $production);
$feedIn = max(0.0, $feedIn);
@@ -106,13 +107,13 @@ final class EnergyChartCalculator
'Einspeisung' => $feedIn,
'Netzbezug' => $grid,
'Hausverbrauch' => $house,
'Eigenverbrauch' => $selfConsumption,
'Eigenverbrauchsquote' => $production > 0.0
'Eigenverbrauch' => $sharesAvailable ? $selfConsumption : null,
'Eigenverbrauchsquote' => !$sharesAvailable ? null : ($production > 0.0
? min(100.0, ($selfConsumption / $production) * 100.0)
: 0.0,
'Autarkiegrad' => $house > 0.0
: 0.0),
'Autarkiegrad' => !$sharesAvailable ? null : ($house > 0.0
? min(100.0, ($selfConsumption / $house) * 100.0)
: 0.0,
: 0.0),
];
}