This question is locked. New answers and comments are not allowed.
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.
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); |