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

XAxis Sort order for line charts

4 Answers 60 Views
Chart
This is a migrated thread and some comments may be shown as answers.
Cuthahotha
Top achievements
Rank 1
Cuthahotha asked on 21 Jun 2010, 02:42 PM
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); 

 

 

4 Answers, 1 is accepted

Sort by
0
Cuthahotha
Top achievements
Rank 1
answered on 21 Jun 2010, 02:44 PM
Adding reply to bump post.  Code block format made a mess of things first time i tried it.
0
Velin
Telerik team
answered on 24 Jun 2010, 02:14 PM
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
0
Cuthahotha
Top achievements
Rank 1
answered on 20 Jul 2010, 02:35 PM
Thanks, I'll try it out.
0
Cuthahotha
Top achievements
Rank 1
answered on 21 Jul 2010, 03:27 AM
Perfect, works exactly as I hoped.
Tags
Chart
Asked by
Cuthahotha
Top achievements
Rank 1
Answers by
Cuthahotha
Top achievements
Rank 1
Velin
Telerik team
Share this question
or