XAxis Sort order for line charts

5 posts, 0 answers
  1. Cuthahotha
    Cuthahotha avatar
    81 posts
    Member since:
    Sep 2008

    Posted 21 Jun 2010 Link to this post

    I have a line chart.  2 or more lines.  I need labels on the XAxis to display in decending order. (Counting down number of months to end of project.)  If I add in the xValue on the series the sort order happens ASC, despite adding to the data series in the order I want to values.

    I'm not using a data table, just add a series and add datapoints to the series. 

    In this example I am adding in the XValue. 

    I'd be fine just adding the yvalue data and and then adding labels in code if that works.  Just not sure how.

     

               LineSeriesDefinition lsd = new LineSeriesDefinition();  
     
                DataSeries ds1 = new DataSeries();  
                  
                ds1.LegendLabel = "Total";  
                ds1.Definition = lsd;  
     
                DataPoint dp1 = new DataPoint();  
                dp1.YValue = 23;  
                dp1.XValue = 12;  
                ds1.Add(dp1);  
     
                DataPoint dp2 = new DataPoint();  
                dp2.YValue = 22;  
                dp2.XValue = 11;  
                ds1.Add(dp2);  
     
                DataPoint dp3 = new DataPoint();  
                dp3.YValue = 22;  
                dp3.XValue = 10;  
                ds1.Add(dp3);  
     
                DataSeries ds2 = new DataSeries();  
                ds2.LegendLabel = "Remaining";  
                ds2.Definition = lsd;  
     
                DataPoint dp21 = new DataPoint();  
                dp21.YValue = 21;  
                dp21.XValue = 12;  
                ds2.Add(dp21);  
     
                DataPoint dp22 = new DataPoint();  
                dp22.YValue = 20;  
                dp22.XValue = 11;  
                ds2.Add(dp22);  
     
                DataPoint dp23 = new DataPoint();  
                dp23.YValue = 19;  
                dp23.XValue = 10;  
                ds2.Add(dp23);  
     
                ChartTitle ct = new ChartTitle();  
     
                RadChart1.DefaultView.ChartTitle.Background = (Brush)App.Current.Resources["Menu"];  
                RadChart1.DefaultView.ChartTitle.Content =  "Monthly report listing";  
                RadChart1.DefaultView.ChartArea.DataSeries.Add(ds1);  
                RadChart1.DefaultView.ChartArea.DataSeries.Add(ds2);  
               ChartSortDescriptor sort = new ChartSortDescriptor();     
        
                sort.Member = "XValue";     
                sort.SortDirection = System.ComponentModel.ListSortDirection.Descending;  
                RadChart1.SortDescriptors.Add(sort); 

     

     

  2. Cuthahotha
    Cuthahotha avatar
    81 posts
    Member since:
    Sep 2008

    Posted 21 Jun 2010 Link to this post

    Adding reply to bump post.  Code block format made a mess of things first time i tried it.
  3. DevCraft banner
  4. Velin
    Admin
    Velin avatar
    391 posts

    Posted 24 Jun 2010 Link to this post

    Hello Cuthahotha,

    Unfortunately, the X axis does not support ordering in descending mode. You could try to set-up categorical chart and add the data points in the order you want to appear on the screen.

    Hope this will help.
    All the best,
    Velin
    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
  5. Cuthahotha
    Cuthahotha avatar
    81 posts
    Member since:
    Sep 2008

    Posted 20 Jul 2010 Link to this post

    Thanks, I'll try it out.
  6. Cuthahotha
    Cuthahotha avatar
    81 posts
    Member since:
    Sep 2008

    Posted 20 Jul 2010 Link to this post

    Perfect, works exactly as I hoped.
Back to Top
DevCraft banner