Sorting SeriesMapping ?

8 posts, 0 answers
  1. Ludovic Gerbault
    Ludovic Gerbault avatar
    226 posts
    Member since:
    Apr 2009

    Posted 30 Dec 2009 Link to this post

    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 ?


  2. Ludovic Gerbault
    Ludovic Gerbault avatar
    226 posts
    Member since:
    Apr 2009

    Posted 30 Dec 2009 Link to this post

    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
  3. DevCraft banner
  4. Ludovic Gerbault
    Ludovic Gerbault avatar
    226 posts
    Member since:
    Apr 2009

    Posted 05 Jan 2010 Link to this post

    Guys, I really need help on this one, please.
  5. Vladimir Milev
    Admin
    Vladimir Milev avatar
    1061 posts

    Posted 05 Jan 2010 Link to this post

    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.
  6. Ludovic Gerbault
    Ludovic Gerbault avatar
    226 posts
    Member since:
    Apr 2009

    Posted 05 Jan 2010 Link to this post

    Yes indeed, I'm trying to sort the legend and the x-axis

    Do you have any (even approximate) release date for such functionnality ?
  7. Vladimir Milev
    Admin
    Vladimir Milev avatar
    1061 posts

    Posted 07 Jan 2010 Link to this post

    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.
  8. Ludovic Gerbault
    Ludovic Gerbault avatar
    226 posts
    Member since:
    Apr 2009

    Posted 07 Jan 2010 Link to this post

    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.
  9. Vladimir Milev
    Admin
    Vladimir Milev avatar
    1061 posts

    Posted 12 Jan 2010 Link to this post

    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.
Back to Top
DevCraft banner