fix(energy-pie): represent indeterminate shares and preserve prepared styling
Tests / test (push) Successful in 50s
Tests / test (push) Successful in 50s
This commit is contained in:
@@ -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),
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user