Interface IChartDataPoint
Represents data point in the chart.
Namespace: Syncfusion.XlsIO
Assembly: Syncfusion.XlsIO.Portable.dll
Syntax
public interface IChartDataPoint : IParentApplication
Properties
DataFormat
Gets or sets the data format.
Declaration
IChartSerieDataFormat DataFormat { get; }
Property Value
Type |
---|
IChartSerieDataFormat |
Examples
The DataFormat property is used to set chart serie formats. Here for example, we access DataFormat and set Syncfusion.XlsIO.Excel2007ChartMarkerType.star to MarkerStyle.
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 chart type
chart.ChartType = ExcelChartType.Line;
//Set serie format
IChartSerieDataFormat format = chart.Series[0].SerieFormat;
//Set marker style
format.MarkerStyle = ExcelChartMarkerType.Star;
//Save and Dispose
workbook.SaveAs("Chart.xlsx");
workbook.Close();
}
DataLabels
Gets the IChartDataLabels object for the IChartDataPoint. Read-only.
Declaration
IChartDataLabels DataLabels { get; }
Property Value
Type |
---|
IChartDataLabels |
Examples
The following code illustrates how to access the IChartDataLabels for a particular IChartDataPoint.
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();
}
Index
Gets index of the IChartDataPoint in the IChartDataPoints collection.
Declaration
int Index { get; }
Property Value
Type |
---|
System.Int32 |
Examples
The following code illustrates how to access the Index of a IChartDataPoint in the 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];
//Get index
Console.WriteLine(serie.DataPoints[0].Index);
//Save and Dispose
workbook.SaveAs("Chart.xlsx");
workbook.Close();
Console.ReadKey();
}
IsDefault
True if the IChartDataPoint is a default one. otherwise False. Read-only.
Declaration
bool IsDefault { get; }
Property Value
Type |
---|
System.Boolean |
Examples
The following code illustrates how to access the IsDefault 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 format
IChartDataPoints dataPoints = chart.Series[0].DataPoints;
//Check default Datapoint
Console.WriteLine(dataPoints.DefaultDataPoint.IsDefault);
Console.WriteLine(dataPoints[0].IsDefault);
//Save and Dispose
workbook.SaveAs("Chart.xlsx");
workbook.Close();
Console.ReadKey();
}
//Output will be
//True
//False
IsDefaultmarkertype
True if the data point has default marker object. otherwise False.
Declaration
bool IsDefaultmarkertype { get; set; }
Property Value
Type |
---|
System.Boolean |
Examples
The following code illustrates how to access the IsDefaultmarkertype 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["D1"].Text = "Apr";
sheet.Range["E1"].Text = "May";
sheet.Range["F1"].Text = "Jun";
sheet.Range["A2"].Value = "5";
sheet.Range["B2"].Value = "21";
sheet.Range["C2"].Value = "15";
sheet.Range["D2"].Value = "12";
sheet.Range["E2"].Value = "28";
sheet.Range["F2"].Value = "9";
//Create chart
IChart chart = sheet.Charts.Add();
//Set range
chart.DataRange = sheet.Range["A1:F2"];
//Set chart type
chart.ChartType = ExcelChartType.Line;
//Set serie data format
IChartSerieDataFormat format = chart.Series[0].DataPoints.DefaultDataPoint.DataFormat;
//Set marker style
format.MarkerStyle = ExcelChartMarkerType.Circle;
//Check default marker
Console.Write(chart.Series[0].DataPoints.DefaultDataPoint.IsDefaultmarkertype);
//Save and Dispose
workbook.SaveAs("Chart.xlsx");
workbook.Close();
Console.ReadKey();
}
//Output will be
//True
SetAsTotal
True if the data point is considered as Subtotals or Totals. otherwise False.
Declaration
bool SetAsTotal { get; set; }
Property Value
Type |
---|
System.Boolean |
Remarks
Applies only to Waterfall charts.
Examples
By default in WaterFall chart data is plotted as floating columns. If we mark a particular column as total or subtotal by setting SetAsTotal property then that particular column starts from zero in horizontal axis and it won't float.
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 chart type
chart.ChartType = ExcelChartType.WaterFall;
//Set serie format
IChartSerieDataFormat format = chart.Series[0].SerieFormat;
//Set SetAsTotal
chart.Series[0].DataPoints[2].SetAsTotal = true;
//Save and Dispose
workbook.SaveAs("Chart.xlsx");
workbook.Close();
}