Skip to main content

Search OfficeIMO

Enter a topic, API type, or PowerShell command.

Documentation Search all OfficeIMO/
Cmdlet

Set-OfficeExcelChartLegend

Aliases: ExcelChartLegend
Module
PSWriteOffice
Aliases
ExcelChartLegend
Inputs
OfficeIMO.Excel.ExcelChart

Shows, hides, positions and styles the chart legend.

Syntax

Set-OfficeExcelChartLegend
[-Bold]
[-Chart] <ExcelChart>
[-Color <OfficeColor>]
[-Font <String>]
[-Hidden]
[-Italic]
[-Overlay]
[-PassThru]
[-Position <Bottom|TopRight|Left|Right|Top>]
[-Size <OfficeLength>]
[<CommonParameters>]
#
Parameter set: Default

Examples

Move the legend to the bottom

New-OfficeExcel -Path .\Reports\Helpdesk-Trend.xlsx {
    ExcelSheet 'Trend' {
        ExcelChart -InputObject (Import-OfficeCsv -Path .\Data\Ticket-Trend.csv) -Category Week -Value Opened, Closed -Type Line -Address A1 -PassThru | ExcelChartLegend -Position Bottom
    }
}

Places the legend of a line chart under the plot area.

Hide the legend of a single-series chart

New-OfficeExcel -Path .\Reports\Availability.xlsx {
    ExcelSheet 'Uptime' {
        $chart = ExcelChart -InputObject (Import-OfficeCsv -Path .\Data\Site-Uptime.csv) -Category Site -Value Uptime -Address A1 -Type Column -Title 'Uptime by site' -PassThru
        ExcelChartLegend -Chart $chart -Hidden
    }
}

Removes the legend where the chart title already names the only series.

Parameters

-Bold SwitchParameter optional
Applies bold text. An explicit false value clears bold; omission preserves the native value.
-Chart ExcelChart requiredposition: 0pipeline: True (ByValue)
Chart to update.
-Color OfficeColor optional
Text or rule colour expressed as a literal OfficeColor or theme role.
-Font String optional
Font family name.
-Hidden SwitchParameter optional
Hide or show the column.
-Italic SwitchParameter optional
Applies italic text. An explicit false value clears italic; omission preserves the native value.
-Overlay SwitchParameter optional
Overlay the legend on the chart area.
-PassThru SwitchParameter optional
Emits the native result after the operation.
-Position OfficeChartLegendPosition optional
Legend position.
Possible values: Bottom, TopRight, Left, Right, Top
-Size OfficeLength optional
Font size, interpreted as points for numbers; explicit physical units are accepted.

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.