Interface IChartErrorBars
Represent error bars on the chart series.
Error bars indicate the degree of uncertainty for chart data. Only series in area, bar, column, line, and scatter groups on a 2-D chart can have error bars. Only series in scatter groups can have x and y error bars.
Namespace: Syncfusion.XlsIO
Assembly: Syncfusion.XlsIO.Base.dll
Syntax
public interface IChartErrorBars
Properties
Border
Gets the border for the drop bars. Read-only.
Declaration
IChartBorder Border { get; }
Property Value
Type | Description |
---|---|
IChartBorder |
Examples
The following code illustrates how to access and format the IChartBorder for IChartErrorBars
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 chart serie
IChartSerie serie = chart.Series[0];
//Enabling the Y Error bars
serie.HasErrorBarsY = true;
//Get Y Error Bars
IChartErrorBars errorBars = serie.ErrorBarsY;
//Set Error bars border color
errorBars.Border.ColorIndex = ExcelKnownColors.Red;
//Save and Dispose
workbook.SaveAs("Chart.xlsx");
workbook.Close();
}
Chart3DOptions
Gets the IThreeDFormat object. Read-only.[Deprecated]
Declaration
IThreeDFormat Chart3DOptions { get; }
Property Value
Type | Description |
---|---|
IThreeDFormat |
HasCap
Gets or sets a boolean value indicating end style for the error bars.
Declaration
bool HasCap { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean |
Examples
The following code illustrates how to remove end style for IChartErrorBars
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 chart serie
IChartSerie serie = chart.Series[0];
//Enabling the Y Error bars
serie.HasErrorBarsY = true;
//Get Y Error Bars
IChartErrorBars errorBars = serie.ErrorBarsY;
//Set false to remove the end style
errorBars.HasCap = false;
//Save and Dispose
workbook.SaveAs("Chart.xlsx");
workbook.Close();
}
Include
Gets or sets the error bar include type.
Declaration
ExcelErrorBarInclude Include { get; set; }
Property Value
Type | Description |
---|---|
ExcelErrorBarInclude |
Examples
The following code illustrates how to set include type for IChartErrorBars
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 chart serie
IChartSerie serie = chart.Series[0];
//Enabling the Y Error bars
serie.HasErrorBarsY = true;
//Get Y Error Bars
IChartErrorBars errorBars = serie.ErrorBarsY;
//Set negative error only to include
errorBars.Include = ExcelErrorBarInclude.Minus;
//Save and Dispose
workbook.SaveAs("Chart.xlsx");
workbook.Close();
}
MinusRange
Gets or sets IRange object with negative error value for custom error bar.
Declaration
IRange MinusRange { get; set; }
Property Value
Type | Description |
---|---|
IRange |
Examples
The following code illustrates how to set the minus range for IChartErrorBars
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";
sheet.Range["D2"].Value = "4";
//Create chart
IChart chart = sheet.Charts.Add();
//Set range
chart.DataRange = sheet.Range["A1:C3"];
//Set chart type
chart.ChartType = ExcelChartType.Column_Clustered;
//Get chart serie
IChartSerie serie = chart.Series[0];
//Enabling the Y Error bars
serie.HasErrorBarsY = true;
//Get Y Error Bars
IChartErrorBars errorBars = serie.ErrorBarsY;
//Set error amount to custom
errorBars.Type = ExcelErrorBarType.Custom;
//Set minus range
errorBars.MinusRange = sheet["D2"];
//Save and Dispose
workbook.SaveAs("Chart.xlsx");
workbook.Close();
}
NumberValue
Gets or sets the number value for applicable ExcelErrorBarType.
Declaration
double NumberValue { get; set; }
Property Value
Type | Description |
---|---|
System.Double |
Examples
The following code illustrates how to set the error value for IChartErrorBars
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 chart serie
IChartSerie serie = chart.Series[0];
//Enabling the Y Error bars
serie.HasErrorBarsY = true;
//Get Y Error Bars
IChartErrorBars errorBars = serie.ErrorBarsY;
//Set error amount to fixed value
errorBars.Type = ExcelErrorBarType.Fixed;
//Set error value
errorBars.NumberValue = 3.0;
//Save and Dispose
workbook.SaveAs("Chart.xlsx");
workbook.Close();
}
PlusRange
Gets or sets IRange object with positive error value for custom error bar.
Declaration
IRange PlusRange { get; set; }
Property Value
Type | Description |
---|---|
IRange |
Examples
The following code illustrates how to set the plus range for IChartErrorBars
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";
sheet.Range["D2"].Value = "4";
//Create chart
IChart chart = sheet.Charts.Add();
//Set range
chart.DataRange = sheet.Range["A1:C3"];
//Set chart type
chart.ChartType = ExcelChartType.Column_Clustered;
//Get chart serie
IChartSerie serie = chart.Series[0];
//Enabling the Y Error bars
serie.HasErrorBarsY = true;
//Get Y Error Bars
IChartErrorBars errorBars = serie.ErrorBarsY;
//Set error amount to custom
errorBars.Type = ExcelErrorBarType.Custom;
//Set plus range
errorBars.PlusRange = sheet["D2"];
//Save and Dispose
workbook.SaveAs("Chart.xlsx");
workbook.Close();
}
Shadow
Gets the IShadow object. Read-only.
Declaration
IShadow Shadow { get; }
Property Value
Type | Description |
---|---|
IShadow |
Examples
The following code illustrates how to access and format the IShadow for IChartErrorBars
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 chart serie
IChartSerie serie = chart.Series[0];
//Enabling the Y Error bars
serie.HasErrorBarsY = true;
//Get Y Error Bars
IChartErrorBars errorBars = serie.ErrorBarsY;
//Set Error bars shadow color
errorBars.Shadow.ShadowColor = System.Drawing.Color.Red;
//Set Error bars shadow outer presets
errorBars.Shadow.ShadowOuterPresets = Excel2007ChartPresetsOuter.OffsetDiagonalTopRight;
//Save and Dispose
workbook.SaveAs("Chart.xlsx");
workbook.Close();
}
Type
Gets or sets the error bar type.
Declaration
ExcelErrorBarType Type { get; set; }
Property Value
Type | Description |
---|---|
ExcelErrorBarType |
Examples
The following code illustrates how to set the error bar type for IChartErrorBars
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 chart serie
IChartSerie serie = chart.Series[0];
//Enabling the Y Error bars
serie.HasErrorBarsY = true;
//Get Y Error Bars
IChartErrorBars errorBars = serie.ErrorBarsY;
//Set error amount to standard deviation
errorBars.Type = ExcelErrorBarType.StandardDeviation;
//Save and Dispose
workbook.SaveAs("Chart.xlsx");
workbook.Close();
}
Methods
ClearFormats()
Clears the formats of the error bars.
Declaration
void ClearFormats()
Examples
The following code illustrates how to clear the formats of IChartErrorBars
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";
sheet.Range["D2"].Value = "4";
//Create chart
IChart chart = sheet.Charts.Add();
//Set range
chart.DataRange = sheet.Range["A1:C3"];
//Set chart type
chart.ChartType = ExcelChartType.Column_Clustered;
//Get chart serie
IChartSerie serie = chart.Series[0];
//Enabling the Y Error bars
serie.HasErrorBarsY = true;
//Get Y Error Bars
IChartErrorBars errorBars = serie.ErrorBarsY;
//Set Error bars border color
errorBars.Border.ColorIndex = ExcelKnownColors.Red;
//Set error amount to custom
errorBars.Type = ExcelErrorBarType.Custom;
//Set minus range
errorBars.MinusRange = sheet["D2"];
//Check error bar contains formats
Console.WriteLine("Is default line color applied in Error bars:" + errorBars.Border.IsAutoLineColor);
Console.WriteLine("Error bar type:" + errorBars.Type);
//Clear the Error bar formats
errorBars.ClearFormats();
//Check error bar contains formats
Console.WriteLine("Is default line color applied in Error bars:"+ errorBars.Border.IsAutoLineColor);
Console.WriteLine("Error bar type:"+ errorBars.Type);
//Save and Dispose
workbook.SaveAs("Chart.xlsx");
workbook.Close();
Console.ReadKey();
}
Delete()
Deletes the error bars.
Declaration
void Delete()
Examples
The following code illustrates how to delete the IChartErrorBars
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 chart serie
IChartSerie serie = chart.Series[0];
//Enabling the Y Error bars
serie.HasErrorBarsY = true;
//Get Y Error bars
IChartErrorBars errorBars = serie.ErrorBarsY;
//Check series contains Error bars
Console.WriteLine("Is serie contains Error bars:" + serie.HasErrorBarsY);
//Removing the Error bars
errorBars.Delete();
//Check series contains Error bars
Console.WriteLine("Is serie contains Error bars:" + serie.HasErrorBarsY);
//Save and Dispose
workbook.SaveAs("Chart.xlsx");
workbook.Close();
Console.ReadKey();
}