Problem dynamically creating a chart

2 posts, 0 answers
  1. MW
    MW avatar
    1 posts
    Member since:
    Sep 2009

    Posted 10 Sep 2009 Link to this post

    Hi

    I am currently using the latest release of the RadControls (2009 SP2).  I am trying to create a chart dynamicall but whenever it hits the following line, chart.DefaultView.ChartArea.DataSeries.Add(dataSeries), the application freezes and its just a white screen.  There are similar posts about this that says this was fixed in a previous release.  Can you tell me if this is still a bug or if I am doing something wrong.

                    // Create a new Chart element.  
                    RadChart chart = new RadChart();  
     
                    // Set some chart defaults.  
                    chart.DefaultView.ChartArea.AxisX.StripLinesVisibility = Visibility.Collapsed;  
                    chart.DefaultView.ChartArea.AxisY.MajorGridLinesVisibility = Visibility.Collapsed;  
          
                    // Create a new DataSeries.  
                    DataSeries dataSeries = new DataSeries();  
     
                    // Add some hardcoded data points.  
                    Dictionary<string, double> dataPoints = new Dictionary<string, double>();  
     
                    dataPoints.Add("A", 0.121127226879971);  
                    dataPoints.Add("B", -0.511961779733487);  
                    dataPoints.Add("C", -0.394865386295022);  
     
                    // Add the datapoints.  
                    foreach (var point in dataPoints)  
                    {  
                        // Create a new DataPoint.  
                        DataPoint dataPoint = new DataPoint();  
     
                        dataPoint.XCategory = point.Key;  
                        dataPoint.YValue = point.Value;  
     
                        // Add DataPoint to DataSeries.  
                        dataSeries.Add(dataPoint);  
                    }  
     
                    // Set the type of graph to draw.  
                    dataSeries.Definition = new BarSeriesDefinition();  
     
                    // Add DataSeries to Chart  
                    chart.DefaultView.ChartArea.DataSeries.Add(dataSeries);  
     

    Thanks
    Mark
  2. Velin
    Admin
    Velin avatar
    391 posts

    Posted 15 Sep 2009 Link to this post

    Hello MW,

    I was not able to reproduce this problematic behavior. Please, find attached my sample application which uses exactly your code. I would ask you to download the latest internal build from your customer account and in case the problem persist, please, prepare and send us a sample project which we could further examine and provide a solution.

    Regards,
    Velin
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Back to Top