Skip to content

Format-SpectreBarChart

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.
See https://spectreconsole.net/widgets/barchart for more information.


Examples

Example 1
This example demonstrates how to display a bar chart of various data points.

$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 -Label "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
[Object]true1true (ByValue)

Label

The title to be displayed above the chart.

TypeRequiredPositionPipelineInputAliases
[String]false2falseTitle

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] <Object> [[-Label] <String>] [[-Width] <Int32>] [-HideValues] [<CommonParameters>]