Refresh graph after changing annotation data

4 posts, 0 answers
  1. Carmen
    Carmen avatar
    10 posts
    Member since:
    Dec 2015

    Posted 09 Dec 2015 Link to this post

    How do I get a radchart to automatically refresh after I change a custom annotation?

     

  2. Todor
    Admin
    Todor avatar
    778 posts

    Posted 12 Dec 2015 Link to this post

    Hello Carmen,

    Most of the changes in the annotation's values should be reflected automatically, however if you have custom values, you may need to call the annotation's requestRender() method to force new rendering of the annotation.

    Let us know if you need further assistance.

    Regards,
    Todor
    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. Carmen
    Carmen avatar
    10 posts
    Member since:
    Dec 2015

    Posted 17 Dec 2015 in reply to Todor Link to this post

    annotations.add(new CartesianCustomAnnotation(verticalAxis, horizontalAxis, 1750.00, "Nov 26", new Annotation(1, 250.00, new Date((long) 1442030400000.0), R.drawable.billgreen, 100, 100)));
    annotations.add(new CartesianCustomAnnotation( verticalAxis, horizontalAxis, 1450.00, "Nov 29", new Annotation(2,150.00, new Date((long)1442030400000.0), R.drawable.billgreen, 100, 100)));
    annotations.add(new CartesianCustomAnnotation( verticalAxis, horizontalAxis, 2950.00, "Dec 1", new Annotation(3, 1500.00, new Date((long)1442030400000.0), R.drawable.money, 100, 100)));
    annotations.add(new CartesianCustomAnnotation( verticalAxis, horizontalAxis, 2835.00, "Dec 4", new Annotation(4, 115.00, new Date((long)1442030400000.0), R.drawable.billorange, 100, 100)));
    annotations.add(new CartesianCustomAnnotation( verticalAxis, horizontalAxis, 2608.00, "Dec 8", new Annotation(5, 227.00, new Date((long)1442030400000.0), R.drawable.billmultiple, 100, 100)));
    annotations.add(new CartesianCustomAnnotation( verticalAxis, horizontalAxis, 1482.00, "Dec 14", new Annotation(6, 69.00, new Date((long)1442030400000.0), R.drawable.billgreen, 100, 100)));
    annotations.add(new CartesianCustomAnnotation( verticalAxis, horizontalAxis, -500.00, "Dec 15", new Annotation(7, 1057.00, new Date((long)1442030400000.0), R.drawable.piggybank, 100, 100)));
    annotations.add(new CartesianCustomAnnotation( verticalAxis, horizontalAxis, 2982.00, "Dec 17", new Annotation(8, 1500.00, new Date((long)1442030400000.0), R.drawable.money, 100, 100)));

    This is my data.

     

    When I call inside a forloop

    annotations.get(i).setHorizontalValue("Dec 1");
    annotations.get(i).requestRender();

     

    I get no change in the annotation positions. 

  5. Todor
    Admin
    Todor avatar
    778 posts

    Posted 22 Dec 2015 Link to this post

    Hi Carmen,

    From the provided information I don't understand if you can't update the annotations or can't display them at all. The CartesianCustomAnnotation only draws the toString value of the provided Object (in your case Annotation). If you need more control over the drawn content, you can extend the class and override its render method as shown in our online documentation. It also important to note that the annotations should be added to the annotations collection of the chart:

    CartesianCustomAnnotation annotation = new CartesianCustomAnnotation(verticalAxis, horizontalAxis, 6, "Feb", "TARGET");
    chartView.getAnnotations().add(annotation);

    Also make sure that the updated value is the same as the value of the axis. In other words since you are providing string values for the horizontal axis, you data should also contain string values for the categories.

    I hope this information helps.

    Regards,
    Todor
    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
DevCraft banner