ChartArea Class

Encapsulates the object that represents the chart area in the worksheet.
Inheritance Hierarchy

Namespace:  Aspose.Cells.Charts
Assembly:  Aspose.Cells (in Aspose.Cells.dll) Version: 21.7.0.0 (21.7)
Syntax
public class ChartArea : ChartFrame

The ChartArea type exposes the following members.

Properties
  NameDescription
Public propertyArea
Gets the area.
(Inherited from ChartFrame.)
Public propertyAutoScaleFont
True if the text in the object changes font size when the object size changes. The default value is True.
(Inherited from ChartFrame.)
Public propertyBackground Obsolete.
Gets and sets the display mode of the background
(Inherited from ChartFrame.)
Public propertyBackgroundMode
Gets and sets the display mode of the background
(Inherited from ChartFrame.)
Public propertyBorder
Gets the border.
(Inherited from ChartFrame.)
Public propertyDefaultHeight
Represents height of default position
(Inherited from ChartFrame.)
Public propertyDefaultWidth
Represents width of default position
(Inherited from ChartFrame.)
Public propertyDefaultX
Represents x of default position
(Inherited from ChartFrame.)
Public propertyDefaultY
Represents y of default position
(Inherited from ChartFrame.)
Public propertyFont
Gets a Font object of the specified chartarea object.
(Overrides ChartFrameFont.)
Public propertyHeight
Gets or sets the vertical offset from its lower right corner row.
(Overrides ChartFrameHeight.)
Public propertyIsAutomaticSize
Indicates whether the chart frame is automatic sized.
(Inherited from ChartFrame.)
Public propertyIsDefaultPosBeSet
Indicates whether default position(DefaultX, DefaultY, DefaultWidth and DefaultHeight) are set.
(Inherited from ChartFrame.)
Public propertyIsInnerMode
Indicates whether the size of the plot area size includes the tick marks, and the axis labels. False specifies that the size shall determine the size of the plot area, the tick marks, and the axis labels.
(Inherited from ChartFrame.)
Public propertyShadow
True if the frame has a shadow.
(Inherited from ChartFrame.)
Public propertyShapeProperties
Gets the ShapeProperties object.
(Inherited from ChartFrame.)
Public propertyTextFont Obsolete.
Gets a Font object of the specified ChartFrame object.
(Inherited from ChartFrame.)
Public propertyWidth
Gets or sets the horizontal offset from its lower right corner column.
(Overrides ChartFrameWidth.)
Public propertyX
Gets or gets the horizontal offset from its upper left corner column.
(Overrides ChartFrameX.)
Public propertyY
Gets or gets the vertical offset from its upper left corner row.
(Overrides ChartFrameY.)
Methods
  NameDescription
Public methodEquals (Inherited from Object.)
Protected methodFinalize (Inherited from Object.)
Public methodGetHashCode (Inherited from Object.)
Public methodGetType (Inherited from Object.)
Protected methodMemberwiseClone (Inherited from Object.)
Public methodSetPositionAuto
Set position of the frame to automatic
(Inherited from ChartFrame.)
Public methodToString (Inherited from Object.)
Fields
  NameDescription
Protected fieldm_AutoScaleFont (Inherited from ChartFrame.)
Protected fieldm_BackgroundMode (Inherited from ChartFrame.)
Protected fieldm_font (Inherited from ChartFrame.)
Protected fieldm_fontIndex (Inherited from ChartFrame.)
Protected fieldm_isAutoSize (Inherited from ChartFrame.)
Protected fieldm_IsAutoXPos (Inherited from ChartFrame.)
Protected fieldm_IsAutoYPos (Inherited from ChartFrame.)
Examples
[C#]

//Instantiating a Workbook object
Workbook workbook = new Workbook();

//Obtaining the reference of the first worksheet
Worksheet worksheet = workbook.Worksheets[0];

//Adding a sample value to "A1" cell
worksheet.Cells["A1"].PutValue(50);

//Adding a sample value to "A2" cell
worksheet.Cells["A2"].PutValue(100);

//Adding a sample value to "A3" cell
worksheet.Cells["A3"].PutValue(150);

//Adding a sample value to "B1" cell
worksheet.Cells["B1"].PutValue(60);

//Adding a sample value to "B2" cell
worksheet.Cells["B2"].PutValue(32);

//Adding a sample value to "B3" cell
worksheet.Cells["B3"].PutValue(50);

//Adding a chart to the worksheet
int chartIndex = worksheet.Charts.Add(ChartType.Column, 5, 0, 15, 5);

//Accessing the instance of the newly added chart
Chart chart = worksheet.Charts[chartIndex];

//Adding NSeries (chart data source) to the chart ranging from "A1" cell to "B3"
chart.NSeries.Add("A1:B3", true);

//Getting Chart Area
ChartArea chartArea = chart.ChartArea;

//Setting the foreground color of the chart area
chartArea.Area.ForegroundColor = Color.Yellow;

//Setting Chart Area Shadow
chartArea.Shadow = true;

//Saving the Excel file
workbook.Save("D:\\book1.xls");

[VB.NET]

'Instantiating a Workbook object
Dim workbook As New Workbook()

'Obtaining the reference of the first worksheet
Dim worksheet As Worksheet = workbook.Worksheets(0)

'Adding a sample value to "A1" cell
worksheet.Cells("A1").PutValue(50)

'Adding a sample value to "A2" cell
worksheet.Cells("A2").PutValue(100)

'Adding a sample value to "A3" cell
worksheet.Cells("A3").PutValue(150)

'Adding a sample value to "B1" cell
worksheet.Cells("B1").PutValue(60)

'Adding a sample value to "B2" cell
worksheet.Cells("B2").PutValue(32)

'Adding a sample value to "B3" cell
worksheet.Cells("B3").PutValue(50)

'Adding a chart to the worksheet
Dim chartIndex As Integer = worksheet.Charts.Add(ChartType.Column, 5, 0, 15, 5)

'Accessing the instance of the newly added chart
Dim chart As Chart = worksheet.Charts(chartIndex)

'Adding NSeries (chart data source) to the chart ranging from "A1" cell to "B3"
chart.NSeries.Add("A1:B3", True)

'Getting Chart Area
Dim chartArea As ChartArea = chart.ChartArea

'Setting the foreground color of the chart area
chartArea.Area.ForegroundColor = Color.Yellow

'Setting Chart Area Shadow
chartArea.Shadow = True

'Saving the Excel file
workbook.Save("D:\book1.xls")
See Also