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

Binding Annotations collection to some items collection

5 Answers 235 Views
ChartView
This is a migrated thread and some comments may be shown as answers.
Intecom
Top achievements
Rank 1
Intecom asked on 21 Aug 2013, 11:55 AM
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:
<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 });
}
But seems it is not a true way.


Best regards,
Dimitr


5 Answers, 1 is accepted

Sort by
0
Accepted
Peshito
Telerik team
answered on 26 Aug 2013, 10:47 AM
Hello,

I am happy that you have found a workaround.

You are right that the annotations does not have an ItemsSource property. We are aware of this limitation and we will consider an improvement for the future.

Regards,
Peshito
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WPF.
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 >>
0
Wouter
Top achievements
Rank 1
answered on 07 Feb 2014, 11:59 AM
Is this something that is evaluated for a possible future release? It would be nice to cut down on code behind.
0
Accepted
Peshito
Telerik team
answered on 11 Feb 2014, 01:03 PM
Hello,

We have this feature logged in as a feature request. Our latest official release is coming out soon and we will be making our road map for the next one really soon, so this feature will be considered for a possible implementation. I however cannot commit for a specific time frame when or will it be included in the next release. You can comment and vote for the feature in order to increase its priority here.

Regards,
Peshito
Telerik

Check out the new Telerik Platform - the only modular platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native apps. Register for the free online keynote and webinar to learn more about the Platform on Wednesday, February 12, 2014 at 11:00 a.m. ET (8:00 a.m. PT).

0
David
Top achievements
Rank 1
answered on 25 Mar 2014, 02:51 PM
I also really hope that being able to bind to a collection of Annotations is added to the ChartView control library in the near future.  I'd be more than happy to beta test it when this functionality is being developed.
0
Accepted
Peshito
Telerik team
answered on 26 Mar 2014, 11:46 AM
Hello David,

We haven's scheduled this feature for the upcoming release, however you can vote and rise its priority by doing so, and we will consider it for the upcoming releases. Thank you for your feedback.

Regards,
Peshito
Telerik
 

Build cross-platform mobile apps using Visual Studio and .NET. Register for the online webinar on 03/27/2014, 11:00AM US ET.. Seats are limited.

 
Tags
ChartView
Asked by
Intecom
Top achievements
Rank 1
Answers by
Peshito
Telerik team
Wouter
Top achievements
Rank 1
David
Top achievements
Rank 1
Share this question
or