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

Categorical binding problem

2 Answers 68 Views
ChartView
This is a migrated thread and some comments may be shown as answers.
srikanth
Top achievements
Rank 1
srikanth asked on 21 May 2013, 09:54 AM
Hello!

I have the problem with binding to the CategoryBinding property.
I have this code:

                <telerik1:BarSeries CategoryBinding="HourName"
                                    ItemsSource="{Binding ChartData}"
                                    ValueBinding="Value"
                                    />

Chart Data has the values for X and Y axises. I need to show datas which represent each day of week per hour, and in one case it must be data per week

so i need to present sunday, monday ..... and whole week.

in my ChartData i put datas apropriately to my needs :

for day of week :
1 2 3 4 5 ... 24  --- CategoricalBinding
4 5 6 7 3 ... 221 --- Some Garbage datas

and for whole week i need have something like this :
1 2 3 4 ... 24 1 2 3 ... 24 1 2 3 ... 24 ..... 24 -CategoricalBinding for whole week this means 168 categories ( 7*24 hours)
2 1 1 1 ................... Some Garbage datas


But chart don't want to display whole week like 168 categories ( 7*24 hours), it just display 24 categories with united data.

What should i do? Could you help me please?

Thanks and Regards!

2 Answers, 1 is accepted

Sort by
0
Accepted
Rosko
Telerik team
answered on 24 May 2013, 08:39 AM
Hello Srikanth,

From the described scenario, we conclude that you are using a CategoricalAxis and HourName is a string. So, you have 7 times "1", "2" and etc. The chard identifies them as the same category and that is why you will have 7 bars and 1 , 2 and so on.

To solve the problem you need to use DateTime value for the CategoryBinding and a DateTimeCategoricalAxis. Respectively, you can set a LabelFormat of your preference. For Instance you can set it so that it shows only the hour of the day, and the day.

<telerik:RadCartesianChart.HorizontalAxis>
   <telerik:DateTimeCategoricalAxis LabelInterval="12" LabelFormat="HH:mm ddd"/>
</telerik:RadCartesianChart.HorizontalAxis>


Regards, Rosko
Telerik

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
srikanth
Top achievements
Rank 1
answered on 03 Jun 2013, 03:00 PM
Hello!
Your solution has solve my issue, but i have some useless data as year month and other.
But in general it works, Thanks!
Tags
ChartView
Asked by
srikanth
Top achievements
Rank 1
Answers by
Rosko
Telerik team
srikanth
Top achievements
Rank 1
Share this question
or