Pre loader

Crash when dragging VerticalLineAnnotation by programmatically created AnnotationLabel

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’ve been beating my head over this for a while and I’m wondering if there’s something wrong with my implementation or whether there’s a bug in the annotationlabel.

I am running into a nullreferenceexception when I begin drag on an Axis AnnotationLabel attached to a VerticalLineAnnotation. An example code is below. This doesn’t seem to be an issue for non-axis labels.

I am able to drag once. When I begin my second drag on the label the crash occurs. This crash does not occur when the annotation line itself is dragged. The crash occurs when you click on the annotation label (at the axis) and drag it twice in succession.

Note — this issue doesn’t crop up when the annotation and label are declared in xaml. For my purposes however, I have been trying to create them programmatically. My actual code is a bit different, I add the label in the codebehind as opposed to the viewmodel, but this below gives the same outcome.

Edit: on further investigation, this seems to occur with annotationviewmodels specifically. Creating the annotation through the codebehind works fine. But creating it via an AnnotationsBinding and annotationviewmodel does not. I found the issue occurs when I set “ShowLabel” on the annotationviewmodel as well as when I add to the label collection.

var a = new VerticalLineAnnotationViewModel()
                {
                    X1 = someInitialVal,
                    XAxisId = "DateTimeXAxis",
                    YAxisId = "PressureYAxis",
                    DragDirections = SciChart.Charting.XyDirection.XDirection,
                    IsEditable = true,
                };

                a.AnnotationLabels.Add( new SciChart.Charting.Visuals.Annotations.AnnotationLabel() );
                Annotations.Add( a);
                RaisePropertyChanged( nameof( Annotations ) );
Version
5.4.0.12119
  • You must to post comments
0
0

If anyone else is running into the same issue, the workaround I found is overriding OnAnnotationMouseMove in the Annotation and returning without calling base if the sender is not the annotation (i.e. is the label or one of the elements in the label).

  • You must to post comments
0
0

It just happened in our application earlier today:

> EXCEPTION OCCURRED:System.NullReferenceException: Object reference not
> set to an instance of an object. at
> SciChart.Charting.Visuals.Annotations.VerticalLineAnnotation.MoveAnnotationTo(AnnotationCoordinates
> coordinates, Double horizOffset, Double vertOffset) at
> SciChart.Charting.Visuals.Annotations.AnnotationBase.OnAnnotationPointerMoved(ModifierMouseArgs
> e) at
> SciChart.Charting.Visuals.Annotations.AnnotationBase.OnAnnotationMouseMove(Object
> sender, MouseEventArgs e)

We have had similar issues with NRE in ToCoordinates() method. We had to create a child class of VerticalLineAnnotationForMvvm and override ToCoordinates(). Since all arguments to MoveAnnotation are value objects the only possibility is that canvas is null for some reason.

  • You must to post comments
Showing 2 results
Your Answer

Please first to submit.

Try SciChart Today

Start a trial and discover why we are the choice
of demanding developers worldwide

Start TrialCase Studies