Skip to content

New-SpectreChartItem

Description

The New-SpectreChartItem function creates a new SpectreChartItem object with the specified label, value, and color for use in Format-SpectreBarChart and Format-SpectreBreakdownChart.


Examples

Example 1 # This example demonstrates how to use SpectreChartItems to create a breakdown chart.

$data = @()
$data += New-SpectreChartItem -Label "Sales" -Value 1000 -Color "green"
$data += New-SpectreChartItem -Label "Expenses" -Value 500 -Color "#ff0000"
$data += New-SpectreChartItem -Label "Profit" -Value 420 -Color ([Spectre.Console.Color]::Blue)
Write-SpectreHost "`nGenerate a bar chart`n"
$data | Format-SpectreBarChart
Write-SpectreHost "`nGenerate a breakdown chart`n"
$data | Format-SpectreBreakdownChart

Parameters

Label

The label for the chart item.

TypeRequiredPositionPipelineInput
[String]true1false

Value

The value for the chart item.

TypeRequiredPositionPipelineInput
[Double]true2false

Color

The color for the chart item. Must be a valid Spectre color as name, hex or a Spectre.Console.Color object.

TypeRequiredPositionPipelineInput
[Color]true3false

Syntax

New-SpectreChartItem [-Label] <String> [-Value] <Double> [-Color] <Color> [<CommonParameters>]