Page 1 of 1

ChartAfterRemdering event causes StackOverflowException

Posted: Mon Sep 12, 2016 8:00 am
by matus
Hello,
after updating to 7.1.4 from v6, we started to get System.StackOverflowException.
I suppose some propety setters are firing ChartAfterRemdering event in v7.

This is the handler:

Code: Select all

        private void ChartAfterRendering(object sender, AfterRenderingEventArgs args)
        {
            if (_leftMargin == 0)
                return;

            _chart.ViewXY.AxisLayout.AutoAdjustMargins = false;
            var margin = _chart.ViewXY.Margins;
            margin.Left = _leftMargin + 30;
            _chart.ViewXY.Margins = margin;
        }
Is there a list of actions, that cause firing of ChartAfterRemdering event?
How should this be handled?

Thanks

Re: ChartAfterRemdering event causes StackOverflowException

Posted: Mon Sep 12, 2016 12:19 pm
by ArctionKestutis
Hello,

AfterRendering event is called whenever refresh of rendering data happen: series data changed, axis range changed, properties set, mouseOver event etc.
In your example, two lines will cause firing:

Code: Select all

            _chart.ViewXY.AxisLayout.AutoAdjustMargins = false;
            _chart.ViewXY.Margins = margin;
To avoid infinite loop you can unsubscribe from event handler at the beginning of and again subscribe at the end. Other option for stopping infinite loop also available.
In this regard, maybe you don't need such strong event in your code. Please consider other events of the Chart or ViewXY.

Al the best,
Kestutis