Many objects in the chart look better when they have a border around them. For this reason it is necessary to have an object controlling the appearance of the border. This object is the LineProperties object, which has various properties that allow you to control the line color, style, factor, and width.
Color of Lines
The Color property controls the color of the line. When line antialising is turned on, the component also uses the alpha value of the color to produce a transparent line. The following line of code changes the color of a line:
VB.NET | |
---|---|
lineProps.Color = Color.Blue |
C# | |
---|---|
lineProps.Color = Color.Blue; |
Pattern and Factor of Lines
The Pattern property defines the pattern of the style. It accepts values from the LinePattern enumeration. The following table shows bars rendered with different pattern styles:
Solid | Dot | Dash | DashDot | DashDotDot |
The Pattern and Factor properties define the line by determining whether a certain pixel from a line should be drawn or not. The values of the LinePattern enumeration actually represent 16-bit integers whose bit pattern determines which fragments of a line will be drawn when the line is rasterized. Bit zero is used first. For example the value of SolidLine is all ones (0xFFFF). You can create your own patterns simply by setting the bits of the short integer value that you want the line to draw. Suppose for example that you want to draw a line with three empty pixels, then one black then three empty and so forth. The value you should pass to LinePattern in this case is 0x8888 or in binary 1000100010001000. You must also set the Factor property to 1. For example:
VB.NET | |
---|---|
|
C# | |
---|---|
|
The following formula shows how the Pattern and Factor properties collaborate:
VB.NET | |
---|---|
DrawPixel = ((2 ^ (DistanceFromLineStart / Factor)) % 16) & Pattern |
C# | |
---|---|
DrawPixel = ((2 ^ (DistanceFromLineStart / Factor)) % 16) & Pattern; |
This is illustrated in the following table, which shows several lines with a dot pattern of 0101010101010101 (in binary code) and different line factors:
Factor | Line with pattern 0101010101010101 |
2 | |
4 | |
8 |
Width of Lines
The Width property controls the line width in pixels. When you set the Width to 0 the control will not draw the line. The code below disables the line:
VB.NET | |
---|---|
someLineProperties.Width = 0 |
C# | |
---|---|
someLineProperties.Width = 0; |
Related Examples
Windows Forms: Dedicated example is not available. The examples Series attributes\Appearance, Series attributes\markers show how to work with line properties.
Web Forms: Dedicated example is not available. The example Series attributes\markers shows how to work with line properties.