This is a migrated thread and some comments may be shown as answers.

Set Series Gradient Color with VB

3 Answers 141 Views
Chart (Obsolete)
This is a migrated thread and some comments may be shown as answers.
Tim Sledge
Top achievements
Rank 1
Tim Sledge asked on 16 Nov 2008, 08:30 PM
I'm attempting to set a bar in a chart to gradient color using the following code, but something is missing.  What else do I need?

chartSeries.Type = ChartSeriesType.Bar

chartSeries.Appearance.FillStyle.MainColor = Drawing.Color.Beige

chartSeries.Appearance.FillStyle.SecondColor = Drawing.Color.Aqua

chartSeries.Appearance.FillStyle.FillType = Styles.FillType.ComplexGradient

I get the following error message...

ColorBlend object that was set is not valid.Array of colors and positions must contain at least two elements. ColorBlend objects must be constructed with the same number of positions and color values. Positions must be between 0.0 and 1.0, 1.0 indicating the last element in the array.

3 Answers, 1 is accepted

Sort by
0
Giuseppe
Telerik team
answered on 17 Nov 2008, 08:38 AM
Hi Tim Sledge,

If you would like to use complex gradient, you need to supply the desired colors via the ChartSeries.Appearance.FillStyle.FillSettings.ComplexGradient collection property like this:

Dim series As ChartSeries = New ChartSeries 
series.Type = ChartSeriesType.Bar 
series.Appearance.FillStyle.FillSettings.ComplexGradient.Add(New GradientElement(Drawing.Color.Red, 0)) 
series.Appearance.FillStyle.FillSettings.ComplexGradient.Add(New GradientElement(Drawing.Color.Green, 0.5)) 
series.Appearance.FillStyle.FillSettings.ComplexGradient.Add(New GradientElement(Drawing.Color.Blue, 1)) 
series.Appearance.FillStyle.FillType = Styles.FillType.ComplexGradient 

Alternatively, if you would like to use simple gradient you can do it like this:

Dim series As ChartSeries = New ChartSeries 
series.Type = ChartSeriesType.Bar 
series.Appearance.FillStyle.MainColor = Drawing.Color.Beige 
series.Appearance.FillStyle.SecondColor = Drawing.Color.Aqua 
series.Appearance.FillStyle.FillType = Styles.FillType.Gradient 



Best wishes,
Manuel
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
D
Top achievements
Rank 1
answered on 15 Apr 2011, 08:16 PM
what would the C# equivalent of this be?  I've tried a thousand different ways...  thx!
0
Missing User
answered on 20 Apr 2011, 12:03 PM
Hello,

You can use our Code Converter to translate these code snippets to C#.

Greetings,
Polina
the Telerik team

Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

Tags
Chart (Obsolete)
Asked by
Tim Sledge
Top achievements
Rank 1
Answers by
Giuseppe
Telerik team
D
Top achievements
Rank 1
Missing User
Share this question
or