Xceed Chart for WinForms v4.4 Documentation
Gradient

Welcome to Xceed Chart for WinForms v4.4 > User Guide > Fill Effects > Gradient

The FillEffect object supports a fill called gradient, which may be familiar to you if you have worked with the Microsoft Chart embedded in Excel. The simple gradients of the FillEffect object provide all the functionality you'll need if you want to apply gradients based on two colors. If you want to apply more complex gradients, please refer to the Advanced Gradient topic in this book for more information. Simple gradients are divided into six groups, each of them with four variants, except for the From Center type, which has only two variants. The group defines the direction of the gradient (horizontal, vertical, diagonal, etc.), and the variant defines how the gradient merges the start and the end color. The programming pattern you'll need to follow in order to apply a gradient is similar to the one we already discussed in the Solid Color topic. For example, to apply a white to black horizontal gradient, you must use the following code:

VB.NET  
fillEffect.SetGradient(GradientStyle.Horizontal, GradientVariant.Variant1, Color.White, Color.Black)
C#  
fillEffect.SetGradient(GradientStyle.Horizontal, GradientVariant.Variant1, Color.White, Color.Black);

You can also manually modify the FillEffect properties to achieve the same result:

VB.NET  

fillEffect.Type = FillEffectType.Gradient

fillEffect.GradientStyle = GradientStyle.Horizontal

fillEffect.GradientVariant = GradientVariant.Variant1

fillEffect.BeginColor = Color.White

fillEffect.EndColor = Color.White

C#  

fillEffect.Type = FillEffectType.Gradient;

fillEffect.GradientStyle = GradientStyle.Horizontal;

fillEffect.GradientVariant = GradientVariant.Variant1;

fillEffect.BeginColor = Color.White;

fillEffect.EndColor = Color.White;

This approach is not recommended because it results in longer code. Internally gradients follow the same mapping rules as textures, and this is why you can also apply advanced texture transformations to them, such as scaling and mapping. To learn more about these features, consult the Texture Mapping topic in this book. The following table shows the different gradient styles and variants for a gradient with a white starting and black ending color. 

Gradient style Variant 1 Variant 2 Variant 3 Variant 4
Horizontal
Vertical
Diagonal up
Diagonal down
From corner
From center    

Related Examples

Windows Forms: Fill Effects\General

See Also

FillEffect | Xceed 3D Lighting Model | Working with Lights | Texture Mapping