Scichart 无法删除注释

Scichart can't remove annotation

当我尝试删除注释时,收到错误消息:

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)

我试过很多方法,比如:

UpdateSuspender.using(priceChart, new Runnable() {
    @Override
    public void run() {
        priceChart.getAnnotations().clear();
    }
});

UpdateSuspender.using(priceChart, new Runnable() {
    @Override
    public void run() {
        priceChart.getAnnotations().remove(myAnnotation);
    }
});

但我无法删除它。

这很奇怪。有一个SciChart Android Tutorial on Annotations here。它使用 'chart.getAnnotations().remove(0)'

可以在 SciChart.Android.Examples Github repository 找到本教程的完整源代码。

对你有用吗?

这是Scichart团队的官方回答:

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