Chart class

Chart class

Encapsulates the object that represents a single Excel chart.

The Chart type exposes the following members:

Properties

PropertyDescription
styleGets and sets the builtin style.
chart_objectRepresents the chartShape;
hide_pivot_field_buttonsIndicates whether hide the pivot chart field buttons only when the chart is PivotChart.
pivot_optionsSpecifies the pivot controls that appear on the chart
pivot_sourceThe source is the data of the pivotTable.
If PivotSource is not empty ,the chart is PivotChart.
plot_byGets and sets whether plot by row or column.
plot_empty_cells_typeGets and sets how to plot the empty cells.
plot_visible_cellsIndicates whether only plot visible cells.
plot_visible_cells_onlyIndicates whether plot visible cells only.
display_na_as_blankIndicates whether displaying #N/A as blank value.
nameGets and sets the name of the chart.
size_with_windowTrue if Microsoft Excel resizes the chart to match the size of the chart sheet window.
worksheetGets the worksheet which contains this chart.
shapesReturns all drawing shapes in this chart.
print_sizeGets and sets the printed chart size.
typeGets or sets a chart’s type.
n_seriesGets a SeriesCollection collection representing the data series in the chart.
filtered_n_seriesGets a SeriesCollection collection representing the data series that are filtered in the chart.
titleGets the chart’s title.
sub_titleGets the chart’s sub-title.
Only for ODS format file.
plot_areaGets the chart’s plot area which includes axis tick labels.
chart_areaGets the chart area in the worksheet.
category_axisGets the chart’s X axis.
value_axisGets the chart’s Y axis.
second_value_axisGets the chart’s second Y axis.
second_category_axisGets the chart’s second X axis.
series_axisGets the chart’s series axis.
legendGets the chart legend.
chart_data_tableRepresents the chart data table.
show_legendGets or sets a value indicating whether the chart legend will be displayed. Default is true.
is_rectangular_corneredGets or sets a value indicating whether the chart area is rectangular cornered.
Default is true.
show_data_tableGets or sets a value indicating whether the chart displays a data table.
first_slice_angleGets or sets the angle of the first pie-chart or doughnut-chart slice, in degrees (clockwise from vertical).
Applies only to pie, 3-D pie, and doughnut charts, 0 to 360.
gap_widthReturns or sets the space between bar or column clusters, as a percentage of the bar or column width.
The value of this property must be between 0 and 500.
gap_depthGets or sets the distance between the data series in a 3-D chart, as a percentage of the marker width.
The value of this property must be between 0 and 500.
floorReturns a Chart.floor object that represents the walls of a 3-D chart.
wallsReturns a Chart.walls object that represents the walls of a 3-D chart.
back_wallReturns a Chart.walls object that represents the back wall of a 3-D chart.
side_wallReturns a Chart.walls object that represents the side wall of a 3-D chart.
walls_and_gridlines_2dTrue if gridlines are drawn two-dimensionally on a 3-D chart.
rotation_angleRepresents the rotation of the 3-D chart view (the rotation of the plot area around the z-axis, in degrees).
elevationRepresents the elevation of the 3-D chart view, in degrees.
right_angle_axesTrue if the chart axes are at right angles. Applies only for 3-D charts(except Column3D and 3-D Pie Charts).
auto_scalingTrue if Microsoft Excel scales a 3-D chart so that it’s closer in size to the equivalent 2-D chart.
The RightAngleAxes property must be True.
height_percentReturns or sets the height of a 3-D chart as a percentage of the chart width (between 5 and 500 percent).
perspectiveReturns or sets the perspective for the 3-D chart view. Must be between 0 and 100.
This property is ignored if the RightAngleAxes property is True.
is_3dIndicates whether the chart is a 3d chart.
depth_percentRepresents the depth of a 3-D chart as a percentage of the chart width (between 20 and 2000 percent).
actual_chart_sizeGets actual size of chart in unit of pixels.
placementRepresents the way the chart is attached to the cells below it.
page_setupRepresents the page setup description in this chart.
lineGets the line.

Methods

MethodDescription
calculateCalculates the custom position of plot area, axes if the position of them are auto assigned.
calculateCalculates the custom position of plot area, axes if the position of them are auto assigned, with Chart Calculate Options.
to_imageCreates the chart image and saves it to a file.
The extension of the file name determines the format of the image.
to_imageCreates the chart image and saves it to a file in the specified image type.
to_imageCreates the chart image and saves it to a file in the Jpeg format.
to_imageCreates the chart image and saves it to a stream in the Jpeg format.
to_imageCreates the chart image and saves it to a stream in the specified format.
to_imageCreates the chart image and saves it to a file.
The extension of the file name determines the format of the image.
to_imageCreates the chart image and saves it to a stream in the specified format.
to_pdfSaves the chart to a pdf file.
to_pdfSaves the chart to a pdf file.
to_pdfCreates the chart pdf and saves it to a stream.
to_pdfCreates the chart pdf and saves it to a stream.
is_refered_by_chartReturns whether the cell refered by the chart.
is_cell_refered_by_chartReturns whether the cell refered by the chart.
is_chart_data_changedDetects if a chart’s data source has changed.
refresh_pivot_dataRefreshes pivot chart’s data from it’s pivot data source.
change_templateChange chart type with preset template.
moveMoves the chart to a specified location.
get_actual_sizeGets actual size of chart in unit of pixels.
has_axisReturns which axes exist on the chart.
switch_row_columnSwitches row/column.
get_chart_data_rangeGets the data source range of the chart.
set_chart_data_rangeSpecifies data range for a chart.

Example

The following codes show how to create a chart with .Net codes.

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

workbook = Workbook()
sheet = workbook.worksheets[0]
cells = sheet.cells
cells.get(0, 1).put_value("Income")
cells.get(1, 0).put_value("Company A")
cells.get(2, 0).put_value("Company B")
cells.get(3, 0).put_value("Company C")
cells.get(1, 1).put_value(10000)
cells.get(2, 1).put_value(20000)
cells.get(3, 1).put_value(30000)
chartIndex = sheet.charts.add(ChartType.COLUMN, 9, 9, 21, 15)
chart = sheet.charts[chartIndex]
chart.set_chart_data_range("A1:B4", True)
chart.show_legend = True
chart.title.text = "Income Analysis"

See Also