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

Answered
1
0

Hello,

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

Version
2.1.0.2192
  • You must to post comments
Best Answer
0
0

Hi Vo Hoa,

Thanks for your inquiry.

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

annotation.setY1(10d);

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:

    annotation.setLabelValue("Label");

    // or 
    annotation.setFormattedLabelValueProvider(new IFormattedValueProvider() {
        @Override
        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());
    annotation.annotationLabels.add(label);

    // then update its text
    this.label.setText("Label");

Hope this will help you!

Best regards,
Yura

  • Vo Hoa
    Thanks a lot for your great answer.
  • 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