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 :
In my scenario, when I group the column, I memorize the GroupDescriptor member, and then use it in the BindChart method like this :
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 ?
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 ?