RadChart X-Axis not Synchronized with RadTimeBar ViewPort

3 posts, 0 answers
  1. Twinkle
    Twinkle avatar
    4 posts
    Member since:
    Jun 2013

    Posted 19 Jan 2014 Link to this post

    The Telerik Team.

    I need RadChart inside the RadTimeBar instead of RadSparkline. I have attached screen shots and my dummy implementation  with this thread. The viewport of the RadTimeBar not property matching with the chart's X-Axis.
    Main issue:
    1. The last hour of Time Bar not matching with chart ( more cleared in screen shot named showing12hronchart.jpg)
    2. for more then 1 days also ( see screen shot formorethen1days-2ndimagefor11pm.png)

    please note i only need to show hourly data.

    <Grid x:Name="LayoutRoot" Background="White">
           <telerik:RadTimeBar Name="timeBar1" Grid.Row="1"  Width="1200" Height="200"
                         PeriodStart="2011-01-01" PeriodEnd="2011-01-03" <!-- please change to one day -->
               <Grid Margin="0,10,0, 10">
                   <telerik:RadChart ItemsSource="{Binding Items}" >
                                   <telerik:ChartLegend Visibility="Collapsed"></telerik:ChartLegend>
                                   <telerik:ChartArea Margin="0 0 0 0" Padding="0 0 0 0">
                                           <telerik:AxisY Visibility="Collapsed" />
                                           <telerik:AxisX DefaultLabelFormat="hh" />
                                   <telerik:BarSeriesDefinition  />
                                   <telerik:ItemMapping FieldName="DateTimeStamp" DataPointMember="XValue" />
                                   <telerik:ItemMapping FieldName="Data" DataPointMember="YValue" />

    namespace timebar
        public partial class MainPage : UserControl
            public MainPage()
                this.DataContext = this;
            public List<Item> Items
                    List<Item> items = new List<Item>();
                    Random r = new Random();
                    for (DateTime date = timeBar1.PeriodStart; date < timeBar1.PeriodEnd; date = date.AddHours(1))
                        items.Add(new Item() { Data = r.Next(10, 100), DateTimeStamp = date });
                    return items;
        public class Item
            public int Data
            public DateTime DateTimeStamp

    Twinkle Bhumra
  2. Tsvetie
    Tsvetie avatar
    1517 posts

    Posted 22 Jan 2014 Link to this post

    Hello Twinkle Bhumra,

    In order to make sure that the axis of the chart matches the axis of the timeBar control, you need to manually synchronize them. In order to do so, you can use the AutoRange, Step, MinValue, MaxValue properties of the chart axis.

    For example:
    <telerik:AxisX x:Name="HorizontalAxis" DefaultLabelFormat="hh"
        Step="{Binding CurrentItemInterval, ElementName=timeBar1, Converter={StaticResource timeConverter}}"
        MinValue="{Binding PeriodStart, ElementName=timeBar1, Converter={StaticResource dateConverter}, ConverterParameter=0}"
        MaxValue="{Binding PeriodEnd, ElementName=timeBar1, Converter={StaticResource dateConverter}, ConverterParameter=-1}"/>

    I have attached my test code for your reference.

    Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
    Sign up for Free application insights >>
  3. Twinkle
    Twinkle avatar
    4 posts
    Member since:
    Jun 2013

    Posted 30 Jan 2014 in reply to Tsvetie Link to this post

    Thanks for your support.
Back to Top