Interface IChartDataLabels
Represents a collection of chart data labels.
Inherited Members
Namespace: Syncfusion.XlsIO
Assembly: Syncfusion.XlsIO.UWP.dll
Syntax
public interface IChartDataLabels : IChartTextArea, IFont, IParentApplication, IOptimizedUpdate
Properties
Delimiter
Gets or sets the variant representing the separator used for data labels on the chart.
Declaration
string Delimiter { get; set; }
Property Value
Type |
---|
System.String |
Examples
The following code illustrates how to access the IChartDataLabels and set delimiter for data labels.
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";
sheet.Range["A3"].Value = "15";
sheet.Range["B3"].Value = "25";
sheet.Range["C3"].Value = "35";
//Create chart
IChart chart = sheet.Charts.Add();
//Set range
chart.DataRange = sheet.Range["A1:C3"];
//Set chart type
chart.ChartType = ExcelChartType.Column_Clustered;
//Get the chart serie
IChartSerie serie = chart.Series[0];
//Get serie data labels
IChartDataLabels dataLabels = serie.DataPoints.DefaultDataPoint.DataLabels;
//Set the data label to show the values
dataLabels.IsValue = true;
//Set the data label to show the series name
dataLabels.IsSeriesName = true;
//Set '-' symbol as separator for data labels
dataLabels.Delimiter = "-";
//Save and Dispose
workbook.SaveAs("chart.xlsx");
workbook.Close();
}
IsBubbleSize
Gets or sets a boolean value indicating whether to show bubble size for data labels.
Declaration
bool IsBubbleSize { get; set; }
Property Value
Type |
---|
System.Boolean |
Examples
The following code illustrates how to access the IChartDataLabels and set to shows the bubble sizes.
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";
sheet.Range["A3"].Value = "1";
sheet.Range["B3"].Value = "2";
sheet.Range["C3"].Value = "3";
//Create chart
IChart chart = sheet.Charts.Add();
//Set range
chart.DataRange = sheet.Range["A1:C3"];
//Set chart type
chart.ChartType = ExcelChartType.Bubble;
//Get the chart serie
IChartSerie serie = chart.Series[0];
//Get serie data labels
IChartDataLabels dataLabels = serie.DataPoints.DefaultDataPoint.DataLabels;
//Set the data label to show the bubble sizes
dataLabels.IsBubbleSize = true;
//Save and Dispose
workbook.SaveAs("chart.xlsx");
workbook.Close();
}
IsCategoryName
Gets or sets a boolean value indicating whether to display category name for data labels.
Declaration
bool IsCategoryName { get; set; }
Property Value
Type |
---|
System.Boolean |
Examples
The following code illustrates how to access the IChartDataLabels and set to shows the categories.
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";
sheet.Range["A3"].Value = "15";
sheet.Range["B3"].Value = "25";
sheet.Range["C3"].Value = "35";
//Create chart
IChart chart = sheet.Charts.Add();
//Set range
chart.DataRange = sheet.Range["A1:C3"];
//Set chart type
chart.ChartType = ExcelChartType.Column_Clustered;
//Get the chart serie
IChartSerie serie = chart.Series[0];
//Get serie data labels
IChartDataLabels dataLabels = serie.DataPoints.DefaultDataPoint.DataLabels;
//Set the data label to show the category names
dataLabels.IsCategoryName = true;
//Save and Dispose
workbook.SaveAs("chart.xlsx");
workbook.Close();
}
IsFormula
Gets or sets a value indicating whether this instance is formula.
Declaration
bool IsFormula { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean |
|
Examples
The following code illustrates the use IsFormula property.
using (ExcelEngine excelEngine = new ExcelEngine())
{
IApplication application = excelEngine.Excel;
IWorkbook workbook = application.Workbooks.Create(1);
IWorksheet sheet = workbook.Worksheets[0];
sheet.Range["A1"].Text = "Month";
sheet.Range["B1"].Text = "Product A";
sheet.Range["C1"].Text = "Product B";
sheet.Range["A2"].Text = "Jan";
sheet.Range["A3"].Text = "Feb";
sheet.Range["A4"].Text = "Mar";
sheet.Range["A5"].Text = "Apr";
sheet.Range["A6"].Text = "May";
sheet.Range["B2"].Number = 111;
sheet.Range["B3"].Number = 361;
sheet.Range["B4"].Number = 336;
sheet.Range["B5"].Number = 40;
sheet.Range["B6"].Number = 219;
sheet.Range["C2"].Number = 182;
sheet.Range["C3"].Number = 283;
sheet.Range["C4"].Number = 406;
sheet.Range["C5"].Number = 449;
sheet.Range["C6"].Number = 337;
IChartShape chart = sheet.Charts.Add();
chart.ChartType = ExcelChartType.Line;
chart.DataRange = sheet.Range["A1:C6"];
chart.Series[0].DataPoints[0].DataLabels.IsFormula = true;
chart.Series[0].DataPoints[0].DataLabels.Text = "='Sheet1'!$A$2";
workbook.SaveAs("Charts.xlsx");
workbook.Close();
}
IsLegendKey
Gets or sets a boolean value indicating whether data label legend key is visible.
Declaration
bool IsLegendKey { get; set; }
Property Value
Type |
---|
System.Boolean |
Examples
The following code illustrates how to access the IChartDataLabels and set to shows the legend keys.
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";
sheet.Range["A3"].Value = "15";
sheet.Range["B3"].Value = "25";
sheet.Range["C3"].Value = "35";
//Create chart
IChart chart = sheet.Charts.Add();
//Set range
chart.DataRange = sheet.Range["A1:C3"];
//Set chart type
chart.ChartType = ExcelChartType.Column_Clustered;
//Get the chart serie
IChartSerie serie = chart.Series[0];
//Get serie data labels
IChartDataLabels dataLabels = serie.DataPoints.DefaultDataPoint.DataLabels;
//Set the data label to show the values
dataLabels.IsValue = true;
//Set the data label to show the legend key
dataLabels.IsLegendKey = true;
//Save and Dispose
workbook.SaveAs("chart.xlsx");
workbook.Close();
}
IsPercentage
Gets or sets a boolean value indicating whether to display percentage value for data labels.
Declaration
bool IsPercentage { get; set; }
Property Value
Type |
---|
System.Boolean |
Examples
The following code illustrates how to access the IChartDataLabels and set to shows the percentage values.
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.Pie;
//Get the chart serie
IChartSerie serie = chart.Series[0];
//Get serie data labels
IChartDataLabels dataLabels = serie.DataPoints.DefaultDataPoint.DataLabels;
//Set the data label to show the percentage values
dataLabels.IsPercentage = true;
//Save and Dispose
workbook.SaveAs("chart.xlsx");
workbook.Close();
}
IsSeriesName
Gets or sets a boolean value indicating whether to display series name for data labels.
Declaration
bool IsSeriesName { get; set; }
Property Value
Type |
---|
System.Boolean |
Examples
The following code illustrates how to access the IChartDataLabels and set to shows the serie name.
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";
sheet.Range["A3"].Value = "15";
sheet.Range["B3"].Value = "25";
sheet.Range["C3"].Value = "35";
//Create chart
IChart chart = sheet.Charts.Add();
//Set range
chart.DataRange = sheet.Range["A1:C3"];
//Set chart type
chart.ChartType = ExcelChartType.Column_Clustered;
//Get the chart serie
IChartSerie serie = chart.Series[0];
//Get serie data labels
IChartDataLabels dataLabels = serie.DataPoints.DefaultDataPoint.DataLabels;
//Set the data label to show the serie name
dataLabels.IsSeriesName = true;
//Save and Dispose
workbook.SaveAs("chart.xlsx");
workbook.Close();
}
IsValue
Gets or sets a boolean value indicating whether to display data label values.
Declaration
bool IsValue { get; set; }
Property Value
Type |
---|
System.Boolean |
Examples
The following code illustrates how to access the IChartDataLabels and set to shows the values.
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";
sheet.Range["A3"].Value = "15";
sheet.Range["B3"].Value = "25";
sheet.Range["C3"].Value = "35";
//Create chart
IChart chart = sheet.Charts.Add();
//Set range
chart.DataRange = sheet.Range["A1:C3"];
//Set chart type
chart.ChartType = ExcelChartType.Column_Clustered;
//Get the chart serie
IChartSerie serie = chart.Series[0];
//Get serie data labels
IChartDataLabels dataLabels = serie.DataPoints.DefaultDataPoint.DataLabels;
//Set the data label to show the values
dataLabels.IsValue = true;
//Save and Dispose
workbook.SaveAs("chart.xlsx");
workbook.Close();
}
IsValueFromCells
Gets or sets a boolean value indicating whether to display value form cells for data labels.
Declaration
bool IsValueFromCells { get; set; }
Property Value
Type |
---|
System.Boolean |
Examples
The following code illustrates how to access the IChartDataLabels and set to shows the vale form cells values.
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";
sheet.Range["A3"].Value = "15";
sheet.Range["B3"].Value = "25";
sheet.Range["C3"].Value = "35";
//Create chart
IChart chart = sheet.Charts.Add();
//Set range
chart.DataRange = sheet.Range["A1:C3"];
//Set chart type
chart.ChartType = ExcelChartType.Column_Clustered;
//Get the chart serie
IChartSerie serie = chart.Series[0];
//Get serie data labels
IChartDataLabels dataLabels = serie.DataPoints.DefaultDataPoint.DataLabels;
//Set the data label to show the value form cells.
dataLabels.IsVlaveFromCells = true;
//Set the data label to show the value form cells range.
datalabels.ValueFromCellsRange= sheet["F5:H5"];
//Save and Dispose
workbook.SaveAs("chart.xlsx");
workbook.Close();
}
Position
Gets or sets the data labels position.
Declaration
ExcelDataLabelPosition Position { get; set; }
Property Value
Type |
---|
ExcelDataLabelPosition |
Examples
The following code illustrates how to access the IChartDataLabels and set the position for labels.
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.Pie;
//Get the chart serie
IChartSerie serie = chart.Series[0];
//Get serie data labels
IChartDataLabels dataLabels = serie.DataPoints.DefaultDataPoint.DataLabels;
//Set the data label to show the values
dataLabels.IsValue = true;
//Set data label position to outside
dataLabels.Position = ExcelDataLabelPosition.Outside;
//Save and Dispose
workbook.SaveAs("chart.xlsx");
workbook.Close();
}
ShowLeaderLines
Gets or sets a boolean value indicating whether to display leader lines.
Declaration
bool ShowLeaderLines { get; set; }
Property Value
Type |
---|
System.Boolean |
Examples
The following code illustrates how to access the IChartDataLabels and set leader lines to show.
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.Pie;
//Get the chart serie
IChartSerie serie = chart.Series[0];
//Get serie data labels
IChartDataLabels dataLabels = serie.DataPoints.DefaultDataPoint.DataLabels;
//Set the data label to show the values
dataLabels.IsValue = true;
//Set data label position to outside
dataLabels.Position = ExcelDataLabelPosition.Outside;
//Set the data label to show the leader lines
dataLabels.ShowLeaderLines = true;
//Save and Dispose
workbook.SaveAs("chart.xlsx");
workbook.Close();
}
ValueFromCellsRange
Gets or sets a boolean value indicating whether to display value form cells range for data labels.
Declaration
IRange ValueFromCellsRange { get; set; }
Property Value
Type |
---|
IRange |
Examples
The following code illustrates how to access the IChartDataLabels and set to shows the value form cells range.
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";
sheet.Range["A3"].Value = "15";
sheet.Range["B3"].Value = "25";
sheet.Range["C3"].Value = "35";
//Create chart
IChart chart = sheet.Charts.Add();
//Set range
chart.DataRange = sheet.Range["A1:C3"];
//Set chart type
chart.ChartType = ExcelChartType.Column_Clustered;
//Get the chart serie
IChartSerie serie = chart.Series[0];
//Get serie data labels
IChartDataLabels dataLabels = serie.DataPoints.DefaultDataPoint.DataLabels;
//Set the data label to show the value form cells.
dataLabels.IsVlaveFromCells = true;
//Set the data label to show the value form cells range.
datalabels.ValueFromCellsRange= sheet["F5:H5"];
//Save and Dispose
workbook.SaveAs("chart.xlsx");
workbook.Close();
}