Pre loader

How to update value of a HorizontalLineAnnotation

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



I have added a HorizontalLineAnnotation successfully on my android app.

However, when data changes, I want to update the position (and the label) of it but I don’t see any method of class HorizontalLineAnnotation to do it.

enter image description here

Can someone help me?

Thank you

  • You must to post comments
Best Answer

Hi Vo Hoa,

Thanks for your inquiry.

To update position of HorizontalLineAnnotation you can use setY1() method:


To update label value you can use setLabelValue() method or if your label value depends on position of annotation you can create custom IFormattedValueProvider implementation:


    // or 
    annotation.setFormattedLabelValueProvider(new IFormattedValueProvider() {
        public CharSequence formatValue(AxisInfo axisInfo) {
            if(axisInfo != null) {
                final Comparable<?> y1Value = axisInfo.dataValue;

                return convertY1ValueToLabel(y1Value);

            return null;

In case if HorizontalLineAnnotation should have more than 1 label and each of them should have independent label then you can set label directly on AnnotationLabel instance:

    // create label and save it somewhere
    this.label = new AnnotationLabel(getActivity());

    // then update its text

Hope this will help you!

Best regards,

  • Vo Hoa
    Thanks a lot for your great answer.
  • You must to post comments
Showing 1 result
Your Answer

Please first to submit.