SciChart® the market leader in Fast WPF Charts, WPF 3D Charts, iOS Chart, Android Chart and JavaScript Chart Components


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)
  • You must to post comments

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,

  • 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.

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);  


            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.