PowerShell/Scripts/write-chart.ps1

46 lines
975 B
PowerShell
Raw Normal View History

2021-08-26 10:46:12 +02:00
<#
2021-08-03 15:53:57 +02:00
.SYNOPSIS
write-chart.ps1
.DESCRIPTION
2021-08-29 17:50:03 +02:00
Writes a chart.
2021-08-03 15:53:57 +02:00
.EXAMPLE
PS> .\write-chart.ps1
2021-08-29 17:50:03 +02:00
.NOTES
Author: Markus Fleschutz · License: CC0
2021-08-03 15:53:57 +02:00
.LINK
https://github.com/fleschutz/PowerShell
#>
2021-06-01 16:44:28 +02:00
2021-06-01 17:55:00 +02:00
function WriteChartLine { param([string]$Text, [float]$Value, [float]$Max)
$Num = ($Value * 40.0) / $Max
2021-06-01 16:44:28 +02:00
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 ""
}
2021-06-01 17:55:00 +02:00
if ($Max -eq 100.0) {
write-host " $($Value)% $Text"
} else {
write-host " $Value / $Max $Text"
}
2021-06-01 16:44:28 +02:00
}
"2021 Wins"
2021-06-01 17:55:00 +02:00
WriteChartLine "Markus" 40.5 100.0
WriteChartLine "Andrea" 30.9 100.0
2021-06-01 16:44:28 +02:00
exit 0