Skip to content
ConsoleMonster
Cmdlet

Out-ConsoleChart

Module
ConsoleMonster
Inputs
System.Management.Automation.PSObject
Outputs
System.String ConsoleMonster.Widgets.PipelineChart

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>]
#
Parameter set: All Parameter Sets

Description

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 10

The ten busiest processes, highest CPU first

Example 2

Get-ChildItem -File | Out-ConsoleChart -Property @{ Name = 'KB'; Expression = { $_.Length / 1KB } } -Type Histogram -Bins 8

Distribution of file sizes with a calculated property

Example 3

$samples | Sort-Object Time | Out-ConsoleChart -Property Latency -Label Server -Type Sparkline

One trend per server, in timestamp order

Example 4

1, 3, 2, 5 | Out-ConsoleChart -Type Histogram -Bins 4 -AsString

Capture a chart as plain text on Windows PowerShell 5.1 or PowerShell 7

Parameters

-AsString SwitchParameter optional
Return one plain-text string for reliable assignment and redirection on every supported PowerShell version. Cannot be combined with AsWidget.
-AsWidget SwitchParameter optional
Return the PipelineChart widget for layout composition or frame export. Cannot be combined with AsString.
-Bins Int32 optional
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 optionalpipeline: True (ByValue)
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 optional
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 optionalposition: 0
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 optional
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 optional
Show this many bars or sparkline groups after sorting. Zero (default) shows all. Histogram always uses every valid sample.
-Type PipelineChartType optional
Bar (default), Histogram or Sparkline. Each sparkline group is one line and preserves sample arrival order.
Possible values: Bar, Histogram, Sparkline
-Unit String optional
Unit suffix appended to numerical values and histogram edges, for example ' ms'.
-Width Int32 optional
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.