Create a chart in Power Point Presentation(PPT/PPTX) using Aspose.Slides cloud

Hi,

Please provide some sample code or a link to a documentation or sample for creating a chart in aspose.slides cloud.

Thanks,
Sumathi

@sumathi

Thank you for contacting us.

With Aspose.Slides REST APIs you can add any shape including Chart to a slide in a Powerpoint document.

You will use POST https://api.aspose.cloud/v1.1/slides/{name}/slides/{slideIndex}/shapes API to create chart.

The following cURL example adds Column Chart to the first slide of MyPresentation.pptx file:

// First get Access Token
// Get App Key and App SID from https://dashboard.aspose.cloud/
curl -v "https://api.aspose.cloud/oauth2/token" \
-X POST \
-d 'grant_type=client_credentials&client_id=0B17F60A-6D69-426B-9ABD-79F35A6E9F7B&client_secret=53b8b19adffa41a3e87dbbd8858977ae' \
-H "Content-Type: application/x-www-form-urlencoded" \
-H "Accept: application/json"
  
// cURL example to add Column Chart
curl -v "https://api.aspose.cloud/v1.1/slides/MyPresentation.pptx/slides/1/shapes" \
-X POST \
-d '{
  "Type": "Chart",
  "ChartType": "ClusteredColumn",
  "Series": [
    {
      "DataPointType": "OneValue",
      "DataPoints": [
        {
          "Value": 30.903210132803398
        },
        {
          "Value": 93.970356133752659
        },
        {
          "Value": 62.40113110393338
        }
      ],
      "Type": "ClusteredColumn",
      "Name": "Seria 0",
      "IsColorVaried": false
    },
    {
      "DataPointType": "OneValue",
      "DataPoints": [
        {
          "Value": 5.55788800379163
        },
        {
          "Value": 76.488545432914307
        },
        {
          "Value": 27.763909952605104
        }
      ],
      "Type": "ClusteredColumn",
      "Name": "Seria 1",
      "IsColorVaried": false
    }
  ],
  "Categories": [
    "Category 0",
    "Category 1",
    "Category 2"
  ],
  "Title": {
    "Text": "Seasonal fluctuation",
    "HasTitle": false
  },
  "Width": 600.0,
  "Height": 500.0,
  "X": 10.0,
  "Y": 15.0
}' \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-H "Authorization: Bearer Q6vND7kSADh8kMBr43p68-yyuoajX9YzR4QAXNVT9koRwqWeP3lnsBXl9GAch9HldX-gXanuTegKLDVPKgkEDMm-OGpDIM-8-prBVFvUeyjcV3yWUjH7GrKgYs78DB5_W8b6DNtp2-5eM992CKhii387ZKEV0fWcdlS9ETqw7GPkxQvpC2AUlK0XiTv5RrUJsXYS-q_NAyaviLqc6yQV-jpgFWTL0kGD2QtZv9-mJfFZ8Q7YokemXu8iVOb3ORz6rw8GVSb370ctK41smsidojvlIRnbD_cnlPc3_6lDnDaHDbp7ufjSXrxra6e3pQNjMtkSQerF3CnAXj5C-OEfBkU4R6L6f7IUtb54h-tMvmY1MsjiimzUU6PnqgevJruGVjKy37J83enSS5s7VvlWHjH9zZpQEylOQ7BIfR8MCp4Einqx"

The general properties for all shape types are:

Property Name Type Description RO/RW
AlternativeText string The alternative text associated with the shape. RW
Height float The height of the shape. RW
Hidden bool Determines whether the shape is hidden. RW
Name string The name of the shape RW
Width float The width of the shape. RW
X float X position of the shape. RW
Y float Y position of the shape. RW
ZOrderPosition int Position of a shape in the z-order. First shape in collection returns the shape at the back of the z-order, and the last shape in collection returns the shape at the front of the z-order. RO
Type enum Type of shape RO
FillFormat FillFormat The fill format of shape. RW
EffectFormat EffectFormat The effect format of shape. RW
LineFormat LineFormat The line format of shape. RW

2. Chart

Represents a chart.

Property Name Type Description RO/RW
ChartType enum The chart type. List of available chart types see below RW
Title Title The chart title. RW
Series Array The array of Series values. Represents chart series. RW
Categories Array The array of string values. Represents chart categories. RW
BackWall ChartWall Represents chart back wall. RW
SideWall ChartWall Represents chart side wall. RW
Floor ChartWall Represents chart floow. RW
PlotArea PlotArea Represents chart plot area. RW
Legend Legend Represents chart legend. RW
Axes Axes Represents chart axes. RW

