Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

IntensityGraph.PlotYAppend not working

Solved!
Go to solution

I am loading some data from disk and processing it on the fly.  When each trace is processed, I would like to append it to the intensitygraph.  When the first trace is ready, I plot is using IntensityGraph.Plot() which works fine.  When the second trace is ready I append it using IntensityPlot.PlotYAppend() which also works.  The problem is that any additional calls to PlotYAppend() causes an exception that says the size of the zdata array is incorrect.  I have verified many times that the size of the data arrays all match.  I've tried all the different settings for the axis such as ScopeChart and StripChart with the same effect.  Is there a known issue or something that I am doing wrong?

 

Thanks!

Jon

0 Kudos
Message 1 of 4
(3,360 Views)

Here is some example code:

 

public Timer1_Tick(object sender, EventArgs e) {

cnt++;

Random r = new Random();

double[,] d = new double[508,1];

for (int i=0; d.GetLength(0); i++)

d[i,0] = r.NextDouble();

 

if (cnt == 1)

intensityGraph1.Plot(d);

else

intensityGraph1.PlotYAppend(d);

}

 For each timer tick the IntensityGraph plot should grow by 1 line.  It only works for the first 2 lines and then PlotYAppend() throws the zdata incorrect size exception.  Any help is appreciated.

 

Thanks!

Jon

0 Kudos
Message 2 of 4
(3,358 Views)
Solution
Accepted by topic author JonB

Hi there,

 

The issue is that you are trying to plot more than the graph can handle by default. You need to set the IntensityPlot.HistoryCapacityX and HistoryCapacityY properties to proper values. The default value of for the capacity is 100. That means, the graph can display only upto 100 data points.

 

So in this case you are plotting 508 points on X Axis. But the HistoryCapacityX is 100.  That means, you can append array of size only [100, <someValueHere>]. You can try this.

 

To make your code work, I just increased the HistoryCapacityX to 1000. And it works like as you expected. If you want the data to be appended in the direction of X Axis, then try the PlotXAppend() overload.

 

Here is the modified code to make data appending in the Y direction.

 

 

        int cnt = 0;
Random r = new Random();
public void timer1_Tick(object sender, EventArgs e)
{
intensityPlot1.HistoryCapacityX = 1000;

cnt++;
double[,] d = new double[508, 1];
for (int i = 0; i < d.GetLength(0); i++)
{
d[i, 0] = r.NextDouble();
}


if (cnt == 1)
{
intensityGraph1.Plot(d);
}
else
{
intensityGraph1.PlotYAppend(d);
}
}

 

 

Here is the modified code to append data in the X direction:

 

        int cnt = 0;
Random r = new Random();
public void timer1_Tick(object sender, EventArgs e)
{
intensityPlot1.HistoryCapacityY = 1000;

cnt++;
double[,] d = new double[1, 508];
for (int i = 0; i < d.GetLength(1); i++)
{
d[0, i] = r.NextDouble();
}


if (cnt == 1)
{
intensityGraph1.Plot(d);
}
else
{
intensityGraph1.PlotXAppend(d);
}
}

 

Hope this helps,

Vijet Patankar

National Instruments.

0 Kudos
Message 3 of 4
(3,355 Views)

That was it.  So simple.  Thanks!

 

Jon

0 Kudos
Message 4 of 4
(3,344 Views)