Color of polygon

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Post Reply
Pujol1986
Newbie
Newbie
Posts: 58
Joined: Thu Jan 29, 2009 12:00 am
Location: Barcelona
Contact:

Color of polygon

Post by Pujol1986 » Thu May 28, 2009 2:40 pm

How I can change the color of a polygon?

I'm using this code:

Code: Select all

                map2.Shapes(i).Brush.Gradient.StartColor = Color.Red
                map2.Shapes(i).Brush.Gradient.EndColor = Color.Red
this doesn't works.

If I want to change the colors using the properties window in execution time, I have to change the gradient colors a lot of time before the chart makes me case.

Sandra
Site Admin
Site Admin
Posts: 3132
Joined: Fri Nov 07, 2008 12:00 am

Post by Sandra » Fri May 29, 2009 9:13 am

Hello Pujol1986,


If you want to change Gradient you could make similar code as next:

Code: Select all

        map1.Brush.Gradient.Visible = True
        map1.Brush.Gradient.StartColor = Color.Red
        map1.Brush.Gradient.EndColor = Color.White
But, if you want change the color of series you needs use only this lines of code:

Code: Select all

        map1.UseColorRange = False
        map1.Color = Color.Red
If I want to change the colors using the properties window in execution time, I have to change the gradient colors a lot of time before the chart makes me case.
I could reproduce your problem, and I have added to enhancement list.

I hope that will helps,


Thanks,
Best Regards,
Sandra Pazos / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

Pujol1986
Newbie
Newbie
Posts: 58
Joined: Thu Jan 29, 2009 12:00 am
Location: Barcelona
Contact:

Post by Pujol1986 » Fri May 29, 2009 9:39 am

Hello Sandra,

Your code changes the color of all polygons in the chart, and I want to change the color of specific polygon.

for example:

Code: Select all

   For i = 0 To 10
               If i Mod 2 = 0 Then
                    map2.Shapes(i).Brush.Gradient.StartColor = Color.Red
                    map2.Shapes(i).Brush.Gradient.EndColor = Color.Red
                ElseIf i Mod 5 = 0 Then
                    map2.Shapes(i).Brush.Gradient.StartColor = Color.Green
                    map2.Shapes(i).Brush.Gradient.EndColor = Color.Green
                End If
  Next i
I've tried to change the gradient color because this code doesn't work

Code: Select all

   For i = 0 To 10
                  map2.Shapes(i).Color = Color.Green
  Next i
How I can change the color of specific polygon?

Thanks in advance.

Sandra
Site Admin
Site Admin
Posts: 3132
Joined: Fri Nov 07, 2008 12:00 am

Post by Sandra » Fri May 29, 2009 10:38 am

Hello Pujol1986,

I make simple example, that I think solve your issue. Please check next code works fine in your application.

Code: Select all

            If i Mod 2 = 0 Then
                map1.Shapes(i).ParentBrush = False
                map1.Shapes(i).Brush.Color = Color.Red
            ElseIf i Mod 5 = 0 Then
                map1.Shapes(i).ParentBrush = False
                map1.Shapes(i).Brush.Color = Color.Green
            End If

Always, you want change the brush(color,gradient,etc)in the run time you needs put property ParentBrush= False.

Also, if you can use gradient you needs put Gradient.Visible= true, see next code:

Code: Select all

    
                map1.Shapes(i).ParentBrush = False
                map1.Shapes(i).Brush.Gradient.Visible = True
                map1.Shapes(i).Brush.Gradient.StartColor = Color.Green
                map1.Shapes(i).Brush.Gradient.EndColor = Color.White

I hope that will helps,

Thanks,
Best Regards,
Sandra Pazos / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

Pujol1986
Newbie
Newbie
Posts: 58
Joined: Thu Jan 29, 2009 12:00 am
Location: Barcelona
Contact:

Post by Pujol1986 » Fri May 29, 2009 2:53 pm

the code works perfectly.

thanks Sandra

Post Reply