Interface IPresentationCharts
Represents a collection of IPresentationChart instance in a slide.
Namespace: Syncfusion.Presentation
Assembly: Syncfusion.Presentation.NET.dll
Syntax
public interface IPresentationCharts : IEnumerable<IPresentationChart>, IEnumerable
Properties
Count
Gets the number of elements in the chart collection. Read-only.
Declaration
int Count { get; }
Property Value
Type | Description |
---|---|
System.Int32 | The total count of the charts in the chart collection. |
Examples
//Create a new presentation.
IPresentation presentation = Presentation.Create();
//Add a blank slide to the presentation.
ISlide slide = presentation.Slides.Add(SlideLayoutType.Blank);
//Create instance to hold chart collection
IPresentationCharts charts = slide.Charts;
//Add chart to slide
IPresentationChart chart =charts.AddChart(300, 100, 300, 300);
//Set the fore color of the chart area.
chart.ChartArea.Fill.ForeColor = Color.AliceBlue;
//Get the count for chart collection
int count = charts.Count;
//Save the presentation
presentation.Save("Sample.pptx");
//Close the presentation
presentation.Close();
'Create a new presentation.
Dim presentation__1 As IPresentation = Presentation.Create()
'Add a blank slide to the presentation.
Dim slide As ISlide = presentation__1.Slides.Add(SlideLayoutType.Blank)
'Create instance to hold chart collection
Dim charts As IPresentationCharts = slide.Charts
'Add chart to slide
Dim chart As IPresentationChart = charts.AddChart(300, 100, 300, 300)
'Set the fore color of the chart area.
chart.ChartArea.Fill.ForeColor = Color.AliceBlue
'Get the count for chart collection
Dim count As Integer = charts.Count
'Save the presentation
presentation__1.Save("Sample.pptx")
'Close the presentation
presentation__1.Close()
Item[Int32]
Gets a single IPresentationChart instance from the collection. Read-only.
Declaration
IPresentationChart this[int index] { get; }
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | index | Index from the collection. |
Property Value
Type | Description |
---|---|
IPresentationChart | Returns the particular chart based on the index. |
Examples
//Create a new presentation.
IPresentation presentation = Presentation.Create();
//Add a blank slide to the presentation.
ISlide slide = presentation.Slides.Add(SlideLayoutType.Blank);
//Create instance to hold chart collection
IPresentationCharts charts = slide.Charts;
//Add chart to slide
charts.AddChart(300, 100, 300, 300);
//Retrieve the chart at index 0
IPresentationChart chart = charts[0];
//Set the fore color of the chart area.
chart.ChartArea.Fill.ForeColor = Color.AliceBlue;
//Save the presentation
presentation.Save("Sample.pptx");
//Close the presentation
presentation.Close();
'Create a new presentation.
Dim presentation__1 As IPresentation = Presentation.Create()
'Add a blank slide to the presentation.
Dim slide As ISlide = presentation__1.Slides.Add(SlideLayoutType.Blank)
'Create instance to hold chart collection
Dim charts As IPresentationCharts = slide.Charts
'Add chart to slide
charts.AddChart(300, 100, 300, 300)
'Retrieve the chart at index 0
Dim chart As IPresentationChart = charts(0)
'Set the fore color of the chart area.
chart.ChartArea.Fill.ForeColor = Color.AliceBlue
'Save the presentation
presentation__1.Save("Sample.pptx")
'Close the presentation
presentation__1.Close()
Methods
AddChart(IEnumerable, Double, Double, Double, Double)
Declaration
IPresentationChart AddChart(IEnumerable enumerable, double left, double top, double width, double height)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.IEnumerable | enumerable | |
System.Double | left | |
System.Double | top | |
System.Double | width | |
System.Double | height |
Returns
Type |
---|
IPresentationChart |
AddChart(Double, Double, Double, Double)
Adds a chart to the shape collection with the specified bounds.
Declaration
IPresentationChart AddChart(double left, double top, double width, double height)
Parameters
Type | Name | Description |
---|---|---|
System.Double | left | Represents the left position, in points. The Left value ranges from -169056 to 169056. |
System.Double | top | Represents the top position, in points. The Top value ranges from -169056 to 169056. |
System.Double | width | Represents the width, in points. The Width value ranges from 0 to 169056. |
System.Double | height | Represents the height, in points. The Height value ranges from 0 to 169056. |
Returns
Type | Description |
---|---|
IPresentationChart | Returns an IPresentationChart instance. |
Examples
//Create a new presentation
IPresentation presentation = Presentation.Create();
//Add a blank slide to the presentation.
ISlide slide = presentation.Slides.Add(SlideLayoutType.Blank);
//Create instance to hold chart collection
IPresentationCharts charts = slide.Charts;
//Add chart to slide
IPresentationChart chart =charts.AddChart(300, 100, 300, 300);
//Set the fore color of the chart area.
chart.ChartArea.Fill.ForeColor = Color.AliceBlue;
//Save the presentation
presentation.Save("Sample.pptx");
//Close the presentation
presentation.Close();
'Create a new presentation
Dim presentation__1 As IPresentation = Presentation.Create()
'Add a blank slide to the presentation.
Dim slide As ISlide = presentation__1.Slides.Add(SlideLayoutType.Blank)
'Create instance to hold chart collection
Dim charts As IPresentationCharts = slide.Charts
'Add chart to slide
Dim chart As IPresentationChart = charts.AddChart(300, 100, 300, 300)
'Set the fore color of the chart area.
chart.ChartArea.Fill.ForeColor = Color.AliceBlue
'Save the presentation
presentation__1.Save("Sample.pptx")
'Close the presentation
presentation__1.Close()
AddChart(Stream, Int32, String, RectangleF)
Creates a chart for the data in specified excel document and adds the chart to the shape collection.
Declaration
IPresentationChart AddChart(Stream excelStream, int sheetNumber, string dataRange, RectangleF bounds)
Parameters
Type | Name | Description |
---|---|---|
System.IO.Stream | excelStream | Excel document stream having the data for chart[Only the "*.xlsx" format is supported]. |
System.Int32 | sheetNumber | Worksheet number of the excel document. |
System.String | dataRange | Data range in the worksheet for the chart to be created. |
RectangleF | bounds | Position and size of the chart, in points. |
Returns
Type | Description |
---|---|
IPresentationChart | Returns an IPresentationChart instance. |
Examples
//Creates a Presentation instance
IPresentation pptxDoc = Presentation.Create();
//Adds a blank slide to the Presentation
ISlide slide = pptxDoc.Slides.Add(SlideLayoutType.Blank);
//Gets the excel file as stream
FileStream excelStream = new FileStream("Book1.xlsx", FileMode.Open);
//Adds a chart to the slide with a data range from excel worksheet – excel workbook, worksheet number, Data range, position, and size.
IPresentationChart chart = slide.Charts.AddChart(excelStream, 1, "A1:D4", new RectangleF(100, 10, 700, 500));
//Save the presentation
pptxDoc.Save("Output.pptx");
//Closes the Presentation
pptxDoc.Close();
'Creates a Presentation instance
Dim pptxDoc As IPresentation = Presentation.Create()
'Adds a blank slide to the Presentation
Dim slide As ISlide = pptxDoc.Slides.Add(SlideLayoutType.Blank)
'Gets the excel file as stream
Dim excelStream As New MemoryStream(File.ReadAllBytes("Book1.xlsx"))
'Adds a chart to the slide with a data range from excel worksheet – excel workbook, worksheet number, Data range, position, and size.
Dim chart As IPresentationChart = slide.Charts.AddChart(excelStream, 1, "A1:D4", New RectangleF(100, 10, 700, 500))
'Saves the Presentation
pptxDoc.Save("output.pptx")
'Closes the Presentation
pptxDoc.Close()
AddChart(Object[][], Double, Double, Double, Double)
Declaration
IPresentationChart AddChart(object[][] data, double left, double top, double width, double height)
Parameters
Type | Name | Description |
---|---|---|
System.Object[][] | data | |
System.Double | left | |
System.Double | top | |
System.Double | width | |
System.Double | height |
Returns
Type |
---|
IPresentationChart |
IndexOf(IPresentationChart)
Returns the zero-based index of the first occurrence of the IPresentationChart instance within the collection.
Declaration
int IndexOf(IPresentationChart chart)
Parameters
Type | Name | Description |
---|---|---|
IPresentationChart | chart | The IPresentationChart instance to locate in the collection. |
Returns
Type | Description |
---|---|
System.Int32 | Returns the zero-based index of the first occurrence of object within the entire collection, if found; otherwise, –1. |
Examples
//Create a new presentation.
IPresentation presentation = Presentation.Create();
//Add a blank slide to the presentation.
ISlide slide = presentation.Slides.Add(SlideLayoutType.Blank);
//Create instance to hold chart collection
IPresentationCharts charts = slide.Charts;
//Add chart to slide
IPresentationChart chart =charts.AddChart(300, 100, 300, 300);
//Set the fore color of the chart area.
chart.ChartArea.Fill.ForeColor = Color.AliceBlue;
//Get the index of specific chart
int index = charts.IndexOf(chart);
//Save the presentation
presentation.Save("Sample.pptx");
//Close the presentation
presentation.Close();
'Create a new presentation.
Dim presentation__1 As IPresentation = Presentation.Create()
'Add a blank slide to the presentation.
Dim slide As ISlide = presentation__1.Slides.Add(SlideLayoutType.Blank)
'Create instance to hold chart collection
Dim charts As IPresentationCharts = slide.Charts
'Add chart to slide
Dim chart As IPresentationChart = charts.AddChart(300, 100, 300, 300)
'Set the fore color of the chart area.
chart.ChartArea.Fill.ForeColor = Color.AliceBlue
'Get the index of specific chart
Dim index As Integer = shapes.IndexOf(chart)
'Save the presentation
presentation__1.Save("Sample.pptx")
'Close the presentation
presentation__1.Close()
RemoveAt(Int32)
Removes the element at the specified index of the chart collection.
Declaration
void RemoveAt(int index)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | index | The zero-based index of the element to be removed. |
Examples
//Create a new presentation.
IPresentation presentation = Presentation.Create();
//Add a blank slide to the presentation.
ISlide slide = presentation.Slides.Add(SlideLayoutType.Blank);
//Create instance to hold chart collection
IPresentationCharts charts = slide.Charts;
//Add chart to slide
IPresentationChart chart = charts.AddChart(100, 300, 200, 200);
//Set the fore color of the chart area.
chart.ChartArea.Fill.ForeColor = Color.LightBlue;
//Add chart to slide
IPresentationChart chart2 = charts.AddChart(300, 300, 200, 200);
//Set the fore color of the chart area.
chart2.ChartArea.Fill.ForeColor = Color.AliceBlue;
//Remove chart specific index
charts.RemoveAt(0);
//Save the presentation
presentation.Save("Sample.pptx");
//Close the presentation
presentation.Close();
'Create a new presentation.
Dim presentation__1 As IPresentation = Presentation.Create()
'Add a blank slide to the presentation.
Dim slide As ISlide = presentation__1.Slides.Add(SlideLayoutType.Blank)
'Create instance to hold chart collection
Dim charts As IPresentationCharts = slide.Charts
'Add chart to slide
Dim chart As IPresentationChart = charts.AddChart(100, 300, 200, 200)
'Set the fore color of the chart area.
chart.ChartArea.Fill.ForeColor = Color.LightBlue
'Add chart to slide
Dim chart2 As IPresentationChart = charts.AddChart(300, 300, 200, 200)
'Set the fore color of the chart area.
chart2.ChartArea.Fill.ForeColor = Color.AliceBlue
'Remove chart specific index
chart.RemoveAt(0)
'Save the presentation
presentation__1.Save("Sample.pptx")
'Close the presentation
presentation__1.Close()