CategoricalAxis, LabelFormat and LabelTemplateSelector problem

2 posts, 0 answers
  1. Jonathan
    Jonathan avatar
    3 posts
    Member since:
    Jul 2016

    Posted 09 Jun Link to this post

    Hello,

    I have a problem with the horizontal axis of my RadCartesianChar when I change the period of my statistics:

    <telerik:RadCartesianChart x:Name="Chart"
                               TrackBallInfoStyle="{StaticResource ResourceKey=TrackBallInfoStyle}"
                               TrackBallLineStyle="{StaticResource ResourceKey=TransparentTrackLineStyle}"
                               helpers:ChartViewUtilities.ChartAlignmentGroup="g1">
      
        <telerik:RadCartesianChart.Resources>
            <DataTemplate x:Key="NormalTemplate">
                <TextBlock Text="{Binding}"
                           Padding="2"/>
            </DataTemplate>
            <DataTemplate x:Key="TodayTemplate">
                <Border BorderThickness="1" BorderBrush="Black">
                    <TextBlock Text="{Binding}"
                               Padding="2"/>
                </Border>
            </DataTemplate>
            <DataTemplate x:Key="HolidayTemplate">
                <TextBlock Text="{Binding}"
                           FontWeight="Bold"
                           Foreground="Red"
                           Padding="2"/>
            </DataTemplate>
            <DataTemplate x:Key="WeekendTemplate">
                <TextBlock Text="{Binding}"
                           FontWeight="Bold"
                           Foreground="Black"
                           Padding="2"/>
            </DataTemplate>
      
            <selectors:DateTypeTemplateSelector x:Key="Selector"
                                                NormalTemplate="{StaticResource NormalTemplate}"
                                                TodayTemplate="{StaticResource TodayTemplate}"
                                                HolidayTemplate="{StaticResource HolidayTemplate}"
                                                WeekendTemplate="{StaticResource WeekendTemplate}"/>
        </telerik:RadCartesianChart.Resources>
      
        <telerik:RadCartesianChart.Behaviors>
            <telerik:ChartTrackBallBehavior ShowTrackInfo="True"
                                            helpers:ChartViewUtilities.ShouldPositionTrackBallCloseToDataPoint="True"
                                            helpers:ChartViewUtilities.TrackedPointFill="{StaticResource IsMouseOverNeutralValueBrush}"
                                            helpers:ChartViewUtilities.TrackBallGroup="g1"
                                            TrackInfoUpdated="ChartTrackBallBehavior_TrackInfoUpdated"/>
        </telerik:RadCartesianChart.Behaviors>
      
        <telerik:RadCartesianChart.Grid>
            <telerik:CartesianChartGrid MajorLinesVisibility="Y" />
        </telerik:RadCartesianChart.Grid>
      
        <telerik:RadCartesianChart.HorizontalAxis>
            <telerik:DateTimeCategoricalAxis LabelFormat="dd"
                                             LabelTemplateSelector="{StaticResource Selector}"/>
        </telerik:RadCartesianChart.HorizontalAxis>
      
        <telerik:RadCartesianChart.VerticalAxis>
            <telerik:LinearAxis SmartLabelsMode="SmartStepAndRange" MajorStep="1" />
        </telerik:RadCartesianChart.VerticalAxis>
      
        <telerik:BarSeries ItemsSource="{Binding SeaDailyStats}"
                           CategoryBinding="DateAction"
                           ValueBinding="NbAction"
                           CombineMode="Stack"
                           helpers:ChartAnimationUtilities.CartesianAnimation="Rise">
      
            <telerik:BarSeries.TrackBallInfoTemplate>
                <DataTemplate>
                    <Border>
                        <StackPanel Orientation="Horizontal">
                            <TextBlock Text="{Binding DisplayContent, StringFormat='Mise(s) en ligne : {0}'}" />
                        </StackPanel>
                    </Border>
                </DataTemplate>
            </telerik:BarSeries.TrackBallInfoTemplate>
      
            <telerik:BarSeries.DefaultVisualStyle>
                <Style TargetType="{x:Type Border}">
                    <Setter Property="Background" Value="{StaticResource NeutralValueBrush}"/>
                </Style>
            </telerik:BarSeries.DefaultVisualStyle>
        </telerik:BarSeries>
      
        <telerik:BarSeries ItemsSource="{Binding SeaDailyStats}"
                           CategoryBinding="DateAction"
                           ValueBinding="Target"
                           CombineMode="Stack"
                           helpers:ChartAnimationUtilities.CartesianAnimation="Rise">
      
            <telerik:BarSeries.TrackBallInfoTemplate>
                <DataTemplate />
            </telerik:BarSeries.TrackBallInfoTemplate>
      
            <telerik:BarSeries.DefaultVisualStyle>
                <Style TargetType="Border">
                    <Setter Property="Background" Value="{StaticResource BadValueBrush}"/>
                </Style>
            </telerik:BarSeries.DefaultVisualStyle>
      
        </telerik:BarSeries>
    </telerik:RadCartesianChart>

     

    The period is a complete month but I display only the day (dd) on horizontal axis.

    The template selector allow me to display differently the type of day (normal, today, week end, holiday).

    The first month all is correct but when I change the month, the SelectTemplate method of DateTypeTemplateSelector is not call again. So the template don't change with the new axis value of the month.

    But if I display not only the day (dd) but the complete day (dd/MM/yyyy) on LabelFormat all works fine.

    So I think that the SelectTemplate method of DateTypeTemplateSelector is call only when the displayed value is different.
    But me I need o display only the day (dd).

    Can you help me please. Thank you in advance and sorry for my bad English.

    Kind regards,

    Jonathan

  2. Dinko
    Admin
    Dinko avatar
    460 posts

    Posted 14 Jun Link to this post

    Hello Jonathan,

    This ticket seems to be a duplicate of the one with ID 1113639. We have already answered your questions in the other thread. Here is the link to the forum thread.

    Regards,
    Dinko
    Progress Telerik
    Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.
Back to Top