When Im trying to remove an annotation, I’m receiving an error:
java.lang.NullPointerException: Attempt to invoke interface method ‘void com.scichart.charting.visuals.annotations.IAnnotationPlacementStrategy.drawAdorner(android.graphics.Canvas)’ on a null object reference at com.scichart.charting.visuals.annotations.AnnotationBase.onDrawAdorner(SourceFile:889) at com.scichart.charting.visuals.annotations.AdornerLayer.onDraw(SourceFile:144) at android.view.View.draw(View.java:17071) at android.view.View.updateDisplayListIfDirty(View.java:16053)
I’ve tried many ways, like:
UpdateSuspender.using(priceChart, new Runnable() {
@Override
public void run() {
priceChart.getAnnotations().clear();
}
});
and
UpdateSuspender.using(priceChart, new Runnable() {
@Override
public void run() {
priceChart.getAnnotations().remove(myAnnotation);
}
});
But I just can't remove it.
this is the official answer from Scichart team:
Hi Marcos,
I want to notify you that I’ve investigated and fixed this issue. It was caused by a small bug in our code – when you remove annotation from chart it doesn’t remove adorner for annotation if it is selected. The fix will be available in our next nightly build and for now you can workaround this issue by unselecting annotation before removing from collection:
UpdateSuspender.using(priceChart, new Runnable() {
@Override
public void run() {
myAnnotation.setSelected(false);
priceChart.getAnnotations().remove(myAnnotation);
}
});
Hope this will help you!
Best regards, Yura