Pre loader

Annotation spawn location bug

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

Whenever I add a new vertical line annotation to my scichartsurface, it allways spawns at the top left corner, then if I zoom in/out it then immidietly moves to the right location. Do any of you have any fix so that I dont need to zoom everytime to fix the annotation positions?

Here is a snippet of my code:

                    var line = new VerticalLineAnnotation() {
                        Stroke = Brushes.Gold,
                        StrokeThickness = 1,
                        X1 = xClicked
                    };
                    var text = new TextAnnotation() {
                        HorizontalAnchorPoint = HorizontalAnchorPoint.Center,
                        X1 = xClicked,
                        Text = input,
                        Foreground = Brushes.Black,
                        Background = Brushes.Gold,
                        BorderBrush = Brushes.Black,
                        BorderThickness = new Thickness(2),
                        CornerRadius = new CornerRadius(5)
                    };
                    ViewModel.SciChartSurface.Annotations.Add(line);
                    ViewModel.SciChartSurface.Annotations.Add(text);
Version
Newest
  • You must to post comments
0
0

At a guess (because you have provided only a partial code sample)

You have YAxis or XAxis with custom ID (one or both)

You have not set YAxisId or XAxisId on the VerticalLIneAnnotation / TextAnnotation. Or you have set them via binding but the binding evaluates slowly (in which case use FallbackValue)

Other than that, I don’t know. If you are stuck and need help, its useful for us to see code that reproduces in a small stand-alone solution. Can you create one and send it over to the support desk?

Best regards,
Andrew

  • Eivind Yu Nilsen
    I fixed it by slightly adjusting the visible range (by 1/10000000th of a second) so that the view updates(?). I think only setting the visible range min and maxes isn’t enough, you need to set the doublerange one.
  • Andrew Burnett-Thompson
    Unless we can see a bug we can’t really comment. Does the problem occur in any of our examples? If YES then we have a clear reproduction. If no, can the example be modified in some way to cause the problem?
  • Eivind Yu Nilsen
    I’ve added an extra comment as an answer, since the formatting of the comments are different than answers.
  • Eivind Yu Nilsen
    I’m sorry. It would be really hard to recreate the bug in a clear reproduction. Since we are using a lot of classes that affects the scichartview, and as I wasn’t the one(s) that made those files I don’t know which is the one that may be causing the bug. I don’t believe the bug would happen in any of scichart’s examples.
  • Eivind Yu Nilsen
    It may just be an unlucky interaction with our classes and scichart, so maybe its not even a bug. But we atleast able to fix it. Maybe the fix we did can help determinate what this error was.
0
0

Did not work:

            if (ViewModel.SciChartSurface.XAxis?.VisibleRange != null)  
                ViewModel.SciChartSurface.XAxis.VisibleRange = new DoubleRange((double)ViewModel.SciChartSurface.XAxis.VisibleRange.Min - 0.01f,   (double)ViewModel.SciChartSurface.XAxis.VisibleRange.Max);  

Worked:

            ViewModel.ViewportManager.BeginInvoke(() => {  
                if (ViewModel.SciChartSurface.XAxis?.VisibleRange != null)  
                    ViewModel.SciChartSurface.XAxis.VisibleRange = new   DoubleRange((double)ViewModel.SciChartSurface.XAxis.VisibleRange.Min - 0.01f,   (double)ViewModel.SciChartSurface.XAxis.VisibleRange.Max);});  

Very wierd

  • 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