How to draw contour from given data?

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Post Reply
amol
Advanced
Posts: 231
Joined: Tue Mar 29, 2005 5:00 am

How to draw contour from given data?

Post by amol » Wed Jul 30, 2014 1:39 pm

Hi Steema Support,

We want to create contour for the data(as given in attached file).

It will so helpful for us if you please provide any alternative solution asap.

Thanks in advance.

Thanks and Regards
Planoresearch
Attachments
Contour.rar
contour data.
(10.87 KiB) Downloaded 802 times

amol
Advanced
Posts: 231
Joined: Tue Mar 29, 2005 5:00 am

Re: How to draw contour from given data?

Post by amol » Fri Aug 08, 2014 6:25 am

Hi Steema Team,

Is it possible or not Please send us a reply asap. this is very urgent.

Thanks

Plano Team

Christopher
Guru
Posts: 1603
Joined: Fri Nov 15, 2002 12:00 am

Re: How to draw contour from given data?

Post by Christopher » Fri Aug 08, 2014 11:18 am

amol wrote:Is it possible or not Please send us a reply asap. this is very urgent.
I have modified your contour file:
Contour.zip
(11.36 KiB) Downloaded 730 times
and can use it like this:

Code: Select all

    private void InitializeChart()
    {
      tChart1.Aspect.View3D = false;
      Contour contour = new Contour(tChart1.Chart);
      contour.IrregularGrid = true;

      tChart1.Legend.Visible = false;

      Random rnd = new Random();

      int count = Assignment_teechart.ContourData.ZValues.Count;

      for (int x = 0; x < count; x++)
      {
        for (int z = 0; z < count; z++)
        {
          contour.Add(Assignment_teechart.ContourData.XValues[x], Assignment_teechart.ContourData.YValues[x], Assignment_teechart.ContourData.ZValues[z]);
        }
      }
    }
the reason the chart doesn't look as what you might be expecting is because there are insufficient YValues - if you use this line instead:

Code: Select all

contour.Add(Assignment_teechart.ContourData.XValues[x], rnd.NextDouble(), Assignment_teechart.ContourData.ZValues[z]);
you can see that with a unique YValue for every (X, Z) combination, the chart plots successfully.
Best Regards,
Christopher Ireland / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Instructions - How to post in this forum

Christopher
Guru
Posts: 1603
Joined: Fri Nov 15, 2002 12:00 am

Re: How to draw contour from given data?

Post by Christopher » Fri Aug 08, 2014 11:31 am

Actually, this probably works as you would better expect:

Code: Select all

    private void InitializeChart()
    {
      tChart1.Aspect.View3D = false;
      Contour contour = new Contour(tChart1.Chart);
      contour.IrregularGrid = true;

      tChart1.Legend.Visible = false;

      Random rnd = new Random();

      int count = Assignment_teechart.ContourData.ZValues.Count;

      int y;

      for (int x = 0; x < count; x+=46)
      {
        for (int z = 0; z < 47; z++)
        {
          y = x > 0 ? z * (x / 46) : z;
          contour.Add(Assignment_teechart.ContourData.XValues[z], Assignment_teechart.ContourData.YValues[y], Assignment_teechart.ContourData.ZValues[x]);
        }
      }
    }
Which gives me this:
contour.PNG
contour.PNG (163.95 KiB) Viewed 23016 times
Best Regards,
Christopher Ireland / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Instructions - How to post in this forum

Christopher
Guru
Posts: 1603
Joined: Fri Nov 15, 2002 12:00 am

Re: How to draw contour from given data?

Post by Christopher » Fri Aug 08, 2014 1:23 pm

A third answer :)

Using
Contour2.zip
(11.36 KiB) Downloaded 754 times
and the following code:

Code: Select all

    private void InitializeChart()
    {
      tChart1.Aspect.View3D = false;
      Contour contour = new Contour(tChart1.Chart);
      contour.IrregularGrid = true;

      tChart1.Legend.Visible = false;

      Random rnd = new Random();

      int length = Assignment_teechart.ContourData.ZValues.Count;
      int y = 0;

      for (int x = 0; x < length; x += 47)
      {
        for (int z = 0; z < 47; z++)
        {
          contour.Add(Assignment_teechart.ContourData.XValues[x], Assignment_teechart.ContourData.YValues[y], Assignment_teechart.ContourData.ZValues[z]);
          y++;
        }
      }
    }
