API Reference
WordChart
Provides functionality for creating and manipulating charts within a WordDocument.
Inheritance
- WordElement
- WordChart
Usage
This type appears in these public API surfaces even when no hand-authored example is attached directly to the page.
Returned or exposed by
- Method WordChart.AddPie3D``1
- Method WordChart.AddPie``1
- Method WordChart.ApplyPalette
- Method WordChart.SetAxisTitleFormat
- Method WordChart.SetPieSliceColor
- Method WordChart.SetSeriesColor
- Method WordChart.SetSize
- Method WordChart.SetTitle
- Method WordChart.SetWidthToPageContent
- Method WordChart.SetXAxisTitle
- Method WordChart.SetYAxisTitle
- Method WordDocument.AddChart
- Method WordDocument.AddComboChart
- Property WordDocument.Charts
- Method WordParagraph.AddChart
- Method WordParagraph.AddComboChart
- Property WordParagraph.Chart
- Property WordSection.Charts
Constructors
public WordChart(WordDocument document, WordParagraph paragraph, String title = "", Boolean roundedCorners = false, Int32 width = 600, Int32 height = 600) #Creates a new chart and inserts it into the specified paragraph.
Parameters
- document OfficeIMO.Word.WordDocument
- Parent document that will contain the chart.
- paragraph OfficeIMO.Word.WordParagraph
- Paragraph where the chart will be placed.
- title System.String = ""
- Optional chart title.
- roundedCorners System.Boolean = false
- Specifies whether the chart frame should have rounded corners.
- width System.Int32 = 600
- Initial chart width in pixels.
- height System.Int32 = 600
- Initial chart height in pixels.
Methods
public Void AddArea3D<T>(String name, List<T> values, OfficeColor color) #VoidAdds a 3D area chart series.
Type Parameters
- T
- Numeric type of the data values.
Parameters
- name System.String
- Series name.
- values System.Collections.Generic.List{``0}
- Series data values.
- color OfficeIMO.Drawing.OfficeColor
- Series color.
public Void AddArea<T>(String name, List<T> values, OfficeColor color) #VoidAdds an area chart series using the provided values.
Type Parameters
- T
- Numeric type of the data values.
Parameters
- name System.String
- Series name.
- values System.Collections.Generic.List{``0}
- Values for the series.
- color OfficeIMO.Drawing.OfficeColor
- Fill color for the series.
public Void AddArea<T>(String name, Int32[] values, OfficeColor color) #VoidAdds an area chart series using an array of integer values.
Type Parameters
- T
- Unused generic parameter.
Parameters
- name System.String
- Series name.
- values System.Int32[]
- Data values.
- color OfficeIMO.Drawing.OfficeColor
- Fill color for the series.
public Void AddBar(String name, Int32 values, OfficeColor color) #VoidAdds a bar series to the chart. When mixing bar and line series be sure to call String>) first so the categories are shared across both chart types.
Parameters
- arg1 System.String
- arg2 System.Int32
- arg3 OfficeIMO.Drawing.OfficeColor
public Void AddBar(String name, Int32[] values, OfficeColor color) #VoidAdds a bar series from an array of values. For combo charts ensure String>) has been called first.
Parameters
- arg1 System.String
- arg2 System.Int32[]
- arg3 OfficeIMO.Drawing.OfficeColor
public Void AddBar3D<T>(String name, List<T> values, OfficeColor color) #VoidAdds a 3D bar chart series.
Type Parameters
- T
- Numeric type of the data values.
Parameters
- name System.String
- Series name.
- values System.Collections.Generic.List{``0}
- Series data values.
- color OfficeIMO.Drawing.OfficeColor
- Color of the bars.
public Void AddBar<T>(String name, List<T> values, OfficeColor color) #VoidAdds a bar series with multiple values. When used in a combo chart with line series the categories must be set via String>) before calling this method.
Type Parameters
- T
Parameters
- arg1 System.String
- arg2 System.Collections.Generic.List{``0}
- arg3 OfficeIMO.Drawing.OfficeColor
public Void AddCategories(List<String> categories) #VoidSets the category labels used by subsequent chart series.
Parameters
- categories System.Collections.Generic.List{System.String}
- List of category names.
public Void AddChartAxisX(List<String> categories) #VoidSets the category labels for the X axis. This should be called before adding bar or line series when creating a combo chart so that both chart types share the same axis.
Parameters
- categories System.Collections.Generic.List{System.String}
public Void AddChartLine<T>(String name, Int32[] values, OfficeColor color) #VoidAdds a line series to the chart from an array of integer values.
Type Parameters
- T
- Unused generic parameter.
Parameters
- name System.String
- Series name.
- values System.Int32[]
- Values for the series.
- color OfficeIMO.Drawing.OfficeColor
- Line color.
public Void AddLegend(OfficeChartLegendPosition legendPosition) #VoidAdds a legend to the chart at the specified position.
Parameters
- legendPosition OfficeIMO.Drawing.OfficeChartLegendPosition
- Desired legend position.
public Void AddLine3D<T>(String name, List<T> values, OfficeColor color) #VoidAdds a 3D line chart series to the chart.
Type Parameters
- T
- The type of data values
Parameters
- name System.String
- The name of the series
- values System.Collections.Generic.List{``0}
- The data values for the series
- color OfficeIMO.Drawing.OfficeColor
- The color of the series
public Void AddLine<T>(String name, List<T> values, OfficeColor color) #VoidAdd a line to a chart. Multiple lines can be added. You cannot mix lines with pie charts. Lines can be combined with bar series to create combo charts, but make sure to call String>) before adding either series.
Type Parameters
- T
Parameters
- name System.String
- values System.Collections.Generic.List{``0}
- color OfficeIMO.Drawing.OfficeColor
public WordChart AddPie3D<T>(String category, T value) #WordChartAdds a single value to a 3D pie chart.
Type Parameters
- T
- Numeric type representing the value.
Parameters
- category System.String
- Category label.
- value ``0
- Data value for the slice.
Returns
The current WordChart instance.
public WordChart AddPie<T>(String category, T value) #WordChartAdds a single value to a pie chart.
Type Parameters
- T
- Numeric type representing the value.
Parameters
- category System.String
- Category label.
- value ``0
- Data value for the slice.
Returns
The current WordChart instance.
public Void AddRadar<T>(String name, List<T> values, OfficeColor color) #VoidAdds a radar chart series.
Type Parameters
- T
- Numeric type of the values.
Parameters
- name System.String
- Series name.
- values System.Collections.Generic.List{``0}
- Values for the series.
- color OfficeIMO.Drawing.OfficeColor
- Color of the series.
public Void AddScatter(String name, List<Double> xValues, List<Double> yValues, OfficeColor color) #VoidAdds a scatter chart series with separate X and Y values.
Parameters
- name System.String
- Series name.
- xValues System.Collections.Generic.List{System.Double}
- Values plotted on the X axis.
- yValues System.Collections.Generic.List{System.Double}
- Values plotted on the Y axis.
- color OfficeIMO.Drawing.OfficeColor
- Color of the series.
public WordChart ApplyPalette(WordChartPalette palette, Boolean semanticOutcomes = true, Boolean applyToPies = true, Boolean applyToSeries = true, Dictionary<String, OfficeColor> overrides = null) #WordChartApplies a built-in palette across the chart. Optionally honors semantic outcome names (Passed/Failed/Skipped/Error). Use applyToPies/applyToSeries to target types.
Parameters
- palette OfficeIMO.Word.WordChart.WordChartPalette
- semanticOutcomes System.Boolean = true
- applyToPies System.Boolean = true
- applyToSeries System.Boolean = true
- overrides System.Collections.Generic.Dictionary{System.String,OfficeIMO.Drawing.OfficeColor} = null
public WordChart SetAxisTitleFormat(String fontName, Int32 fontSize, OfficeColor color) #WordChartDefines font formatting for axis titles.
Parameters
- fontName System.String
- Font family name.
- fontSize System.Int32
- Font size in points.
- color OfficeIMO.Drawing.OfficeColor
- Text color.
Returns
The current WordChart instance.
public WordChart SetPieSliceColor(UInt32 index, OfficeColor color) #WordChartSets the color of a specific pie slice by zero-based index.
Parameters
- index System.UInt32
- color OfficeIMO.Drawing.OfficeColor
public WordChart SetSeriesColor(UInt32 index, OfficeColor color) #WordChartSets the color of a specific series by its zero-based index across supported chart types.
Parameters
- index System.UInt32
- color OfficeIMO.Drawing.OfficeColor
public WordChart SetSize(Int32 widthPx, Nullable<Int32> heightPx = null) #WordChartSets the chart frame size. Values are in pixels.
Parameters
- widthPx System.Int32
- heightPx System.Nullable{System.Int32} = null
public WordChart SetTitle(String title) #WordChartSet the title of the chart
Parameters
- title System.String
public WordChart SetWidthToPageContent(Double fraction = 1, Nullable<Int32> heightPx = null) #WordChartSets chart width to the page content width (page width minus left/right margins). Optionally scales by fraction and adjusts height in pixels.
Parameters
- fraction System.Double = 1
- heightPx System.Nullable{System.Int32} = null
public WordChart SetXAxisTitle(String title) #WordChartSets the title displayed on the X axis.
Parameters
- title System.String
- Axis title text.
Returns
The current WordChart instance.
public WordChart SetYAxisTitle(String title) #WordChartSets the title displayed on the Y axis.
Parameters
- title System.String
- Axis title text.
Returns
The current WordChart instance.
public Boolean TryGetLayoutSnapshot(out WordDrawingLayoutSnapshot snapshot) #BooleanReads persisted inline or anchored package geometry for this chart.
Parameters
- snapshot OfficeIMO.Word.WordDrawingLayoutSnapshot@
- The package-geometry snapshot when the chart has a supported drawing frame.
Returns
true when persisted layout evidence was available.
public Boolean TryGetSnapshot(out WordChartSnapshot snapshot) #BooleanTries to create a dependency-free chart snapshot from cached Word chart data.
Parameters
- snapshot OfficeIMO.Word.WordChartSnapshot@
public Boolean TrySetCategories(IEnumerable<String> categories) #BooleanReplaces the cached categories on every category-based series with literal values. Existing worksheet references are detached so Word cannot silently restore stale linked cache values. Scatter charts do not have category-axis data and are not changed.
Parameters
- categories System.Collections.Generic.IEnumerable{System.String}
- The literal category labels to persist.
Returns
true when at least one imported or code-created series was updated.
public Boolean TrySetSeriesName(UInt32 seriesIndex, String name) #BooleanReplaces the cached name of an existing series with a literal value.
Parameters
- seriesIndex System.UInt32
- The persisted chart series index (c:idx).
- name System.String
- The new series name.
Returns
true when the indexed series has a mutable series-text element.
public Boolean TrySetSeriesValues(UInt32 seriesIndex, IEnumerable<Double> values) #BooleanReplaces one series' cached numeric values with literal values. Worksheet references for that value range are detached, while unrelated embedded-workbook parts are preserved.
Parameters
- seriesIndex System.UInt32
- The persisted chart series index (c:idx).
- values System.Collections.Generic.IEnumerable{System.Double}
- The literal numeric values to persist.
Returns
true when the indexed series and its numeric value container were found.
Inherited Methods
public override Boolean Equals(Object obj) #BooleanParameters
- obj Object
Properties
public Nullable<WordChartBarGrouping> BarGrouping { get; set; } #Gets or sets the bar grouping mode for bar charts.
public Nullable<WordChartBarDirection> BarDirection { get; set; } #Gets or sets the bar direction (row or column) for bar charts.
public Boolean RoundedCorners { get; set; } #Gets or sets whether the chart frame uses rounded corners.
public String Title { get; set; } #Get or set the title of the chart