WordChart
OfficeIMO.Word
Provides functionality for creating and manipulating charts within a WordDocument.
Inheritance
- WordElement
- WordChart
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.
Returned or exposed by 30
- Method WordChart.AddDoughnut``1
- Method WordChart.AddPie3D``1
- Method WordChart.AddPie``1
- Method WordChart.ApplyPalette
- Method WordChart.SetAxisTitleFormat
- Method WordChart.SetCountAxis
- Method WordChart.SetData
- Method WordChart.SetDataPointStyle
- Method WordChart.SetPaperStyle
- Method WordChart.SetPieSliceColor
- Method WordChart.SetRadialLayout
- Method WordChart.SetSecondaryValueAxis
- Method WordChart.SetSeriesColor
- Method WordChart.SetSize
- Method WordChart.SetTitle
- Method WordChart.SetWidthToPageContent
- Method WordChart.SetXAxisTitle
- Method WordChart.SetYAxisTitle
- Property WordChartAxis.Chart
- Property WordChartLegend.Chart
- Property WordChartSeries.Chart
- Method WordDocument.AddChart
- Method WordDocument.AddChart``1
- Method WordDocument.AddChart``2
- 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 = "", 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
- Parent document that will contain the chart.
- paragraph OfficeIMO.Word.WordParagraph
- Paragraph where the chart will be placed.
- title string = ""
- Optional chart title.
- roundedCorners bool = false
- Specifies whether the chart frame should have rounded corners.
- width OfficeIMO.OfficeLength? = null
- Initial chart width; defaults to 600 pixels.
- height OfficeIMO.OfficeLength? = null
- 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
- Series name.
- values System.Collections.Generic.List<T?>
- Series data values.
- color OfficeIMO.OfficeColor
- Series color.
Returns
WordChartSeriespublic 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
- Series name.
- values System.Collections.Generic.IEnumerable<T?>
- Values for the series.
- color OfficeIMO.OfficeColor
- Fill color for the series.
Returns
WordChartSeriespublic 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
- Series name.
- values System.Collections.Generic.List<T?>
- Series data values.
- color OfficeIMO.OfficeColor
- Color of the bars.
Returns
WordChartSeriespublic 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
- values System.Collections.Generic.IEnumerable<T?>
- color OfficeIMO.OfficeColor
Returns
WordChartSeriespublic WordChartAxis AddCategories(IEnumerable<string> categories) #Sets the category labels used by subsequent chart series.
Parameters
- categories System.Collections.Generic.IEnumerable<string>
- List of category names.
Returns
WordChartAxispublic 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
- The slice's category label.
- value T?
- A finite, nonnegative slice value.
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
- Desired legend position.
Returns
WordChartLegendpublic 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
- The name of the series
- values System.Collections.Generic.List<T?>
- The data values for the series
- color OfficeIMO.OfficeColor
- The color of the series
Returns
WordChartSeriespublic 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
- values System.Collections.Generic.IEnumerable<T?>
- color OfficeIMO.OfficeColor
Returns
WordChartSeriespublic 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
- Category label.
- value T?
- Data value for the slice.
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
- Category label.
- value T?
- Data value for the slice.
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
- Series name.
- values System.Collections.Generic.List<T?>
- Values for the series.
- color OfficeIMO.OfficeColor
- Color of the series.
Returns
WordChartSeriespublic 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
- Series name.
- xValues System.Collections.Generic.List<double>
- Values plotted on the X axis.
- yValues System.Collections.Generic.List<double>
- Values plotted on the Y axis.
- color OfficeIMO.OfficeColor
- Color of the series.
Returns
WordChartSeriespublic 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
- semanticOutcomes bool = true
- applyToPies bool = true
- applyToSeries bool = true
- overrides System.Collections.Generic.Dictionary<string, OfficeIMO.OfficeColor>? = null
Returns
WordChartpublic WordChart SetAxisTitleFormat(string fontFamily, OfficeLength fontSize, OfficeColor color) #Defines font formatting for axis titles.
Parameters
- fontFamily string
- Font family name.
- fontSize OfficeIMO.OfficeLength
- Font size in points.
- color OfficeIMO.OfficeColor
- Text color.
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 distance between ticks in whole counts. When omitted, a readable integral interval is selected from the cached values.
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
- The default chart family for series without their own render kind.
- data OfficeIMO.Drawing.OfficeChartData
- Categories and series, including supported point and marker styles.
public WordChart SetDataPointStyle(int seriesIndex, uint pointIndex, OfficeChartPointStyle? style) #Replaces a point's fill/outline overrides. Null restores series/theme inheritance.
Parameters
- seriesIndex int
- pointIndex uint
- style OfficeIMO.Drawing.OfficeChartPointStyle?
Returns
WordChartpublic 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
- True for percentage-only pie labels; false for numeric count labels.
- titleColor OfficeIMO.OfficeColor? = null
- Text color for the chart title.
public WordChart SetPieSliceColor(uint index, OfficeColor color) #Sets the color of a specific pie slice by zero-based index.
Parameters
- index uint
- color OfficeIMO.OfficeColor
Returns
WordChartpublic WordChart SetRadialLayout(OfficeChartRadialLayout layout) #Sets geometry for an existing native two-dimensional pie or doughnut chart.
Parameters
- layout OfficeIMO.Drawing.OfficeChartRadialLayout
Returns
WordChartpublic 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
Returns
WordChartpublic 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
- color OfficeIMO.OfficeColor
Returns
WordChartpublic WordChart SetSize(OfficeLength width, OfficeLength? height = null) #Sets the chart frame width and, when supplied, its height.
Parameters
- width OfficeIMO.OfficeLength
- height OfficeIMO.OfficeLength? = null
Returns
WordChartpublic WordChart SetTitle(string title) #Set the title of the chart
Parameters
- title string
Returns
WordChartpublic 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
- height OfficeIMO.OfficeLength? = null
Returns
WordChartpublic WordChart SetXAxisTitle(string title) #Sets the title displayed on the X axis.
Parameters
- title string
- Axis title text.
public WordChart SetYAxisTitle(string title) #Sets the title displayed on the Y axis.
Parameters
- title string
- Axis title text.
public bool TryGetLayoutSnapshot(out WordDrawingLayoutInfo snapshot) #Reads persisted inline or anchored package geometry for this chart.
Parameters
- snapshot OfficeIMO.Word.WordDrawingLayoutInfo
Returns
boolpublic bool TryGetOfficeSnapshot(out OfficeChartSnapshot snapshot) #Reads supported native charts into the shared two-dimensional Drawing contract.
Parameters
- snapshot OfficeIMO.Drawing.OfficeChartSnapshot
- 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>
- 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
- The persisted chart series index (c:idx).
- name string
- 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
- The persisted chart series index (c:idx).
- values System.Collections.Generic.IEnumerable<double>
- The literal numeric values to persist.
Returns
bool true when the indexed series and its numeric value container were found.Inherited Methods
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 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.