LightningChartUltimate.ViewXY.YAxes.Fit(int MarginPixels,..)

A forum dedicated to WPF version of LightningChart Ultimate.

Moderator: Queue Moderators

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

LightningChartUltimate.ViewXY.YAxes.Fit(int MarginPixels,..)

Post by SESruss » Wed Aug 20, 2014 5:50 pm

I have in my code in the routine to create a Lightning Chart :

_chart.ViewXY.ZoomPanOptions.ViewFitYMarginPixels = 10;

to add Y margin to my chart. This seems to only work when I left click and hold, and drag to the left to resize the chart to its aspect ratio of 1:1. So anything that causes the chart to recreate itself and the initial draw seems to ignore this YAxis margin.

I've tried experimenting with the AixsY Fit() but I am not seeing any changes from that. The CreateChart routines bottom looks like:

_chart.ViewXY.FitView();
bool foo=true;
AxisY.Fit(100, out foo, true,true);
//Allow chart drawing
_chart.EndUpdate();

Can you tell me where I am going wrong?

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

Re: LightningChartUltimate.ViewXY.YAxes.Fit(int MarginPixels

Post by ArctionPasi » Fri Aug 22, 2014 11:20 am

If I understand right, you are doing FitView before the chart has got appeared on the screen or got it's final size on screen.

If so, FitView with given margins makes the fit for default chart size, which is small. When the chart resizes larger, the margin between data max and graph border in pixels grows. That's because data is bound to axis values, not screen coordinates.

Try making FitView after the chart has rendered once. You can subsribe to AfterRendering event handler, call FitView there, and then unsubscribe from the handler.

I hope I understood the problem right... If I didn't please attach a couple of descriptive pictures about the problem.
LightningChart Support Team, PT

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

Re: LightningChartUltimate.ViewXY.YAxes.Fit(int MarginPixels

Post by SESruss » Fri Aug 22, 2014 3:21 pm

I have changed the bottom half of my create chart routine to match the Demo Applications so its just:

_chart.AfterRendering += ChartRenderEventHandler;

_chart.EndUpdate();

gridChart.Children.Add(_chart);

And added routine for the AfterRendering event

private void ChartRenderEventHandler(LightningChartUltimate chart)
{
chart.ViewXY.FitView();
_chart.AfterRendering -= ChartRenderEventHandler;
}

What I've noticed is that although the 'AfterRendering' event is raised immediately after the create chart routine executes, it takes a chart event (MouseOn, MouseClick, etc) for the chart to redraw itself with the Y Margins as defined by the code in my create chart routine.

_chart.ViewXY.ZoomPanOptions.ViewFitYMarginPixels = 10;

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

Re: LightningChartUltimate.ViewXY.YAxes.Fit(int MarginPixels

Post by SESruss » Mon Aug 25, 2014 2:52 pm

I've gotten things to behave by implementing my own custom Y margin code except for one case. When you leftclick and drag from right to left I have the ZoomAction set to 'FitView'. I have not been able to find an event for that to subscribe to. I guess if there is not one I can remove that functionality but I do really like it.

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

Re: LightningChartUltimate.ViewXY.YAxes.Fit(int MarginPixels

Post by ArctionPasi » Mon Aug 25, 2014 3:07 pm

In FitView, axis.RangeChanged events should fire. Would it help?
LightningChart Support Team, PT

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

Re: LightningChartUltimate.ViewXY.YAxes.Fit(int MarginPixels

Post by SESruss » Mon Aug 25, 2014 7:34 pm

In FitView, axis.RangeChanged events
Not sure what you are saying, the only FitView I know of is a function and I don't see a RangeChanged event in LightingChartUltimate.ViewXY.

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

Re: LightningChartUltimate.ViewXY.YAxes.Fit(int MarginPixels

Post by ArctionPasi » Mon Aug 25, 2014 8:27 pm

Sorry not being clear enough. :|

ViewXY.XAxes[0].RangeChanged
ViewXY.YAxes[0].RangeChanged
LightningChart Support Team, PT

Post Reply