Class ErrorBar

ErrorBar class

Represents error bar of data series.

public class ErrorBar : Line

Properties

NameDescription
Amount { get; set; }Represents amount of error bar.
BeginArrowLength { get; set; }Specifies the length of the arrowhead for the begin of a line.(Inherited from Line.)
BeginArrowWidth { get; set; }Specifies the width of the arrowhead for the begin of a line.(Inherited from Line.)
BeginType { get; set; }Specifies an arrowhead for the begin of a line.(Inherited from Line.)
CapType { get; set; }Specifies the ending caps.(Inherited from Line.)
Color { get; set; }Represents the Color of the line.(Inherited from Line.)
CompoundType { get; set; }Specifies the compound line type(Inherited from Line.)
DashType { get; set; }Specifies the dash line type(Inherited from Line.)
DisplayType { get; set; }Represents the display type of error bar.
EndArrowLength { get; set; }Specifies the length of the arrowhead for the end of a line.(Inherited from Line.)
EndArrowWidth { get; set; }Specifies the width of the arrowhead for the end of a line.(Inherited from Line.)
EndType { get; set; }Specifies an arrowhead for the end of a line.(Inherited from Line.)
FormattingType { get; set; }Gets or sets format type.(Inherited from Line.)
GradientFill { get; }Represents gradient fill.(Inherited from Line.)
IsAuto { get; set; }Indicates whether this line style is auto assigned.(Inherited from Line.)
IsAutomaticColor { get; }Indicates whether the color of line is automatic assigned.(Inherited from Line.)
IsVisible { get; set; }Represents whether the line is visible.(Inherited from Line.)
JoinType { get; set; }Specifies the joining caps.(Inherited from Line.)
MinusValue { get; set; }Represents negative error amount when error bar type is Custom.
PlusValue { get; set; }Represents positive error amount when error bar type is Custom.
ShowMarkerTTop { get; set; }Indicates if formatting error bars with a T-top.
Style { get; set; }Represents the style of the line.(Inherited from Line.)
ThemeColor { get; set; }Gets and sets the theme color.(Inherited from Line.)
Transparency { get; set; }Returns or sets the degree of transparency of the line as a value from 0.0 (opaque) through 1.0 (clear).(Inherited from Line.)
Type { get; set; }Represents error bar amount type.
Weight { get; set; }Gets or sets the WeightType of the line.(Inherited from Line.)
WeightPt { get; set; }Gets or sets the weight of the line in unit of points.(Inherited from Line.)
WeightPx { get; set; }Gets or sets the weight of the line in unit of pixels.(Inherited from Line.)

Examples

namespace AsposeCellsExamples
{
    using Aspose.Cells;
    using Aspose.Cells.Charts;
    using System;

    public class ErrorBarDemo
    {
        public static void ErrorBarExample()
        {
            // Create a new workbook
            Workbook workbook = new Workbook();
            Cells cells = workbook.Worksheets[0].Cells;

            // Add sample data to cells
            cells["A1"].PutValue(2);
            cells["A2"].PutValue(5);
            cells["A3"].PutValue(3);
            cells["A4"].PutValue(6);
            cells["B1"].PutValue(4);
            cells["B2"].PutValue(3);
            cells["B3"].PutValue(6);
            cells["B4"].PutValue(7);
            cells["C1"].PutValue("Q1");
            cells["C2"].PutValue("Q2");
            cells["C3"].PutValue("Y1");
            cells["C4"].PutValue("Y2");

            // Add a chart to the worksheet
            int chartIndex = workbook.Worksheets[0].Charts.Add(ChartType.Column, 11, 0, 27, 10);
            Chart chart = workbook.Worksheets[0].Charts[chartIndex];

            // Add NSeries (chart data source) to the chart
            chart.NSeries.Add("A1:B4", true);
            chart.NSeries.CategoryData = "C1:C4";

            // Configure error bars for each series in the chart
            for (int i = 0; i < chart.NSeries.Count; i++)
            {
                Series series = chart.NSeries[i];
                series.YErrorBar.DisplayType = ErrorBarDisplayType.Minus;
                series.YErrorBar.Type = ErrorBarType.FixedValue;
                series.YErrorBar.Amount = 5;

                // Additional properties for demonstration
                series.YErrorBar.ShowMarkerTTop = true;
                series.YErrorBar.PlusValue = "=Sheet1!A1";
                series.YErrorBar.MinusValue = "=Sheet1!A2";
                series.YErrorBar.CompoundType = Aspose.Cells.Drawing.MsoLineStyle.ThickThin;
                series.YErrorBar.DashType = Aspose.Cells.Drawing.MsoLineDashStyle.DashDot;
                series.YErrorBar.CapType = Aspose.Cells.Drawing.LineCapType.Round;
                series.YErrorBar.JoinType = Aspose.Cells.Drawing.LineJoinType.Bevel;
                series.YErrorBar.BeginType = Aspose.Cells.Drawing.MsoArrowheadStyle.Arrow;
                series.YErrorBar.EndType = Aspose.Cells.Drawing.MsoArrowheadStyle.ArrowDiamond;
                series.YErrorBar.BeginArrowLength = Aspose.Cells.Drawing.MsoArrowheadLength.Short;
                series.YErrorBar.EndArrowLength = Aspose.Cells.Drawing.MsoArrowheadLength.Long;
                series.YErrorBar.BeginArrowWidth = Aspose.Cells.Drawing.MsoArrowheadWidth.Narrow;
                series.YErrorBar.EndArrowWidth = Aspose.Cells.Drawing.MsoArrowheadWidth.Wide;
                series.YErrorBar.ThemeColor = new Aspose.Cells.ThemeColor(Aspose.Cells.ThemeColorType.Accent1, 0.5);
                series.YErrorBar.Color = System.Drawing.Color.Red;
                series.YErrorBar.Transparency = 0.5;
                series.YErrorBar.Style = Aspose.Cells.Drawing.LineType.DashDotDot;
                series.YErrorBar.Weight = Aspose.Cells.Drawing.WeightType.WideLine;
                series.YErrorBar.WeightPt = 2.0;
                series.YErrorBar.WeightPx = 3.0;
                series.YErrorBar.FormattingType = ChartLineFormattingType.Gradient;
                series.YErrorBar.IsVisible = true;
                series.YErrorBar.IsAuto = false;
            }

            // Save the workbook
            workbook.Save("ErrorBarExample.xlsx");
            workbook.Save("ErrorBarExample.pdf");
        }
    }
}

See Also