Page 1 of 1

How to draw contour from given data?

Posted: Wed Jul 30, 2014 1:39 pm
by 9526439
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

Re: How to draw contour from given data?

Posted: Fri Aug 08, 2014 6:25 am
by 9526439
Hi Steema Team,

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

Thanks

Plano Team

Re: How to draw contour from given data?

Posted: Fri Aug 08, 2014 11:18 am
by Christopher
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.

Re: How to draw contour from given data?

Posted: Fri Aug 08, 2014 11:31 am
by Christopher
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 23023 times

Re: How to draw contour from given data?

Posted: Fri Aug 08, 2014 1:23 pm
by Christopher
A third answer :)

Using
Contour2.zip
(11.36 KiB) Downloaded 755 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 23006 times
not as pretty as the last answer, but probably more faithful to the original data.

Re: How to draw contour from given data?

Posted: Tue Aug 12, 2014 1:41 pm
by 9526439
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

Re: How to draw contour from given data?

Posted: Tue Aug 12, 2014 1:55 pm
by Christopher
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?

Re: How to draw contour from given data?

Posted: Wed Aug 13, 2014 6:54 am
by 9526439
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

Re: How to draw contour from given data?

Posted: Wed Aug 13, 2014 8:57 am
by Christopher
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.

Re: How to draw contour from given data?

Posted: Wed Aug 13, 2014 11:29 am
by 9526439
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

Re: How to draw contour from given data?

Posted: Wed Aug 13, 2014 11:35 am
by Christopher
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.

Re: How to draw contour from given data?

Posted: Wed Aug 13, 2014 12:14 pm
by 9526439
Hi Steema Forum.

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

Thanks
Plano Team

Re: How to draw contour from given data?

Posted: Thu Aug 14, 2014 9:50 am
by 9526439
Hi Steema forum,

Please response ASAP.

Thanks

Plano

Re: How to draw contour from given data?

Posted: Thu Aug 14, 2014 9:51 am
by Christopher
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++;
        }
      }
    }