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


Hi Guys,

Can you please help me with the following functionality?
I have got a context menu attached to the SciChartSurface and one of the items is to add an annotation(as it is shown in the image attached). So, the idea is that when I open the menu and select the “Add annotation” It will pick up the nearest point in the chart related to where the click was done and then it will add the annotation to the chart as it is shown in the image attached.
I have already figured out with reading some of the question in this forum, to get the mouse points and the nearest Y point in the series related to that mouse click… like this:

private void AddAnnotationOnClick(object sender, RoutedEventArgs e)
// Hit tests are done per renderable series, so get a renderable series
// or iterate over all RenderableSeries
var renderableSeries = SciChartSurface.RenderableSeries[0];

        // Perform the hit test relative to the GridLinesPanel
        var hitTest = renderableSeries.HitTest(MousePoint);

        SciChartSurface.Annotations.Add(new CustomAnnotation { DataContext = hitTest.YValue });

    private Point MousePoint { get; set; }

    private void OnMouseUp(object sender, MouseButtonEventArgs e)
        MousePoint = e.GetPosition(SciChartSurface.GridLinesPanel as UIElement);

As it can be noticed, I have already two annotations that are fix, they are always displayed…

Sorry for my terrible English… hope you guys get the idea…

Thanks very much. đŸ™‚

  • You must to post comments

Hello there,

You just need to set CustomAnnotation.X1 and Y1 to the HitTest XValue and YValue. Debug these values to see if they are what you expect. Also there are a lot of other properties on HitTestInfo struct which may be useful to you!

In order to set the alignment of the CustomAnnotation, please take a look at this reference article which discusses the VerticalAnchorPoint and HorizontalAnchorPoint properties on annotations.

Let me know if this helps,

  • You must to post comments
Showing 1 result
Your Answer

Please first to submit.