Page 1 of 1

Issue when graphing horizontal line

Posted: Mon Dec 07, 2009 6:39 pm
by 13052841
I am experiencing an issue with zooming on a graph. I execute a custom zoom function that is based on the values on a specific line graph (MinXValue(); MaxXValue(); ...)

I have uploaded a Test project that will demonstrate this (DragPoint_FlatLine.zip). If you click on Show Graph and then "Generate Line with Zero Points" to get a flat line at y=2. Ignore the button name "..with zero points".

If you then click the "Line 1" and "Line 2" buttons back and forth, the graph zooming eventually gets way out of wack and you don't see any lines. If you still continue clicking, you will eventually see both lines on top of each other at the zero position OR the program will freeze up on the line:

Code: Select all

tChart1.Zoom.ZoomRect(rect);
Have you seen this before?

Re: Issue when graphing horizontal line

Posted: Wed Dec 09, 2009 11:09 am
by 10050769
Hello LibDundas,

We are not sure what problem is and nor what the sequence of buttons that must follow what is sequence of buttons we must follow for reproduce the issue.
Please, you could say what is the exactly sequence of buttons we must use, because we can reproduce the issue here.

Thanks,

Re: Issue when graphing horizontal line

Posted: Wed Dec 09, 2009 4:55 pm
by 13052841
Hi Sandra, sorry I should have made it more clear in my first post. Using the sample program that I uploaded (DragPoint_FlatLine.zip), you can do the following to reproduce the error:

Click the following buttons in this order:

"Generate Line with Zero Points"
"Line 1"
"Line 2"
"Line 1"
"Line 2" at this point, you will probably see it zoom into some random y-axis position
"Line 1"
"Line 2"
...
Continue licking Line 1 and Line 2 buttons until either the program will stop responding or you will see a graph like this:
Image

Re: Issue when graphing horizontal line

Posted: Thu Dec 10, 2009 12:46 pm
by 10050769
Hello LibDundas,

I could reproduce your problem and I think that problem occurs when you call method
AutoZoomToActiveLineGraph(int lineToZoom) and concretely when you calculate positions to use for create zoomRect(rect), because we understand, zoomRect(rect) is accessing to axes areas where series there aren't represented and there comes a moment, that can not calculate correctly the position of two series. Therefore, I recommend that debug your code for see exactly what happens and change your code for next that use SetMinMax():

Code: Select all

  private void AutoZoomToActiveLineGraph(int lineToZoom)
        {
            tChart1.Zoom.Undo(); // this was added to prevent a bug that occurs when going from one zoomed param (that has all zero values) to a different param

            origChartBoundaries.Reset();
            origChartBoundaries.horizMin = Math.Ceiling(tChart1.Series[lineToZoom].MinXValue());
            origChartBoundaries.horizMax = Math.Ceiling(tChart1.Series[lineToZoom].MaxXValue() * 1.03);
            origChartBoundaries.vertMin = Math.Ceiling(tChart1.Series[lineToZoom].MinYValue());
            origChartBoundaries.vertMax = Math.Ceiling(tChart1.Series[lineToZoom].MaxYValue() * 1.1);    // add 10% so the top mark doesn't get cut off

            tChart1.Axes.Bottom.SetMinMax(origChartBoundaries.horizMin, origChartBoundaries.horizMax);
            tChart1.Axes.Left.SetMinMax(origChartBoundaries.vertMin, origChartBoundaries.vertMax);
           
        }
        #endregion
I hope will help.

Thanks,

Re: Issue when graphing horizontal line

Posted: Thu Dec 10, 2009 3:19 pm
by 13052841
Thank you Sandra, that works great. The only trade-off is that the animated zoom effect is not visible since we are not zooming any more. This is only visual, so I will have to run it by the graphics people.

Is there any way to achieve the zoom effect when using the SetMinMax?

Re: Issue when graphing horizontal line

Posted: Thu Dec 10, 2009 3:47 pm
by narcis
Hi LibDundas,
Is there any way to achieve the zoom effect when using the SetMinMax?
The only solution I can think of is performing intermediate SetMinMax operations. For example, for zooming from 0 to 100 do it at: 10, 20, 30, 40, ..., 90 and 100; to get an animation effect.

Hope this helps!

Re: Issue when graphing horizontal line

Posted: Fri Dec 11, 2009 2:54 pm
by 13052841
Hi NarcĂ­s, that makes sense. It might be a lot of work in my actual application so I will leave it out for now and hopefully no misses the effect :)

Thanks!