ChartType values are:

0: ClusteredColumn
1: StackedColumn
2: PercentsStackedColumn
3: ClusteredColumn3D
4: StackedColumn3D
5: PercentsStackedColumn3D
6: Column3D
7: ClusteredCylinder
8: StackedCylinder
9: PercentsStackedCylinder
10: Cylinder3D
11: ClusteredCone
12: StackedCone
13: PercentsStackedCone
14: Cone3D
15: ClusteredPyramid
16: StackedPyramid
17: PercentsStackedPyramid
18: Pyramid3D
19: Line
20: StackedLine
21: PercentsStackedLine
22: LineWithMarkers
23: StackedLineWithMarkers
24: PercentsStackedLineWithMarkers
25: Line3D
26: Pie
27: Pie3D
28: PieOfPie
29: ExplodedPie
30: ExplodedPie3D
31: BarOfPie
32: PercentsStackedBar
33: ClusteredBar3D
34: ClusteredBar
35: StackedBar
36: StackedBar3D
37: PercentsStackedBar3D
38: ClusteredHorizontalCylinder
39: StackedHorizontalCylinder
40: PercentsStackedHorizontalCylinder
41: ClusteredHorizontalCone
42: StackedHorizontalCone
43: PercentsStackedHorizontalCone
44: ClusteredHorizontalPyramid
45: StackedHorizontalPyramid
46: PercentsStackedHorizontalPyramid
47: Area
48: StackedArea
49: PercentsStackedArea
50: Area3D
51: StackedArea3D
52: PercentsStackedArea3D
53: ScatterWithMarkers
54: ScatterWithSmoothLinesAndMarkers
55: ScatterWithSmoothLines
56: ScatterWithStraightLinesAndMarkers
57: ScatterWithStraightLines
58: HighLowClose
59: OpenHighLowClose
60: VolumeHighLowClose
61: VolumeOpenHighLowClose
62: Surface3D
63: WireframeSurface3D
64: Contour
65: WireframeContour
66: Doughnut
67: ExplodedDoughnut
68: Bubble
69: BubbleWith3D
70: Radar
71: RadarWithMarkers
72: FilledRadar
73: SeriesOfMixedTypes

Title

Property Name Type Description RO/RW
Text string Custom chart title. If this value is empty, autogenerated title shows. RW
HasTitle bool Determines visibility of title. RW

Series

Property Name Type Description RO/RW
Type enum The type of series. List of available see types see above RW
Name string Series name. RW
InvertIfNegative bool True if the bar, column or bubble series shall invert its colors if the value is negative. RW
IsColorVaried bool Specifies that each data marker in the series has a different color. RW
InvertedSolidFillColor string Specifies invert solid color for series. RW
DataPointType enum Type of data points RO
DataPoints Array Array of data points. Type depends on DataPointType. Can be OneValue, Scatter and Bubble RO
Smooth bool True if curve smoothing is turned on for the line chart or scatter chart RW
PlotOnSecondAxis bool Indicates if this series is plotted on second value axis RW
Order int Series order RW
NumberFormatOfValues string Returns or sets the number format for series values RW
NumberFormatOfXValues string Returns or sets the number format for series x values RW
NumberFormatOfYValues string Returns or sets the number format for series y values RW
NumberFormatOfBubbleSizes string Returns or sets the number format for series bubble sizes RW
Explosion int The distance of an open pie slice from the center of the pie chart is expressed as a percentage of the pie diameter RW
Marker Marker The series marker RW
FillFormat FillFormat The fill format of the series RW
EffectFormat EffectFormat The effect format of the series RW
LineFormat LineFormat The line format of the series RW

One value data point

Used for all chart types except scatter and bubble.

Property Name Type Description RO/RW
Value double Point value RW

Scatter data point

Used for scatter charts.

Property Name Type Description RO/RW
XValue double Horizontal value. RW
YValue double Vertical value. RW

Bubble data point

Used for bubble charts.

Property Name Type Description RO/RW
XValue double Horizontal value. RW
YValue double Vertical value. RW
BubbleSize double Size of bubble. RW

Marker

Property Name Type Description RO/RW
Size int Marker size RW
Symbol enum Marker symbol. List of available values see below RW
FillFormat FillFormat The fill format of the series RW
EffectFormat EffectFormat The effect format of the series RW
LineFormat LineFormat The line format of the series RW

MarkerStyleType values

