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.
Type | Required | Position | PipelineInput |
---|---|---|---|
[Object] | true | 1 | true (ByValue) |
Label
The title to be displayed above the chart.
Type | Required | Position | PipelineInput | Aliases |
---|---|---|---|---|
[String] | false | 2 | false | Title |
Width
The width of the chart in characters.
Type | Required | Position | PipelineInput |
---|---|---|---|
[Int32] | false | 3 | false |
HideValues
Hides the values from being displayed on the chart.
Type | Required | Position | PipelineInput |
---|---|---|---|
[Switch] | false | named | false |
Syntax
Format-SpectreBarChart [-Data] <Object> [[-Label] <String>] [[-Width] <Int32>] [-HideValues] [<CommonParameters>]