Skip to content

Format-SpectreBarChart

Synopsis

Formats and displays a bar chart using the Spectre Console module. Example bar chart


Description

This function takes an array of data and displays it as a bar chart using the Spectre Console module. The chart can be customized with a title and width.


Examples

This example uses the new helper for generating chart items New-SpectreChartItem and shows the various ways of passing color values in

$data = @()
$data += New-SpectreChartItem -Label "Apples" -Value 10 -Color "Green"
$data += New-SpectreChartItem -Label "Oranges" -Value 5 -Color "DarkOrange"
$data += New-SpectreChartItem -Label "Bananas" -Value 2.2 -Color "#FFFF00"

Format-SpectreBarChart -Data $data -Title "Fruit Sales" -Width 50

Parameters

Data

An array of objects containing the data to be displayed in the chart. Each object should have a Label, Value, and Color property.

TypeRequiredPositionPipelineInput
[Array]true1true (ByValue)

Title

The title to be displayed above the chart.

TypeRequiredPositionPipelineInput
[String]false2false

Width

The width of the chart in characters.

TypeRequiredPositionPipelineInput
[Int32]false3false

HideValues

Hides the values from being displayed on the chart.

TypeRequiredPositionPipelineInput
[Switch]falsenamedfalse

Syntax

Format-SpectreBarChart [-Data] <Array> [[-Title] <String>] [[-Width] <Int32>] [-HideValues] [<CommonParameters>]