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

LegendItemCreated event of Xamarin SfChart control doesn't fire

Hi,

I am using Syncfusion SfChart in my Xamarin Android project. I noticed that the LegendItemCreated event never fires. The Syncfusion.SfChart.Android.dll version is 17.3451.0.26. Please let me know on which version it works

Regards
Khasan

3 Replies

HM Hemalatha Marikumar Syncfusion Team December 3, 2019 11:43 AM UTC

i khasan, 
  
Greetings from Syncfusion. 
  
Query: LegendItemCreated event never fires. 
  
We have validated your query and we were unable to reproduce the reported issue even with 17.3451.0.26 and latest version 17.3451.0.29 also. We suspect that the reported issue may occur while not enabling the Legend visibility for SfChart. Please enable the Legend visibility as per the below code snippet. 
  
Code Snippet [C#]: 
  
chart.Legend.Visibility = Visibility.Visible; 
chart.LegendItemCreated += Chart_LegendItemCreated; 
  
  
And we have prepared a sample based on your requirement and you can download the sample from the below link. 
  
  
For more details please refer the UG link below. 
  
Please let us know if you have any further assistance on this. 
  
Regards, 
Hemalatha M. 



KH khasan December 8, 2019 07:18 PM UTC

Hi Hemalatha, thanks to this example, I understood why the event doesn't fire. if I subscribe after series being adding the event doesn't work but if I subscribe before adding series it works for example:

In the below example Chart_LegendItemCreated handler will not be called:
chart.Series.Add(series);
chart.LegendItemCreated += Chart_LegendItemCreated;

In the below example Chart_LegendItemCreated handler will be called:
chart.LegendItemCreated += Chart_LegendItemCreated;
chart.Series.Add(series);


Regards
Khasan


HM Hemalatha Marikumar Syncfusion Team December 9, 2019 06:32 AM UTC

Hi Khasan, 
 
Thanks for your update. 
 
We glad to hear that you have found the solution. 
 
We would like to let you know that currently we have maintained the flow of execution only invoke the LegendItemCreated before adding the series collection with having visibility of Legend as per in below 
 
chart.Legend.Visibility = Visibility.Visible; 
….. 
chart.LegendItemCreated += Chart_LegendItemCreated; 
chart.Series.Add(series); 
 
 
Please let us know if you have any other concern. 
 
Regards, 
Hemalatha M. 


Loader.
Up arrow icon