Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

Setting Y axis Range slow

I narrowed down in my code what is using alot of time. And it's down to the Range object for the Y axis. I use a time format for the yaxis. When data comes in (1/sec), I get the time of that data and set the min and max of the yaxis. To do this you have to new a Range object and set the yaxis Range object to the newed object.

This takes about 200ms to set the yaxis range alone, for a graph around 800 pixels hight by 3200 pixels wide! Not counting manipulating the background bitmap. The NI graph activeX control I used last year definitely did not take this long.

Is this expected behavior? Am I doing something wrong in setting the yaxis?

-VS 2003
-C#
-XP

See attached jpg for part of what my graph looks like.

Code snippet:

public void SetYAxis(DateTime currentTime)
{
Debug.WriteLine("BitmapDisplayCtrl SetYAxis");
if( _Dispose )
return;
//Bitmap bm = (Bitmap)_NIGraph.PlotAreaImage;

Range rng;
DateTime minTime, maxTime;

if( _DirectionOfDataFlow == DataFlowDirection.TopToBottom )
{
minTime = currentTime;
maxTime = currentTime.AddSeconds(_NIGraph.PlotAreaImage.Height);
yPrimaryAxis.Inverted = false;
}
else
{
minTime = currentTime;
maxTime = currentTime.AddSeconds(_NIGraph.PlotAreaImage.Height);
yPrimaryAxis.Inverted = true;
}
try
{
rng = new Range(minTime, maxTime);
yPrimaryAxis.Range = rng;
}
catch( InvalidOperationException ie )
{
Console.WriteLine(ie.Message);
}

}

Message Edited by scottyoo on 04-12-2005 05:03 PM

0 Kudos
Message 1 of 5
(4,129 Views)
i tried the following for a 1200 by 800 graph.

//timing code here
waveformGraph1.PlotYAppend(data,new TimeSpan(0,0,1));
data++;

DateTime currentTime = DateTime.Now;
DateTime min,max;
min = currentTime;
max = currentTime.AddSeconds(600);


Range rng = new Range(min,max);
yAxis1.Range = rng;
//timing code here


The average time for this code block was 3ms. This was occuring inside of a timer callback firing every 1 second. I used QueryPerformanceCounter to time the code. Im using XP, P4 with 2Ghz to time this.

Some sample code might help track this down.

One thing you could try is using BeginUpdate()/EndUpdate() to delay the drawing on the graph until after all the updates have been made.

Let me know if you find anything else. Or if I missed anything. I didnt do anything with the image manipulation since you said this delay was specific to the Range.

Hope this helps
Bilal Durrani
NI
0 Kudos
Message 2 of 5
(4,103 Views)
BTW, I thought I'd let everyone on the forum know what was causing the slowdown on the axis update. A little minor property setting killed me. "Immediate Updates" was unknowingly set to true for the Scattergraph object. If you drop a Scattergraph control on a form in design mode you will see this property on the Properties page.

With it set to true I was costing me 50ms to update the yaxis, >500ms if my control was full screen! That was bad, so I was in panic mode. I painstakingly went through every suspect property setting on the NI graph, rebuilt, run and checked timing. What this setting does I don't know and may be useful to someone, but for my time critical app I needed it set to false.

Now, for a full screen graph the axis update is <3ms! Even drawing to the plotareaimage and displaying it, with a 3200 point plot is <20ms!

Set Immediate Updates = False

I spent the money, you don't have to!

There you go!

Scott O'

Message Edited by scottyoo on 04-26-2005 01:57 PM

0 Kudos
Message 3 of 5
(4,080 Views)
scottyoo,

All Measurement Studio Windows Forms .NET controls (including the ScatterGraph) have ImmediateUpdates set to false by default. When the controls are dropped in the designer, you should see them set to false in the Properties page. It seems that the property got set to true inadvertantly after it was dropped. Please could you let us know if you have seen otherwise.
Abhishek Ghuwalewala | Measurement Studio | National Instruments
0 Kudos
Message 4 of 5
(4,070 Views)
I have exactly the same problem but the ImmediateUpdates property is always set to false. Moreover I have 10 ScatterGraph with same Y axis data and the problem appens only to some of this graphs...
0 Kudos
Message 5 of 5
(3,513 Views)