Fill the area between the points on the line series

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Post Reply
Lakshmi
Newbie
Newbie
Posts: 40
Joined: Fri Oct 07, 2005 4:00 am
Location: India
Contact:

Fill the area between the points on the line series

Post by Lakshmi » Wed Mar 15, 2006 10:52 am

I have a line series formulated using the below code:

line1.Add(1,1);
line1.Add(5,5);
line1.Add(10,1);
line1.Add(15,5);
line1.Add(20,1);
line1.Add(25,5);

This forms a triangular wave curve.

I need to know if there is any way to fill the triangular area formed by this series?

Thanks!

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

Post by Narcís » Wed Mar 15, 2006 2:51 pm

Hi Lakshmi,

You have 2 options to achieve that:

1. Using Area series which already does that.

2. Custom drawing on TeeChart's canvas doing something like this:

Code: Select all

    private void Form1_Load(object sender, EventArgs e)
    {
      line1.Add(1, 1);
      line1.Add(5, 5);
      line1.Add(10, 1);
      line1.Add(15, 5);
      line1.Add(20, 1);
      line1.Add(25, 5); 

    }

    private void tChart1_AfterDraw(object sender, Steema.TeeChart.Drawing.Graphics3D g)
    {
      g.Brush.Color = line1.Color;
      g.Brush.Solid = true;
      g.Brush.Visible = true;
      g.Brush.Transparency = 50;

      int i;
      
      for (i = 0; i+2 < line1.Count; i=i+2)
      {
        Steema.TeeChart.Drawing.Triangle3D Triangle = new Steema.TeeChart.Drawing.Triangle3D();

        Triangle.p0.X = line1.CalcXPos(i);
        Triangle.p0.Y = line1.CalcYPos(i);
        Triangle.p1.X = line1.CalcXPos(i+1);
        Triangle.p1.Y = line1.CalcYPos(i+1);
        Triangle.p2.X = line1.CalcXPos(i+2);
        Triangle.p2.Y = line1.CalcYPos(i+2);

        g.Triangle(Triangle);
      }

      if (i<line1.Count)
      {
        Steema.TeeChart.Drawing.Triangle3D Triangle = new Steema.TeeChart.Drawing.Triangle3D();

        Triangle.p0.X = line1.CalcXPos(i);
        Triangle.p0.Y = line1.CalcYPos(i);
        Triangle.p1.X = line1.CalcXPos(i + 1);
        Triangle.p1.Y = line1.CalcYPos(i + 1);
        Triangle.p2.X = line1.CalcXPos(i + 1);
        Triangle.p2.Y = line1.CalcYPos(i);

        g.Triangle(Triangle);        
      }
    }
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

Lakshmi
Newbie
Newbie
Posts: 40
Joined: Fri Oct 07, 2005 4:00 am
Location: India
Contact:

Fill the area between the points on the line series

Post by Lakshmi » Thu Mar 16, 2006 5:30 am

Hi Narcis,

If I use the area series, then that would fill the area starting from origin, but I wish to fill the area only between the traingles. How do I achieve that using area series?

Thanks

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

Post by Narcís » Thu Mar 16, 2006 11:47 am

Hi Lakshmi,

You can set an origin for Area series as shown in the All Features\Welcome !\Chart styles\Standard\Area\Setting origin example at TeeChart's features demo.
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