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