This is a migrated thread and some comments may be shown as answers.
Sorting SeriesMapping ?
7 Answers 63 Views
This is a migrated thread and some comments may be shown as answers.
Ludovic Gerbault
Top achievements
Rank 1
Ludovic Gerbault asked on 30 Dec 2009, 03:50 PM
Is it possible to sort the itemmapping of the radchart in the ChartAggregate Example ?

Cause I have a chart bound to a collection of datarows (I'm using the latest version of the lightweight datatable for silverlight)

I can't bind the chart itemsource directly to the grid itemsource because I have some code inbetween used when the grid is being filtered (so that the chart data is filtered as well)

The thing is, the order the series are appearing is the order in the source collection.

I've tried to write a method to compare two datarows :

 public class DataRowComparer : IComparer<DataRow> 
    { 
        private String member = "r_mois"
        public DataRowComparer() 
        { 
            this.member = "r_mois"
        } 
 
        public DataRowComparer(String member) 
        { 
            this.member = member; 
        } 
        public int Compare(DataRow x, DataRow y) 
        { 
            int retour = 0; 
            if (x.ContainsKey(member)) 
            { 
                int mois1 = Convert.ToInt32(x[member]); 
                int mois2 = Convert.ToInt32(y[member]); 
 
                if (mois1 == mois2) 
                { 
                    retour = 0; 
                } 
                else 
                { 
                    if (mois1 > mois2) 
                    { 
                        retour = 1; 
                    } 
                    else 
                    { 
                        if (mois1 < mois2) 
                        { 
                            retour = -1; 
                        } 
                    } 
                } 
            } 
            return retour; 
        } 
    } 

In my scenario, when I group the column, I memorize the GroupDescriptor member, and then use it in the BindChart method like this :

collectionGraph.Rows.Sort(new DataRowComparer(member)); 

Works like a charm the first time, but I don't seem to be able to handle two sort at once (year in X-Axis and month in LegendLabel for example)

It's really bothering me, because the chart can't be used until it's properly sorted.

Does anyone has a though about how to sort a chart ?


7 Answers, 1 is accepted

Sort by
0
Ludovic Gerbault
Top achievements
Rank 1
answered on 30 Dec 2009, 05:02 PM
In addition to that, I must say that the DataTable collectionGraph is properly sorted in debug mode, but it doesn't change the sorting of the chart.

And to reset the graph, I set the itemsource to null and I clear DefaultView.ChartArea.DataSeries
0
Ludovic Gerbault
Top achievements
Rank 1
answered on 05 Jan 2010, 09:13 AM
Guys, I really need help on this one, please.
0
Vladimir Milev
Telerik team
answered on 05 Jan 2010, 09:41 AM
Hi Subileau Pascal,

Are you trying to sort the legend items? If so that is unsupported at present.

The good news is that we are currently working on adding Sort and Filter descriptors for the chart which will allow you to sort your data when data binding out of the box.

Sincerely yours,
Vladimir Milev
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Ludovic Gerbault
Top achievements
Rank 1
answered on 05 Jan 2010, 09:50 AM
Yes indeed, I'm trying to sort the legend and the x-axis

Do you have any (even approximate) release date for such functionnality ?
0
Vladimir Milev
Telerik team
answered on 07 Jan 2010, 03:42 PM
Hi Subileau Pascal,

Legend items are always in the same order as the series. If you reorder the series you will reorder the legend items. SortDescriptors will allow you to reoder DataPoints within a DataSeries. DataSeries order is dependent on the order of your SeriesMappings if you use data binding or the order you add them to the ChartArea.DataSeries collection.

Regards,
Vladimir Milev
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Ludovic Gerbault
Top achievements
Rank 1
answered on 07 Jan 2010, 04:17 PM
That's exactly what I thought and what I've been trying to achieve.

I can see my source collection (lightweight datatable in the order I want it to be, but the RadChart only use that the very first I set its item source.

For exemple, if I want a column Month to go from 1 to 12 at first, the graph displays it from 1 to 12 in the legend.

If then I try to change that order, the changes are just being ignorded.


The last thing is that I can't seem to be able to have for exemple Months from 1 to 12 in the legend, and (with grouping), years from 2007 to 2010 on the X axis.

One of them (or both), is always unsorted.
0
Vladimir Milev
Telerik team
answered on 12 Jan 2010, 09:36 AM
Hello Subileau Pascal,

SortDescriptors will allow you to sort the data within a data series, not sort data series within the data series collection. However, due to the specifics of the underlying data engine used, if you are performing grouping and aggregation your series will be generated from the sorted data and will be sorted according to the sort descriptor.

Unfortunately, you will need to wait until the Q1 release in order to be able to use these new features still under development.

All the best,
Vladimir Milev
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Tags
Chart
Asked by
Ludovic Gerbault
Top achievements
Rank 1
Answers by
Ludovic Gerbault
Top achievements
Rank 1
Vladimir Milev
Telerik team
Share this question
or