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?
LightningChartUltimate.ViewXY.YAxes.Fit(int MarginPixels,..)
Moderator: Queue Moderators
- ArctionPasi
- Posts: 1367
- Joined: Tue Mar 26, 2013 10:57 pm
- Location: Finland
- Contact:
Re: LightningChartUltimate.ViewXY.YAxes.Fit(int MarginPixels
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.
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
Re: LightningChartUltimate.ViewXY.YAxes.Fit(int MarginPixels
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;
_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;
Re: LightningChartUltimate.ViewXY.YAxes.Fit(int MarginPixels
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.
- ArctionPasi
- Posts: 1367
- Joined: Tue Mar 26, 2013 10:57 pm
- Location: Finland
- Contact:
Re: LightningChartUltimate.ViewXY.YAxes.Fit(int MarginPixels
In FitView, axis.RangeChanged events should fire. Would it help?
LightningChart Support Team, PT
Re: LightningChartUltimate.ViewXY.YAxes.Fit(int MarginPixels
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.In FitView, axis.RangeChanged events
- ArctionPasi
- Posts: 1367
- Joined: Tue Mar 26, 2013 10:57 pm
- Location: Finland
- Contact:
Re: LightningChartUltimate.ViewXY.YAxes.Fit(int MarginPixels
Sorry not being clear enough.
ViewXY.XAxes[0].RangeChanged
ViewXY.YAxes[0].RangeChanged
ViewXY.XAxes[0].RangeChanged
ViewXY.YAxes[0].RangeChanged
LightningChart Support Team, PT