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.
Can someone help me?
Thank you
- Vo Hoa asked 6 years ago
- last edited 6 years ago
- You must login to post comments
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
- Yura Khariton answered 6 years ago
-
Thanks a lot for your great answer.
- You must login to post comments
Please login first to submit.