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


Hello, SciChart Team

I am using VerticalLineAnnotations on my charts to show harmonics. I am generating them programmatically by code:

double x = harmonic.Frequency; // interval between lines
        int i = 1;
        while (x < Math.Min((double)MainChartSurface.XAxes[0].DataRange.Max,10000.0))
            VerticalLineAnnotation newAnn = new VerticalLineAnnotation() {
                X1 = x,
                Stroke = new SolidColorBrush(harmonic.Color),
                ShowLabel = false,
                IsEditable = false
            x = harmonic.Frequency * ++i;

After this code runs i expect vertical lines to appear, but they don’t.
They appear only when I pan or zoom chart (just do something): images before and after are attached, please help me to understand what i’m missing to make surface refresh. i tried to use method “SciChartSurface.UpdateLayout();” but it didn’t help.

On the first image there’s chart right after code runs. in the left upper corner there appears little line. if i run code for another harmonic right after it – it will appear normally, but the first one wouldn’t appear until user touches chart (uses pan or zoom, etc.)

Please help with this minor but uncomfortable issue.
Thanks in advance

  • You must to post comments
Best Answer

Hi there,

This can occur when you have multiple XAxis or YAxis and have not set the VerticalLineAnnotation.YAxisId or VerticalLineAnnotation.XAxisId.

Please ensure that you either leave all axis IDs default, or, you set both VerticalLineAnnotation.YAxisId or VerticalLineAnnotation.XAxisId to register the vertical line on an axis. It should then work!

Best regards,

  • You must to post comments
Showing 1 result
Your Answer

Please first to submit.