mirror of
https://github.com/fleschutz/PowerShell.git
synced 2024-11-08 09:04:18 +01:00
46 lines
975 B
PowerShell
46 lines
975 B
PowerShell
<#
|
|
.SYNOPSIS
|
|
write-chart.ps1
|
|
.DESCRIPTION
|
|
Writes a chart.
|
|
.EXAMPLE
|
|
PS> .\write-chart.ps1
|
|
.NOTES
|
|
Author: Markus Fleschutz · License: CC0
|
|
.LINK
|
|
https://github.com/fleschutz/PowerShell
|
|
#>
|
|
|
|
function WriteChartLine { param([string]$Text, [float]$Value, [float]$Max)
|
|
$Num = ($Value * 40.0) / $Max
|
|
while ($Num -ge 1.0) {
|
|
write-host -noNewLine "█"
|
|
$Num -= 1.0
|
|
}
|
|
if ($Num -ge 0.875) {
|
|
write-host -noNewLine "▉"
|
|
} elseif ($Num -ge 0.75) {
|
|
write-host -noNewLine "▊"
|
|
} elseif ($Num -ge 0.625) {
|
|
write-host -noNewLine "▋"
|
|
} elseif ($Num -ge 0.5) {
|
|
write-host -noNewLine "▌"
|
|
} elseif ($Num -ge 0.375) {
|
|
write-host -noNewLine "▍"
|
|
} elseif ($Num -ge 0.25) {
|
|
write-host -noNewLine "▎"
|
|
} elseif ($Num -ge 0.125) {
|
|
write-host -noNewLine "▏"
|
|
}
|
|
if ($Max -eq 100.0) {
|
|
write-host " $($Value)% $Text"
|
|
} else {
|
|
write-host " $Value / $Max $Text"
|
|
}
|
|
}
|
|
|
|
"2021 Wins"
|
|
WriteChartLine "Markus" 40.5 100.0
|
|
WriteChartLine "Andrea" 30.9 100.0
|
|
exit 0
|