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, in units of 1/4000 of the chart area.
yGets or gets the vertical offset from its upper left corner row, in units of 1/4000 of the chart area.
heightGets or sets the vertical offset from its lower right corner row, in units of 1/4000 of the chart area.
widthGets or sets the horizontal offset from its lower right corner column, in units of 1/4000 of the chart area.
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 in units of 1/4000 of the chart area.
default_yRepresents y of default position in units of 1/4000 of the chart area.
default_widthRepresents width of default position in units of 1/4000 of the chart area.
default_heightRepresents height of default position in units of 1/4000 of the chart area.
default_x_ratio_to_chartRepresents x of default position in units of Fraction of the chart area.
default_y_ratio_to_chartRepresents y of default position in units of Fraction of the chart area.
default_width_ratio_to_chartRepresents width of default position in units of Fraction of the chart area.
default_height_ratio_to_chartRepresents height of default position in units of Fraction of the chart area.
x_ratio_to_chartGets or gets the horizontal offset from its upper left corner column, in units of ratio of the chart area.
y_ratio_to_chartGets or gets the vertical offset from its upper left corner row, in units of ratio of the chart area.
width_ratio_to_chartGets or sets the horizontal offset from its lower right corner column, in units of ratio of the chart area.
height_ratio_to_chartGets or sets the vertical offset from its lower right corner row, in units of ratio of the chart area.
x_pixelGets or sets the x coordinate of the upper left corner in units of Pixel.
y_pixelGets or sets the y coordinate of the upper left corner in units of Pixel.
width_pixelGets or sets the width of frame in units of Pixel.
height_pixelGets or sets the height of frame in units of Pixel.

Methods

MethodDescription
set_position_auto(self)Set 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