RadCartesianChart: Displaying of CartesianGridLineAnnotation

4 posts, 0 answers
  1. K.
    K. avatar
    2 posts
    Member since:
    Apr 2009

    Posted 24 Jul 2015 Link to this post

     In our project we are using the RadCartesianChart and we want to (dynamically) display some vertical lines.

    For this we have code like the following in place: 

    var collection = GetSomeFilteredData();
    foreach (var dateTime in collection)
                {
                    var cartesianGridLineAnnotation = new CartesianGridLineAnnotation
                    {
                        ZIndex = -100,                     
                        Value = dateTime, 
                        Stroke = new SolidColorBrush(Colors.Black), 
                        StrokeThickness = 1, 
                        Axis = this.HorizontalAxis
                    };

                    this.ChartControl.Annotations.Add(cartesianGridLineAnnotation);
                }

     

    When debugging I can verify that the data is loaded and added to the ChartControl.Annotations collection. But it doesn't display.

    Other than that, everything works fine (e.g. display of static horizontal lines  as declared in xaml, which are also in the Annotations collection).

     

    Any idea what I am missing here?

    Also, is there a "better" way of achieving our goal? I would like it if I could just bind a collection in the ViewModel to a property of the chart.

    Thanks in advance for any help. 

     

     

  2. Martin
    Admin
    Martin avatar
    1099 posts

    Posted 28 Jul 2015 Link to this post

    Hi,

    Let me start with your last question - currently, the chart's Annotations collection cannot be data bound and the approach that you are using is the way to go. About the missing annotations, the code declaration seems correct, so I am afraid that without your implementation I cannot be sure what is causing this behavior. Can you please, send me a runnable code snippets or a project that demonstrates an isolated version of your implementation? This way I will be able to test it locally and investigate why the grid lines are missing. Thank you for the cooperation.

    Regards,
    Martin
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  3. DevCraft banner
  4. K.
    K. avatar
    2 posts
    Member since:
    Apr 2009

    Posted 30 Jul 2015 in reply to Martin Link to this post

    Hello Martin

    Thank you for trying to help, but creating an extra project didnt seem feasible since our project is highly complex.

    However, I figured my problem out: it was a data-related problem.

    In the future, will you add support for a collection of vertical lines (and horizontal lines aswell)? I think its not a too unusal use case :)

    Best regards

    Kosta

  5. Martin
    Admin
    Martin avatar
    1099 posts

    Posted 31 Jul 2015 Link to this post

    Hello Kosta,

    I am glad to hear that you managed to resolve the issue. As for lines support you mentioned, actually we have a feature request logged in our feedback portal which concerns implementing annotations ItemsSource which once its implemented will be helpful for your case. If you follow the feedback item you will be notified as soon as there is any change in its status. 

    Regards,
    Martin
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Back to Top