change color on a part of a line graph

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Post Reply
Lars Iversen
Newbie
Newbie
Posts: 61
Joined: Wed Jun 22, 2005 4:00 am
Location: cph

change color on a part of a line graph

Post by Lars Iversen » Mon Apr 03, 2006 2:28 pm

Hi I have a line graph with about 100 points.
It is a red line
Now I want the line connecting point number 45, 46 and 47 to be green.
Is that possible? How?

Thanks in advance

Lars Iversen

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Mon Apr 03, 2006 2:53 pm

Hi Lars,

Yes, you have 2 options:

1) Setting the color when populating the series:

Code: Select all

    private void Form1_Load(object sender, EventArgs e)
    {
      Random rd = new Random();

      for (int i = 0; i < 100; i++)
      {
        if ((i>45) && (i<=47))
          line1.Add(rd.Next(),Color.Green);
        else
          line1.Add(rd.Next(),Color.Red);
      }
    }
2) Setting the color for the points you want doing something like:

Code: Select all

    private void button1_Click(object sender, EventArgs e)
    {
      line1.Colors[46] = Color.Green;
      line1.Colors[47] = Color.Green;
      line1.Repaint();
    }
Best Regards,
Narcís Calvet / 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

Post Reply