Hello,
if I'm using multiple datasources. The datamember for AxisX is from type DateTime. If there are for example two series with following date values:
series 1:
series 2:
In this case the chart automatically sorts it like in the attached image. That causes a really ugly line (see also attached image) that is not suitible to what I want to have.
I tried to use a ChartSortDescriptor on each series that was not working:
If I am using a ChartSortDescriptor on the chart:
This also does not work.
How do I get this axis sorted? Maybe you could give me a hint.
Thanks in andvance!
Regards,
Julian
if I'm using multiple datasources. The datamember for AxisX is from type DateTime. If there are for example two series with following date values:
series 1:
- March 2011
- April 2011
- June 2011
- July 2011
- September 2011
series 2:
- January 2011
- February 2011
- March 2011
- April 2011
- June 2011
- July 2011
- September 2011
In this case the chart automatically sorts it like in the attached image. That causes a really ugly line (see also attached image) that is not suitible to what I want to have.
I tried to use a ChartSortDescriptor on each series that was not working:
private
void
CreateSeriesMappings()
{
SeriesMappingCollection mappingCollection =
new
SeriesMappingCollection();
for
(
int
i = 0; i < Data.Count; i++)
{
mappingCollection.Add(CreateNewSeriesMapping(i));
}
this
.SeriesMappings = mappingCollection;
}
private
static
SeriesMapping CreateNewSeriesMapping(
int
collectionIndex)
{
SeriesMapping series =
new
SeriesMapping
{
CollectionIndex = collectionIndex,
SeriesDefinition =
new
LineSeriesDefinition()
};
series.ItemMappings.Add(
new
ItemMapping(
"Date"
, DataPointMember.XCategory));
series.ItemMappings.Add(
new
ItemMapping(
"Value"
, DataPointMember.YValue));
series.GroupingSettings.ShouldFlattenSeries =
true
;
series.GroupingSettings.GroupDescriptors.Add(
new
ChartYearGroupDescriptor(
"Date"
));
series.SortDescriptors.Add(
new
ChartSortDescriptor(
"Date"
, ListSortDirection.Ascending));
return
series;
}
If I am using a ChartSortDescriptor on the chart:
<telerik:RadChart x:Name=
"Chart1"
ItemsSource=
"{Binding Data}"
>
<telerik:RadChart.SortDescriptors>
<telerik:ChartSortDescriptor Member=
"Date"
SortDirection=
"Ascending"
/>
</telerik:RadChart.SortDescriptors>
<telerik:RadChart.DefaultView>
<telerik:ChartDefaultView>
<telerik:ChartDefaultView.ChartLegend>
<telerik:ChartLegend Name=
"legend3"
/>
</telerik:ChartDefaultView.ChartLegend>
<telerik:ChartDefaultView.ChartArea>
<telerik:ChartArea LegendName=
"legend3"
>
<telerik:ChartArea.AxisX>
<telerik:AxisX x:Name=
"axisX"
DefaultLabelFormat=
"yyyy MMM"
LayoutMode=
"Between"
LabelRotationAngle=
"45"
/>
</telerik:ChartArea.AxisX>
<telerik:ChartArea.AxisY>
<telerik:AxisY ExtendDirection=
"Smart"
/>
</telerik:ChartArea.AxisY>
</telerik:ChartArea>
</telerik:ChartDefaultView.ChartArea>
</telerik:ChartDefaultView>
</telerik:RadChart.DefaultView>
</telerik:RadChart>
This also does not work.
How do I get this axis sorted? Maybe you could give me a hint.
Thanks in andvance!
Regards,
Julian