Hello,
I’ve got Annotations ViewModels collection (BoxAnnotationViewModel, VerticalLineAnnotationViewModel, LineAnnotationViewModel) bound by AnnotationsBinding. Every Annotation ViewModel has properties set to:
CoordinateMode = AnnotationCoordinateMode.Absolute
IsEditable = true
DragDirections = XyDirection.XYDirection
ResizeDirections = XyDirection.XYDirection
My goal is to move and resize every annotation on SciChart surface only by integer value. Is there any way to achieve this?
Best regards,
Anna
- Anna Kozłowska asked 2 years ago
- You must login to post comments
Hello Anna,
Thanks for your inquiry. Usually we suggest overloading the MoveAnnotationTo(…) method from AnnotationBase and changing the “horizontalOffset” parameter correspondingly. For instance, this implementation allows an annotation to snap to data points while dragging it:
public class VerticalLineEx : VerticalLineAnnotation
{
protected override void MoveAnnotationTo(AnnotationCoordinates coordinates, double horizOffset, double vertOffset)
{
var series = ParentSurface.RenderableSeries[0];
var hitTestResult = series.VerticalSliceHitTest(new Point(coordinates.X1Coord + horizOffset, 0));
horizOffset = hitTestResult.HitTestPoint.X - coordinates.X1Coord;
base.MoveAnnotationTo(coordinates, horizOffset, vertOffset);
}
}
In similar way, you can implement dragging between integer values only.
Then, since you use MVVM API, you will have to create a custom AnnotationViewModel and link it with your custom Annotation. Please check the “Declaring Custom Annotationswith MVVM” section in this docs article.
Regarding resizing, unfortunately, there is no easy solution because It is handled internally. You may try overriding the SetBasePoint(…) method from AnnotationBase. We don’t have any examples of that because it is quite deep customization of annotations. Unfortunately, it goes beyond the scope of our support.
Hope this helps!
Best regards,
Joeri
- Joeri R answered 2 years ago
- You must login to post comments
Please login first to submit.