Skip to main content

Search OfficeIMO

Enter a topic, API type, or PowerShell command.

Documentation Search all OfficeIMO/
Class

WordChart

OfficeIMO.Word

Namespace
OfficeIMO.Word
Assembly
OfficeIMO.Word
Source revision
0eef6a5756b9 with working tree changes

Provides functionality for creating and manipulating charts within a WordDocument.

Inheritance

Usage

Explore 30 API references to this type

This type appears in these public API surfaces even when no hand-authored example is attached directly to the page.

Constructors

public WordChart(WordDocument document, WordParagraph paragraph, string title = "", bool roundedCorners = false, OfficeLength? width = null, OfficeLength? height = null) #

Creates a new chart and inserts it into the specified paragraph.

Parameters

document OfficeIMO.Word.WordDocument required
Parent document that will contain the chart.
paragraph OfficeIMO.Word.WordParagraph required
Paragraph where the chart will be placed.
title string = "" optional
Optional chart title.
roundedCorners bool = false optional
Specifies whether the chart frame should have rounded corners.
width OfficeIMO.OfficeLength? = null optional
Initial chart width; defaults to 600 pixels.
height OfficeIMO.OfficeLength? = null optional
Initial chart height; defaults to 600 pixels.

Methods

public WordChartSeries AddArea3D<T>(string name, List<T?> values, OfficeColor color) #

Adds a 3D area chart series.

Type Parameters

T
Numeric type of the data values.

Parameters

name string required
Series name.
values System.Collections.Generic.List<T?> required
Series data values.
color OfficeIMO.OfficeColor required
Series color.
public WordChartSeries AddArea<T>(string name, IEnumerable<T?> values, OfficeColor color) #

Adds an area chart series using the provided values.

Type Parameters

T
Numeric type of the data values.

Parameters

name string required
Series name.
values System.Collections.Generic.IEnumerable<T?> required
Values for the series.
color OfficeIMO.OfficeColor required
Fill color for the series.
public WordChartSeries AddBar3D<T>(string name, List<T?> values, OfficeColor color) #

Adds a 3D bar chart series.

Type Parameters

T
Numeric type of the data values.

Parameters

name string required
Series name.
values System.Collections.Generic.List<T?> required
Series data values.
color OfficeIMO.OfficeColor required
Color of the bars.
public WordChartSeries AddBar<T>(string name, IEnumerable<T?> values, OfficeColor color) #

Adds a bar series with multiple values. When used in a combo chart with line series the categories must be set via WordChart.AddCategories before calling this method.

Type Parameters

T

Parameters

name string required
values System.Collections.Generic.IEnumerable<T?> required
color OfficeIMO.OfficeColor required
public WordChartAxis AddCategories(IEnumerable<string> categories) #

Sets the category labels used by subsequent chart series.

Parameters

categories System.Collections.Generic.IEnumerable<string> required
List of category names.
public WordChart AddDoughnut<T>(string category, T? value) #

Adds a category and value to an editable native doughnut chart with a 50-percent hole.

Type Parameters

T
An int, double, or float value.

Parameters

category string required
The slice's category label.
value T? required
A finite, nonnegative slice value.

Returns

WordChart The current chart.

Exceptions

  • NotSupportedException – The chart already has another family, or its values use worksheet references.
public WordChartLegend AddLegend(OfficeChartLegendPosition legendPosition) #

Adds a legend to the chart at the specified position.

Parameters

legendPosition OfficeIMO.Drawing.OfficeChartLegendPosition required
Desired legend position.
public WordChartSeries AddLine3D<T>(string name, List<T?> values, OfficeColor color) #

Adds a 3D line chart series to the chart.

Type Parameters

T
The type of data values

Parameters

name string required
The name of the series
values System.Collections.Generic.List<T?> required
The data values for the series
color OfficeIMO.OfficeColor required
The color of the series
public WordChartSeries AddLine<T>(string name, IEnumerable<T?> values, OfficeColor color) #

