Out-ConsoleChart
Draws horizontal bars, a histogram or grouped sparklines from pipeline objects.
Syntax
Out-ConsoleChart
[-AsString]
[-AsWidget]
[-Bins <Int32>]
[-InputObject <PSObject>]
[-Label <Object>]
[[-Property] <Object>]
[-Sort <Ascending| Descending>]
[-Top <Int32>]
[-Type <Bar| Histogram| Sparkline>]
[-Unit <String>]
[-Width <Int32>]
[<CommonParameters>]#All Parameter SetsDescription
Select one numeric property, including a calculated property, or pipe numbers directly. Bars show value labels in theme colours. Sorting is stable and happens before Top. Sparkline labels identify groups; samples within each group retain arrival order, so sort timestamped input before piping it. Histogram uses every valid sample regardless of Sort or Top, and integral data has whole-number bucket edges. Null, malformed, boolean and non-finite values produce a non-terminating error and are skipped; an empty input produces no output. No-colour output lists numeric values, bucket counts or all trend samples. Signed trends also use numerical text because the existing sparkline renderer scales from zero. Output uses the normal ConsoleMonster formatting route.
Examples
Example 1
Get-Process | Out-ConsoleChart -Property CPU -Label ProcessName -Sort Descending -Top 10The ten busiest processes, highest CPU first
Example 2
Get-ChildItem -File | Out-ConsoleChart -Property @{ Name = 'KB'; Expression = { $_.Length / 1KB } } -Type Histogram -Bins 8Distribution of file sizes with a calculated property
Example 3
$samples | Sort-Object Time | Out-ConsoleChart -Property Latency -Label Server -Type SparklineOne trend per server, in timestamp order
Example 4
1, 3, 2, 5 | Out-ConsoleChart -Type Histogram -Bins 4 -AsStringCapture a chart as plain text on Windows PowerShell 5.1 or PowerShell 7
Parameters
- -AsString SwitchParameter
- Return one plain-text string for reliable assignment and redirection on every supported PowerShell version. Cannot be combined with AsWidget.
- -AsWidget SwitchParameter
- Return the PipelineChart widget for layout composition or frame export. Cannot be combined with AsString.
- -Bins Int32
- Requested histogram bucket count, 1 through 128 (default 10). Small integral ranges and identical values use fewer buckets to avoid fractional or repeated edges.
- -InputObject PSObject
- Numbers or objects containing the numeric property, supplied directly or through the pipeline. Explicit null samples produce a non-terminating invalid-data error; no input produces no output.
- -Label Object
- A property name or calculated-property hashtable for bar labels and sparkline group names. Defaults to Name, then row number for bars or one unnamed trend for scalars. Labels are literal text.
- -Property Object
- One numeric property name, wildcard matching one property, or calculated-property hashtable. Uses the raw numeric expression result regardless of FormatString. Defaults to Value for scalar input.
- -Sort PipelineChartSort
- None (default), Ascending or Descending by numeric value; trends use the latest sample. Ties retain input order. Ignored for Histogram.
- Possible values:
Ascending,Descending - -Top Int32
- Show this many bars or sparkline groups after sorting. Zero (default) shows all. Histogram always uses every valid sample.
- -Type PipelineChartType
- Bar (default), Histogram or Sparkline. Each sparkline group is one line and preserves sample arrival order.
- Possible values:
Bar,Histogram,Sparkline - -Unit String
- Unit suffix appended to numerical values and histogram edges, for example ' ms'.
- -Width Int32
- Layout width in terminal cells; zero uses the current terminal width.
Common Parameters
This command supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable.
For more information, see about_CommonParameters.