NotDefined,
Circle,
Dash,
Diamond,
Dot,
None,
Picture,
Plus,
Square,
Star,
Triangle,
X

ChartWall

Represents a chart wall.

Property Name Type Description RO/RW
Thickness int Wall thickness as a percentage of the largest dimension of the plot volume. RW
PictureType enum The mode of bar picture filling RW
FillFormat FillFormat The fill format of the wall. RW
EffectFormat EffectFormat The effect format of the wall. RW
LineFormat LineFormat The line format of the wall. RW

PlotArea

Represents a chart plot area.

Property Name Type Description RO/RW
X float X RW
Y float Y RW
Width float Width RW
Height float Height RW
FillFormat FillFormat The fill format of the wall. RW
EffectFormat EffectFormat The effect format of the wall. RW
LineFormat LineFormat The line format of the wall. RW

Legend

Represents a chart legend.

Property Name Type Description RO/RW
Position enum Legend position RW
X float X RW
Y float Y RW
Width float Width RW
Height float Height RW
Overlay bool True if other elements are allowed to overlay the legend RW
FillFormat FillFormat The fill format of the wall. RW
EffectFormat EffectFormat The effect format of the wall. RW
LineFormat LineFormat The line format of the wall. RW

Axes

Represents chart axes.

Property Name Type Description RO/RW
HorizontalAxis Axis Horizontal axis RW
VerticalAxis Axis Vertical axis RW
SecondaryHorizontalAxis Axis Secondary horizontal axis RW
SecondaryVerticalAxis Axis Secondary vertical axis RW

Axis

Represents chart axis.

Property Name Type Description RO/RW
IsVisible bool True if the axis is visible RW
HasTitle bool True if the axis has a visible title RW
Position enum Axis position RW
DisplayUnit enum The scaling value of the display units for the value axis. List of available display units see below RW
BaseUnitScale enum The smallest time unit that is represented on the date axis. List of available time units see below RW
IsAutomaticMajorUnit bool True if the major unit of the axis is automatically assigned RW
MajorUnit double The major units for the date or value axis RW
MajorUnitScale enum The major unit scale for the date axis. List of available time units see below RW
MajorTickMark enum The type of major tick mark for the specified axis. List of available tick mark types see below RW
IsAutomaticMinorUnit bool True if the minor unit of the axis is automatically assigned RW
MinorUnit double The minor units for the date or value axis RW
MinorUnitScale enum The minor unit scale for the date axis. List of available time units see below RW
MinorTickMark enum The type of minor tick mark for the specified axis. List of available tick mark types see below RW
IsAutomaticMaxValue bool True if the max value is automatically assigned RW
MaxValue double The maximum value on the value axis RW
IsAutomaticMinValue bool True if the min value is automatically assigned RW
MinValue double The minimum value on the value axis RW
IsLogarithmic bool True if the value axis scale type is logarithmic RW
LogBase double The logarithmic base. Default value is 10 RW
CategoryAxisType enum The type of the category axis RW
AxisBetweenCategories bool True if the value axis crosses the category axis between categories RW
LabelOffset int The distance of labels from the axis. Applied to category or date axis. Value must be between 0% and 1000% RW
IsPlotOrderReversed bool True if MS PowerPoint plots data points from last to first RW
IsNumberFormatLinkedToSource bool True if the format is linked to source data RW
NumberFormat string The format string for the Axis Labels RW
CrossType enum The CrossType on the specified axis where the other axis crosses RW
CrossAt float The point on the axis where the perpendicular axis crosses it RW
IsAutomaticTickMarksSpacing bool True for automatic tick marks spacing value RW
TickMarksSpacing int Specifies how many tick marks shall be skipped before the next one shall be drawn. Applied to category or series axis RW
IsAutomaticTickLabelSpacing bool True for automatic tick label spacing value RW
TickLabelsSpacing int Specifies how many tick labels shall be skipped before the next one shall be drawn RW
TickLabelPositionType enum The position of tick-mark labels on the specified axis RW
Represents the rotation angle of tick labels float Represents the rotation angle of tick labels RW
FillFormat FillFormat The fill format of the axis. RW
EffectFormat EffectFormat The effect format of the axis. RW
LineFormat LineFormat The line format of the axis. RW

We hope this helps!

Hi Sohail,

Thanks for the details, I’ll go through this.

Best regards,
Sumathi

@sumathi

Aspose.Slides Cloud SDKs are available on the GitHub (Aspose.Slides Cloud · GitHub). An SDK takes care of a lot of low-level details of making requests and handling responses and lets you focus on writing code specific to your particular project.