Pre loader

how to cancel annotation creation in OnAnnotationCreatedListener()

Welcome to the SciChart Forums!

  • Please read our Question Asking Guidelines for how to format a good question
  • Some reputation is required to post answers. Get up-voted to avoid the spam filter!
  • We welcome community answers and upvotes. Every Q&A improves SciChart for everyone

WPF Forums | JavaScript Forums | Android Forums | iOS Forums

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.

Try SciChart Today

Start a trial and discover why we are the choice
of demanding developers worldwide

Start TrialCase Studies