We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

Removing SfChart from SuperView

What's the procedure for properly removing a SfChart from superview.
Let said that I have the following chart:

_Chart = new SFChart ();

SFNumericalAxis primaryAxis = new SFNumericalAxis ();

_Chart.PrimaryAxis = primaryAxis;

primaryAxis.Interval = new NSNumber (25);

SFNumericalAxis secondaryAxis = new SFNumericalAxis ();

_Chart.SecondaryAxis = secondaryAxis;

secondaryAxis.Minimum = new NSNumber (2);

secondaryAxis.Maximum = new NSNumber (5);

secondaryAxis.Interval = new NSNumber (0.5);


ChartAreaDataSource dataModel = new ChartAreaDataSource ();
 //from the sample app
_Chart.DataSource = dataModel as SFChartDataSource;

If I try to remove the graph form the superview the app instantly crash with a SIGSEGV error.

Alternatively, if I comment the datasource lines (defeating the purpose of the chart) I can remove it from the super view without causing it to crash the application.

If I try to override the RemoveFromSuperview function in my view and set the datasource to null I got a null reference exception.
public override void RemoveFromSuperview () {
_Chart.DataSource = null; // throw null reference exception
base.RemoveFromSuperview ();
}

Thanks for your input

3 Replies

ME Manivannan Elangovan Syncfusion Team March 8, 2016 07:29 AM UTC

Hi Guillaume,

Thanks for contacting Syncfusion support.

We can remove SfChart from its SuperView by calling its RemoveFromSuperView() method and it is not necessary to override this method.

We have prepared a sample and it can be downloaded from the following location.

Sample: http://www.syncfusion.com/downloads/support/forum/123316/ze/ChartSample-951298044

Regards,
Manivannan E.



GL Guillaume L'Heureux March 8, 2016 04:40 PM UTC

Thanks,

The sample work as advertised. 

After further analysis of it appear that it was a threading issue. 
The remove from super view wasn't called from the ui thread. 


ME Manivannan Elangovan Syncfusion Team March 9, 2016 06:08 AM UTC

Hi Guillaume,

Thanks for the update. Please let us know if you have any other queries.

Regards,
Manivannan E.

Loader.
Live Chat Icon For mobile
Up arrow icon