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 | |
---|---|
|
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 | |
---|---|
|
C# | |
---|---|
floatbar.AddFloatBar(10, 15); |
A labeled float bar is also easy:
VB.NET | |
---|---|
|
C# | |
---|---|
floatbar.AddFloatBar(10, 15, "Bar1"); // show labels in data point labels |
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 | |
---|---|
|
C# | |
---|---|
floatbar.WidthPercent = 80; |
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 | |
---|---|
|
C# | |
---|---|
floatbar.BarStyle = BarStyle.SmoothEdgeBar; |
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 | |
---|---|
|
C# | |
---|---|
floatbar.FloatBarFillEffect.SetSolidColor(Color.Blue); |
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