Spread Windows Forms 17
Spread Windows Forms 17.0 Product Documentation / Developer's Guide / Chart Control / Understanding Charts / Error Bars
In This Topic
    Error Bars
    In This Topic

    Error bars are graphical elements that are used to display the variability of data points. By using the ErrorBars class properties and associated enums, you can add and customize error bars according to your specific requirements, ensuring an accurate representation of data in charts. Spread also provides support for import and export error bars in charts from/to XML and Excel formats.

    To determine the direction of the error bars concerning the axes, use the ErrorBarDirection enum. It offers two values:

    Using the ErrorBarType enum, you can define the type of error bars. It includes three values:

    To define the type of error value, use the ErrorBarValueType enum which consists of four values:

    Spread lets you use Error Bars in different chart series, such as:

    Using Code

    The following sample code shows how to implement ErrorBar in ClusteredBarSeries in Spread.

    fpSpread1.ActiveSheet.AddChart(new CellRange(0, 0, 3, 6), typeof(FarPoint.Win.Chart.ClusteredBarSeries), 600, 300, 50, 50);
    fpSpread1.ActiveSheet.SetClip(0, 1, 1, 5, "1.2\\t0\\t-12.5\\t-5\\t15");
    fpSpread1.ActiveSheet.SetClip(1, 0, 1, 6, "1\\t-15.43\\t-11\\t16\\t0\\t17.5");
    fpSpread1.ActiveSheet.SetClip(2, 0, 1, 6, "2\\t7\\t12\\0\\t-10\\t10\\t0");
    if (fpSpread1.ActiveSheet.Charts[0].Model.PlotAreas[0].Series[0] is ClusteredBarSeries cluster)
      {
        foreach (BarSeries series in cluster.Series)
        {
          ErrorBars errorBar = series.SetErrorBarsVisible(true);
          errorBar.ValueType = ErrorBarValueType.StandardError;
          errorBar.Type = FarPoint.Win.Chart.ErrorBarType.Both;
        }
      }
    
    FpSpread1.ActiveSheet.AddChart(New CellRange(0, 0, 3, 6), GetType(FarPoint.Win.Chart.ClusteredBarSeries), 600, 300, 50, 50)FpSpread1.ActiveSheet.SetClip(0, 1, 1, 5, "1.2" & vbTab & "0" & vbTab & "-12.5" & vbTab & "-5" & vbTab & "15")FpSpread1.ActiveSheet.SetClip(1, 0, 1, 6, "1" & vbTab & "-15.43" & vbTab & "-11" & vbTab & "16" & vbTab & "0" & vbTab & "17.5")FpSpread1.ActiveSheet.SetClip(2, 0, 1, 6, "2" & vbTab & "7" & vbTab & "12" & vbNullChar & vbTab & "-10" & vbTab & "10" & vbTab & "0")
    Dim cluster As ClusteredBarSeries = Nothing
    If CSharpImpl.__Assign(cluster, TryCast(FpSpread1.ActiveSheet.Charts(0).Model.PlotAreas(0).Series(0), ClusteredBarSeries)) IsNot Nothing Then
            For Each series As BarSeries In cluster.Series
                Dim errorBar As ErrorBars = series.SetErrorBarsVisible(True)
                errorBar.ValueType = ErrorBarValueType.StandardError
                errorBar.Type = FarPoint.Win.Chart.ErrorBarType.Both
            Next
    End If
    

    The following image depicts the output of the above code.

    Customizing Error Bars in Spread Chart Designer

    Spread provides functionality to customize error bars properties within the Chart Designer. Follow the steps below to access and modify error bars settings:

    1. Right-click on the chart in the Spread Designer.
    2. Click Chart Designer... from the menu that opens the Spread Chart Designer dialog.
    3. From the left side panel, locate and click the Error Bars on which you want to make the changes.
      When selected, the property list will appear on the right side of the dialog.
    4. Customize the error bars values according to your requirements using the provided properties.

    Limitations

    See Also