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

Refresh graph after changing annotation data

3 Answers 176 Views
Chart
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Carmen
Top achievements
Rank 1
Carmen asked on 09 Dec 2015, 07:03 PM

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

 

3 Answers, 1 is accepted

Sort by
0
Todor
Telerik team
answered on 12 Dec 2015, 08:45 AM
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
0
Carmen
Top achievements
Rank 1
answered on 17 Dec 2015, 03:53 PM

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. 

0
Todor
Telerik team
answered on 22 Dec 2015, 12:11 PM
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
Tags
Chart
Asked by
Carmen
Top achievements
Rank 1
Answers by
Todor
Telerik team
Carmen
Top achievements
Rank 1
Share this question
or