Hello.
I need to implement a chart with vertical lines and labels, as I understand it can be implemented using annotations.
As I can see from examples, it should look lile this:
But information for annotations I get from ViewModel. And I don't see a way how to bind my collections from ViewModel to Annotations collection. Is it possible? I mean something like this:
I found a workaround, to add annotations in a code-behind class of the view:
But seems it is not a true way.
Best regards,
Dimitr
I need to implement a chart with vertical lines and labels, as I understand it can be implemented using annotations.
As I can see from examples, it should look lile this:
<
telerik:RadCartesianChart.Annotations
>
<
telerik:CartesianGridLineAnnotation
Axis
=
"{Binding ElementName=horizontalAxis}"
Value
=
"3000"
Label
=
"label1"
>
<
telerik:CartesianGridLineAnnotation.LabelDefinition
>
<
telerik:ChartAnnotationLabelDefinition
Location
=
"Right"
VerticalAlignment
=
"Top"
HorizontalOffset
=
"4"
DefaultVisualStyle
=
"{StaticResource annotationLabelStyle}"
>
</
telerik:ChartAnnotationLabelDefinition
>
</
telerik:CartesianGridLineAnnotation.LabelDefinition
>
</
telerik:CartesianGridLineAnnotation
>
<
telerik:CartesianGridLineAnnotation
Axis
=
"{Binding ElementName=horizontalAxis}"
Value
=
"3200"
Label
=
"label2"
>
<
telerik:CartesianGridLineAnnotation.LabelDefinition
>
<
telerik:ChartAnnotationLabelDefinition
Location
=
"Right"
VerticalAlignment
=
"Top"
HorizontalOffset
=
"4"
DefaultVisualStyle
=
"{StaticResource annotationLabelStyle}"
>
</
telerik:ChartAnnotationLabelDefinition
>
</
telerik:CartesianGridLineAnnotation.LabelDefinition
>
</
telerik:CartesianGridLineAnnotation
>
</
telerik:RadCartesianChart.Annotations
>
But information for annotations I get from ViewModel. And I don't see a way how to bind my collections from ViewModel to Annotations collection. Is it possible? I mean something like this:
<
telerik:AnnotationSeries
ItemsSource
=
"{Binding AnnotationsItems}"
/>
I found a workaround, to add annotations in a code-behind class of the view:
foreach
(var item
in
ViewModel.AnnotationsItems)
{
Chart1.Annotations.Add(
new
CartesianGridLineAnnotation { Label = item.Name, Value = item .Coordinate, Axis = Chart1.HorizontalAxis });
}
Best regards,
Dimitr