Aspose::Cells::Charts::Chart class

Chart class

Encapsulates the object that represents a single Excel chart.

class Chart

Methods

MethodDescription
Calculate()Calculates the custom position of plot area, axes if the position of them are auto assigned.
Calculate(const ChartCalculateOptions& calculateOptions)Calculates the custom position of plot area, axes if the position of them are auto assigned, with Chart Calculate Options.
ChangeTemplate(const Vector <uint8_t>& data)Change chart type with preset template.
Chart(Chart_Impl* impl)Constructs from an implementation object.
Chart(const Chart& src)Copy constructor.
GetActualSize()Gets actual size of chart in unit of pixels.
GetAutoScaling()True 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.
GetBackWall()Returns a Walls object that represents the back wall of a 3-D chart.
GetCategoryAxis()Gets the chart’s X axis.
GetChartArea()Gets the chart area in the worksheet.
GetChartDataRange()Gets the data source range of the chart.
GetChartDataTable()Represents the chart data table.
GetChartObject()Represents the chartShape;.
GetDepthPercent()Represents the depth of a 3-D chart as a percentage of the chart width (between 20 and 2000 percent).
GetDisplayNaAsBlank()Indicates whether displaying #N/A as blank value.
GetElevation()Represents the elevation of the 3-D chart view, in degrees.
GetFilteredNSeries()Gets a SeriesCollection collection representing the data series that are filtered in the chart.
GetFirstSliceAngle()Gets 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.
GetFloor()Returns a Floor object that represents the walls of a 3-D chart.
GetGapDepth()Gets 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.
GetGapWidth()Returns 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.
GetHeightPercent()Returns or sets the height of a 3-D chart as a percentage of the chart width (between 5 and 500 percent).
GetHidePivotFieldButtons()Indicates whether hide the pivot chart field buttons only when the chart is PivotChart.
GetIs3D()Indicates whether the chart is a 3d chart.
GetLegend()Gets the chart legend.
GetLine()Gets the line.
GetName()Gets and sets the name of the chart.
GetNSeries()Gets a SeriesCollection collection representing the data series in the chart.
GetPageSetup()Represents the page setup description in this chart.
GetPerspective()Returns 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.
GetPivotOptions()Specifies the pivot controls that appear on the chart.
GetPivotSource()The source is the data of the pivotTable. If PivotSource is not empty ,the chart is PivotChart.
GetPlacement()Represents the way the chart is attached to the cells below it.
GetPlotArea()Gets the chart’s plot area which includes axis tick labels.
GetPlotBy()Gets and sets whether plot by row or column.
GetPlotEmptyCellsType()Gets and sets how to plot the empty cells.
GetPlotVisibleCellsOnly()Indicates whether plot visible cells only.
GetPrintSize()Gets and sets the printed chart size.
GetRightAngleAxes()True if the chart axes are at right angles. Applies only for 3-D charts(except Column3D and 3-D Pie Charts).
GetRotationAngle()Represents the rotation of the 3-D chart view (the rotation of the plot area around the z-axis, in degrees).
GetSecondCategoryAxis()Gets the chart’s second X axis.
GetSecondValueAxis()Gets the chart’s second Y axis.
GetSeriesAxis()Gets the chart’s series axis.
GetShapes()Returns all drawing shapes in this chart.
GetShowDataTable()Gets or sets a value indicating whether the chart displays a data table.
GetShowLegend()Gets or sets a value indicating whether the chart legend will be displayed. Default is true.
GetSideWall()Returns a Walls object that represents the side wall of a 3-D chart.
GetSizeWithWindow()True if Microsoft Excel resizes the chart to match the size of the chart sheet window.
GetStyle()Gets and sets the builtin style.
GetSubTitle()Gets the chart’s sub-title. Only for ODS format file.
GetTitle()Gets the chart’s title.
GetType()Gets or sets a chart’s type.
GetValueAxis()Gets the chart’s Y axis.
GetWalls()Returns a Walls object that represents the walls of a 3-D chart.
GetWallsAndGridlines2D()True if gridlines are drawn two-dimensionally on a 3-D chart.
GetWorksheet()Gets the worksheet which contains this chart.
HasAxis(AxisType aixsType, bool isPrimary)Returns which axes exist on the chart.
IsCellReferedByChart(int32_t sheetIndex, int32_t rowIndex, int32_t columnIndex)Returns whether the cell refered by the chart.
IsChartDataChanged()Detects if a chart’s data source has changed.
IsNull() constChecks whether the implementation object is nullptr.
IsRectangularCornered()Gets or sets a value indicating whether the chart area is rectangular cornered. Default is true.
Move(int32_t upperLeftRow, int32_t upperLeftColumn, int32_t lowerRightRow, int32_t lowerRightColumn)Moves the chart to a specified location.
explicit operator bool() constoperator bool()
operator=(const Chart& src)operator=
RefreshPivotData()Refreshes chart’s data from pivot table.
SetAutoScaling(bool value)True 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.
SetChartDataRange(const U16String& area, bool isVertical)Specifies data range for a chart.
SetChartDataRange(const char16_t* area, bool isVertical)Specifies data range for a chart.
SetDepthPercent(int32_t value)Represents the depth of a 3-D chart as a percentage of the chart width (between 20 and 2000 percent).
SetDisplayNaAsBlank(bool value)Indicates whether displaying #N/A as blank value.
SetElevation(int32_t value)Represents the elevation of the 3-D chart view, in degrees.
SetFirstSliceAngle(int32_t value)Gets 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.
SetGapDepth(int32_t value)Gets 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.
SetGapWidth(int32_t value)Returns 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.
SetHeightPercent(int32_t value)Returns or sets the height of a 3-D chart as a percentage of the chart width (between 5 and 500 percent).
SetHidePivotFieldButtons(bool value)Indicates whether hide the pivot chart field buttons only when the chart is PivotChart.
SetIsRectangularCornered(bool value)Gets or sets a value indicating whether the chart area is rectangular cornered. Default is true.
SetName(const U16String& value)Gets and sets the name of the chart.
SetName(const char16_t* value)Gets and sets the name of the chart.
SetPerspective(int16_t value)Returns 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.
SetPivotSource(const U16String& value)The source is the data of the pivotTable. If PivotSource is not empty ,the chart is PivotChart.
SetPivotSource(const char16_t* value)The source is the data of the pivotTable. If PivotSource is not empty ,the chart is PivotChart.
SetPlacement(PlacementType value)Represents the way the chart is attached to the cells below it.
SetPlotEmptyCellsType(PlotEmptyCellsType value)Gets and sets how to plot the empty cells.
SetPlotVisibleCellsOnly(bool value)Indicates whether plot visible cells only.
SetPrintSize(PrintSizeType value)Gets and sets the printed chart size.
SetRightAngleAxes(bool value)True if the chart axes are at right angles. Applies only for 3-D charts(except Column3D and 3-D Pie Charts).
SetRotationAngle(int32_t value)Represents the rotation of the 3-D chart view (the rotation of the plot area around the z-axis, in degrees).
SetShowDataTable(bool value)Gets or sets a value indicating whether the chart displays a data table.
SetShowLegend(bool value)Gets or sets a value indicating whether the chart legend will be displayed. Default is true.
SetSizeWithWindow(bool value)True if Microsoft Excel resizes the chart to match the size of the chart sheet window.
SetStyle(int32_t value)Gets and sets the builtin style.
SetType(ChartType value)Gets or sets a chart’s type.
SetWallsAndGridlines2D(bool value)True if gridlines are drawn two-dimensionally on a 3-D chart.
SwitchRowColumn()Switches row/column.
ToImage(const U16String& imageFile)Creates the chart image and saves it to a file. The extension of the file name determines the format of the image.
ToImage(const char16_t* imageFile)Creates the chart image and saves it to a file. The extension of the file name determines the format of the image.
ToImage(const U16String& imageFile, Aspose::Cells::Drawing::ImageType imageType)Creates the chart image and saves it to a file in the specified image type.
ToImage(const char16_t* imageFile, Aspose::Cells::Drawing::ImageType imageType)Creates the chart image and saves it to a file in the specified image type.
ToImage(const U16String& imageFile, int64_t jpegQuality)Creates the chart image and saves it to a file in the Jpeg format.
ToImage(const char16_t* imageFile, int64_t jpegQuality)Creates the chart image and saves it to a file in the Jpeg format.
ToImage(int64_t jpegQuality)Creates the chart image and saves it to a stream in the Jpeg format.
ToImage(Aspose::Cells::Drawing::ImageType imageType)Creates the chart image and saves it to a stream in the specified format.
ToImage(const U16String& imageFile, const ImageOrPrintOptions& options)Creates the chart image and saves it to a file. The extension of the file name determines the format of the image.
ToImage(const char16_t* imageFile, const ImageOrPrintOptions& options)Creates the chart image and saves it to a file. The extension of the file name determines the format of the image.
ToImage(const ImageOrPrintOptions& options)Creates the chart image and saves it to a stream in the specified format.
ToPdf(const U16String& fileName)Saves the chart to a pdf file.
ToPdf(const char16_t* fileName)Saves the chart to a pdf file.
ToPdf(const U16String& fileName, float desiredPageWidth, float desiredPageHeight, PageLayoutAlignmentType hAlignmentType, PageLayoutAlignmentType vAlignmentType)Saves the chart to a pdf file.
ToPdf(const char16_t* fileName, float desiredPageWidth, float desiredPageHeight, PageLayoutAlignmentType hAlignmentType, PageLayoutAlignmentType vAlignmentType)Saves the chart to a pdf file.
ToPdf()Creates the chart pdf and saves it to a stream.
ToPdf(float desiredPageWidth, float desiredPageHeight, PageLayoutAlignmentType hAlignmentType, PageLayoutAlignmentType vAlignmentType)Creates the chart pdf and saves it to a stream.
~Chart()Destructor.

Fields

FieldDescription
_implThe implementation object.

Examples

Aspose::Cells::Startup();
//The following codes show how to create a chart with c++ codes.

Workbook workbook;
Worksheet sheet = workbook.GetWorksheets().Get(0);

Cells cells = sheet.GetCells();
cells.Get(0, 1).PutValue(u"Income");
cells.Get(1, 0).PutValue(u"Company A");
cells.Get(2, 0).PutValue(u"Company B");
cells.Get(3, 0).PutValue(u"Company C");
cells.Get(1, 1).PutValue(10000);
cells.Get(2, 1).PutValue(20000);
cells.Get(3, 1).PutValue(30000);

int chartIndex = sheet.GetCharts().Add(ChartType::Column, 9, 9, 21, 15);

Chart chart = sheet.GetCharts().Get(chartIndex);
chart.SetChartDataRange(u"A1:B4", true);
chart.SetShowLegend(true);
chart.GetTitle().SetText(u"Income Analysis");
Aspose::Cells::Cleanup();

See Also