API Reference
WordChart
Provides functionality for creating and manipulating charts within a WordDocument.
Inheritance
- WordElement
- WordChart
Constructors
public WordChart(WordDocument document, WordParagraph paragraph, Drawing drawing) #Initializes a WordChart instance from an existing drawing.
Parameters
- document OfficeIMO.Word.WordDocument
- Parent document that owns the chart.
- paragraph OfficeIMO.Word.WordParagraph
- Paragraph containing the chart.
- drawing DocumentFormat.OpenXml.Wordprocessing.Drawing
- Existing drawing element with chart data.
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 AddArea<T>(String name, Int32[] values, Color color) #VoidType Parameters
- T
Parameters
- name String
- values List<T>
- color Color
public Void AddArea3D<T>(String name, List<T> values, Color color) #VoidType Parameters
- T
Parameters
- name String
- values List<T>
- color Color
AddArea3D``1(System.String name, System.Collections.Generic.List{``0} values, SixLabors.ImageSharp.Color color) #Adds 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 SixLabors.ImageSharp.Color
- Series color.
AddArea``1(System.String name, System.Collections.Generic.List{``0} values, SixLabors.ImageSharp.Color color) #Adds 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 SixLabors.ImageSharp.Color
- Fill color for the series.
AddArea``1(System.String name, System.Int32[] values, SixLabors.ImageSharp.Color color) #Adds 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 SixLabors.ImageSharp.Color
- Fill color for the series.
public Void AddBar(String name, Int32[] values, Color 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.
Type Parameters
- T
Parameters
- name System.String
- values System.Int32
- color SixLabors.ImageSharp.Color
AddBar(System.String name, System.Int32[] values, SixLabors.ImageSharp.Color color) #Adds a bar series from an array of values. For combo charts ensure String>) has been called first.
Parameters
- name System.String
- values System.Int32[]
- color SixLabors.ImageSharp.Color
public Void AddBar3D<T>(String name, List<T> values, Color color) #VoidType Parameters
- T
Parameters
- name String
- values List<T>
- color Color
AddBar3D``1(System.String name, System.Collections.Generic.List{``0} values, SixLabors.ImageSharp.Color color) #Adds 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 SixLabors.ImageSharp.Color
- Color of the bars.
AddBar``1(System.String name, System.Collections.Generic.List{``0} values, SixLabors.ImageSharp.Color color) #Adds 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.
Parameters
- name System.String
- values System.Collections.Generic.List{``0}
- color SixLabors.ImageSharp.Color
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, Color color) #VoidType Parameters
- T
Parameters
- name String
- values Int32[]
- color Color
AddChartLine``1(System.String name, System.Int32[] values, SixLabors.ImageSharp.Color color) #Adds 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 SixLabors.ImageSharp.Color
- Line color.
public Void AddLegend(LegendPositionValues legendPosition) #VoidAdds a legend to the chart at the specified position.
Parameters
- legendPosition DocumentFormat.OpenXml.Drawing.Charts.LegendPositionValues
- Desired legend position.
public Void AddLine<T>(String name, List<T> values, Color color) #VoidType Parameters
- T
Parameters
- name String
- values List<T>
- color Color
public Void AddLine3D<T>(String name, List<T> values, Color color) #VoidType Parameters
- T
Parameters
- name String
- values List<T>
- color Color
AddLine3D``1(System.String name, System.Collections.Generic.List{``0} values, SixLabors.ImageSharp.Color color) #Adds 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 SixLabors.ImageSharp.Color
- The color of the series
AddLine``1(System.String name, System.Collections.Generic.List{``0} values, SixLabors.ImageSharp.Color 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 String>) before adding either series.
Parameters
- name System.String
- values System.Collections.Generic.List{``0}
- color SixLabors.ImageSharp.Color
public WordChart AddPie<T>(String category, T value) #WordChartType Parameters
- T
Parameters
- category String
- value T
public WordChart AddPie3D<T>(String category, T value) #WordChartType Parameters
- T
Parameters
- category String
- value T
AddPie3D``1(System.String category, ``0 value) #Adds 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.
AddPie``1(System.String category, ``0 value) #Adds 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, Color color) #VoidType Parameters
- T
Parameters
- name String
- values List<T>
- color Color
AddRadar``1(System.String name, System.Collections.Generic.List{``0} values, SixLabors.ImageSharp.Color color) #Adds 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 SixLabors.ImageSharp.Color
- Color of the series.
public Void AddScatter(String name, List<Double> xValues, List<Double> yValues, Color 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 SixLabors.ImageSharp.Color
- Color of the series.
AddSingleCategory(System.String category) #Adds single category to charts
Parameters
- category System.String
- The category.
AddSingleValue``1(``0 data) #Adds the single value to charts
Type Parameters
- T
Parameters
- data ``0
- The data.
public WordChart ApplyPalette(WordChartPalette palette, Boolean semanticOutcomes = true, Boolean applyToPies = true, Boolean applyToSeries = true, Dictionary<String, Color> 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,SixLabors.ImageSharp.Color} = null
public WordChart SetAxisTitleFormat(String fontName, Int32 fontSize, Color color) #WordChartDefines font formatting for axis titles.
Parameters
- fontName System.String
- Font family name.
- fontSize System.Int32
- Font size in points.
- color SixLabors.ImageSharp.Color
- Text color.
Returns
The current WordChart instance.
public WordChart SetPieSliceColor(UInt32 index, Color color) #WordChartSets the color of a specific pie slice by zero-based index.
Parameters
- index System.UInt32
- color SixLabors.ImageSharp.Color
public WordChart SetSeriesColor(UInt32 index, Color color) #WordChartSets the color of a specific series by its zero-based index across supported chart types.
Parameters
- index System.UInt32
- color SixLabors.ImageSharp.Color
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.
UpdateTitle() #Update the title of the chart
Inherited Methods
public override Boolean Equals(Object obj) #BooleanParameters
- obj Object
Properties
public Nullable<BarGroupingValues> BarGrouping { get; set; } #Gets or sets the bar grouping mode for bar charts.
public Nullable<BarDirectionValues> 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.
PrivateTitle #Holds the title of the chart until we can add it to the chart Note: the title can't really be added to a chart before we know what type of chart it is Since we don't know what type of chart it is until we add the first Pie, Bar, Line or Area we need to wait until then to add the title This is why we have a separate property for the title, but the method to add the title is in the WordChart class
public String Title { get; set; } #Get or set the title of the chart