I am using a XamDataChart in a Silverlight sdk tab control. The chart has a Radial Area series and two Radial Line series. The itemsource and visibility for these are bound to properties in a view model. I also have a Legend on this tab for the chart.
Tab selection is controlled by the view model. After the relevant properties are defined, the view model sets the tab to the one with this chart. At this point, one of the line series is not visible. However, the legend shows all of the series, even the one that is not visible.
When I run the app, if I select another tab, then re-select the tab with the chart, the hidden series appears as it should. I've tried many workarounds found on this and other forums to no avail.
Update: I found out by chance that if I allow the radial axis to auto-scale (instead of setting a Maximum) that the mystery series displays on start up as it should. Note that the data in this series is well within the bounds of the maximum I was setting. Weird.
Hello,
I am not sure why you would be experiencing this issue. I attempted to reproduce it based on the description you provided but the behavior was as expected and all of the series were drawn.
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 14.2.20142.1000 in Infragistics for Silverlight 2014 Volume 2.
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 questions.
Sincerely,
Valerie
Developer Support Supervisor - XAML
Infragistics
www.infragistics.com/support
Thank you, Valerie. The sample code you provided worked fine on my machine ( I used the version utility to roll the IGreferences back to 14.1). I think this must be related to binding or my VM properties.
<ig:RadialLineSeries Title="Current" x:Name="seriesCurrent" MouseLeftButtonDown="rt_MouseMove" ItemsSource="{Binding Meas_HI_Data, Mode=TwoWay}" ClipSeriesToBounds="True" AngleAxis="{Binding ElementName=angleAxis}" ValueAxis="{Binding ElementName=radiusAxis}" ValueMemberPath="Value" Visibility="{Binding Meas_HI_Data.Visible, Converter={StaticResource VisibilityConverter}}" Brush="Brown" MarkerType="Circle" MarkerBrush="Brown" > <ig:RadialLineSeries.ToolTip> <Border BorderBrush="Black" BorderThickness="1" Background="Azure"> <StackPanel Orientation="Vertical" Margin="3"> <TextBlock Text="{Binding Item.Label}"/> </StackPanel> </Border> </ig:RadialLineSeries.ToolTip> </ig:RadialLineSeries>
private CategoryDataCollection m_Meas_HI_Data; public CategoryDataCollection Meas_HI_Data { get { return m_Meas_HI_Data; } set { if (m_Meas_HI_Data == value) { return; } m_Meas_HI_Data = value; NotifyPropertyChanged("Meas_HI_Data"); } }
using System; using System.Collections.Generic; using System.Collections.ObjectModel; using System.ComponentModel; using System.Linq; { public class CategoryDataCollection : ObservableCollection<CategoryDataPoint> { public CategoryDataCollection() { _title = ""; } private string _title; public string Title { get { return _title; } set { if (_title.Equals(value)) return; _title = value; OnPropertyChanged(new PropertyChangedEventArgs("Title")); } } private bool _visible; public bool Visible { get { return _visible; } set { if (_visible == value) return; _visible = value; OnPropertyChanged(new PropertyChangedEventArgs("Visible")); } } } public class CategoryDataPoint : INotifyPropertyChanged { public CategoryDataPoint() { } public CategoryDataPoint(double value, string cat, string label) { this.Value = value; this.Category = cat; this.Label = label; } public CategoryDataPoint(CategoryDataPoint dataPoint) { this.Index = dataPoint.Index; this.Category = dataPoint.Category; this.Value = dataPoint.Value; this.Date = dataPoint.Date; this.High = dataPoint.High; this.Low = dataPoint.Low; } public double Change { get { return High - Low; } } public double ChangePerCent { get { return (Change / High) * 100; } } private double _index; public double Index { get { return _index; } set { if (_index == value) return; _index = value; NotifyPropertyChanged("Index"); } } private double _value; public double Value { get { return _value; } set { if (_value == value) return; _value = value; NotifyPropertyChanged("Value"); } } private double _high; public double High { get { return _high; } set { if (_high == value) return; _high = value; NotifyPropertyChanged("High"); } } private double _low; public double Low { get { return _low; } set { if (_low == value) return; _low = value; NotifyPropertyChanged("Low"); } } private string _category; public string Category { get { return _category; } set { if (_category == value) return; _category = value; NotifyPropertyChanged("Category"); } } private string _label; public string Label { get { return _label; } set { if (_label == value) return; _label = value; NotifyPropertyChanged("Label"); } } private DateTime _date; public DateTime Date { get { return _date; } set { if (_date == value) return; _date = value; NotifyPropertyChanged("Date"); } } public new string ToString() { return String.Format("Category {0}, Value {1}", Category, Value); } #region INotifyPropertyChanged Implementation public event PropertyChangedEventHandler PropertyChanged; private void NotifyPropertyChanged(string propertyName) { if (PropertyChanged != null) { PropertyChanged(this, new PropertyChangedEventArgs(propertyName)); } } #endregion } //public abstract class ObservableModel : INotifyPropertyChanged //{ // #region INotifyPropertyChanged // public event PropertyChangedEventHandler PropertyChanged; // protected void OnPropertyChanged(string propertyName) // { // if (this.PropertyChanged != null) // this.PropertyChanged(this, new PropertyChangedEventArgs(propertyName)); // } // #endregion //} }
Hello Alan,
I modified my sample based on the code provided and tested with 14.1 build 14.1.20141.1012 and I was still able to see all the series initially. I have attached the modified sample.
I still unsure what would be causing the issue. If the latest sample works for you, Please provide with more information on how / when you are setting the visibility or any other differences you can find between your app and the sample which may be causing the issue.
Let me know if you have any questions.
I am glad to hear you found a solution.
I am still unsure exactly what the issue was. If you are using an ObservableCollection then once the points are added to the collection the series should be drawn. I tested delaying adding the points to the collection Data2 in my sample and was able to see the new series after the collection was filled. You shouldn’t need to reset the collection the chart points to unless the collection itself is recreated after the initial binding was set. Then you would need to reset the chart’s properties to point to the new instance of the collection.
Thanks again for helping me with a problem that isn't really an Infragistics issue. I compared your latest sample to my project and wasn't able to spot any differences that would explain my missing series. I found a solution, however, and am posting it here in case it helps anyone else.
I believe my issue was due to the timing of the chart creation and when the bound data collection is updated. In my application, when the tab containing this chart control is loaded (created), the data collection in question is empty (no data points have been added). I assumed that adding data points to this observable collection would automatically result in it showing in the UI. Not so.
What worked for me was to create a copy of the data collection as a view model field (private member of the vm) then to assign it to the bound property only after all the other series had been updated.
I've never understood why adding items to an *observable* collection doesn't trigger a notification to the view. It only works if the complete collection is reassigned.
What's interesting from an Infragistics point of view is that when I set the Radial axis to auto scale, the problem went away. I suspect that using auto scale forces the control to check its bound data every time it gets focus or is rendered.