Xceed Chart for WinForms v4.4 Documentation
Floating Bar Series

Welcome to Xceed Chart for WinForms v4.4 > User Guide > Series > Floating Bar Series

Float bar series are created by using the FloatBarSeries object. It is derived from the Series base class and inherits all its functionality. The following figure represents a typical floating bar chart. 



figure 1.

Creating the Floating Bar Series

An instance of the FloatBarSeries class can be obtained from the SeriesCollection.Add method. This method will add the newly created series to the series collection and return a reference to it. If the user wants to save the reference for further use, it must be explicitly cast to the FloatBarSeries type. The following code will create a FloatBarSeries object in the series collection and save the returned reference:

VB.NET  

' there is one chart created by default

Dim chart As Chart = CType(chartControl1.Charts(0), Chart)

' add a float bar series to it

Dim floatbar As FloatBarSeries = CType(Chart.Series.Add(SeriesType.FloatBar), FloatBarSeries)

C#  
TODO

 

[VB.NET]

[C#]

 

Passing Data to the Float Bar Series

Once the float bar series is created, you can add data to it. A Float Bar series uses the Values data series of its base class for the bar begin values. In addition to the standard Values data series, the float bar series also adds another data series of type Double, which holds the bar ending values. It is accessible through the EndValues property of the FloatBarSeries object. For consistency the Values data series of the base class can also be accessed from the BeginValues property of the FloatBarSeries object. 

The FloatBarSeries implements the following helper routines: 

void AddFloatBar(double begin, double end)
- Adds a new float bar with the specified begin and end values.

void AddFloatBar(double begin, double end, string label)
- Adds a new float bar with the assigned label.

void AddFloatBar(double begin, double end, string label, FillEffect barFE)
- Adds a new float bar with the specified fill effect.

void AddFloatBar(double begin, double end, string label, FillEffect barFE, LineProperties barBorder)
- Adds a new float bar with the specified fill effect and border. 

For example, the following code will generate a simple float bar chart:

VB.NET  

floatbar.AddFloatBar(10, 15)

floatbar.AddFloatBar(12, 17)

floatbar.AddFloatBar(8, 16)

C#  
floatbar.AddFloatBar(10, 15);
floatbar.AddFloatBar(12, 17);
floatbar.AddFloatBar(8, 16);

A labeled float bar is also easy:

VB.NET  

floatbar.AddFloatBar(10, 15, "Bar1")

floatbar.AddFloatBar(12, 17, "Bar2")

floatbar.AddFloatBar(8, 16, "Bar3")

 

// show labels in data point labels

bar.DataLabels.Mode = DataLabelsMode.Every

bar.DataLabels.Format = "<label>"

C#  
floatbar.AddFloatBar(10, 15, "Bar1");
floatbar.AddFloatBar(12, 17, "Bar2");
floatbar.AddFloatBar(8, 16, "Bar3");
// show labels in data point labels
bar.DataLabels.Mode = DataLabelsMode.Every;
bar.DataLabels.Format = "<label>";

Controlling the Float Bar's Dimensions

The width and depth dimensions of floating bars are specified as a percentage of the grid cell they occupy. The WidthPercent and DepthPercent properties control these percent values. By default the WidthPercent property is set to 70 while the DepthPercent is set to 50. The following code will make the bars a slightly bolder:

VB.NET  

floatbar.WidthPercent = 80

floatbar.DepthPercent = 70

C#  
floatbar.WidthPercent = 80;
floatbar.DepthPercent = 70;

Controlling the Float Bar's Style

The shape of the floating bars is controlled with the help of the BarStyle property. It is of type BarStyle and accepts the following values (for details, see BarStyle Enumeration):

Bar

Cylinder

Cone

InvertedCone

Pyramid

InvertedPyramid

Ellipsoid

SmoothEdgeBar

CutEdgeBar
 

The following code will display the floating bars as Cones:

VB.NET  
floatbar.BarStyle = BarStyle.Cone
C#  
floatbar.BarStyle = BarStyle.Cone;

When bars are displayed as smooth-edge or cut-edge, the user can control whether the top and bottom edges of the bar are displayed in the respective manner with the help of the HasTopEdge and HasBottomEdge properties. The following code will display the bar as a smooth-edge bar with top and bottom edges:

VB.NET  

floatbar.BarStyle = BarStyle.SmoothEdgeBar

floatbar.HasTopEdge = True

floatbar.HasBottomEdge = True

C#  
floatbar.BarStyle = BarStyle.SmoothEdgeBar;
floatbar.HasTopEdge = true;
floatbar.HasBottomEdge = true;

The size of the edge is represented by a percent value of the smaller width or depth of the bar's dimensions. By default it is set to 15. The following code will make the smooth bar edges twice as large:

VB.NET  
floatbar.EdgePercent = 30
C#  
floatbar.EdgePercent = 30;

Controlling the Float Bar's Appearance

By default all bars are displayed with the filling specified by the FillEffect object accessible through the FloatBarFillEffect property, and the border specified by the LineProperties object accessible through the FloatBarBorder property. The following example will display all bars in blue with a yellow border.

VB.NET  

floatbar.FloatBarFillEffect.SetSolidColor(Color.Blue)

floatbar.FloatBarBorder.Color = Color.Yellow

C#  
floatbar.FloatBarFillEffect.SetSolidColor(Color.Blue);
floatbar.FloatBarBorder.Color = Color.Yellow;

Please refer to the Series Appearance topic, which describes the how to apply individual fillings and lines to the series data points.

Related Examples

Windows Forms: Series\Float Bar\Standard Float Bar

See Also

FloatBarSeries