From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

Seperate Y axis by plots makes data disrupted

Solved!
Go to solution

Hi,

In the attached project I have a check-box which decide if the graph contains main y axis or y axis for each exist plot.

 

in the follow picture you can see the first screen with data : 

 

firstscreen.PNG

After that, I choose the seperate check box that cause the graph disapear (because have 5 axes) - and it's OK for me.

 

The problem occures when I unchecked the seperate check box, the data disrupted. You can see that in the following picture:

secondscreen.PNG

 

This will be fixed when you move the graph by ctrl + left mouse.

 

Why is it happening and how can I fix this?

 

0 Kudos
Message 1 of 8
(3,757 Views)

Hello,

 

I downloaded the zip file, and I am seeing the same behavior. I have an idea as to what could be the cause, but I would need more information on your solution to better find out where the behavio is happening

 

It seems like the code is stretching the data that is on there when you uncheck the selector box. Exactly what snippet of code is executing when you check and uncheck the multiple axis? Would it be possible to redraw the graph whenever the box is unchecked?

 

Best,

 

Shamik C

Applications Engineer 

National Instruments 

http://www.ni.com/support 

0 Kudos
Message 2 of 8
(3,728 Views)

After further investigation, this appears to be an issue with the graph trying to re-use a subset of previously decimated data, and not recognizing the change to the plot area size when the axes are hidden.

 

As Shamik mentioned, the best workaround would be to schedule a refresh whenver the mode is toggled:

 

    Dispatcher.BeginInvoke( new Action( graph.Refresh ), DispatcherPriority.Loaded );

~ Paul H
0 Kudos
Message 3 of 8
(3,712 Views)
 
The solution you offer good only in this particular case.
 
There are other cases in which this bug happens. (example: I can open window that reflects the graph. and when the checkbox is already checked the same bug happen).
 
I need to locate the code that solves the problem in place which it will cover all cases.
I tried to move the code to graph loaded method, but it does not cover everything.
0 Kudos
Message 4 of 8
(3,652 Views)

It is difficult to say if there is a single event that will catch everything you want without filtering out cases that you do not want.

 

You could either find cases for everything that you specifically need and put that code in each one. Or, you could have something as vague as a mouse click or timer event to constantly refresh the graph. Personally, I would do the former.

 

 

0 Kudos
Message 5 of 8
(3,637 Views)

I don't believe we expose any specific event that would fit this case, but you should be able to use the DesiredPlotAreaMargin property on the graph. To listen for changes, just bind a property on your window or model to that dependency property, and use the scheduled refresh code from earlier to force the graph to redraw whenever it changes (assuming a refresh has not been queued already).

~ Paul H
0 Kudos
Message 6 of 8
(3,634 Views)
Solution
Accepted by topic author hodaya273

Finally, I solved the problem in the following way:

 

I register to plot area SizeChanged event, and when the size was greater from the previous size & the previous size was smaller from spesific width (which means that the screen was small and now it is grown), I call the refresh function.

 

private void PlotArea_SizeChanged(object sender, SizeChangedEventArgs e)
{
   if (e.PreviousSize.Width < 80 && e.NewSize.Width > e.PreviousSize.Width)
      Application.Current.Dispatcher.BeginInvoke(new System.Action(Refresh), System.Windows.Threading.DispatcherPriority.ContextIdle);
}

I change the priority to ContextIdle because when I open the reflect window the loaded priority not help, and for this case I needed lower priority.

0 Kudos
Message 7 of 8
(3,619 Views)

Just wanted to let you know this issue was fixed in the Measurement Studio 2019 release.

~ Paul H
0 Kudos
Message 8 of 8
(2,121 Views)