I get this:
contour2.PNG
contour2.PNG (31.66 KiB) Viewed 22999 times
not as pretty as the last answer, but probably more faithful to the original data.
Best Regards,
Christopher Ireland / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Instructions - How to post in this forum

amol
Advanced
Posts: 231
Joined: Tue Mar 29, 2005 5:00 am

Re: How to draw contour from given data?

Post by amol » Tue Aug 12, 2014 1:41 pm

Hi,

We have modified the contour data file. Please create contour using this data file attached with mail.

We are waiting for your response.


Thanks in advance

Plano Team
Attachments
Data.rar
Contour data file
(2.23 KiB) Downloaded 753 times

Christopher
Guru
Posts: 1603
Joined: Fri Nov 15, 2002 12:00 am

Re: How to draw contour from given data?

Post by Christopher » Tue Aug 12, 2014 1:55 pm

amol wrote:Hi,

We have modified the contour data file. Please create contour using this data file attached with mail.

We are waiting for your response.
Can you please me why you cannot plot this data extrapolating from the technique in the last answer I gave you?
Best Regards,
Christopher Ireland / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Instructions - How to post in this forum

amol
Advanced
Posts: 231
Joined: Tue Mar 29, 2005 5:00 am

Re: How to draw contour from given data?

Post by amol » Wed Aug 13, 2014 6:54 am

Hi Steema,

We used below way suggested by you for plotting contour. but in both way we are not able to understand what is significance of 46 and 47 in loop. Is it a fixed value(Static) and how can use it according to our new data (sent you yesterday).
why you are calculating y value.


Way :1
int y;
for (int x = 0; x < count; x += 46)
{
for (int z = 0; z < 47; z++)
{
y = x > 0 ? z * (x / 46) : z;
contour.Add(Assignment_teechart.ContourData.XValues[z], Assignment_teechart.ContourData.YValues[y], Assignment_teechart.ContourData.ZValues[x]);
}
}

Way: 2
int y = 0;
for (int x = 0; x < Assignment_teechart.ContourData.ZValues.Count; x += 47)
{
for (int z = 0; z < 47; z++)
{
contour.Add(Assignment_teechart.ContourData.XValues[x], Assignment_teechart.ContourData.YValues[y], Assignment_teechart.ContourData.ZValues[z]);
y++;
}
}

one more thing we want to ask, is it necessary to use loop for plotting contour.
is it possible to create contour by this way?
contour.Add(Assignment_teechart.ContourData.Xvalue.ToArray(), Assignment_teechart.ContourData.Yvalue.ToArray(), Assignment_teechart.ContourData.Zvalue.ToArray());


Thanks
Plano Team

Christopher
Guru
Posts: 1603
Joined: Fri Nov 15, 2002 12:00 am

Re: How to draw contour from given data?

Post by Christopher » Wed Aug 13, 2014 8:57 am

amol wrote: We used below way suggested by you for plotting contour. but in both way we are not able to understand what is significance of 46 and 47 in loop. Is it a fixed value(Static) and how can use it according to our new data (sent you yesterday).
Way 2 is the correct way, using x += 47. The number 47 comes from the size of the loop. In the original data:

Code: Select all

