Skip to content

Commit

Permalink
New Colour for battery utilisation
Browse files Browse the repository at this point in the history
  • Loading branch information
Ruan-Rossouw committed Oct 25, 2023
1 parent 0749391 commit 6563356
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 22 deletions.
4 changes: 2 additions & 2 deletions src/apps/blazor-app/Components/Advanced/BuildYourHome.razor
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@
<div class="flex relative flex-col justify-center w-full has-tooltip">
<DaylightChart hours="@dlh" daylightHours="@daylight" />
<div class="flex w-full justify-center absolute top-1/2 left-0 items-center gap-1 mt-5">
@if(float.IsInfinity(dlh) || dlh == 12 || dlh == 99) {
@if(float.IsInfinity(dlh) || dlh == 99) {
<p class="text-5xl text-primary-900 font-semibold">99+</p>
} else {
<p class="text-5xl text-primary-900 font-semibold">@dlh</p>
Expand Down Expand Up @@ -407,7 +407,7 @@
<DaylightChart hours="@dlh" daylightHours="@daylight" />
<div class="flex w-full justify-center absolute top-1/2 left-0 items-center gap-1 mt-5">
@{
if (float.IsInfinity(dlh) || dlh == 12 || dlh == 99)
if (float.IsInfinity(dlh) || dlh == 99)
{
<p class="text-5xl text-primary-900 font-semibold">99+</p>
}
Expand Down
48 changes: 34 additions & 14 deletions src/apps/blazor-app/Components/DaylightChart.razor
Original file line number Diff line number Diff line change
Expand Up @@ -113,32 +113,52 @@

private string[] GetColorGradient(float hours)
{
byte greenR = 31, greenG = 56, greenB = 100, yellowR = 46, yellowG = 90, redR = 155, redG = 0;
@* middle top : 46,90,155
middle bottom: 255,193,8
top 31, 56, 100
bottom 241,70,36)*@

byte topR = 31, topG = 56, topB = 100; //Top
byte middleTopR = 46, middleTopG = 90, middleTopB = 155; //Top middle
byte middleBottomR = 255, middleBottomG = 193, middleBottomB = 8; // Bottom middle
byte bottomR = 241, bottomG = 70, bottomB = 0; // Bottom
byte redValue, greenValue, blueValue = 0;

if (hours <= 3)
{
redValue = redR;
greenValue = redG;
redValue = bottomR;
greenValue = bottomG;
blueValue = bottomB;
}
else if (hours >= 12)
{
redValue = greenR;
greenValue = greenG;
blueValue = greenB;
}
redValue = topR;
greenValue = topG;
blueValue = topB;
}
else if(hours < 8 && hours >= 6) {
@* float t = (hours - 6) / 2;
redValue = (byte)(t * middleTopR + (1 - t) * middleBottomR); // Decreasing red component
greenValue = (byte)(t * middleTopG + (1 - t) * middleBottomG); // Increasing green component
blueValue = (byte)(t * middleTopB + (1 - t) * middleBottomB); // Increasing blue component *@
redValue = middleBottomR;
greenValue = middleBottomG;
blueValue = middleBottomB;
}
else if (hours < 6)
{
float t = hours / 6;
redValue = yellowR;
greenValue = (byte)(t * yellowG);
float t = (hours - 3) / 3;
redValue = (byte)((t * middleBottomR) + (1 - t) * bottomR); // Decreasing red component
greenValue = (byte)(t * middleBottomG + (1 - t) * bottomG); // Increasing green component
blueValue = (byte)(t * middleBottomB + (1 - t) * bottomB); // Increasing blue component
}
else
{
float t = (hours - 6) / 6;
redValue = (byte)(t * greenR + (1 - t) * yellowR); // Decreasing red component
greenValue = (byte)(t * greenG + (1 - t) * yellowG); // Increasing green component
blueValue = (byte)(t * greenB); // Increasing blue component
float t = (hours - 8) / 4;
redValue = (byte)(t * topR + (1 - t) * middleTopR); // Decreasing red component
greenValue = (byte)(t * topG + (1 - t) * middleTopG); // Increasing green component
blueValue = (byte)(t * topB + (1 - t) * middleTopB); // Increasing blue component
}

string[] colors = {
Expand Down
2 changes: 1 addition & 1 deletion src/apps/blazor-app/Pages/Dashboard.razor
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@
<DaylightChart hours="@dlh" daylightHours="@daylight" />
<div class="flex w-full justify-center absolute top-1/2 left-0 items-center gap-1 mt-20">
@{
if (float.IsInfinity(dlh) || dlh == 12 || dlh == 99)
if (float.IsInfinity(dlh) || dlh == 99)
{
<p class="text-5xl text-primary-900 font-semibold">99+</p>
}
Expand Down
2 changes: 1 addition & 1 deletion src/apps/blazor-app/Pages/Report.razor
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@
<div class="flex w-fit mx-auto">
<p class="text-primary-900 font-semibold">
@{
if (float.IsInfinity(dlh) || dlh == 12 || dlh == 99)
if (float.IsInfinity(dlh) || dlh == 99)
{
<p>99+</p>
}
Expand Down
8 changes: 4 additions & 4 deletions src/libs/shared-utils/DataHandlers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -980,7 +980,7 @@ public float CalculateConcurrentRunningHours(

if (sumOfAppliances == 0)
{
return 100;
return 825; //Equates to 99 hours
}

float runningHours = (float)(numBatteries * batteryStorage) / sumOfAppliances;
Expand All @@ -1003,7 +1003,7 @@ public float CalculateConcurrentRunningHours(

if (sumOfAppliances == 0)
{
return 100;
return 825; //Equates to 99 hours
}

float runningHours = (float)(numBatteries * batteryStorage) / sumOfAppliances;
Expand All @@ -1021,7 +1021,7 @@ public float CalculateRunningHours(int numBatteries, double batteryStorage, List

if (sumOfAppliances == 0)
{
return 100;
return 825; //Equates to 99 hours
}

Console.WriteLine("Sum of appliances: " + sumOfAppliances + "----------------------->>>>>>>>>");
Expand All @@ -1045,7 +1045,7 @@ public float CalculateRunningHours(int numBatteries, double batteryStorage, List

if (sumOfAppliances == 0)
{
return 100;
return 825; //Equates to 99 hours
}

Console.WriteLine("Sum of appliances: " + sumOfAppliances + "----------------------->>>>>>>>>");
Expand Down

0 comments on commit 6563356

Please sign in to comment.