ChartArea class

ChartArea class

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

Inheritance: ChartAreaChartFrame

The ChartArea type exposes the following members:

Properties

PropertyDescription
is_inner_modeIndicates 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.
borderGets the Line.
areaGets the ChartFrame.area.
text_fontGets a ChartFrame.font object of the specified ChartFrame object.
text_optionsGets and sets the options of the text.
fontGets a ChartArea.font object of the specified chartarea object.
auto_scale_fontTrue if the text in the object changes font size when the object size changes. The default value is True.
background_modeGets and sets the display mode of the background
backgroundGets and sets the display mode of the background
is_automatic_sizeIndicates whether the chart frame is automatic sized.
xGets or gets the horizontal offset from its upper left corner column.
yGets or gets the vertical offset from its upper left corner row.
heightGets or sets the vertical offset from its lower right corner row.
widthGets or sets the horizontal offset from its lower right corner column.
shadowTrue if the frame has a shadow.
shape_propertiesGets the ChartFrame.shape_properties object.
is_default_pos_be_setIndicates whether default position(DefaultX, DefaultY, DefaultWidth and DefaultHeight) are set.
default_xRepresents x of default position
default_yRepresents y of default position
default_widthRepresents width of default position
default_heightRepresents height of default position

Methods

MethodDescription
set_position_autoSet position of the frame to automatic

Example

from aspose.cells import Workbook
from aspose.cells.charts import ChartType
from aspose.pydrawing import Color

# Instantiating a Workbook object
workbook = Workbook()
# Obtaining the reference of the first worksheet
worksheet = workbook.worksheets[0]
# Adding a sample value to "A1" cell
worksheet.cells.get("A1").put_value(50)
# Adding a sample value to "A2" cell
worksheet.cells.get("A2").put_value(100)
# Adding a sample value to "A3" cell
worksheet.cells.get("A3").put_value(150)
# Adding a sample value to "B1" cell
worksheet.cells.get("B1").put_value(60)
# Adding a sample value to "B2" cell
worksheet.cells.get("B2").put_value(32)
# Adding a sample value to "B3" cell
worksheet.cells.get("B3").put_value(50)
# Adding a chart to the worksheet
chartIndex = worksheet.charts.add(ChartType.COLUMN, 5, 0, 15, 5)
# Accessing the instance of the newly added chart
chart = worksheet.charts[chartIndex]
# Adding NSeries (chart data source) to the chart ranging from "A1" cell to "B3"
chart.n_series.add("A1:B3", True)
# Getting Chart Area
chartArea = chart.chart_area
# Setting the foreground color of the chart area
chartArea.area.foreground_color = Color.yellow
# Setting Chart Area Shadow
chartArea.shadow = True
# Saving the Excel file
workbook.save("book1.xls")

See Also