This is a migrated thread and some comments may be shown as answers.

Error after upgrade to 2011 version

2 Answers 101 Views
This is a migrated thread and some comments may be shown as answers.
Top achievements
Rank 2
Tibi asked on 31 Mar 2011, 05:38 PM

We recently purchased the new version of telerik Developer Components. Until now, we had the q3 2010 version. All was working well in our charting project.
After the upgrade (uninstalled the previous version, removed the past references and added the new ones), the chart is not working any longer. We had two radchart controls on a page. The first one received the collection, made, grouped the data into series.
After this is created, we used the dataseries created in this one and created another radchart with default layout false, to put each series on a different chartarea(with different axes). We receive an error on the function that creates this second chart based on the data from the first one. The error does not appear with the debugger,the silverlight application goes all blank and ie reports in the left lower corner "Error on page":

Webpage error details

User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET4.0C; .NET4.0E; .NET CLR 3.5.30729; .NET CLR 3.0.30729)
Timestamp: Thu, 31 Mar 2011 16:25:06 UTC

Message: Unhandled Error in Silverlight Application 
Code: 4004    
Category: ManagedRuntimeError       
Message: System.Windows.Markup.XamlParseException:  [Line: 0 Position: 0] ---> System.NullReferenceException: Object reference not set to an instance of an object.
   la Telerik.Windows.Controls.Charting.DataPoint.GetNextSignificantIndex()
   la Telerik.Windows.Controls.Charting.DataPoint.GetNextSignificantDataPoint()
   la Telerik.Windows.Controls.Charting.SimpleShiftXAggregator.CalculateItemWidth(DataSeries dataSeries, Int32 index, DataRange range)
   la Telerik.Windows.Controls.Charting.SimpleShiftXAggregator.CalculateRange(DataSeries dataSeries, Int32 index, DataRange range)
   la Telerik.Windows.Controls.Charting.AxisX.CalculateItemRange(DataSeries dataSeries, Int32 index)
   la Telerik.Windows.Controls.Charting.SelfDrawingSeries.EvaluateXRangeAtIndex(Int32 index)
   la Telerik.Windows.Controls.Charting.SelfDrawingSeries.CalculateLinePoints(Func`2 extractXRangeValue, Func`3 extractYRangeValue)
   la Telerik.Windows.Controls.Charting.LineSeries.CalculatePoints(Func`2 extractXRangeValue, Func`3 extractYRangeValue)
   la Telerik.Windows.Controls.Charting.SelfDrawingSeries.CreateFigures()
   la Telerik.Windows.Controls.Charting.SelfDrawingSeries.InitializeTopBorderLineGeometry()
   la Telerik.Windows.Controls.Charting.SelfDrawingSeries.InitializeSeriesGeometry()
   la Telerik.Windows.Controls.Charting.SelfDrawingSeries.OnApplyTemplate()
   la System.Windows.FrameworkElement.OnApplyTemplate(IntPtr nativeTarget)
   --- Final urmărire stivă internă de excepţii ---
   la MS.Internal.XcpImports.MethodEx(IntPtr ptr, String name, CValue[] cvData)
   la MS.Internal.XcpImports.MethodEx(DependencyObject obj, String name)
   la MS.Internal.XcpImports.FrameworkElement_ApplyTemplate(FrameworkElement frameworkElement)
   la System.Windows.Controls.ItemContainerGenerator.LayoutStatesManager.GetElementRoot(Boolean templatesAreGenerated)
   la System.Windows.Controls.ItemContainerGenerator.LayoutStatesManager.Load()
   la System.Windows.Controls.ItemContainerGenerator.System.Windows.Controls.Primitives.IItemContainerGenerator.PrepareItemContainer(DependencyObject container)
   la System.Windows.Controls.ItemsControl.AddVisualChild(Int32 containerIndex, DependencyObject container, Boolean needPrepareContainer)
   la System.Windows.Controls.ItemsControl.AddContainers()
   la System.Windows.Controls.ItemsControl.RecreateVisualChildren(IntPtr unmanagedObj)     

Line: 57
Char: 13
Code: 0
URI: http://localhost/TestRiaRadLinq.Web/Romanian.aspx

