Y Margins much larger than they should be

A forum dedicated to WinForms version of LightningChart Ultimate.

Moderator: Queue Moderators

Post Reply
SESruss
Posts: 22
Joined: Wed Mar 12, 2014 6:36 pm

Y Margins much larger than they should be

Post by SESruss » Wed Mar 12, 2014 6:51 pm

I am hoping you might be able to help me figure out where I am going wrong.
When my app initially opens the very first chart to be displayed always has way wider Y margin settings. I'm seeing something like 40 or 50 pixels where my setting is 10.

This is with:
_chart.ViewXY.ZoomPanOptions.ViewFitYMarginPixels = 10;(In Constructor)
_chart.ViewXY.FitView();(very last function call before EndUpdate() in my chart drawing routine)

Things I have noticed:
-increasing the ViewFitYMarginPixels also increases the first renderings way to big margins linearly
-when I set the ViewFitYMarginPixels to 100 pixels the initial chart has a Y margin of 0
-choosing a different chart to open first results in the same problem
-anything that causes the chart to re-render draws the Y margins correctly and I have no more issues

Any help would be greatly appreciated as I am stuck on this one.

User avatar
ArctionPasi
Posts: 1367
Joined: Tue Mar 26, 2013 10:57 pm
Location: Finland
Contact:

Re: Y Margins much larger than they should be

Post by ArctionPasi » Wed Mar 12, 2014 10:47 pm

Hello, when calling the FitView with ViewFitYMarginPixels defined in constructor, the chart is in its default size (small). Y axis Min and Max are therefore calculated based on that size and the pixel margins. When the chart grows before it actually renders in its real place, the Y axis Min and Max are rateined, and actual margin in pixels is larger. The pixel margin error is in proportion to real size and default size.

To go around the problem, define SizeChanged event handler. In the handler, call FitView(), and unsubscribe from the SizeChanged event.

That should help.
LightningChart Support Team, PT

SESruss
Posts: 22
Joined: Wed Mar 12, 2014 6:36 pm

Re: Y Margins much larger than they should be

Post by SESruss » Thu Mar 13, 2014 11:51 am

Thanks for the fast reply. Problem solved.

_chart.SizeChanged += SizeChangedEventHandler;


private void SizeChangedEventHandler(object sender, EventArgs e)
{
_chart.ViewXY.FitView();
_chart.SizeChanged -= SizeChangedEventHandler;

}

Post Reply