Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
760
NullReferenceException when setting OlapAxis DataSource
posted

Hello,

When setting the DataSource of the OlapAxis, it throws NullReferenceException.

Here is the code snippet that causes the exception:



                   
                    var numericYAxis= new NumericYAxis()
                                          {
                                              LabelSettings = new AxisLabelSettings()
                                                                  {
                                                                      Extent = 55,
                                                                      Location = AxisLabelsLocation.OutsideLeft,
                                                                      IsHitTestVisible = true
                                                                  }
                                          };

                    DataChart.Axes.Add(numericYAxis);

                    OlapXAxis olapXAxis = new OlapXAxis();
                    olapXAxis.YAxis = numericYAxis;
                    olapXAxis.Label = "{Label}";
                    olapXAxis.OlapAxisSource = OlapAxisSource.Rows;
                    olapXAxis.LabelSettings = new AxisLabelSettings();
                    olapXAxis.LabelSettings.Extent = 35;
                    olapXAxis.LabelSettings.Location = AxisLabelsLocation.OutsideBottom;
                                       
                    olapXAxis.DataSource = chartViewModel.OlapViewModel;//Note:OlapViewModel is not null

   at Infragistics.Controls.Charts.OlapXAxis.LayoutArranged()
   at Infragistics.Controls.Charts.OlapAxis.ArrangeLayoutInternal()
   at Infragistics.Controls.Charts.OlapAxis.DataSourceChanged(DependencyObject obj, DependencyPropertyChangedEventArgs e)
   at System.Windows.DependencyObject.RaisePropertyChangeNotifications(DependencyProperty dp, Object oldValue, Object newValue)
   at System.Windows.DependencyObject.UpdateEffectiveValue(DependencyProperty property, EffectiveValueEntry oldEntry, EffectiveValueEntry& newEntry, ValueOperation operation)
   at System.Windows.DependencyObject.SetValueInternal(DependencyProperty dp, Object value, Boolean allowReadOnlySet, Boolean isBindingInStyleSetter)
   at System.Windows.DependencyObject.SetValue(DependencyProperty dp, Object value)
   at Infragistics.Controls.Charts.OlapAxis.set_DataSource(IOlapViewModel value)
   at GoIT.Dashboard.Infrastructure.Controls.Charts.DataChartControl.ResolveXAxis(IChartViewModel chartViewModel)

Is there any way how to fix it?

Thank you

Parents
No Data
Reply
  • 760
    posted

    Also I have tried to use the  data binding. Please see the code below.

     Binding binding = new Binding("OlapViewModel");
     olapXAxis.SetBinding(OlapAxis.DataSourceProperty, binding);

    In this case the exception is : cannot change observablecollection during a collectionchanged or propertychanged event

       at System.Collections.ObjectModel.ObservableCollection`1.CheckReentrancy()
       at System.Collections.ObjectModel.ObservableCollection`1.InsertItem(Int32 index, T item)
       at System.Collections.ObjectModel.Collection`1.Add(T item)
       at Infragistics.Controls.Charts.OlapXAxis.SetCategoryAxis()
       at Infragistics.Controls.Charts.OlapAxis.BuildSeries()
       at Infragistics.Controls.Charts.OlapAxis.ArrangeLayoutInternal()
       at Infragistics.Controls.Charts.OlapAxis.DataSourceChanged(DependencyObject obj, DependencyPropertyChangedEventArgs e)
       at System.Windows.DependencyObject.RaisePropertyChangeNotifications(DependencyProperty dp, Object oldValue, Object newValue)
       at System.Windows.DependencyObject.UpdateEffectiveValue(DependencyProperty property, EffectiveValueEntry oldEntry, EffectiveValueEntry& newEntry, ValueOperation operation)
       at System.Windows.DependencyObject.RefreshBLOCKED EXPRESSION

Children