Project

PSWriteHTML

Generate HTML reports, dashboards, and emails from PowerShell without writing HTML, CSS, or JavaScript.

Stars 1,023
Forks 115
Open issues 54
PowerShell Gallery downloads 7,576,901
Release v1.45.0
Language: PowerShell Updated: 2026-11-03
Command

New-ChartLegend

Module
PSWriteHTML

Creates a new chart legend with customizable options.

Syntax

New-ChartLegend
[[-Color] <String[]>]
[-DisableOnItemClickToggleDataSeries]
[-DisableOnItemHoverHighlightDataSeries]
[-Floating]
[[-FontFamily] <String>]
[[-FontSize] <Object>]
[[-FontWeight] <String>]
[-HideLegend]
[[-HorizontalAlign] <left|center|right>]
[-InverseOrder]
[[-ItemMarginHorizontal] <Nullable`1>]
[[-ItemMarginVertical] <Nullable`1>]
[[-LegendPosition] <top|left|right|bottom>]
[[-Names] <Array>]
[[-OffsetX] <Nullable`1>]
[[-OffsetY] <Nullable`1>]
[-UseSeriesColors]
[<CommonParameters>]
#
Parameter set: All Parameter Sets

Description

The New-ChartLegend function creates a new chart legend with various customization options such as position, alignment, font settings, and more.

Examples

Example 1

New-ChartLegend -Names @('A', 'B', 'C') -Color @('red', 'blue', 'green') -LegendPosition 'top' -HorizontalAlign 'center' -FontSize 12

Creates a new chart legend with three items ('A', 'B', 'C') in red, blue, and green colors positioned at the top with center alignment and font size of 12.

Parameters

-Color String[] optionalposition: 1
Specifies an array of colors for the legend items.
-DisableOnItemClickToggleDataSeries SwitchParameter optional
Indicates whether to disable toggling data series on legend item click.
-DisableOnItemHoverHighlightDataSeries SwitchParameter optional
Indicates whether to disable highlighting data series on legend item hover.
-Floating SwitchParameter optional
Indicates whether the legend should float.
-FontFamily String optionalposition: 9
Specifies the font family of the legend labels.
-FontSize Object optionalposition: 8
Specifies the font size of the legend labels.
-FontWeight String optionalposition: 10
Specifies the font weight of the legend labels.
Possible values: normal, bold, bolder, lighter, 100, 200, 300, 400, 500, 600, 700, 800, 900
-HideLegend SwitchParameter optional
Indicates whether to hide the legend.
-HorizontalAlign String optionalposition: 3
Specifies the horizontal alignment of the legend labels (left, center, right).
Possible values: left, center, right
-InverseOrder SwitchParameter optional
Indicates whether to display legend items in reverse order.
-ItemMarginHorizontal Nullable<T> optionalposition: 6
Specifies the horizontal margin between legend items.
-ItemMarginVertical Nullable<T> optionalposition: 7
Specifies the vertical margin between legend items.
-LegendPosition String optionalposition: 2
Specifies the position of the legend (top, left, right, bottom).
Possible values: top, left, right, bottom
-Names Array optionalposition: 0
Specifies an array of names for the legend items.
-OffsetX Nullable<T> optionalposition: 4
Specifies the horizontal offset of the legend.
-OffsetY Nullable<T> optionalposition: 5
Specifies the vertical offset of the legend.
-UseSeriesColors SwitchParameter optional
Indicates whether to use series colors for legend items.

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.