WPF Charting Documentation - SciChart WPF Charts SDK v5.x
Editing and Interacting with Annotations

Editing Annotations via User Drag

All annotations support dragging and repositioning via the mouse when AnnotationBase.IsEditable = true. Similarly, to make an annotation read-only, set IsEditable = false.


Creating Annotations on Mouse-Clicks

SciChart features a ChartModifier to help you create annotations on mouse click/drag. This is the AnnotationCreationModifier.

Adding an AnnotationCreationModifier in XAML

To add an AnnotationCreationModifier to your chart, simply declare it in XAML as follows:

Adding an AnnotationCreationModifier
Copy Code

   <!-- XAxis, YAxis, RenderableSeries omitted for brevity -->

         <s:AnnotationCreationModifier x:Name="annotationCreation"   
                    AnnotationType="{x:Type s:LineAnnotation}"
                    AnnotationStyle="{StaticResource LineAnnotationStyle}/>


The AnnotationCreationModifier will listen to mouse-clicks and create an annotation for you. It creates the annotation specified by the AnnotationCreationModifier.AnnotationType. It applies the style specified by AnnotationCreationModifier.AnnotationStyle to the newly created annotation. If you want to change the annotation type or style dynamically then set these properties in code or via a binding.


Adding an AnnotationCreationModifier in Code

To add an AnnotationCreationModifier to your chart, simply declare the following C# code:

Adding an AnnotationCreationModifier
Copy Code
// Create a SciChartSurface. XAxis, YAxis omitted for brevity
var sciChartSurface = new SciChartSurface();
var annotationCreationModifier = new AnnotationCreationModifier()
       AnnotationType = typeof(LineAnnotation),
       AnnotationStyle = this.TryFindResource("SomeStyleDeclaredInXaml") as Style,           
sciChartSurface.ChartModifier = new ModifierGroup(
       new XAxisDragModifier(),
       new YAxisDragModifier());

Rolling Your Own Annotation Creation code

You don’t have to use our AnnotationCreationModifier. Fact is, we simple create annotations on mouse-clicks, so you could do the following.

In pseudocode:

On SciChartSurface MouseDown

    Convert MousePoint to X,Y data values.

    Create an annotation.

    Set Annotation.X1, Y1 to data-values calculated above

    Add Annotation to SciChartSurface.Annotations


On SciChartSurface MouseMove

    Convert MousePoint to X,Y data-values

    Update Annotation.X2,Y2 to the latest X,Y data value


On SciChartSurface MouseUp

    Convert MousePoint to X,Y data-values

    Set Annotation.X2,Y2 to the latest X,Y data value

    Clear any flags to stop dragging/updating annotations 




SCICHART ® is a Registered Trademark in the UK, US and EEC. Copyright SciChart Ltd 2011-2018.

Email us to give feedback!