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

ChartAnnotationLabelDefinition ignore when using ChartAnnotationsProvider

2 Answers 173 Views
ChartView
This is a migrated thread and some comments may be shown as answers.
Florent
Top achievements
Rank 1
Florent asked on 17 May 2017, 03:07 PM

Hello,

I try to customize Label for Cartesian grid line annotation.
In the context of ChartAnnotationsProvider the ChartAnnotationLabelDefinition  seams ignored...

For instance, neither the label is red, neither the offsets are applied.

<telerik:RadCartesianChart  x:Name="Chart">
             <telerik:RadCartesianChart.HorizontalAxis>
               <telerik:LinearAxis  Minimum="{Binding MinX}" Maximum="{Binding MaxX}" TickOrigin="0" x:Name="HorizAxis"/>
           </telerik:RadCartesianChart.HorizontalAxis>
           <telerik:RadCartesianChart.VerticalAxis >
               <telerik:LinearAxis Minimum="{Binding MinY}" Maximum="{Binding MaxY}" LabelFormat="n1" />
           </telerik:RadCartesianChart.VerticalAxis>
                           <telerik:RadCartesianChart.Series>
               <!-- ... -->
           </telerik:RadCartesianChart.Series>
           <telerik:RadCartesianChart.AnnotationsProvider>
               <telerik:ChartAnnotationsProvider Source="{Binding ListeAnnotations}">
                   <telerik:ChartAnnotationDescriptor>
                       <telerik:ChartAnnotationDescriptor.Style>
                           <Style TargetType="telerik:CartesianGridLineAnnotation" BasedOn="{StaticResource CartesianGridLineAnnotationStyle}">
                               <Setter Property="Axis" Value="{Binding ElementName=HorizAxis}" />
                               <Setter Property="Value" Value="{Binding Item1}" />
                               <Setter Property="Label" Value="{Binding Item2}" />
                               <Setter Property="LabelDefinition">
                                   <Setter.Value>
                                       <telerik:ChartAnnotationLabelDefinition Location="Inside" VerticalAlignment="Top" HorizontalOffset="-50"  VerticalOffset="-150">
                                           <telerik:ChartAnnotationLabelDefinition.DefaultVisualStyle>
                                               <Style TargetType="TextBlock" BasedOn="{StaticResource TextBoxStyle}">
                                                   <Setter Property="Foreground" Value="Red"></Setter>
                                               </Style>
                                           </telerik:ChartAnnotationLabelDefinition.DefaultVisualStyle>
                                       </telerik:ChartAnnotationLabelDefinition>
                                   </Setter.Value>
                               </Setter>
                               <Setter Property="StrokeThickness" Value="0.3"/>
                               <Setter Property="DashArray" Value="24 8"/>
                               <Setter Property="Stroke" Value="Green"/>
                           </Style>
                       </telerik:ChartAnnotationDescriptor.Style>
                   </telerik:ChartAnnotationDescriptor>
               </telerik:ChartAnnotationsProvider>
 
           </telerik:RadCartesianChart.AnnotationsProvider>
 
       </telerik:RadCartesianChart>

2 Answers, 1 is accepted

Sort by
0
Florent
Top achievements
Rank 1
answered on 18 May 2017, 07:56 AM

To be more accurate, I try to replace the following annotations definition :

<telerik:RadCartesianChart.Annotations>
             <telerik:CartesianGridLineAnnotation Value="60" Stroke="Red" Label="PK60.0" StrokeThickness="1"
                                                  Axis="{Binding ElementName=HorizAxis}" LabelDefinition="{StaticResource MyLabelDefinition}"/>
             <telerik:CartesianGridLineAnnotation Value="260" Stroke="Red" Label="PK260.0" StrokeThickness="1"
                                                  Axis="{Binding ElementName=HorizAxis}" LabelDefinition="{StaticResource MyLabelDefinition}"/>
         </telerik:RadCartesianChart.Annotations>

By this follwing one. Althought the annotations are displayed, my LabelDefinition is ignored

<telerik:RadCartesianChart.AnnotationsProvider>
                <telerik:ChartAnnotationsProvider Source="{Binding AnnotationsList}">
                    <telerik:ChartAnnotationDescriptor>
                        <telerik:ChartAnnotationDescriptor.Style>
                            <Style TargetType="telerik:CartesianGridLineAnnotation" BasedOn="{StaticResource CartesianGridLineAnnotationStyle}">
                                <Setter Property="Axis" Value="{Binding ElementName=HorizAxis2}" />
                                <Setter Property="Value" Value="{Binding Item1}" />
                                <Setter Property="Label" Value="{Binding Item2}" />
                                <Setter Property="LabelDefinition" Value="{StaticResource MyLabelDefinition}"/>
                                <Setter Property="StrokeThickness" Value="1"/>
                                <Setter Property="Stroke" Value="Red"/>
                            </Style>
                        </telerik:ChartAnnotationDescriptor.Style>
                    </telerik:ChartAnnotationDescriptor>
                </telerik:ChartAnnotationsProvider>
 
            </telerik:RadCartesianChart.AnnotationsProvider>
0
Dinko | Tech Support Engineer
Telerik team
answered on 22 May 2017, 12:43 PM
Hello Florent,

Thank you for contacting us.

There is an issue with the LabelDefinition property of the CartesianGridLineAnnotation when you try to set it in style. You can take a look at this forum thread where a workaround was suggested.

Regards,
Dinko
Telerik by Progress
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 you to write beautiful native mobile apps using a single shared C# codebase.
Tags
ChartView
Asked by
Florent
Top achievements
Rank 1
Answers by
Florent
Top achievements
Rank 1
Dinko | Tech Support Engineer
Telerik team
Share this question
or