Our function is:
public void createRadChart(DataSeriesCollection dS, SeriesMapping sMap, ChartLegend colectieItems, List<wcfService.Signal> listaLegenda)
         // sMap.ChartAreaName = "Chart1";
          radChart2.UseDefaultLayout = false;
         // radChart2.SeriesMappings.Add(sMap);
          Grid chartLayout = new Grid();
          chartLayout.Margin = new Thickness(10, 10, 0, 20);
          chartLayout.RowDefinitions.Add(new RowDefinition());
          chartLayout.RowDefinitions[0].Height = new GridLength(60);
          radChart2.SamplingSettings.SamplingThreshold = 1000;
          radChart2.SamplingSettings.SamplingFunction = ChartSamplingFunction.KeepExtremes;
          //Creating ChartTitle for the left chart
          Telerik.Windows.Controls.Charting.ChartTitle chartTitle = new Telerik.Windows.Controls.Charting.ChartTitle();
          chartTitle.Margin = new Thickness(0, 0, 0, 10);
          chartTitle.HorizontalAlignment = HorizontalAlignment.Stretch;
          chartTitle.Content = ApplicationStrings.Vibrations_GeneratorPageTitle+Environment.NewLine + startDate.SelectedDate.Value.Day+"/"+ startDate.SelectedDate.Value.Month+"/"+ startDate.SelectedDate.Value.Year+" <--> "+endDate.SelectedDate.Value.Day+"/"+ endDate.SelectedDate.Value.Month+"/"+ endDate.SelectedDate.Value.Year;
          Grid.SetRow(chartTitle, 0);
          for (int i=0; i<dS.Count;i++)
              chartLayout.RowDefinitions.Add(new RowDefinition());
             // chartLayout.RowDefinitions.Add(new RowDefinition());
          chartLayout.RowDefinitions.Add(new RowDefinition());
          chartLayout.RowDefinitions[dS.Count+1].Height = new GridLength(150);
          Telerik.Windows.Controls.Charting.ChartLegend ChartLegend = new Telerik.Windows.Controls.Charting.ChartLegend();
          ChartLegend.HorizontalAlignment = HorizontalAlignment.Stretch;
          ChartLegend.VerticalAlignment = VerticalAlignment.Stretch;
          ChartLegend.UseAutoGeneratedItems = false;
          ChartLegend.Name = "LegendaComuna";
          radChart2.Content = chartLayout;
          Grid.SetRow(ChartLegend, dS.Count+1);
          List<ChartItemsLegend> lista = new List<ChartItemsLegend>();
          for (int i = 0; i < dS.Count; i++)
              Telerik.Windows.Controls.Charting.ChartArea chartArea1 = new Telerik.Windows.Controls.Charting.ChartArea();
              chartArea1.Name = "Chart" + i;
              chartArea1.AxisY.AutoRange = false;
              if (i == 5)
                  chartArea1.AxisY.AddRange(Convert.ToDouble(listaLegenda[i].Disp_Min), Convert.ToDouble(listaLegenda[i].Disp_Max), Convert.ToDouble(listaLegenda[i].Disp_Max) / 5);
                  chartArea1.AxisY.AddRange(Convert.ToDouble(listaLegenda[i].Disp_Min), Convert.ToDouble(listaLegenda[i].Disp_Max), Convert.ToDouble(listaLegenda[i].Disp_Max) / 5);
              chartArea1.AxisX.DefaultLabelFormat = "MMM-dd";
              chartArea1.EnableAnimations = false;
              chartArea1.EnableTransitionAnimations = false;
              chartArea1.LabelFormatBehavior = LabelFormatBehavior.None;
              chartArea1.AxisY.Title = listaLegenda[i].Disp_Unit;
              chartArea1.AxisX.AutoRange = false;
              chartArea1.AxisX.MinValue = new DateTime(Convert.ToDateTime(sDate).Ticks).ToOADate();
              chartArea1.AxisX.MaxValue = new DateTime(Convert.ToDateTime(eDate).Ticks).ToOADate();
              chartArea1.AxisX.Step = 5;
                  chartArea1.AxisY.MajorGridLinesVisibility = Visibility.Visible;
                  chartArea1.AxisX.MajorGridLinesVisibility = Visibility.Visible;
                  if (i == dS.Count-1)
              chartArea1.AxisX.Visibility = Visibility.Visible;
               chartArea1.AxisX.Visibility = Visibility.Collapsed;
           chartArea1.LegendName = "LegendaComuna";
           Color culoare = GetRandomColor();
           Brush brush = new SolidColorBrush(Culori[i]);
              chartArea1.PaletteBrushes.Add(brush) ;
              ChartLegendItem item1 = new ChartLegendItem();
              item1.Label = listaLegenda[i].Signal_Name + " - " + listaLegenda[i].Description;
              item1.MarkerFill = new SolidColorBrush(Culori[i]);
              Grid.SetRow(chartArea1, i+1);
          busyIndicator.IsBusy = false;

I have no ideea how to debug this, because the error does not appear to be in our code.
Do you have any ideea why this is happening?

Thank you,

2 Answers, 1 is accepted

Sort by
Telerik team
answered on 05 Apr 2011, 03:06 PM
Hi Marian,

RadChart does not support reuse of the DataSeries / DataPoint instances across different instances of the chart control and that is causing the exception in your scenario. Actually this was not supported in previous versions as well (the internal logical tree would have been broken again) but the problem would not be visible in all scenarios. Now due to the changes related to the Empty Values feature, the control requires the internal logical tree to be in working condition at all times and that is why you are seeing the changed behavior.

We would suggest you to manually "clone" the DataSeriesCollection (DataSeries and DataPoints) for the second chart in order to achieve the desired effect like this:

private DataSeriesCollection CloneDataSeriesColleciotn(DataSeriesCollection dS)
    DataSeriesCollection clone = new DataSeriesCollection();
    foreach (var series in dS)
        var cloneSeries = new DataSeries();
        cloneSeries.Definition = new LineSeriesDefinition();
        foreach (var point in series)
            cloneSeries.Add(new DataPoint() { XValue = point.XValue, YValue = point.YValue });
    return clone;
public void createRadChart(DataSeriesCollection dS)
    dS = CloneDataSeriesColleciotn(dS);

the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Top achievements
Rank 2
answered on 05 Apr 2011, 03:58 PM

Thank you for the solution, it worked just fine. I tried to clone the dataseries myself, but i now realise that i did not clone each datapoint. 
I was referencing them from the old dataseries. Not knowing from what this problem may be, i did not persue in this direction, because the q3 2010 worked fine with the dataseries created in another radchart in every scenario we used.

Thank you,

Dan Gheorghe
Asked by
Top achievements
Rank 2
Answers by
Telerik team
Top achievements
Rank 2
Share this question