Aspose::Cells::Charts::ChartArea class

ChartArea class

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

class ChartArea : public Aspose::Cells::Charts::ChartFrame

Methods

MethodDescription
ChartArea(ChartArea_Impl* impl)Constructs from an implementation object.
ChartArea(const ChartArea& src)Copy constructor.
ChartArea(const ChartFrame& src)Constructs from a parent object.
ChartFrame(ChartFrame_Impl* impl)Constructs from an implementation object.
ChartFrame(const ChartFrame& src)Copy constructor.
GetArea()Gets the area.
GetAutoScaleFont()True if the text in the object changes font size when the object size changes. The default value is True.
GetBackgroundMode()Gets and sets the display mode of the background.
GetBorder()Gets the border.
GetDefaultHeight()Represents height of default position.
GetDefaultWidth()Represents width of default position.
GetDefaultX()Represents x of default position.
GetDefaultY()Represents y of default position.
GetFont()Gets a Font object of the specified chartarea object.
GetHeight()Gets or sets the vertical offset from its lower right corner row.
GetShadow()True if the frame has a shadow.
GetShapeProperties()Gets the ShapeProperties object.
GetTextOptions()Gets and sets the options of the text.
GetWidth()Gets or sets the horizontal offset from its lower right corner column.
GetX()Gets or gets the horizontal offset from its upper left corner column.
GetY()Gets or gets the vertical offset from its upper left corner row.
IsAutomaticSize()Indicates whether the chart frame is automatic sized.
IsDefaultPosBeSet()Indicates whether default position(DefaultX, DefaultY, DefaultWidth and DefaultHeight) are set.
IsInnerMode()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.
IsNull() constChecks whether the implementation object is nullptr.
explicit operator bool() constoperator bool()
operator=(const ChartArea& src)operator=
operator=(const ChartFrame& src)operator=
SetAutoScaleFont(bool value)True if the text in the object changes font size when the object size changes. The default value is True.
SetBackgroundMode(BackgroundMode value)Gets and sets the display mode of the background.
SetHeight(int32_t value)Gets or sets the vertical offset from its lower right corner row.
SetIsAutomaticSize(bool value)Indicates whether the chart frame is automatic sized.
SetIsInnerMode(bool value)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.
SetPositionAuto()Set position of the frame to automatic.
SetShadow(bool value)True if the frame has a shadow.
SetWidth(int32_t value)Gets or sets the horizontal offset from its lower right corner column.
SetX(int32_t value)Gets or gets the horizontal offset from its upper left corner column.
SetY(int32_t value)Gets or gets the vertical offset from its upper left corner row.
~ChartArea()Destructor.
~ChartFrame()Destructor.

Fields

FieldDescription
_implThe implementation object.

Examples

Aspose::Cells::Startup();
//Instantiating a Workbook object
Workbook workbook;

//Obtaining the reference of the first worksheet
Worksheet worksheet = workbook.GetWorksheets().Get(0);

//Adding a sample value to "A1" cell
worksheet.GetCells().Get(u"A1").PutValue(50);

//Adding a sample value to "A2" cell
worksheet.GetCells().Get(u"A2").PutValue(100);

//Adding a sample value to "A3" cell
worksheet.GetCells().Get(u"A3").PutValue(150);

//Adding a sample value to "B1" cell
worksheet.GetCells().Get(u"B1").PutValue(60);

//Adding a sample value to "B2" cell
worksheet.GetCells().Get(u"B2").PutValue(32);

//Adding a sample value to "B3" cell
worksheet.GetCells().Get(u"B3").PutValue(50);

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

//Accessing the instance of the newly added chart
Chart chart = worksheet.GetCharts().Get(chartIndex);

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

//Getting Chart Area
ChartArea chartArea = chart.GetChartArea();

//Setting the foreground color of the chart area
chartArea.GetArea().SetForegroundColor(Color{ 0xff, 0xff, 0xff, 0 });

//Setting Chart Area Shadow
chartArea.SetShadow(true);

//Saving the Excel file
workbook.Save(u"book1.xls");

Aspose::Cells::Cleanup();

See Also