Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
79
XamTimeline: display both date AND time on DateTimeAxis
posted

Hi

I have this XamTimeline

<ig:XamTimeline x:Name="MyTimeLine" Grid.Row="1">
            <ig:XamTimeline.Axis>
                <ig:DateTimeAxis Minimum="01/01/10"
                                 AutoRange="False"
                                 Maximum="01/30/10"
                                 ShowLabels="True"
                                 ShowMajorTickMarks="True"
                                 ShowMinorTickMarks="True"
                                 UnitType="Hours"
                                 ShowThumb="True">
                </ig:DateTimeAxis>
            </ig:XamTimeline.Axis>
 </ig:XamTimeline>

I want it to display both date AND time based on the zoom resolution but it seems that the "resolution" is calculated based on the DateTimeAxis range therefore it displays date OR time

Thx

Parents
  • 17605
    posted

    Hi,

    You can format the date time labels with:

          <Style x:Key="labelStyle" TargetType="ig:AxisLabel">

                 <Setter Property="StringFormat" Value="{}{0:f}" />

          </Style>

    <ig:XamTimeline.Axis>

                    <ig:DateTimeAxis  Minimum="01/01/2012"

                                      Maximum="04/01/2013"

                                      LabelStyle="{StaticResource labelStyle}"

                                      AutoRange="False"

                                      Unit="1"/>

                </ig:XamTimeline.Axis>

     

    More info you can find:

     

    http://help.infragistics.com/NetAdvantage/DV/2010.3/CLR4.0/?page=SL_DV_xamWebTimeline_Format_DateTime_Values.html

     

     

Reply
  • 79
    Suggested Answer
    posted in reply to Teodor Taushanov

    Thanks for your fast reply but what I need is different

    I need to "adapt" the UnitType and Unit by the XamTimeLine.DateTimeAxis VisibleMinimum and VisibleMaximum. Something like that:

     

    or

     

    so the user will see both the days and the hours, and not like the default that display hours without indication of days

     

    So is there a way to do it automatically through XAML or do i need to in the code :

     

            void Zoombar_ZoomChanged(object sender, Infragistics.Controls.ZoomChangedEventArgs e)
            {
                TimeSpan diff = (((DateTimeAxis)MyTimeLine.Axis).VisibleMaximum - ((DateTimeAxis)MyTimeLine.Axis).VisibleMinimum);
                SetResolution(diff);
            }

            private void SetResolution(TimeSpan diff)
            {
                DateTimeAxis axis = MyTimeLine.Axis as DateTimeAxis;
                if (axis == null)
                    return;

                _monthSeries.Entries.Clear();
                _daySeries.Entries.Clear();

                if (diff.Hours < 24)
                {
                    axis.UnitType = DateTimeUnitType.Minutes;
                    axis.Unit = 1;
                }
                if (diff.Days < 4)
                {
                    axis.UnitType = DateTimeUnitType.Hours;
                    axis.Unit = 1;
                    var days = GetDays(axis.VisibleMinimum , axis.VisibleMaximum);
                    SetDaysSeries(days);
                }
                else if (diff.Days > 4 && diff.Days < 30)
                {
                    axis.UnitType = DateTimeUnitType.Days;
                    axis.Unit = 1;
                }
                else
                {
                    axis.UnitType = DateTimeUnitType.Months;
                    axis.Unit = 1;
                    var months = GetMonths(axis.VisibleMinimum , axis.VisibleMaximum);
                    SetMonthSeries(months);
                }
            }

Children