09-04-2012 02:34 PM
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.
09-13-2012 04:26 PM
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.
09-14-2012 06:00 PM
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.
09-17-2012 08:27 PM
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.
09-18-2012 10:45 AM
No, that workaround does not apply to this case. Are you saying there isn't a solution to this problem, then?
09-19-2012 02:30 PM
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.
09-19-2012 03:07 PM
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).
09-20-2012 09:16 AM
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.
09-20-2012 09:23 AM
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.
09-21-2012 11:54 AM
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.