Hi,
I am trying to add text annotation on the chart but it doesn’t show. I’m wondering what went wrong with my code.
TextAnnotation textAnnotation = sciChartBuilder.newTextAnnotation()
.withText("hello")
.withX1(450)
.withY1(1)
.withFontStyle(20, Color.WHITE)
.build();
ecgSurface.getAnnotations().add(textAnnotation);
- Gang Xu asked 2 years ago
- You must login to post comments
Thanks Yura.
I just figured out the reason for annotation not showing up, which is because the AxisID. I defined XAxisID for the chart and the annotation works if I add withXAxisID(“ecgX”) in the code.
Except this, may I ask if there’s an efficient way to add hundreds of annotations at a time?
And is there a way to make an annotation selectable but not movable or resizable?
Also I noticed the annotations were off the position where they were supposed to be when I dragging the chart. Is that how it works?
Gang
- Gang Xu answered 2 years ago
- last edited 2 years ago
- Well maybe if you need to add hundreds annotations, then maybe it would be better to draw it as custom renderable series, because annotations are implemented as custom Views and if there are too many of them then it could cause poor performance.
- As for disabling resizing/moving we have IsEditable property (https://www.scichart.com/documentation/android/current/webframe.html#SciChart.Charting~com.scichart.charting.visuals.annotations.IAnnotation~setIsEditable.html), but in this case when you click on it it won’t be highlighted
- As for position of annotation by default X1/Y1 coordinates set position top left corner of text annotation. If you want to change it you can use HorizontalAnchorPoint(https://www.scichart.com/documentation/android/current/webframe.html#SciChart.Charting~com.scichart.charting.visuals.annotations.AnchorPointAnnotation~setHorizontalAnchorPoint.html) or VerticalAnchorPoint(https://www.scichart.com/documentation/android/current/webframe.html#SciChart.Charting~com.scichart.charting.visuals.annotations.AnchorPointAnnotation~setVerticalAnchorPoint.html)
- Thanks. Drawing it as renderable series is a good idea to avoid poor performance. For the isEditable property, I need to have annotation selectable for deletion, but not movable or resizable. Is there a way around?
- You must login to post comments
Hi Gang Xu,
Is it possible that your X1 or Y1 coordinates are outside of VisibleRange for X or Y axis? If annotation is placed outside chart’s viewport bounds, then it won’t be visible. Also I would suggest to check logcat output if there are any errors there.
Best regards,
Yura
- Yura Khariton answered 2 years ago
- You must login to post comments
Please login first to submit.