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

Java.lang.Illegalstateexception while exporting invisible sfchart

Hello, 
i have a screen in xamarin.forms which displays either chart data, or chart itself (toggles with switch )
i have a share button which calls the code to share chart
it's ok when chart is visible, but i'm getting an exception on chart.GetStream () in android part

Java.Lang.IllegalStateException: The specified child already has a parent. You must call removeView() on the child's parent first.

i attaching stack trace

is it a bug or a feature and i can't export invisible chart ?

sincerely
Ilya


Attachment: stack_fa33c21f.zip

3 Replies

BK Bharathiraja K Syncfusion Team February 25, 2019 10:52 AM UTC

Hi Ilya, 
 
Greetings from Syncfusion. 
 
We were able to reproduce the reported issue at our end when setting chart IsVisible property to false. May I know the purpose of disabling the chart while converting the chart as stream? If you provide the use case scenario of your requirement, it will be helpful for us to provide you a better solution.  
 
Regards, 
Bharathi. 



IL Ilya February 25, 2019 11:39 AM UTC

i have a page which displays either text information or its chart representation with radio button switching the view
also, there is a share button to share information. on tap of this button the chart will be shared .

currently i sort it out bit rude ;) switching chart visible, sharing it and switching back

 bool bShowChart = ShowChart.IsToggled;
   if (!bShowChart)
            {
                ShowChart.IsToggled = true;
                Device.StartTimer(new TimeSpan(0, 0, 0, 0, 10), () =>
                {
                    if (!chartData.IsVisible) return (true);
                    try
                    {
                        DependencyService.Get<iUtility>().ShareChartAsImage(chartData);
                    }
                    catch (Exception ex)
                    {

                    }
                    if (!bShowChart) ShowChart.IsToggled = false;
                    return (false);
                });
                return;
            }




BK Bharathiraja K Syncfusion Team February 25, 2019 11:47 AM UTC

Hi Ilya, 
 
Greetings from Syncfusion. 
 
We were able to reproduce the reported issue at our end when setting chart IsVisible property to false. May I know the purpose of disabling the chart while converting the chart as stream? If you provide the use case scenario of your requirement, it will be helpful for us to provide you a better solution.  
 
Regards, 
Bharathi. 


Loader.
Up arrow icon