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

Problem dynamically creating a chart

1 Answer 92 Views
Chart
This is a migrated thread and some comments may be shown as answers.
MW
Top achievements
Rank 1
MW asked on 10 Sep 2009, 12:56 PM
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

1 Answer, 1 is accepted

Sort by
0
Velin
Telerik team
answered on 15 Sep 2009, 07:06 AM
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.
Tags
Chart
Asked by
MW
Top achievements
Rank 1
Answers by
Velin
Telerik team
Share this question
or