Skip to main content

Search OfficeIMO

Enter a topic, API type, or PowerShell command.

Documentation Search all OfficeIMO/
Cmdlet

Add-OfficePowerPointChart

Aliases: PowerPointChart
Module
PSWriteOffice
Aliases
PowerPointChart
Inputs
System.Object[]
Outputs
OfficeIMO.PowerPoint.PowerPointChart

Adds a chart to a PowerPoint slide.

Syntax

Add-OfficePowerPointChart
[-Column <Int32>]
[-Height <OfficeLength>]
[-PassThru]
[-Slide <PowerPointSlideSelector>]
[-Span <Int32>]
[-Title <String>]
[-Type <OfficeChartType>]
[-Width <OfficeLength>]
[-X <OfficeLength>]
[-Y <OfficeLength>]
[<CommonParameters>]
#
Parameter set: Sample
Add-OfficePowerPointChart
-Category <String>
[-Column <Int32>]
[-Height <OfficeLength>]
-InputObject <Object[]>
[-PassThru]
[-Slide <PowerPointSlideSelector>]
[-Span <Int32>]
[-Title <String>]
[-Type <OfficeChartType>]
-Value <String[]>
[-Width <OfficeLength>]
[-X <OfficeLength>]
[-Y <OfficeLength>]
[<CommonParameters>]
#
Parameter set: InputObject

Description

Supports default chart data or object-based category/series mappings for standard and scatter charts.

Examples

Add a clustered column chart from objects.

$rows = @(
    [pscustomobject]@{ Month = 'Jan'; Sales = 42; Profit = 9 }
    [pscustomobject]@{ Month = 'Feb'; Sales = 55; Profit = 13 }
)
New-OfficePowerPoint -Path .\Examples\Documents\PowerPointChart.pptx {
    $slide = Add-OfficePowerPointSlide -PassThru
    Add-OfficePowerPointChart -Slide $slide -InputObject $rows -Category Month -Value Sales,Profit -Title 'Monthly performance'
}

Creates a clustered column chart using Month for categories and Sales/Profit as series.

Add a scatter chart from numeric properties.

$rows = @(
    [pscustomobject]@{ Quarter = 1; Revenue = 20 }
    [pscustomobject]@{ Quarter = 2; Revenue = 34 }
)
New-OfficePowerPoint -Path .\Examples\Documents\PowerPointScatter.pptx {
    $slide = Add-OfficePowerPointSlide -PassThru
    Add-OfficePowerPointChart -Slide $slide -Type Scatter -InputObject $rows -Category Quarter -Value Revenue -Title 'Revenue trend'
}

Creates a scatter chart using Quarter on the X axis and Revenue on the Y axis.

Parameters

-Column Int32 optional
One-based start column in the native twelve-column grid; explicit X overrides it.
-Height OfficeLength optional
Chart height; numbers mean points.
-PassThru SwitchParameter optional
Emit the object created or changed by the command.
-Slide PowerPointSlideSelector optional
Target slide that will receive the chart (optional inside DSL).
-Span Int32 optional
Number of grid columns; defaults to twelve, and explicit Width overrides it.
-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
-Width OfficeLength optional
Chart width; numbers mean points.
-X OfficeLength optional
Left offset from the slide origin; numbers mean points.
-Y OfficeLength optional
Top offset from the slide origin; numbers mean points.
-Category String requiredsets: InputObject
Property used for category labels, or numeric X values on scatter charts.
-InputObject Object[] requiredpipeline: True (ByValue)sets: InputObject
Source objects used to build chart data.
-Value String[] requiredsets: InputObject
Properties used as numeric series, or Y series on scatter charts.

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.