Pre loader

Proper Syntax to Set Annotation to selected status at Adorner Layer in SciChart JS...

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

I’m working on a charting program for financial markets, and trying to develop a drawing system that uses SciChartJS annotations.

The initial implementation allowed annotations to be “naturally” selected, but leaving them editable to be selected resulted in users accidentally ‘snagging’ one annotation while trying to draw another, or while trying to pan the chart. To get around this, we implemented a “right-click -> edit” function to activate an annotation for editing, that programmatically sets isEditable and isSelected to true. I understand that this is not advised, but I’m not familiar with another way to exert the necessary control/restraint over annotations. (we DO let them de-select “naturally” and that seems to work)

This has worked with LineAnnotation and HorizontalLineAnnotation with no issues. But when implementing BoxAnnotations, we found that, while the annotation looks to be in “selected” state, the adorners don’t “fully open”. I can click them inside the box and drag to re-size, but if I click them on the box border or outside the box, they don’t respond and the box de-selects.

The adorners DO fully open if I click the annotation anywhere, or if I drag it or drag an adorner from the inside. After that, I can click anywhere on the adorner circle and drag properly.

Based on other posts in this forum, I’m assuming that this has to do with the AdornerLayer selection information not being set by a programmatic “isSelected = true”. Can you provide sample code for how to set an annotation as selected at the AdornerLayer?

(I asked an LLM to try to interpret this prior post https://www.scichart.com/questions/js/programmatically-select-customannotation and generate code, but I’m not sure it’s implementing the AdornerLayer change properly)

Thank you!
-Mark

Version
4
  • You must to post comments
0
0

This is a known problem that we hope to address relatively soon. If you set annotation.isSelected then you need to do

scichartSurface.adornerLayer.selectedAnnotation = annotation;

for resize to work properly. If you programmatically deselect, do

scichartSurface.adornerLayer.selectedAnnotation = undefined;

Do not try and call adornerLayer.selectAnnotation. This is called internally on mouse down and does a hitTest on all annotations based on the mouse args passed in, selecting the hit annotation.

Regards
David

  • You must to post comments
Showing 1 result
Your Answer

Please first to submit.