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

Welcome to the SciChart Community Forums!

Please use the forums below to ask questions about SciChart. Take a moment to read our Question asking guidelines on how to ask a good question and our support policy. We also have a tag=SciChart on where you can earn rep for your questions!

Please note: SciChart team will only answer questions from customers with active support subscriptions. Expired support questions will be ignored. If your support status shows incorrectly, contact us and we will be glad to help.


I have an application where I’m attempting to add annotations from the code-behind. My chart XAML looks like this:

   <pre class="brush: xml; gutter: true; first-line: 1; highlight: []; html-script: false"> &lt;s:SciChartSurface Grid.Row=&quot;1&quot; Margin=&quot;3&quot; x:Name=&quot;Chart&quot;
            &lt;s:FastLineRenderableSeries SeriesColor=&quot;Blue&quot; DataSeries=&quot;{Binding Series1.ChartData}&quot; XAxisId=&quot;XAxis1&quot; YAxisId=&quot;YAxis1&quot;/&gt;
            &lt;s:FastLineRenderableSeries SeriesColor=&quot;Red&quot; DataSeries=&quot;{Binding Series2.ChartData}&quot; XAxisId=&quot;XAxis1&quot; YAxisId=&quot;YAxis1&quot;/&gt;

            &lt;s:NumericAxis AxisTitle=&quot;{Binding Series1.XCaption}&quot; Id=&quot;XAxis1&quot; AnimatedVisibleRange=&quot;{Binding Series1.XRange, Mode=OneWay}&quot; GrowBy=&quot;0.05, 0.05&quot; /&gt;

            &lt;s:NumericAxis AxisTitle=&quot;{Binding Series1.YCaption}&quot; Id=&quot;YAxis1&quot; AnimatedVisibleRange=&quot;{Binding Series1.YRange, Mode=OneWay}&quot; GrowBy=&quot;0.05, 0.05&quot; /&gt;

                &lt;s:RubberBandXyZoomModifier  IsEnabled=&quot;True&quot; IsXAxisOnly=&quot;False&quot; ZoomExtentsY=&quot;False&quot; IsAnimated=&quot;True&quot;/&gt;
                &lt;s:MouseWheelZoomModifier /&gt;
                &lt;s:ZoomPanModifier IsEnabled=&quot;True&quot; ExecuteOn=&quot;MouseMiddleButton&quot; /&gt;

I’m trying to add a vertical line annotation like this:

            <pre class="brush: csharp; gutter: true; first-line: 1; highlight: []; html-script: false">var line = new VerticalLineAnnotation
                X1 = 85,
                Y1 = 0,
                XAxisId = &quot;XAxis1&quot;,
                YAxisId = &quot;YAxis1&quot;,
                VerticalAlignment = VerticalAlignment.Stretch,
                LabelValue = &quot;Level&quot;,
                ShowLabel = true,
                LabelPlacement = LabelPlacement.Axis,
                Stroke = new SolidColorBrush(Colors.DeepSkyBlue)
            Chart.Annotations.Add(line);  </pre>              

Unfortunately the annotation is not appearing. Everything else seems to work fine, including the data, axis ranges and modifiers. If I create the annotation manually in XAML, it works fine. Am I missing a step in my code-behind to make the annotation display properly?

  • You must to post comments


Your code looks alright at first sight. Try removing YAxisId and Y1 coordinate setting as it requires setup for X coord only. Also, please, take a look at this thread, where an example of annotations added in code was shown.

If the above doesn’t help, could I ask you to make a small sample project which reproduces the issue and post here/send it to us?

Best regards,

  • You must to post comments
Showing 1 result
Your Answer

Please first to submit.