Class WChart
Represents the chart in the Word document.
Inheritance
Inherited Members
Namespace: Syncfusion.DocIO.DLS
Assembly: Syncfusion.DocIO.NET.dll
Syntax
public class WChart : ShapeBase, IXDLSSerializable, IParagraphItem, IOfficeRun, IEntity, ILeafWidget, IWidget
Remarks
This class, its properties and methods are not supported in Silverlight, WinRT, Windows Phone, Universal, Universal Windows Platform and Xamarin applications.
Examples
The following code illustrates how to create a new chart.
Private Sub button_Click(sender As Object, e As EventArgs)
'Create a new Word document
Dim document As New WordDocument()
'Add section to the document
Dim sec As IWSection = document.AddSection()
'Add paragraph to the section
Dim paragraph As IWParagraph = sec.AddParagraph()
'Input data for chart
Dim data As Object()() = New Object(5)() {}
For i As Integer = 0 To 5
data(i) = New Object(2) {}
Next
data(0)(0) = ""
data(1)(0) = "Gravad lax"
data(2)(0) = "Louisiana Hot spiced Okara"
data(3)(0) = "Mascarpone Fabioli"
data(4)(0) = "Wimmers gute SemmelKnodel"
data(5)(0) = "Maxilaku"
data(0)(1) = "Sum of Purchases"
data(1)(1) = 286
data(2)(1) = 680
data(3)(1) = 288
data(4)(1) = 200
data(5)(1) = 731
data(0)(2) = "Sum of Future Expenses"
data(1)(2) = 1300
data(2)(2) = 700
data(3)(2) = 1280
data(4)(2) = 1200
data(5)(2) = 2660
'Create and Append chart to the paragraph
Dim chart As WChart = paragraph.AppendChart(data, 470, 300)
'Set chart type and title
chart.ChartType = OfficeChartType.Column_Clustered
chart.ChartTitle = "Purchase Details"
chart.ChartTitleArea.FontName = "Calibri"
chart.ChartTitleArea.Size = 14
chart.ChartArea.Border.LinePattern = OfficeChartLinePattern.None
chart.PrimaryCategoryAxis.Title = "Products"
chart.PrimaryValueAxis.Title = "In Dollars"
'Set position of legend
chart.Legend.Position = OfficeLegendPosition.Bottom
'Save the document
document.Save("Sample.docx", FormatType.Docx)
'Close the document
document.Close()
End Sub
Constructors
WChart(WordDocument)
Initializes a new instance of the WChart class with the specified WordDocument instance.
Declaration
public WChart(WordDocument doc)
Parameters
Type | Name | Description |
---|---|---|
WordDocument | doc | The WordDocument instance. |
Properties
AutoScaling
Gets or sets a value indicating whether to scale a 3-D chart size.
Declaration
public bool AutoScaling { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean | True if to scale the 3-D chart; otherwise, false. |
BackWall
Gets the back wall of the chart. Read-only.
Declaration
public IOfficeChartWallOrFloor BackWall { get; }
Property Value
Type |
---|
IOfficeChartWallOrFloor |
Remarks
The 3D charts, stacked charts and clustered charts only can have back walls.
Examples
The following code illustrates how to specify back wall formatting.
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Create a new Word document
WordDocument document = new WordDocument();
//Add section to the document
IWSection sec = document.AddSection();
//Add paragraph to the section
IWParagraph paragraph = sec.AddParagraph();
//Load the excel file as stream
Stream excelStream = File.OpenRead("Excel_Template.xlsx");
//Create and Append chart to the paragraph with excel stream as parameter
WChart chart = paragraph.AppendChart(excelStream, 1, "B2:C6", 470, 300);
//Set chart type and title
chart.ChartType = OfficeChartType.Column_Clustered_3D;
chart.ChartTitle = "Purchase Details";
chart.ChartTitleArea.FontName = "Calibri";
chart.ChartTitleArea.Size = 14;
chart.ChartArea.Border.LinePattern = OfficeChartLinePattern.None;
//Set name to chart series
chart.Series[0].Name = "Sum of Purchases";
chart.Series[1].Name = "Sum of Future Expenses";
chart.PrimaryCategoryAxis.Title = "Products";
chart.PrimaryValueAxis.Title = "In Dollars";
//Set position of legend
chart.Legend.Position = OfficeLegendPosition.Bottom;
//Set roatation and elevation values
chart.Rotation = 20;
chart.Elevation = 15;
//Set the Backwall fill option.
chart.BackWall.Fill.FillType = OfficeFillType.Gradient;
//Set the Texture Type.
chart.BackWall.Fill.GradientColorType = OfficeGradientColor.TwoColor;
chart.BackWall.Fill.GradientStyle = OfficeGradientStyle.Diagonl_Down;
chart.BackWall.Fill.ForeColor = Color.WhiteSmoke;
chart.BackWall.Fill.BackColor = Color.LightBlue;
//Set the Border Linecolor.
chart.BackWall.Border.LineColor = System.Drawing.Color.Wheat;
//Set the Picture Type.
chart.BackWall.PictureUnit = OfficeChartPictureType.stretch;
//Set the Backwall thickness.
chart.BackWall.Thickness = 10;
//Save and close the document
document.Save("Sample.docx", FormatType.Docx);
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Create a new Word document
Dim document As New WordDocument()
'Add section to the document
Dim sec As IWSection = document.AddSection()
'Add paragraph to the section
Dim paragraph As IWParagraph = sec.AddParagraph()
'Load the excel file as stream
Dim excelStream As Stream = File.OpenRead("Excel_Template.xlsx")
'Create and Append chart to the paragraph with excel stream as parameter
Dim chart As WChart = paragraph.AppendChart(excelStream, 1, "B2:C6", 470, 300)
'Set chart type and title
chart.ChartType = OfficeChartType.Column_Clustered_3D
chart.ChartTitle = "Purchase Details"
chart.ChartTitleArea.FontName = "Calibri"
chart.ChartTitleArea.Size = 14
chart.ChartArea.Border.LinePattern = OfficeChartLinePattern.None
'Set name to chart series
chart.Series(0).Name = "Sum of Purchases"
chart.Series(1).Name = "Sum of Future Expenses"
chart.PrimaryCategoryAxis.Title = "Products"
chart.PrimaryValueAxis.Title = "In Dollars"
'Set position of legend
chart.Legend.Position = OfficeLegendPosition.Bottom
'Set rotation and elevation values
chart.Rotation = 20
chart.Elevation = 15
'Set the Backwall fill option.
chart.BackWall.Fill.FillType = OfficeFillType.Gradient
'Set the Texture Type.
chart.BackWall.Fill.GradientColorType = OfficeGradientColor.TwoColor
chart.BackWall.Fill.GradientStyle = OfficeGradientStyle.Diagonl_Down
chart.BackWall.Fill.ForeColor = Color.WhiteSmoke
chart.BackWall.Fill.BackColor = Color.LightBlue
'Set the Border Linecolor.
chart.BackWall.Border.LineColor = System.Drawing.Color.Wheat
'Set the Picture Type.
chart.BackWall.PictureUnit = OfficeChartPictureType.stretch
'Set the Backwall thickness.
chart.BackWall.Thickness = 10
'Save and close the document
document.Save("Sample.docx", FormatType.Docx)
document.Close()
End Sub
Categories
Gets the collection of
Declaration
public IOfficeChartCategories Categories { get; }
Property Value
Type |
---|
IOfficeChartCategories |
CategoryLabelLevel
Gets or sets the category name filter option for the chart.
Declaration
public OfficeCategoriesLabelLevel CategoryLabelLevel { get; set; }
Property Value
Type | Description |
---|---|
OfficeCategoriesLabelLevel | The |
ChartArea
Gets the chart area. Read-only.
Declaration
public IOfficeChartFrameFormat ChartArea { get; }
Property Value
Type |
---|
IOfficeChartFrameFormat |
Examples
The following code illustrates how to apply the formatting for chart area.
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Load the template document
WordDocument document = new WordDocument("Template.docx", FormatType.Docx);
//Get the paragraph
WParagraph paragraph = document.LastParagraph;
//Get the chart entity
WChart chart = paragraph.ChildEntities[1] as WChart;
//Format chart area.
IOfficeChartFrameFormat chartArea = chart.ChartArea;
//Set border line pattern, color, line weight
chartArea.Border.LinePattern = OfficeChartLinePattern.Solid;
chartArea.Border.LineColor = Color.Blue;
chartArea.Border.LineWeight = OfficeChartLineWeight.Hairline;
//Set fill type and fill colors
chartArea.Fill.FillType = OfficeFillType.Gradient;
chartArea.Fill.GradientColorType = OfficeGradientColor.TwoColor;
chartArea.Fill.BackColor = Color.FromArgb(205, 217, 234);
chartArea.Fill.ForeColor = Color.White;
//Save and close the document
document.Save("Sample.docx", FormatType.Docx);
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Load the template document
Dim document As New WordDocument("Template.docx", FormatType.Docx)
'Get the paragraph
Dim paragraph As WParagraph = document.LastParagraph
'Get the chart entity
Dim chart As WChart = TryCast(paragraph.ChildEntities(1), WChart)
'Format chart area.
Dim chartArea As IOfficeChartFrameFormat = chart.ChartArea
'Set border line pattern, color, line weight
chartArea.Border.LinePattern = OfficeChartLinePattern.Solid
chartArea.Border.LineColor = Color.Blue
chartArea.Border.LineWeight = OfficeChartLineWeight.Hairline
'Set fill type and fill colors
chartArea.Fill.FillType = OfficeFillType.Gradient
chartArea.Fill.GradientColorType = OfficeGradientColor.TwoColor
chartArea.Fill.BackColor = Color.FromArgb(205, 217, 234)
chartArea.Fill.ForeColor = Color.White
'Save and close the document
document.Save("Sample.docx", FormatType.Docx)
document.Close()
End Sub
ChartData
Gets the chart data. Read-only.
Declaration
public IOfficeChartData ChartData { get; }
Property Value
Type |
---|
IOfficeChartData |
ChartTitle
Gets or sets the title of the chart.
Declaration
public string ChartTitle { get; set; }
Property Value
Type | Description |
---|---|
System.String | The string that specifies the chart title. |
ChartTitleArea
Gets the
Declaration
public IOfficeChartTextArea ChartTitleArea { get; }
Property Value
Type |
---|
IOfficeChartTextArea |
ChartType
Gets or sets the type of the chart
Declaration
public OfficeChartType ChartType { get; set; }
Property Value
Type | Description |
---|---|
OfficeChartType | The OfficeChartType member that specifies the type of chart. |
DataRange
Gets or sets
Declaration
public IOfficeDataRange DataRange { get; set; }
Property Value
Type |
---|
IOfficeDataRange |
DataTable
Gets the data table of the chart. Read-only.
Declaration
public IOfficeChartDataTable DataTable { get; }
Property Value
Type | Description |
---|---|
IOfficeChartDataTable | The |
DepthPercent
Gets or sets the depth of a 3-D chart as a percentage of the chart width(between 20 and 2000 percent).
Declaration
public int DepthPercent { get; set; }
Property Value
Type |
---|
System.Int32 |
DisplayBlanksAs
Gets or sets a value indicating how that blank cells are plotted on a chart.
Declaration
public OfficeChartPlotEmpty DisplayBlanksAs { get; set; }
Property Value
Type | Description |
---|---|
OfficeChartPlotEmpty | The |
Elevation
Gets or sets the rotation value for y-axis of the 3-D chart, measured in degrees.
Declaration
public int Elevation { get; set; }
Property Value
Type | Description |
---|---|
System.Int32 | The integer that specifies the value for elevation. |
See Also
EntityType
Gets the type of the entity. Read-only.
Declaration
public override EntityType EntityType { get; }
Property Value
Type | Description |
---|---|
EntityType | The EntityType of the current item. |
Overrides
ExternalDataPath
Gets or sets the external data file path of WChart.
Declaration
public string ExternalDataPath { get; set; }
Property Value
Type |
---|
System.String |
Examples
The following code illustrates how to sets the external data file path of WChart.
//Loads the template document
WordDocument document = new WordDocument("Template.docx");
//Gets the last paragraph
WParagraph paragraph = document.LastParagraph;
//Gets the chart entity from the paragraph items
WChart chart = paragraph.ChildEntities[0] as WChart;
//Modifies the external data file path of chart
chart.ExternalDataPath = @"Data\Excel_Template.xlsx";
//Saves and closes the document
document.Save("Sample.docx", FormatType.Docx);
document.Close();
'Loads the template document
Dim document As New WordDocument("Template.docx")
'Gets the last paragraph
Dim paragraph As WParagraph = document.LastParagraph
'Gets the chart entity from the paragraph items
Dim chart As WChart = TryCast(paragraph.ChildEntities(0), WChart)
'Modifies the external data file path of chart
chart.ExternalDataPath = "Data\Excel_Template.xlsx"
'Saves and closes the document
document.Save("Sample.docx", FormatType.Docx)
document.Close()
Floor
Gets the floor of the chart. Read-only.
Declaration
public IOfficeChartWallOrFloor Floor { get; }
Property Value
Type |
---|
IOfficeChartWallOrFloor |
Remarks
The 3D charts, stacked charts and clustered charts only can have floor.
GapDepth
Gets or sets the distance between the data series in a 3-D chart, as a percentage of the marker width.
Declaration
public int GapDepth { get; set; }
Property Value
Type |
---|
System.Int32 |
HasDataTable
Gets or sets value indicating whether the chart has a data table.
Declaration
public bool HasDataTable { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean | True if the chart has data table; otherwise, false. |
Examples
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Create a new Word document
WordDocument document = new WordDocument();
//Add section to the document
IWSection sec = document.AddSection();
//Add paragraph to the section
IWParagraph paragraph = sec.AddParagraph();
//Load the excel file as stream
Stream excelStream = File.OpenRead("Excel_Template.xlsx");
//Create and Append chart to the paragraph with excel stream as parameter
WChart chart = paragraph.AppendChart(excelStream, 1, "B2:C6", 470, 300);
//Set chart type and title
chart.ChartType = OfficeChartType.Column_Clustered;
chart.ChartTitle = "Purchase Details";
chart.ChartTitleArea.FontName = "Calibri";
chart.ChartTitleArea.Size = 14;
chart.ChartArea.Border.LinePattern = OfficeChartLinePattern.None;
//Set name to chart series
chart.Series[0].Name = "Sum of Purchases";
chart.Series[1].Name = "Sum of Future Expenses";
//Display data table
chart.HasDataTable = true;
chart.PrimaryCategoryAxis.Title = "Products";
chart.PrimaryValueAxis.Title = "In Dollars";
//Set position of legend
chart.Legend.Position = OfficeLegendPosition.Bottom;
//Save the document
document.Save("Sample.docx", FormatType.Docx);
//Close the document
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Create a new Word document
Dim document As New WordDocument()
'Add section to the document
Dim sec As IWSection = document.AddSection()
'Add paragraph to the section
Dim paragraph As IWParagraph = sec.AddParagraph()
'Load the excel file as stream
Dim excelStream As Stream = File.OpenRead("Excel_Template.xlsx")
'Create and Append chart to the paragraph with excel stream as parameter
Dim chart As WChart = paragraph.AppendChart(excelStream, 1, "B2:C6", 470, 300)
'Set chart type and title
chart.ChartType = OfficeChartType.Column_Clustered
chart.ChartTitle = "Purchase Details"
chart.ChartTitleArea.FontName = "Calibri"
chart.ChartTitleArea.Size = 14
chart.ChartArea.Border.LinePattern = OfficeChartLinePattern.None
'Set name to chart series
chart.Series(0).Name = "Sum of Purchases"
chart.Series(1).Name = "Sum of Future Expenses"
chart.PrimaryCategoryAxis.Title = "Products"
chart.PrimaryValueAxis.Title = "In Dollars"
'Set position of legend
chart.Legend.Position = OfficeLegendPosition.Bottom
'Display data table
chart.HasDataTable = True
'Save the document
document.Save("Sample.docx", FormatType.Docx)
'Close the document
document.Close()
End Sub
HasLegend
Gets or sets value indicating whether the chart has a legend.
Declaration
public bool HasLegend { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean | True if the chart has legend; otherwise, false. |
HasPlotArea
Gets or sets a value indicating whether the chart has plot area.
Declaration
public bool HasPlotArea { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean | True if the chart has plot area; otherwise, false. |
HeightPercent
Gets or sets the height of a 3-D chart as a percentage of the chart width(between 5 and 500 percent).
Declaration
public int HeightPercent { get; set; }
Property Value
Type |
---|
System.Int32 |
IsSeriesInRows
Gets or sets value indicating whether chart series are represented as rows.
Declaration
public bool IsSeriesInRows { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean | True if the series are represented as rows; otherwise, false. |
Legend
Gets the chart legend. Read-only.
Declaration
public IOfficeChartLegend Legend { get; }
Property Value
Type |
---|
IOfficeChartLegend |
Examples
The following code illustrates how to apply the formatting for legend.
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Load the template document
WordDocument document = new WordDocument("Template.docx", FormatType.Docx);
WParagraph paragraph = document.LastParagraph;
//Get the chart entity
WChart chart = paragraph.ChildEntities[0] as WChart;
//Set the legend position
chart.Legend.Position = OfficeLegendPosition.Left;
//Set the layout inclusion
chart.Legend.IncludeInLayout = true;
//Set the legend border format - color, pattern, weight
chart.Legend.FrameFormat.Border.AutoFormat = false;
chart.Legend.FrameFormat.Border.IsAutoLineColor = false;
chart.Legend.FrameFormat.Border.LineColor = Color.Blue;
chart.Legend.FrameFormat.Border.LinePattern = OfficeChartLinePattern.DashDot;
chart.Legend.FrameFormat.Border.LineWeight = OfficeChartLineWeight.Wide;
//Set the legend's text area formatting - font name, weight, color, size
chart.Legend.TextArea.Bold = true;
chart.Legend.TextArea.Color = OfficeKnownColors.Bright_green;
chart.Legend.TextArea.FontName = "Times New Roman";
chart.Legend.TextArea.Size = 20;
chart.Legend.TextArea.Strikethrough = true;
//Modify the legend entry
chart.Legend.LegendEntries[0].IsDeleted = true;
//Modify the legend layout - height, left, top, width
chart.Legend.Layout.Height = 50;
chart.Legend.Layout.HeightMode = LayoutModes.factor;
chart.Legend.Layout.Left = 10;
chart.Legend.Layout.LeftMode = LayoutModes.factor;
chart.Legend.Layout.Top = 30;
chart.Legend.Layout.TopMode = LayoutModes.factor;
chart.Legend.Layout.Width = 100;
chart.Legend.Layout.WidthMode = LayoutModes.factor;
//Save and close the document
document.Save("Sample.docx", FormatType.Docx);
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Load the template document
Dim document As New WordDocument("Template.docx", FormatType.Docx)
Dim paragraph As WParagraph = document.LastParagraph
'Get the chart entity
Dim chart As WChart = TryCast(paragraph.ChildEntities(0), WChart)
'Set the legend position
chart.Legend.Position = OfficeLegendPosition.Left
'Set the layout inclusion
chart.Legend.IncludeInLayout = True
'Set the legend border format - color, pattern, weight
chart.Legend.FrameFormat.Border.AutoFormat = False
chart.Legend.FrameFormat.Border.IsAutoLineColor = False
chart.Legend.FrameFormat.Border.LineColor = Color.Blue
chart.Legend.FrameFormat.Border.LinePattern = OfficeChartLinePattern.DashDot
chart.Legend.FrameFormat.Border.LineWeight = OfficeChartLineWeight.Wide
'Set the legend's text area formatting - font name, weight, color, size
chart.Legend.TextArea.Bold = True
chart.Legend.TextArea.Color = OfficeKnownColors.Bright_green
chart.Legend.TextArea.FontName = "Times New Roman"
chart.Legend.TextArea.Size = 20
chart.Legend.TextArea.Strikethrough = True
'Modify the legend entry
chart.Legend.LegendEntries(0).IsDeleted = True
'Modify the legend layout - height, left, top, width
chart.Legend.Layout.Height = 50
chart.Legend.Layout.HeightMode = LayoutModes.factor
chart.Legend.Layout.Left = 10
chart.Legend.Layout.LeftMode = LayoutModes.factor
chart.Legend.Layout.Top = 30
chart.Legend.Layout.TopMode = LayoutModes.factor
chart.Legend.Layout.Width = 100
chart.Legend.Layout.WidthMode = LayoutModes.factor
'Save and close the document
document.Save("Sample.docx", FormatType.Docx)
document.Close()
End Sub
OfficeChart
Declaration
public IOfficeChart OfficeChart { get; }
Property Value
Type |
---|
IOfficeChart |
Perspective
Gets or sets the perspective value for the 3-D chart, measured in degrees.
Declaration
public int Perspective { get; set; }
Property Value
Type |
---|
System.Int32 |
PlotArea
Gets the plot area of the chart. Read-only.
Declaration
public IOfficeChartFrameFormat PlotArea { get; }
Property Value
Type |
---|
IOfficeChartFrameFormat |
Examples
The following code illustrates how to apply the formatting for plot area.
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Load the template document
WordDocument document = new WordDocument("Template.docx", FormatType.Docx);
WParagraph paragraph = document.LastParagraph;
//Get the chart entity
WChart chart = paragraph.ChildEntities[0] as WChart;
//Set border settings - line color, pattern, weight, transparency
chart.PlotArea.Border.AutoFormat = false;
chart.PlotArea.Border.IsAutoLineColor = false;
chart.PlotArea.Border.LineColor = Color.Blue;
chart.PlotArea.Border.LinePattern = OfficeChartLinePattern.DashDot;
chart.PlotArea.Border.LineWeight = OfficeChartLineWeight.Wide;
chart.PlotArea.Border.Transparency = 0.6;
//Set the plot area’s fill type, color
chart.PlotArea.Fill.FillType = OfficeFillType.SolidColor;
chart.PlotArea.Fill.ForeColor = Color.LightPink;
//Set the plot area shadow presence
chart.PlotArea.Shadow.ShadowInnerPresets = Office2007ChartPresetsInner.InsideDiagonalTopLeft;
//Save and close the document
document.Save("Sample.docx", FormatType.Docx);
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Load the template document
Dim document As New WordDocument("Template.docx", FormatType.Docx)
Dim paragraph As WParagraph = document.LastParagraph
'Get the chart entity
Dim chart As WChart = TryCast(paragraph.ChildEntities(0), WChart)
'Set border settings - line color, pattern, weight, transparency
chart.PlotArea.Border.AutoFormat = False
chart.PlotArea.Border.IsAutoLineColor = False
chart.PlotArea.Border.LineColor = Color.Blue
chart.PlotArea.Border.LinePattern = OfficeChartLinePattern.DashDot
chart.PlotArea.Border.LineWeight = OfficeChartLineWeight.Wide
chart.PlotArea.Border.Transparency = 0.6
'Set the plot area’s fill type, color
chart.PlotArea.Fill.FillType = OfficeFillType.SolidColor
chart.PlotArea.Fill.ForeColor = Color.LightPink
'Set the plot area shadow presence
chart.PlotArea.Shadow.ShadowInnerPresets = Office2007ChartPresetsInner.InsideDiagonalTopLeft
'Save and close the document
document.Save("Sample.docx", FormatType.Docx)
document.Close()
End Sub
PlotVisibleOnly
Gets or sets a value indicating whether to plot only the visible cells of the data table.
Declaration
public bool PlotVisibleOnly { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean | True if to plot only visible cells; false if both visible and hidden cells are plotted. |
PrimaryCategoryAxis
Gets the primary category axis of the chart. Read-only.
Declaration
public IOfficeChartCategoryAxis PrimaryCategoryAxis { get; }
Property Value
Type | Description |
---|---|
IOfficeChartCategoryAxis | The |
PrimarySeriesAxis
Gets the primary series axis of the chart. Read-only.
Declaration
public IOfficeChartSeriesAxis PrimarySeriesAxis { get; }
Property Value
Type | Description |
---|---|
IOfficeChartSeriesAxis | The |
PrimaryValueAxis
Gets the primary value axis of the chart. Read-only.
Declaration
public IOfficeChartValueAxis PrimaryValueAxis { get; }
Property Value
Type | Description |
---|---|
IOfficeChartValueAxis | The |
RightAngleAxes
Gets or sets value indicating whether the chart axes are at right angles.
Declaration
public bool RightAngleAxes { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean | True if the chart axis are at right angles; otherwise, false. |
Rotation
Gets or sets the rotation value for x-axis of the 3-D chart, measured in degrees.
Declaration
public int Rotation { get; set; }
Property Value
Type | Description |
---|---|
System.Int32 | The integer that specifies the value for rotation. |
Examples
The following code illustrates how to rotation for 3D chart.
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Create a new Word document
WordDocument document = new WordDocument();
//Add section to the document
IWSection sec = document.AddSection();
//Add paragraph to the section
IWParagraph paragraph = sec.AddParagraph();
//Load the excel file as stream
Stream excelStream = File.OpenRead("Excel_Template.xlsx");
//Create and Append chart to the paragraph with excel stream as parameter
WChart chart = paragraph.AppendChart(excelStream, 1, "B2:C6", 470, 300);
//Set chart type and title
chart.ChartType = OfficeChartType.Column_Clustered_3D;
chart.ChartTitle = "Purchase Details";
chart.ChartTitleArea.FontName = "Calibri";
chart.ChartTitleArea.Size = 14;
chart.ChartArea.Border.LinePattern = OfficeChartLinePattern.None;
//Set name to chart series
chart.Series[0].Name = "Sum of Purchases";
chart.Series[1].Name = "Sum of Future Expenses";
chart.PrimaryCategoryAxis.Title = "Products";
chart.PrimaryValueAxis.Title = "In Dollars";
//Set position of legend
chart.Legend.Position = OfficeLegendPosition.Bottom;
//Set roatation and elevation values
chart.Rotation = 20;
chart.Elevation = 15;
//Save and close the document
document.Save("Sample.docx", FormatType.Docx);
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Create a new Word document
Dim document As New WordDocument()
'Add section to the document
Dim sec As IWSection = document.AddSection()
'Add paragraph to the section
Dim paragraph As IWParagraph = sec.AddParagraph()
'Load the excel file as stream
Dim excelStream As Stream = File.OpenRead("Excel_Template.xlsx")
'Create and Append chart to the paragraph with excel stream as parameter
Dim chart As WChart = paragraph.AppendChart(excelStream, 1, "B2:C6", 470, 300)
'Set chart type and title
chart.ChartType = OfficeChartType.Column_Clustered_3D
chart.ChartTitle = "Purchase Details"
chart.ChartTitleArea.FontName = "Calibri"
chart.ChartTitleArea.Size = 14
chart.ChartArea.Border.LinePattern = OfficeChartLinePattern.None
'Set name to chart series
chart.Series(0).Name = "Sum of Purchases"
chart.Series(1).Name = "Sum of Future Expenses"
chart.PrimaryCategoryAxis.Title = "Products"
chart.PrimaryValueAxis.Title = "In Dollars"
'Set position of legend
chart.Legend.Position = OfficeLegendPosition.Bottom
'Set rotation and elevation values
chart.Rotation = 20
chart.Elevation = 15
'Save and close the document
document.Save("Sample.docx", FormatType.Docx)
document.Close()
End Sub
SecondaryCategoryAxis
Gets the secondary category axis of the chart. Read-only.
Declaration
public IOfficeChartCategoryAxis SecondaryCategoryAxis { get; }
Property Value
Type | Description |
---|---|
IOfficeChartCategoryAxis | The |
SecondaryValueAxis
Gets the secondary value axis of the chart. Read-only.
Declaration
public IOfficeChartValueAxis SecondaryValueAxis { get; }
Property Value
Type | Description |
---|---|
IOfficeChartValueAxis | The |
Series
Gets collection of
Declaration
public IOfficeChartSeries Series { get; }
Property Value
Type |
---|
IOfficeChartSeries |
SeriesNameLevel
Gets or sets the series name filter option for the chart.
Declaration
public OfficeSeriesNameLevel SeriesNameLevel { get; set; }
Property Value
Type | Description |
---|---|
OfficeSeriesNameLevel | The |
SideWall
Gets the side wall of the chart. Read-only.
Declaration
public IOfficeChartWallOrFloor SideWall { get; }
Property Value
Type |
---|
IOfficeChartWallOrFloor |
Remarks
The 3D charts, stacked charts and clustered charts only can have side walls.
Examples
The following code illustrates how to specify side wall formatting.
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Create a new Word document
WordDocument document = new WordDocument();
//Add section to the document
IWSection sec = document.AddSection();
//Add paragraph to the section
IWParagraph paragraph = sec.AddParagraph();
//Load the excel file as stream
Stream excelStream = File.OpenRead("Excel_Template.xlsx");
//Create and Append chart to the paragraph with excel stream as parameter
WChart chart = paragraph.AppendChart(excelStream, 1, "B2:C6", 470, 300);
//Set chart type and title
chart.ChartType = OfficeChartType.Column_Clustered_3D;
chart.ChartTitle = "Purchase Details";
chart.ChartTitleArea.FontName = "Calibri";
chart.ChartTitleArea.Size = 14;
chart.ChartArea.Border.LinePattern = OfficeChartLinePattern.None;
//Set name to chart series
chart.Series[0].Name = "Sum of Purchases";
chart.Series[1].Name = "Sum of Future Expenses";
chart.PrimaryCategoryAxis.Title = "Products";
chart.PrimaryValueAxis.Title = "In Dollars";
//Set position of legend
chart.Legend.Position = OfficeLegendPosition.Bottom;
//Set roatation and elevation values
chart.Rotation = 20;
chart.Elevation = 15;
//Set side wall properties
chart.SideWall.Fill.FillType = OfficeFillType.SolidColor;
chart.SideWall.Fill.ForeColor = Color.White;
chart.SideWall.Fill.BackColor = Color.White;
chart.SideWall.Border.LineColor = System.Drawing.Color.Beige;
//Save and close the document
document.Save("Sample.docx", FormatType.Docx);
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Create a new Word document
Dim document As New WordDocument()
'Add section to the document
Dim sec As IWSection = document.AddSection()
'Add paragraph to the section
Dim paragraph As IWParagraph = sec.AddParagraph()
'Load the excel file as stream
Dim excelStream As Stream = File.OpenRead("Excel_Template.xlsx")
'Create and Append chart to the paragraph with excel stream as parameter
Dim chart As WChart = paragraph.AppendChart(excelStream, 1, "B2:C6", 470, 300)
'Set chart type and title
chart.ChartType = OfficeChartType.Column_Clustered_3D
chart.ChartTitle = "Purchase Details"
chart.ChartTitleArea.FontName = "Calibri"
chart.ChartTitleArea.Size = 14
chart.ChartArea.Border.LinePattern = OfficeChartLinePattern.None
'Set name to chart series
chart.Series(0).Name = "Sum of Purchases"
chart.Series(1).Name = "Sum of Future Expenses"
chart.PrimaryCategoryAxis.Title = "Products"
chart.PrimaryValueAxis.Title = "In Dollars"
'Set position of legend
chart.Legend.Position = OfficeLegendPosition.Bottom
'Set rotation and elevation values
chart.Rotation = 20
chart.Elevation = 15
'Set side wall properties
chart.SideWall.Fill.FillType = OfficeFillType.SolidColor
chart.SideWall.Fill.ForeColor = Color.White
chart.SideWall.Fill.BackColor = Color.White
chart.SideWall.Border.LineColor = System.Drawing.Color.Beige
'Save and close the document
document.Save("Sample.docx", FormatType.Docx)
document.Close()
End Sub
Walls
Gets the walls of the chart. Read-only.
Declaration
public IOfficeChartWallOrFloor Walls { get; }
Property Value
Type |
---|
IOfficeChartWallOrFloor |
Remarks
The 3D charts, stacked charts and clustered charts only can have walls.
Methods
CloneImpl()
Creates a duplicate copy of the entity.
Declaration
protected override object CloneImpl()
Returns
Type | Description |
---|---|
System.Object | A reference to the newly created object. |
Overrides
CreateLayoutInfo()
Creates layout information.
Declaration
protected override void CreateLayoutInfo()
Overrides
Refresh(Boolean)
Replaces the chart data with the worksheet data.
Declaration
public void Refresh(bool updateFormula = false)
Parameters
Type | Name | Description |
---|---|---|
System.Boolean | updateFormula | Optional Boolean. Set to true to update all the formulas in the Excel sheet. The default value is false. |
Examples
//Open the template document.
WordDocument document = new WordDocument("Template.docx");
//Get the paragraph.
WParagraph paragraph = document.LastParagraph;
//Get the chart entity.
WChart chart = paragraph.ChildEntities[0] as WChart;
//Replaces the chart data with the worksheet data.
chart.Refresh(true);
//Save and close the document
document.Save("Sample.docx");
document.Close();
'Open the template document.
Dim document As WordDocument = New WordDocument("Template.docx")
'Get the paragraph.
Dim paragraph As WParagraph = document.LastParagraph
'Get the chart entity.
Dim chart As WChart = TryCast(paragraph.ChildEntities(0), WChart)
'Replaces the chart data with the worksheet data..
chart.Refresh(True)
'Save and close the document
document.Save("Sample.docx")
document.Close()
SetChartData(Object[][])
Sets the data for the chart from the specified System.Object collection.
Declaration
public void SetChartData(object[][] data)
Parameters
Type | Name | Description |
---|---|---|
System.Object[][] | data | An System.Object that represents the two dimensional array. |
SetDataRange(IEnumerable, Int32, Int32)
Sets the data for the chart from the specified System.Collections.IEnumerable collection with the row index and column index.
Declaration
public void SetDataRange(IEnumerable enumerable, int rowIndex, int columnIndex)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.IEnumerable | enumerable | An System.Collections.IEnumerable object with desired data. |
System.Int32 | rowIndex | The integer that specifies the row of the first cell where array should be imported. |
System.Int32 | columnIndex | The integer that specifies the column of the first cell where array should be imported. |
SetDataRange(Object[][], Int32, Int32)
Sets the data for the chart from the specified System.Object collection with the row index and column index.
Declaration
public void SetDataRange(object[][] data, int rowIndex, int columnIndex)
Parameters
Type | Name | Description |
---|---|---|
System.Object[][] | data | An System.Object that represents the two dimensional array. |
System.Int32 | rowIndex | The integer that specifies the row of the first cell where array should be imported. |
System.Int32 | columnIndex | The integer that specifies the column of the first cell where array should be imported. |