XAML for component
<ig:XamDataChart x:Name="DataChart1" Title="Vami" Legend="{x:Reference Legend}" IsHorizontalZoomEnabled="True" IsVerticalZoomEnabled="True"> </ig:XamDataChart> <ig:Legend x:Name="Legend" HorizontalOptions="End" VerticalOptions="Start"> </ig:Legend> </Grid>
code behind to populate charts
xAxis.ItemsSource = Manager1; xAxis.Label = "Filedate"; ChartVami.Axes.Add(xAxis); ChartVami.Axes.Add(yAxis); var series = new LineSeries { ValueMemberPath = "Vami", ItemsSource = Manager1, Title = Account1, XAxis = xAxis, YAxis = yAxis }; var series2 = new LineSeries { ValueMemberPath = "Vami", ItemsSource = Manager2, Title = Account2, XAxis = xAxis, YAxis = yAxis }; var series3 = new LineSeries { ValueMemberPath = "Vami", ItemsSource = Manager3, Title = Account3, XAxis = xAxis, YAxis = yAxis }; ChartVami.Series.Add(series); ChartVami.Series.Add(series2); ChartVami.Series.Add(series3);
Hello Stephen,
I have been investigating into this behavior you are seeing and I have put together a sample project heavily based on the sample code that you have provided. In doing so, though, I cannot seem to reproduce the behavior you are seeing, as the XamDataChart's Legend is showing normally for me at the start.
I have attached the sample project I used to test this. Please test this project on your PC; whether or not it works correctly may help indicate the nature of this problem.
If the project does not work correctly, this indicates either a problem possibly specific to your environment, or a difference in the DLL versions we are using. My test was performed using version 18.1.20181.5 in Infragistics for Xamarin.Forms 2018.1.
If the project does show the product feature working correctly, this indicates a possible problem in the code of your application. It will help if you can provide a small, isolated sample application that demonstrates the behavior you are seeing.
Or, if this sample project is not an accurate demonstration of what you're trying to do, please feel free to modify it and send it back, or send a small sample project of your own if you have one.
Please let me know if you have any other questions or concerns on this matter.
XFChartLegendTest.zip
I was able to run your sample which runs correctly. I simplified my code a bit to match yours and I still have the same problem. The legend only shows up when I turn the phone horizontal... it gets added then and when I turn the phone vertical again, the legend stays like it should.
I am glad that you were able to run the sample project, although it is unfortunate that you are still having this issue in your project. This leads me to believe that this issue must be something specific to the code used in your project. Would it be possible for you to please provide some additional information on exactly how your page's layout is set up in your project, along with any Android or iOS manifest settings that you may be setting in this case?
If possible, could you also attach an isolated sample project that demonstrates the behavior that you are seeing in this case?
I have pinpointed the issue. Your example works because the data is loaded into chart on page load. I put your code in my project in the viewmodel when loading page and it works perfectly. Now in my project the user hits a button to load the data.... when I switch the code, from loading data into chart on startup, TO load chart data after a user hits a button the issue occurs and the legend does not show up till I turn the phone. any idea how to fix this?
I even used your sample project and changed to code to load the chart data after user hits a button and the problem also shows up in your sample code. so you can see it in your code as well.
Thank you for your update. I have modified the sample project I created to dynamically load the data items and series, and I can see the behavior you are referring to. This behavior appears to be due to the HorizontalOptions and VerticalOptions being set on the Legend, as if these are not set, the Legend loads normally. As such, I would recommend that when you dynamically load your data, that you set these properties programmatically, rather than having them set at the start, like so:
legend.HorizontalOptions = LayoutOptions.End; legend.VerticalOptions = LayoutOptions.Start;
This behavior is unexpected, and as such, I have asked our engineering staff to examine it further. To ensure it receives attention, I have logged it in our internal tracking systems with a development ID of 254980. I have also created a private support case for you so that you can be notified when a fix or other resolution becomes available for this issue. This case has an ID of CAS-196626-W1N2M0 and you can access it here.
any update on this @Andrew
I apologize for the delay in my response on this matter.
I am able to reproduce the behavior you are seeing, but unfortunately, I cannot really seem to find a *good* workaround to this. The only thing that I have been able to find thus far that keeps the Legend in place and allows the plotted series to remain concurrent is to remove the Legend from the view and then re-add it. In the case of the sample project I had originally attached, this would look like the following, where "layoutRoot" is the Grid element containing the chart and the Legend:
layoutRoot.Children.Remove(Legend); layoutRoot.Children.Add(Legend);
This is unexpected behavior, and I have logged a separate issue for it with a development ID of 255235. I will link this one to support case CAS-196626-W1N2M0 as well.