Add 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 WordChart.AddCategories before adding either series.

Type Parameters

T

Parameters

name string required
values System.Collections.Generic.IEnumerable<T?> required
color OfficeIMO.OfficeColor required
public WordChart AddPie3D<T>(string category, T? value) #

Adds a single value to a 3D pie chart.

Type Parameters

T
Numeric type representing the value.

Parameters

category string required
Category label.
value T? required
Data value for the slice.

Returns

WordChart The current WordChart instance.
public WordChart AddPie<T>(string category, T? value) #

Adds a single value to a pie chart.

Type Parameters

T
Numeric type representing the value.

Parameters

category string required
Category label.
value T? required
Data value for the slice.

Returns

WordChart The current WordChart instance.
public WordChartSeries AddRadar<T>(string name, List<T?> values, OfficeColor color) #

Adds a radar chart series.

Type Parameters

T
Numeric type of the values.

Parameters

name string required
Series name.
values System.Collections.Generic.List<T?> required
Values for the series.
color OfficeIMO.OfficeColor required
Color of the series.
public WordChartSeries AddScatter(string name, List<double> xValues, List<double> yValues, OfficeColor color) #

Adds a scatter chart series with separate X and Y values.

Parameters

name string required
Series name.
xValues System.Collections.Generic.List<double> required
Values plotted on the X axis.
yValues System.Collections.Generic.List<double> required
Values plotted on the Y axis.
color OfficeIMO.OfficeColor required
Color of the series.
public WordChart ApplyPalette(WordChartPalette palette, bool semanticOutcomes = true, bool applyToPies = true, bool applyToSeries = true, Dictionary<string, OfficeColor>? overrides = null) #

Applies 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 required
semanticOutcomes bool = true optional
applyToPies bool = true optional
applyToSeries bool = true optional
overrides System.Collections.Generic.Dictionary<string, OfficeIMO.OfficeColor>? = null optional

Returns

WordChart
public WordChart SetAxisTitleFormat(string fontFamily, OfficeLength fontSize, OfficeColor color) #

Defines font formatting for axis titles.

Parameters

fontFamily string required
Font family name.
fontSize OfficeIMO.OfficeLength required
Font size in points.
color OfficeIMO.OfficeColor required
Text color.

Returns

WordChart The current WordChart instance.
public WordChart SetCountAxis(uint? majorUnit = null) #

Sets count axes to start at zero, use whole-number labels and a positive integral tick interval.

Parameters

majorUnit uint? = null optional
Optional distance between ticks in whole counts. When omitted, a readable integral interval is selected from the cached values.

Returns

WordChart The chart.
public WordChart SetData(OfficeChartType chartKind, OfficeChartData data) #

Initializes or updates an editable native chart and its embedded worksheet from shared chart data. Existing chart and drawing titles, dimensions, and accessibility text are preserved. Use series render kinds and axis groups to describe combinations and secondary value axes.

Parameters

chartKind OfficeIMO.OfficeChartType required
The default chart family for series without their own render kind.
data OfficeIMO.Drawing.OfficeChartData required
Categories and series, including supported point and marker styles.

Returns

WordChart The current chart.
public WordChart SetDataPointStyle(int seriesIndex, uint pointIndex, OfficeChartPointStyle? style) #

Replaces a point's fill/outline overrides. Null restores series/theme inheritance.

Parameters

seriesIndex int required
pointIndex uint required
style OfficeIMO.Drawing.OfficeChartPointStyle? required

Returns

WordChart
public WordChart SetPaperStyle(bool percentageLabels = false, OfficeColor? titleColor = null) #

Uses percentage-only pie labels or count-only bar labels, and removes the chart background and frame.

Parameters

percentageLabels bool = false optional
True for percentage-only pie labels; false for numeric count labels.
titleColor OfficeIMO.OfficeColor? = null optional
Text color for the chart title.

Returns

WordChart The chart.
public WordChart SetPieSliceColor(uint index, OfficeColor color) #

