Pre loader

Moving MVVM Annotations by Integer delta

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

1
0

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

Version
6.6.0.26505
  • You must to post comments
1
0

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

  • You must to post comments
Showing 1 result
Your Answer

Please first to submit.