I have a situation where the user can select different sources to show in a line graph. Depended on the source I want to show one, two or three line series in the graph. So I added three line series to my graph. In case I don't need all series I set the ItemsSource of the not used serie(s) to null but this gives issue in iOS. Also the legend of the not used series is always shown. There don't seem to be some IsVisible or IsEnabled property I can bind to so the the serie is ignored while redering.
I guess I could add or remove series to the Series collection in code behind but since I am using MVVM I really would not like to do that.
How can I solve this issue in a mvvm way? Can we use some data template selector?
5 Answers, 1 is accepted
If you need to initially hide your chart series, setting the ItemsSource property to null is perfectly fine solution. Can you provide more information about the issues you observe with this approach in iOS?
About your problem with the legend - currently there is no mechanism to hide series from the legend. I have logged the task as a feature request at our end. You can track its progress on the following link from our Ideas & Feedback portal - Chart: Allow series to be excluded from the Legend. Please subscribe to the item in order to be automatically notified when an update is available.
I hope I've been helpful.
The issue on iOS can best be demonstrated with some screenshots. I am showing some data over time so I am using the DateTimeContinuousAxis. I have two series, first an AreaSeries and second a LineSeries. If I set both ItemsSource's to the same collection it shows fine like in the first screenshot. If I set the first to the collection and the second to null it will show the first serie like a short vertical line like in the second screenshot. I have no idea why. On Android it does work fine b.t.w.
Also I need a way to hide not shown series from the legend like you mentioned because it will now show an (ugly) empty legend.
Thank you for providing screenshots and additional information about your setup.
I've tested the described scenario and I was able to reproduce the problem - it seems like the issue is reproducible only when using DateTimeContinuousAxis. I can confirm that this is a bug in the iOS implementation of our chart control. I have logged a Bug Report in our backlog about this behaviour. Here is a link to the public item in our Feedback Portal where you can track the progress on the matter.
The only reasonable work around I can suggest you is to add and remove the series from code behind instead of setting the ItemsSource of the series to null.
Your Telerik points were updated to thank you for bringing this issue to our attention.
Our apologies for the inconvenience this causes you.
Thank you for creating a bug report.
But there is something I need off my chest. The chart control is potentially a very very useful control but issues like this, the fact I can't control the series in the legend, the fact I can't bind axis and grid properties which is know for one year and not fixed yet makes it impossible to use this control to it's full potential. I have to create some functionality where this control fits in perfectly and I am almost there but I can not finish it because of these small yet vital issues which is very frustrating if I may say so.
Thank you for sending your feedback and I am sorry to hear about your dissatisfaction with our RadChart component.
I understand that you came upon a few issues as well as missing features that are preventing you from achieving the desired scenario - indeed I agree that RadChart needs polishing and I'd like to assure you that the items in the Feedback Portal you're referring to are carefully reviewed by the product management and hopefully will be planned for some of the upcoming releases. This, however, depends on various factors, such as demand, severity, complexity, available resources, etc,
Let me know if I can be of any further assistance.