Sets the color of a specific pie slice by zero-based index.

Parameters

index uint required
color OfficeIMO.OfficeColor required

Returns

WordChart
public WordChart SetRadialLayout(OfficeChartRadialLayout layout) #

Sets geometry for an existing native two-dimensional pie or doughnut chart.

Parameters

layout OfficeIMO.Drawing.OfficeChartRadialLayout required

Returns

WordChart
public WordChart SetSecondaryValueAxis(OfficeChartValueAxisLayout layout) #

Sets independent bounds, tick spacing and appearance, and number format on the existing secondary value axis.

Parameters

layout OfficeIMO.Drawing.OfficeChartValueAxisLayout required

Returns

WordChart
public WordChart SetSeriesColor(uint index, OfficeColor color) #

Sets the base fill of a filled cartesian, filled radar, bubble or 3-D line series, or the connecting stroke of a 2-D line, scatter or unfilled radar series. Explicit point and marker overrides are retained.

Parameters

index uint required
color OfficeIMO.OfficeColor required

Returns

WordChart
public WordChart SetSize(OfficeLength width, OfficeLength? height = null) #

Sets the chart frame width and, when supplied, its height.

Parameters

width OfficeIMO.OfficeLength required
height OfficeIMO.OfficeLength? = null optional

Returns

WordChart
public WordChart SetTitle(string title) #

Set the title of the chart

Parameters

title string required

Returns

WordChart
public WordChart SetWidthToPageContent(double fraction = 1, OfficeLength? height = null) #

Fits chart width to its owning section or cell, optionally adjusting its height.

Parameters

fraction double = 1 optional
height OfficeIMO.OfficeLength? = null optional

Returns

WordChart
public WordChart SetXAxisTitle(string title) #

Sets the title displayed on the X axis.

Parameters

title string required
Axis title text.

Returns

WordChart The current WordChart instance.
public WordChart SetYAxisTitle(string title) #

Sets the title displayed on the Y axis.

Parameters

title string required
Axis title text.

Returns

WordChart The current WordChart instance.
public bool TryGetLayoutSnapshot(out WordDrawingLayoutInfo snapshot) #

Reads persisted inline or anchored package geometry for this chart.

Parameters

snapshot OfficeIMO.Word.WordDrawingLayoutInfo required

Returns

bool
public bool TryGetOfficeSnapshot(out OfficeChartSnapshot snapshot) #

Reads supported native charts into the shared two-dimensional Drawing contract.

Parameters

snapshot OfficeIMO.Drawing.OfficeChartSnapshot required
The cached chart data and supported presentation metadata.

Returns

bool True when a complete supported chart projection can be produced.
public bool TrySetCategories(IEnumerable<string> categories) #

Replaces 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<string> required
The literal category labels to persist.

Returns

bool true when at least one imported or code-created series was updated.
public bool TrySetSeriesName(uint seriesIndex, string name) #

Replaces the cached name of an existing series with a literal value.

Parameters

seriesIndex uint required
The persisted chart series index (c:idx).
name string required
The new series name.

Returns

bool true when the indexed series has a mutable series-text element.
public bool TrySetSeriesValues(uint seriesIndex, IEnumerable<double> values) #

Replaces 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 uint required
The persisted chart series index (c:idx).
values System.Collections.Generic.IEnumerable<double> required
The literal numeric values to persist.

Returns

bool true when the indexed series and its numeric value container were found.

Properties

public WordChartBarGrouping? BarGrouping { get; set; } #

Gets or sets the bar grouping mode for bar charts.

public WordChartBarDirection? BarDirection { get; set; } #

Gets or sets the bar direction (row or column) for bar charts.

public bool 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

public OfficeChartRadialLayout RadialLayout { get; } #

Native pie rotation and doughnut hole geometry, with native defaults when unspecified.

public string? Name { get; set; } #

Gets or sets the native drawing name without changing chart data.

public string? AltText { get; set; } #

Gets or sets alternative text persisted in the native Word drawing.