FlexChart | ComponentOne
Chart Types / Statistical Charts / WinForms Error Bar
In This Topic
    WinForms Error Bar
    In This Topic

    Error bars are the charts that indicate the estimated error or uncertainty in the measured data to give an idea about how precise that data is. They most often represent this through the standard deviation of data set. Error bars are, generally useful while plotting results of scientific studies, experiments, or any other measurements that show variation in data from original values. Deviation in sales forecast is one of the good examples that can be presented using these error bars.

    WinForms Error Bar chart

    Create a WinForms Error Bar Chart

    In FlexChart, error bars can be shown along with various chart types such as line, area, column, scatter and, spline charts. Error bars can be implemented using the ErrorBar class which represents an error bar series. Apart from other series related properties, this class provides properties specific to error bar series such as the ErrorAmount property, which lets you specify the error amount of the series as a standard error amount, a percentage or a standard deviation. This property accepts the values from ErrorAmount enumeration. FlexChart also provides options to specify whether to display error bars in plus, minus or both directions using the Direction property. EndStyle property of FlexChart lets you specify whether to display caps or not at the ends of error bars. To customize the appearance of bar style, you can use the ErrorBarStyle property.

    // clear data series collection
    //Setting FlexChart header
    flexChart1.Header.Content = "Sales Forecast Accuracy";
    //Create and add ErrorBar
    _bar = new C1.Win.Chart.ErrorBar()
        Binding = "Sales",
        Name = "Sales",
        ErrorAmount = ErrorAmount.FixedValue,
        ErrorValue = 50,
    //Specify the datasource for the chart
    flexChart1.DataSource = GetCountrySales();
            ''' <summary>
            ''' Method for initializing StatisticalChart
            ''' </summary
            Private Sub SetupChart()
    #Region "SetupChart"
                ' clear data series collection
                'Setting FlexChart header
                flexChart1.Header.Content = "Sales Forecast Accuracy"
                'Create and add ErrorBar
                _bar = New C1.Win.Chart.ErrorBar() With {
                     .Binding = "Sales",
                     .Name = "Sales",
                     .ErrorAmount = ErrorAmount.FixedValue,
                     .ErrorValue = 50
                'Specify the datasource for the chart
                flexChart1.DataSource = GetCountrySales()

    Note that the above sample code uses a custom method named GetCountrySales to supply data to the chart. You can set up the data source as per your requirements.

    /// <summary>
    /// Method for creating data for StatisticalChart
    /// </summary>
    private DataSource _dataHelper = new DataSource().Instance;
    private Random rnd = new Random();
    public List<Country> GetCountrySales(int rangeMin = 100, int rangeMax = 1000)
        var data = new List<Country>();
        for (int i = 0; i < _dataHelper.Countries.Length; i++)
            var country = new Country
                Name = _dataHelper.Countries[i],
                Sales = rnd.Next(rangeMin, rangeMax),
        return data;
    ''' <summary>
    ''' Method for creating data for StatisticalChart
    ''' </summary>
    Private _dataHelper As DataSource = New DataSource().Instance
    Private rnd As New Random()
    Public Function GetCountrySales(Optional rangeMin As Integer = 100, Optional rangeMax As Integer = 1000) As List(Of Country)
        Dim data As List(Of Country) = New List(Of Country)()
        For i As Integer = 0 To _dataHelper.Countries.Length - 1
            Dim country As Country = New Country() With {
                .Name = _dataHelper.Countries(i),
                .Sales = rnd.[Next](rangeMin, rangeMax)
        Return data
    End Function