This is a migrated thread and some comments may be shown as answers.

Labeling the RadCartesianChart Categorical axis

5 Answers 358 Views
Chart for XAML
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Tariq
Top achievements
Rank 2
Tariq asked on 11 Sep 2012, 07:17 AM

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

Sort by
0
Tsvyatko
Telerik team
answered on 12 Sep 2012, 02:07 PM
Hello Tareq,

 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.

Regards,
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.

0
Mop
Top achievements
Rank 1
answered on 15 Oct 2012, 02:04 PM
I think he has a bit different  problem.

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.
0
Tsvyatko
Telerik team
answered on 17 Oct 2012, 10:52 AM
Hello Mop,

 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.

All the best,
Tsvyatko
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Mop
Top achievements
Rank 1
answered on 18 Oct 2012, 02:39 PM
I have managed to make something like this:

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
0
Tsvyatko
Telerik team
answered on 23 Oct 2012, 08:57 AM
Hello Mop,

 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.

Greetings,
Tsvyatko
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Tags
Chart for XAML
Asked by
Tariq
Top achievements
Rank 2
Answers by
Tsvyatko
Telerik team
Mop
Top achievements
Rank 1
Share this question
or