2023-07-29 10:34:04 +02:00
|
|
|
*write-chart.ps1*
|
|
|
|
================
|
2022-11-17 20:02:26 +01:00
|
|
|
|
|
|
|
write-chart.ps1
|
2021-10-17 14:33:27 +02:00
|
|
|
|
|
|
|
|
2023-07-29 10:04:38 +02:00
|
|
|
Parameters
|
|
|
|
----------
|
2021-10-17 14:33:27 +02:00
|
|
|
```powershell
|
|
|
|
|
|
|
|
|
|
|
|
[<CommonParameters>]
|
|
|
|
This script supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction,
|
|
|
|
WarningVariable, OutBuffer, PipelineVariable, and OutVariable.
|
|
|
|
```
|
|
|
|
|
2023-07-29 10:04:38 +02:00
|
|
|
Script Content
|
|
|
|
--------------
|
2022-11-17 20:05:34 +01:00
|
|
|
```powershell
|
2022-11-17 20:02:26 +01:00
|
|
|
<#
|
|
|
|
.SYNOPSIS
|
|
|
|
Writes a chart
|
|
|
|
.DESCRIPTION
|
|
|
|
This PowerShell script writes a chart.
|
|
|
|
.EXAMPLE
|
|
|
|
PS> ./write-chart
|
|
|
|
.LINK
|
|
|
|
https://github.com/fleschutz/PowerShell
|
|
|
|
.NOTES
|
|
|
|
Author: Markus Fleschutz | License: CC0
|
|
|
|
#>
|
|
|
|
|
|
|
|
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 # success
|
2022-11-17 20:05:34 +01:00
|
|
|
```
|
2022-11-17 20:02:26 +01:00
|
|
|
|
2023-08-06 21:36:33 +02:00
|
|
|
*(generated by convert-ps2md.ps1 using the comment-based help of write-chart.ps1 as of 08/06/2023 21:36:18)*
|