Performance problems

2 posts, 0 answers
  1. Andy
    Andy avatar
    11 posts
    Member since:
    Feb 2009

    Posted 24 Apr 2009 Link to this post

    Hi

    I think I'm seeing a regression in the current build with regards to the charts rendering performance. My example is mapping 24 data points on a line series. In the previous build I saw a slight freezing of the UI when initial rendering takes place (milliseconds although I never did any significant testing), now however I'm seeing a much longer freezing of the UI (nearly a second) while the chart is rendering which is causing a problem with my application as the users are constantly changing data and we wish for that to be immediately re-rendered on the chart but the UI freeze on the render makes it a difficult. I've got some test code below, if you press the refresh button you will see a noticiable freeze of the UI. 
    Any ideas, thoughts would be appreciated.

    Thanks
    Andy

    public partial class Page : UserControl 
        { 
            ObservableCollection<TestObject> testCollection; 
     
            public Page() 
            { 
                InitializeComponent(); 
                testCollection = new ObservableCollection<TestObject>(); 
     
                SeriesMapping SeriesMapping1 = new SeriesMapping(); 
                SeriesMapping1.ItemMappings.Add(new ItemMapping("Value", DataPointMember.YValue)); 
                SeriesMapping1.SeriesDefinition = new LineSeriesDefinition(); 
                testChart.SeriesMappings.Add(SeriesMapping1); 
                testChart.ItemsSource = testCollection
     
                DefineData();             
      
            } 
     
            private void DefineData() 
            { 
                testCollection.Clear(); 
                for (int i = 0; i < 23; i++) 
                { 
                    Random r = new Random(); 
                    testCollection.Add(new TestObject() { Value = r.Next(0, 20000) }); 
                } 
            } 
     
            public class TestObject 
            { 
                public double Value { get; set; } 
            } 
     
            private void Button_Click(object sender, RoutedEventArgs e) 
            { 
                DefineData(); 
            }  
        } 
     
    //xaml 
     
    <UserControl x:Class="TelerikChartPerf.Page" 
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"  
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"  
        xmlns:telerikChart="clr-namespace:Telerik.Windows.Controls.Charting;assembly=Telerik.Windows.Controls.Charting" 
        xmlns:telerikControls="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.Charting"
        <Grid x:Name="LayoutRoot" Background="White"
            <Grid.RowDefinitions> 
                <RowDefinition Height="300" /> 
                <RowDefinition Height="25" /> 
            </Grid.RowDefinitions> 
            <telerikControls:RadChart Grid.Row="0" Width="500" Height="300" x:Name="testChart" /> 
            <Button Content="refresh" Grid.Row="1" Click="Button_Click" /> 
        </Grid> 
    </UserControl> 
     
     

  2. Dwight
    Admin
    Dwight avatar
    475 posts

    Posted 27 Apr 2009 Link to this post

    Hello Andy,

    The issue comes from the fact, that on each update of the series, an invalidation of the chart is triggered. That includes invalidation of the X and Y ranges and the whole UI.

    To speed-up the update, please, try the following:
    private void DefineData()  
    {  
      testCollection.Clear();  
      // Suspend notifications to stop unnecessary updates. 
      testCollection.SuspendNotifications(); 
     
      for (int i = 0; i < 23; i++)  
      {  
         Random r = new Random();  
         testCollection.Add(new TestObject() { Value = r.Next(0, 20000) });  
      } 
      // Resume notifications (that will trigger updates if changes in the collection occured during the suspended notifications) 
      testCollection.ResumeNotifications(); 

    Best,
    Evtim
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
Back to Top