Interface IChartDataPoints
Represents a collection of data points in the series.
Namespace: Syncfusion.XlsIO
Assembly: Syncfusion.XlsIO.NET.dll
Syntax
public interface IChartDataPoints : IParentApplication, IEnumerable
Properties
DefaultDataPoint
Gets the default data point. Read-only.
Declaration
IChartDataPoint DefaultDataPoint { get; }
Property Value
Type |
---|
IChartDataPoint |
Examples
To customize the properties of all the IChartDataPoint in the IChartDataPoints collection at the same time, we can use DefaultDataPoint property.
using (ExcelEngine excelEngine = new ExcelEngine())
{
//Create worksheet
IApplication application = excelEngine.Excel;
application.DefaultVersion = ExcelVersion.Excel2013;
IWorkbook workbook = application.Workbooks.Create(1);
IWorksheet sheet = workbook.Worksheets[0];
//Add data
sheet.Range["A1"].Text = "Jan";
sheet.Range["B1"].Text = "Feb";
sheet.Range["C1"].Text = "Mar";
sheet.Range["A2"].Value = "10";
sheet.Range["B2"].Value = "20";
sheet.Range["C2"].Value = "30";
//Create chart
IChart chart = sheet.Charts.Add();
//Set range
chart.DataRange = sheet.Range["A1:C2"];
//Set serie
IChartSerie serie = chart.Series[0];
//Set data labels value visibility
serie.DataPoints.DefaultDataPoint.DataLabels.IsValue = true;
//Save and Dispose
workbook.SaveAs("Chart.xlsx");
workbook.Close();
}
Item[Int32]
Gets the data point with the specified index. Read-only.
Declaration
IChartDataPoint this[int index] { get; }
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | index |
Property Value
Type |
---|
IChartDataPoint |
Examples
The following code illustrates how a particular IChartDataPoint can be accessed from IChartDataPoints collection.
using (ExcelEngine excelEngine = new ExcelEngine())
{
//Create worksheet
IApplication application = excelEngine.Excel;
application.DefaultVersion = ExcelVersion.Excel2013;
IWorkbook workbook = application.Workbooks.Create(1);
IWorksheet sheet = workbook.Worksheets[0];
//Add data
sheet.Range["A1"].Text = "Jan";
sheet.Range["B1"].Text = "Feb";
sheet.Range["C1"].Text = "Mar";
sheet.Range["A2"].Value = "10";
sheet.Range["B2"].Value = "20";
sheet.Range["C2"].Value = "30";
//Create chart
IChart chart = sheet.Charts.Add();
//Set range
chart.DataRange = sheet.Range["A1:C2"];
//Set serie
IChartSerie serie = chart.Series[0];
//Set data labels value visibility
serie.DataPoints[0].DataLabels.IsValue = true;
//Save and Dispose
workbook.SaveAs("Chart.xlsx");
workbook.Close();
}