YArray = new double[] {  3 ,3  ,3  ,3  ,3  ,3  ,3  ,3  ,3  ,3  ,3  ,3  ,3  ,3  ,3  ,3  ,3  ,3  ,3  ,3  ,3  ,3  ,3  ,3  ,3  ,3  ,3  ,3  ,3  ,3  ,3  ,3  ,3  , 3  ,3  ,3  ,3  ,3  ,3  ,3  ,3  ,3  ,3  ,3  ,3  ,3  ,3 
as you can see, here there are 47 identical numbers, which is what defines 47. In your new data, you have:

Code: Select all

 double[] YArray= new double[] {  61.779,61.779  ,61.779  ,61.779  ,61.779  ,61.779  ,61.779  ,61.779  ,61.779  ,61.779  ,61.779  ,61.779  ,61.779  ,61.779  ,61.779  ,
61.779  ,61.779  ,61.779  ,61.779  ,61.779  ,61.779  ,61.779  ,61.779  ,61.779  ,61.779  ,61.779  ,61.779  ,61.779  ,61.779  ,61.779  ,61.779  ,61.779  ,61.779  ,
61.779  ,61.779  ,61.779
36 identical numbers, meaning x += 36 and so on.
amol wrote: why you are calculating y value.
In Way 2 we do not calculate the y value.
amol wrote: one more thing we want to ask, is it necessary to use loop for plotting contour.
Yes, it is necessary, as the TeeChart code cannot automatically derive the loop sizes, that is, the numbers 47 and 36 and so on.
Best Regards,
Christopher Ireland / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Instructions - How to post in this forum

amol
Advanced
Posts: 231
Joined: Tue Mar 29, 2005 5:00 am

Re: How to draw contour from given data?

Post by amol » Wed Aug 13, 2014 11:29 am

Hi Steema forum,

Thanks for quick response, we are using second way but not able to display any contour .

This code is done according to data file which we have sent you yesterday. in below code don't get confused in argument of contour.Add() method (y & z argument). this is according to data file. please look data file.

private void InitializeChart()
{

tChart1.Aspect.View3D = false;
Contour contour = new Contour(tChart1.Chart);
contour.IrregularGrid = true;

tChart1.Legend.Visible = false;

int y = 0;
for (int x = 0; x < Assignment_teechart.Class1.ZValues.Count; x += 36)
{
for (int z = 0; z < 36; z++)
{
contour.Add(Assignment_teechart.Class1.XValues[x], Assignment_teechart.Class1.ZValues[y], Assignment_teechart.Class1.YValues[z]);
y++;
}
}
}

Thanks

Plano team

Christopher
Guru
Posts: 1603
Joined: Fri Nov 15, 2002 12:00 am

Re: How to draw contour from given data?

Post by Christopher » Wed Aug 13, 2014 11:35 am

amol wrote: Thanks for quick response, we are using second way but not able to display any contour .
Can you please provide me with the classes you are using for your data. Your previous attachment contained Data\Class1.cs, but Class1 has no static methods, meaning that I cannot run the code sample you provide in your last message in this thread.
Best Regards,
Christopher Ireland / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Instructions - How to post in this forum

amol
Advanced
Posts: 231
Joined: Tue Mar 29, 2005 5:00 am

Re: How to draw contour from given data?

Post by amol » Wed Aug 13, 2014 12:14 pm

Hi Steema Forum.

Thank you so much for prompt reply. please find attached data file with static methods.

Thanks
Plano Team
Attachments
Data.rar
Data File
(2.51 KiB) Downloaded 812 times

amol
Advanced
Posts: 231
Joined: Tue Mar 29, 2005 5:00 am

Re: How to draw contour from given data?

Post by amol » Thu Aug 14, 2014 9:50 am

Hi Steema forum,

Please response ASAP.

Thanks

Plano

Christopher
Guru
Posts: 1603
Joined: Fri Nov 15, 2002 12:00 am

Re: How to draw contour from given data?

Post by Christopher » Thu Aug 14, 2014 9:51 am

amol wrote: Thank you so much for prompt reply. please find attached data file with static methods.

This code seems to plot the data:

Code: Select all

    private void InitializeChart()
    {
      tChart1.Aspect.View3D = false;
      Contour contour = new Contour(tChart1.Chart);
      contour.IrregularGrid = true;

      tChart1.Legend.Visible = false;

      Random rnd = new Random();

      int length = Assignment_teechart.Class1.ZValues.Count;
      int y = 0;
      int step = 36;

      for (int x = 0; x < length; x += step)
      {
        for (int z = 0; z < step; z++)
        {
          contour.Add(Assignment_teechart.Class1.ZValues[x], Assignment_teechart.Class1.YValues[y], Assignment_teechart.Class1.XValues[z]);
          y++;
        }
      }
    }
Best Regards,
Christopher Ireland / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Instructions - How to post in this forum

Post Reply