# Add-OfficeWordChart

Adds a chart to a Word document. Review available syntax, parameters, pipeline guidance, and reference details in PSWriteOffice Cmdlet Reference.

Cmdlet 

Aliases: WordChart

**Module**

`PSWriteOffice`

**Aliases**

`WordChart`

**Inputs**

`System.Object[]`

**Outputs**

`OfficeIMO.Word.WordChart`

**Source**

[AddOfficeWordChartCommand.cs:45](https://github.com/EvotecIT/OfficeIMO/blob/be6c300e4ab1859837b961c64fbfb2b2a1886cd0/PowerShell/PSWriteOffice/Sources/PSWriteOffice/Cmdlets/Word/AddOfficeWordChartCommand.cs#L45) 

Adds a chart to a Word document.

## Syntax

```
Add-OfficeWordChart
-Category <String>
[-FitToPageWidth]
[-Height <OfficeLength>]
-InputObject <Object[]>
[-Legend]
[-LegendPosition <Bottom|TopRight|Left|Right|Top>]
[-PassThru]
[-SeriesColor <OfficeColor[]>]
[-Title <String>]
[-Type <OfficeChartType>]
-Value <String[]>
[-Width <OfficeLength>]
[-WidthFraction <Double>]
[-XAxisTitle <String>]
[-YAxisTitle <String>]
[<CommonParameters>]
```

[#](#member-13bc6a0140fed3c4aece46a7)

Parameter set: `Context`

```
Add-OfficeWordChart
-Category <String>
-Document <WordDocument>
[-FitToPageWidth]
[-Height <OfficeLength>]
-InputObject <Object[]>
[-Legend]
[-LegendPosition <Bottom|TopRight|Left|Right|Top>]
[-PassThru]
[-SeriesColor <OfficeColor[]>]
[-Title <String>]
[-Type <OfficeChartType>]
-Value <String[]>
[-Width <OfficeLength>]
[-WidthFraction <Double>]
[-XAxisTitle <String>]
[-YAxisTitle <String>]
[<CommonParameters>]
```

[#](#member-a03a570189641d4afa2724c7)

Parameter set: `Document`

```
Add-OfficeWordChart
-Category <String>
[-FitToPageWidth]
[-Height <OfficeLength>]
-InputObject <Object[]>
[-Legend]
[-LegendPosition <Bottom|TopRight|Left|Right|Top>]
-Paragraph <WordParagraph>
[-PassThru]
[-SeriesColor <OfficeColor[]>]
[-Title <String>]
[-Type <OfficeChartType>]
-Value <String[]>
[-Width <OfficeLength>]
[-WidthFraction <Double>]
[-XAxisTitle <String>]
[-YAxisTitle <String>]
[<CommonParameters>]
```

[#](#member-709aa9107121c3770bd99486)

Parameter set: `Paragraph`

## Description

Creates a Word chart from object data using one category property and one or more numeric series properties.

## Guides & Samples

Authored walkthroughs and practical samples linked to this command.

- [Readable document layouts](/docs/pswriteoffice/document-layout/) Guide
  
  Build readable PSWriteOffice reports with paragraph spacing, table-cell padding, consistent colours, clear chart units, and page-aware layouts.
- [Patch compliance report from PowerShell](/showcase/pswriteoffice-patch-report/) Sample
  
  Review patch compliance and site exceptions with a PowerShell report, including a summary chart, an editable Word document and a PDF.

## Examples

### Add pie and line charts to a report.

```powershell
$rows = @(
    [pscustomobject]@{ Region = 'North America'; Revenue = 125000; Profit = 42000 }
    [pscustomobject]@{ Region = 'EMEA'; Revenue = 98000; Profit = 31000 }
    [pscustomobject]@{ Region = 'APAC'; Revenue = 143000; Profit = 52000 }
)
New-OfficeWord -Path .\RegionalReport.docx {
    Add-OfficeWordParagraph -Text 'Regional revenue'
    Add-OfficeWordChart -Type Pie -InputObject $rows -Category Region -Value Revenue -Title 'Revenue mix' -FitToPageWidth -WidthFraction 0.75
    Add-OfficeWordChart -Type Bar -InputObject $rows -Category Region -Value Revenue, Profit -Legend -XAxisTitle 'Region' -YAxisTitle 'Amount'
}
```

Creates a report with a pie chart and a multi-series bar chart from PowerShell objects.

### Add a line chart to an open document.

```powershell
$trend = @(
    [pscustomobject]@{ Month = 'Jan'; Sales = 10; Profit = 4 }
    [pscustomobject]@{ Month = 'Feb'; Sales = 12; Profit = 5 }
    [pscustomobject]@{ Month = 'Mar'; Sales = 15; Profit = 7 }
)
$doc = New-OfficeWord -Path .\Trend.docx -NoSave
Add-OfficeWordChart -Document $doc -Type Line -InputObject $trend -Category Month -Value Sales, Profit -Legend -Title 'Quarter trend'
Save-OfficeWord -Document $doc
```

Creates a multi-series line chart on the document and shows a legend.

## Parameters

**-Category String required**

Property name used for category labels.

**-FitToPageWidth SwitchParameter optional**

Scale the chart width to the page content width.

**-Height OfficeLength optional**

Chart height; numbers mean points.

**-InputObject Object[] requiredpipeline: True (ByValue)aliases: Data**

Source objects used to build chart data.

**-Legend SwitchParameter optional**

Add a legend to the chart.

**-LegendPosition OfficeChartLegendPosition optional**

Legend position when -Legend is used.

Possible values: `Bottom`, `TopRight`, `Left`, `Right`, `Top`

**-PassThru SwitchParameter optional**

Emit the created chart.

**-SeriesColor OfficeColor[] optional**

Color values applied to the series in order.

**-Title String optional**

Optional chart title.

**-Type OfficeChartType optional**

Chart type to create.

Possible values: `ColumnClustered`, `Column`, `ColumnStacked`, `ColumnStacked100`, `BarClustered`, `Bar`, `BarStacked`, `BarStacked100`, `Line`, `LineStacked`, `LineStacked100`, `Area`, `AreaStacked`, `AreaStacked100`, `Scatter`, `Radar`, `Pie`, `Doughnut`, `Bubble`, `Column3DClustered`, `Column3DStacked`, `Column3DStacked100`, `Bar3DClustered`, `Bar3DStacked`, `Bar3DStacked100`, `Line3D`, `Area3D`, `Area3DStacked`, `Area3DStacked100`, `Pie3D`, `PieOfPie`, `BarOfPie`, `Stock`, `Surface`, `SurfaceWireframe`, `SurfaceContour`, `Funnel`, `Waterfall`, `BoxWhisker`, `Treemap`, `SurfaceContourWireframe`, `Sunburst`

**-Value String[] required**

Property names used as numeric series.

**-Width OfficeLength optional**

Chart width; numbers mean points.

**-WidthFraction Double optional**

Fraction of the page content width to use when -FitToPageWidth is specified.

**-XAxisTitle String optional**

Optional X axis title for non-pie charts.

**-YAxisTitle String optional**

Optional Y axis title for non-pie charts.

**-Document WordDocument requiredsets: Document**

Target document that will receive the chart.

**-Paragraph WordParagraph requiredsets: Paragraph**

Target paragraph used as the chart anchor.

## 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](https://learn.microsoft.com/powershell/module/microsoft.powershell.core/about/about_commonparameters).

<!-- PowerForge markdown artifact sha256:053E2123DB23FC2E1F9B09F9D7978D63B4063604CAFA87893766596E39F6D6B4 -->
