Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

Waveform Graph Grid Lines Become Offset

Here is a stripped down sample. Both "Raw Data" and "Smoothed Data" check boxes start off checked. When you click and drag on either graph with this state, the gridlines behave as expected. Unceck either one (there is code to ensure at least one is always checked) and then try to drag the top graph to the right. The gridlines will become offset. If you try to drag the bottom graph to the right, the gridlines behave as expected. 

0 Kudos
Message 11 of 20
(2,886 Views)

Any news? I'm running ito this problem in another way as well now. When I change the x axis range on both my graphs to show the whole testing time (max of 12 hours), the gridlines become offset on the bottom graph. They are always fine on the top graph and offset on the bottom.

 

 

0 Kudos
Message 12 of 20
(2,879 Views)

Hi VHalbur,

 

Sorry for not replying sooner, I missed the post of the code. I will try and take a look at it on Monday and see if anything stands out.


Milan
0 Kudos
Message 13 of 20
(2,866 Views)

Hi VHalbur,

 

I do see the same behavior when using Measurement Studio 2012 and Visual Studio 2010 with the attached application. I had seen an older Corrective Action Request that seemed to indicate that performing a redraw of the graph would correct the gridlines, but I am not sure if that workaround would apply to this case.


Milan
0 Kudos
Message 14 of 20
(2,846 Views)

No, that workaround does not apply to this case. Are you saying there isn't a solution to this problem, then?

0 Kudos
Message 15 of 20
(2,841 Views)

Hi VHalbur,

 

Looking through the attached code again it looks like there is one edge case occuring that is causing the behavior you are seeing. The behavior occurs in the Ch1Graph_BeforeDrawPlot and the Ch2Graph_BeforeDrawPlot function.

 

        private void Ch1Graph_BeforeDrawPlot(object sender, BeforeDrawXYPlotEventArgs e)
        {

                xMin = Ch1Graph.XAxes[0].Range.Minimum;
                xMax = Ch1Graph.XAxes[0].Range.Maximum;

            if (Ch1Graph.XAxes[0].Range.Minimum < 0)
            {
                Ch1Graph.XAxes[0].Range = new Range(0, WindowInterval);
                Ch2Graph.XAxes[0].Range = new Range(0, WindowInterval);
            }

            else if (Ch1Graph.XAxes[0].Range.Maximum > totalMax)
            {
                Ch1Graph.XAxes[0].Range = new Range(totalMax - WindowInterval, totalMax);
                Ch2Graph.XAxes[0].Range = new Range(totalMax - WindowInterval, totalMax);
            }

            Ch2Graph.XAxes[0].Range = new Range(xMin, xMax);
        }

 

On the last line of the function you call:

 

Ch2Graph.XAxes[0].Range = new Range(xMin, xMax);

 

However, if the previous conditional statements modfied the value of the Range, that value would be ignored as you are using the old xMin and xMax values instead of the newly updated values. It makes it appear that the Grid Lines themselves are scolling but it is actually the whole plot because the Range is not being modified.

 

If the line is changed to the following it seems to provide the desired behavior:

 

Ch2Graph.XAxes[0].Range = Ch1Graph.XAxes[0].Range;

 

Make sure to update both of the BeforePlotDraw callbacks to make sure they calculate and save the Ranges correctly.


Milan
0 Kudos
Message 16 of 20
(2,824 Views)

Thank you. Changing that solved my original problem. However, I still have the problem when I choose to show the entire test:

 


@VHalbur wrote:

Any news? I'm running ito this problem in another way as well now. When I change the x axis range on both my graphs to show the whole testing time (max of 12 hours), the gridlines become offset on the bottom graph. They are always fine on the top graph and offset on the bottom.

 

 




I've attached code that shows this problem. Before running it, you will have to change the directory location depending on where you save the folder containing the project on your computer. When the form loads, it will read fake data from an XML file in the OffsetGridlines/bin/Debug folder of the project (where the .exe is).

0 Kudos
Message 17 of 20
(2,818 Views)

Hi VHalbur,

 

Have you already tried looking through the Range calculation code for the "show entire test" issue? It may require some stepping through as the previous issue did to make sure the calculations being made work in all cases.


Milan
0 Kudos
Message 18 of 20
(2,811 Views)

Yes I have. However, it calls the same code that was causing the problem before so fixing that should've fixed this issue as well. However, that is not the case. When I step through the code, I the range is always getting set to the same as the top graph, which is behaving correctly. 

0 Kudos
Message 19 of 20
(2,809 Views)

Hi VHalbur,

 

The new code that you attached does not include the change that was mentioned above. When I added the change I don't see any problem with the attached code. If I scroll and then change to "Show Entire Test" the graph grid-lines appear lined up. I am not able to reproduce the behavior you are seeing.


Milan
0 Kudos
Message 20 of 20
(2,800 Views)