SciChart® the market leader in Fast WPF Charts, WPF 3D Charts, iOS Chart, Android Chart and JavaScript Chart Components

0
0

Hi,

I’d like to learn how to cancel creating annotation in the OnAnnotationCreatedListener(). Thanks.

annotationCreationModifier.setAnnotationCreationListener(new OnAnnotationCreatedListener() {
        @Override
        public void onAnnotationCreated(IAnnotation iAnnotation) {
            if (outofbound) {
                 // remove current annotation
            }
         }
Version
4.2.0.4557
  • You must to post comments
0
0

Hi Gang Xu,

You can cancel creation of annotation, because it already created in listener and passed as parameter. The only thing which you can do is to remove annotation from chart so it won’t be shown.

@Override
public void onAnnotationCreated(@NonNull IAnnotation annotation) {
    // get chart where annotation is placed
    final ISciChartSurface parentSurface = ((AnnotationBase) annotation).getParentSurface();

    // try remove annotation from chart
    if(parentSurface != null)
        parentSurface.getAnnotations().remove(annotation);
}

Hope this will help you!

Best regards,
Yura

  • Gang Xu
    Thanks. It works like a charm.
  • You must to post comments
Showing 1 result
Your Answer

Please first to submit.