Hello,
I'm trying to label the Horizontal Categorical axis, so I'm doing this:
<
telerik:LineSeries
>
<
telerik:LineSeries.ValueBinding
>
<
telerik:PropertyNameDataPointBinding
PropertyName
=
"Score"
/>
</
telerik:LineSeries.ValueBinding
>
<
telerik:LineSeries.CategoryBinding
>
<
telerik:PropertyNameDataPointBinding
PropertyName
=
"TimeID"
/>
</
telerik:LineSeries.CategoryBinding
>
</
telerik:LineSeries
>
My Data Model includes (Score,TimeID, TimeString)
I want to use a TimeID (which is 1,2,3...etc) for the value, but I want to show instead TimeString (which is Q1 2012, Q2 2012, Q3 2013 ... etc) .
I tried to use the "CategoricalAxis.LabelTemplate" but it looks like it doesn't accept other than Empty Binding...
5 Answers, 1 is accepted
Based on description of your case I assume that you are trying to display Cartesian chart with line series that displays certain score for each Q. If this is the case you would probably can go with properties in the datamodel Score and TimeString (since the Score will supply the vertical "Value" axis and TimeString will supply the horizontal "Categorical" axis). I have prepared simple example demonstrating how to achieve this.
Let us know if this is the desired result. If not can you ebalorate a bit more on how the expected result should look like.
Tsvyatko
the Telerik team
Time to cast your vote for Telerik! Tell DevPro Connections and Windows IT Pro why Telerik is your choice. Telerik is nominated in a total of 25 categories.

He's got values like :
Score: 4 TimeId: 1 Timestring:Q1
Score: 2 TimeId: 2 Timestring:Q1
Score: 2 TimeId: 3 Timestring:Q1
Score: 1 TimeId: 4 Timestring:Q2
Score: 6 TimeId: 5 Timestring:Q2
Score: 8 TimeId: 6 Timestring:Q2
And rather to have every point labeled with TimeId he would like to see Q1 2012 for the first three Scores and Q2 for another 3 Scores.
I've got similiar problem with dates. Got 5-10 points in one month and everyone is labeled with dd-MM-yyyy. The chart got 100 points and each label overrides other so You can't see date.
First, lets look into the immediate problem - the overlapping of the labels. Axes labels support label fit mode that allows them to fit in the available space - using axis property FitMode of type LabelFitMode. In addition you can customize the label format to show only part of the date (if the scenario allows it).
Regarding the scenario you are describing - using axis customization to achieve behavior closer to described one, however this will not work in the general cases (and thus I would not recomend going in this direction).
Nevertheless, I will log this as feature request and we will consider implementing such feature in our control.
I have also updated your points accordingly.
Tsvyatko
the Telerik team
Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

XAML:
<
DataTemplate
x:Key
=
"customLabelTemplate"
>
<
TextBlock
Text
=
"{Binding Converter={StaticResource dateToGroupQuatersConverter}}"
/>
</
DataTemplate
>
<
telerik:RadCartesianChart.HorizontalAxis
>
<
telerik:CategoricalAxis
LabelTemplate
=
"{StaticResource customLabelTemplate}"
/>
</
telerik:RadCartesianChart.HorizontalAxis
>
And .cs
public
class
DateToGroupQuatersConverter : IValueConverter
{
static
int
temp = 0;
static
string
prevDate =
""
;
public
object
Convert(
object
value, Type targetType,
object
parameter,
string
language)
{
string
quoter =
""
;
var valueDt = (DateTime)value;
switch
(valueDt.Month)
{
case
1: quoter =
"Q1"
;
break
;
case
2: quoter =
"Q1"
;
break
;
case
3: quoter =
"Q1"
;
break
;
case
4: quoter =
"Q2"
;
break
;
case
5: quoter =
"Q2"
;
break
;
case
6: quoter =
"Q2"
;
break
;
case
7: quoter =
"Q3"
;
break
;
case
8: quoter =
"Q3"
;
break
;
case
9: quoter =
"Q3"
;
break
;
case
10: quoter =
"Q4"
;
break
;
case
11: quoter =
"Q4"
;
break
;
case
12: quoter =
"Q4"
;
break
;
default
:
break
;
}
var monthYear = quoter +
"-"
+ valueDt.Year;
// 1-2012 1-2013
if
(prevDate == monthYear)
{
return
""
;
}
prevDate = monthYear;
return
quoter;
}
}
Still it is not what i wanted. I would like to se quoters at the center of the chart, rather on the beginning. (something with converter parameter? could it be bound to something?)
Also is there a way to color line chart with different colors? Like from Q1 to Q2 Green, Q2 to Q3 yellow ?
Prev and result
http://i46.tinypic.com/33p6ow1.png
Unfortunately, there is no reliable way to position the axes label and group the repeating ones in the current version.
Regarding the coloring of the series you can apply deferent styles on the points or bar (in case of bar series) using series PointTemplateSelector. However, currently there is no option to display line series with different colored segments. Nevertheless, we are considering adding this feature in our future versions.
Tsvyatko
the Telerik team
Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.