Measuring Silverlight chart loading time
charts, rendering, silverlight
Solution
I've found some workarounds for some chart libraries and for some others I did not. Here are the events I could hook up to to get a realistic measurement time:
Dundas Charts:
Chart chart;
Chart.ImageReady += new ImageDownloaded(Chart_ImageReady); // Stop timer at this event
Silverlight Toolkit:
Chart chart;
DataPointSeries series;
Chart.Series.Add(series);
Chart.Series[0].Loaded += new RoutedEventHandler(Chart_Loaded); // Stop timer at this event
Steema TeeChart:
TChart chart;
chart.AfterDraw += new PaintChartEventHandler(chart_AfterDraw); // Stop timer at this event
Telerik RAD Charts:
RadChart chart;
chart.DefaultView.ChartArea.Loaded += new RoutedEventHandler(Chart_Loaded); // Stop timer at this event
Visifire
Chart chart;
chart.AnimationEnabled = false; // Turn off animation
chart.Loaded += new RoutedEventHandler(Chart_Loaded); // Stop timer at this event
The only library I couldn't hook up to an event fired at the right time was for Infagristics Netadvantage.
Problem
I am trying to measure how long it takes for different Silverlight charting libraries (e.g. Silverlight Control Toolkit, Visifire, Telerik) to load on screen. My problem is that I can only measure the time until the control is loaded and drawing starts to take place on the screen, however rendering takes more time because of animation effects (e.g. points fading in). Is there any chance I can set up some automated way of detecting when the rendering has ended? My problem is that I only found the Loaded event handler on a Silverlight Framework element to hook on to which only notifies of when rendering starts. An example code I am currently using for Silverlight Control Toolkit is as follows: ``` public void Init() { Chart chart = new Chart(); // Init chart object DataPointSeries series; (...)// Init series, add lots of points, set data binding Chart.Series.Add(series); // Add series to chart chart.Loaded += new RoutedEventHandler(Chart_Loaded); LayoutRoot.Children.Add(chart); StartTimer(); // Start timer and wait for control to load } public void Chart_Loaded(object sender, RoutedEventArgs e) { StopTimer(); // Problem: rendering just started at this point, hasn't finished yet! } ```