Fixed coloring
This commit is contained in:
parent
2d8b17d1f4
commit
d1c0f10097
1 changed files with 12 additions and 3 deletions
|
@ -2,6 +2,7 @@ package z
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"math"
|
||||||
"time"
|
"time"
|
||||||
"github.com/gookit/color"
|
"github.com/gookit/color"
|
||||||
"github.com/shopspring/decimal"
|
"github.com/shopspring/decimal"
|
||||||
|
@ -53,7 +54,7 @@ func GetOutputBarForHours(hours decimal.Decimal, stats []Statistic) ([]string) {
|
||||||
colorFractionPrevAmount := 0.0
|
colorFractionPrevAmount := 0.0
|
||||||
|
|
||||||
for _, stat := range stats {
|
for _, stat := range stats {
|
||||||
statHoursInt := int((stat.Hours.Round(0)).IntPart())
|
statHoursInt, _ := stat.Hours.Float64()
|
||||||
statRest := (stat.Hours.Round(0)).Mod(decimal.NewFromInt(4))
|
statRest := (stat.Hours.Round(0)).Mod(decimal.NewFromInt(4))
|
||||||
statRestFloat, _ := statRest.Float64()
|
statRestFloat, _ := statRest.Float64()
|
||||||
|
|
||||||
|
@ -62,7 +63,15 @@ func GetOutputBarForHours(hours decimal.Decimal, stats []Statistic) ([]string) {
|
||||||
colorFraction = stat.Color
|
colorFraction = stat.Color
|
||||||
}
|
}
|
||||||
|
|
||||||
fullColoredParts := int(statHoursInt / 4)
|
fmt.Printf("%f\n", statHoursInt)
|
||||||
|
fullColoredParts := int(math.Round(statHoursInt) / 4)
|
||||||
|
|
||||||
|
if fullColoredParts == 0 && statHoursInt > colorFractionPrevAmount {
|
||||||
|
colorFractionPrevAmount = statHoursInt
|
||||||
|
colorFraction = stat.Color
|
||||||
|
}
|
||||||
|
|
||||||
|
fmt.Printf("Full parts: %d\n", fullColoredParts)
|
||||||
for i := 0; i < fullColoredParts; i++ {
|
for i := 0; i < fullColoredParts; i++ {
|
||||||
colorsFull[colorsFullIdx] = stat.Color
|
colorsFull[colorsFullIdx] = stat.Color
|
||||||
colorsFullIdx++
|
colorsFullIdx++
|
||||||
|
@ -75,7 +84,7 @@ func GetOutputBarForHours(hours decimal.Decimal, stats []Statistic) ([]string) {
|
||||||
bar[i] = " " + GetOutputBoxForNumber(4, colorsFull[iColor]) + " "
|
bar[i] = " " + GetOutputBoxForNumber(4, colorsFull[iColor]) + " "
|
||||||
iColor++
|
iColor++
|
||||||
} else {
|
} else {
|
||||||
bar[i] = " " + GetOutputBoxForNumber(4, color.FgWhite.Render) + " "
|
bar[i] = " " + GetOutputBoxForNumber(4, colorFraction) + " "
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue