Categorical binding problem

3 posts, 1 answers
  1. srikanth
    srikanth avatar
    23 posts
    Member since:
    Jul 2012

    Posted 21 May 2013 Link to this post


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

                    <telerik1:BarSeries CategoryBinding="HourName"
                                        ItemsSource="{Binding ChartData}"

    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. Answer
    Rosko avatar
    137 posts

    Posted 24 May 2013 Link to this post

    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:DateTimeCategoricalAxis LabelInterval="12" LabelFormat="HH:mm ddd"/>

    Regards, Rosko

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

  3. srikanth
    srikanth avatar
    23 posts
    Member since:
    Jul 2012

    Posted 03 Jun 2013 Link to this post

    Your solution has solve my issue, but i have some useless data as year month and other.
    But in general it works, Thanks!
Back to Top