Pre loader

How to add annotations programmatically?

Welcome to the SciChart Forums!

  • Please read our Question Asking Guidelines for how to format a good question
  • Some reputation is required to post answers. Get up-voted to avoid the spam filter!
  • We welcome community answers and upvotes. Every Q&A improves SciChart for everyone

WPF Forums | JavaScript Forums | Android Forums | iOS Forums

0
0

I want to add annotations programmatically. I need to add line with arrow and textbox at Y1 and X1 of a line. It creates pointed annotation.

  • You must to post comments
4
0

(I’m fairly new with SciChart myself, so I’m not sure if this is the best way to do it…)
You can look at what I’m building for a start. (Functional, but no comments yet. Hopefully the names are obvious enough)
I’m sure there will be a few extensions missing, but hopefully it’ll be obvious what they do.

When you add an annotation, it will show the textbox and tail pointers at an offset from the referenced data point.
When you zoom in and out and pan around, the annotation components will retain their relative size and offset to the point.
In edit mode, you can drag the text and reference points to new locations.

Here are two of the main extensions I know of:

    public static void AddHandler(this DependencyProperty prop, object component, EventHandler handler)
    {
        DependencyPropertyDescriptor dpd = DependencyPropertyDescriptor.FromProperty(prop, component.GetType());
        if (dpd != null)
            dpd.AddValueChanged(component, handler);
    }
    public static void AddHandler(this object component, DependencyProperty prop, EventHandler handler)
    {
        DependencyPropertyDescriptor dpd = DependencyPropertyDescriptor.FromProperty(prop, component.GetType());
        if (dpd != null)
            dpd.AddValueChanged(component, handler);
    }
Attachments
  • Elteros Projektai
    Can't find Utilities.Extensions; Utilities.Extensions.XDocument; Utilities.XML.Serialization;
  • You must to post comments
1
0

Hi guys,

To add annotations programmatically, just create an annotation in code, set up all desired properties and add it to the SciChartSurface.Annotations collection. For reference, please take a look at the Histogram example from this thread.

UPDATE:
To create annotations at the mouse cursor position, please take a look at the Create Annotations dynamically example.
Basically, you should use the AnnotationCreationModifier for this purpose.

Hope it helps! If you have any questions, feel free to ask,

Best regards,
Yuriy

  • Elteros Projektai
    Yeah, I tried this method. But I need that X and Y points to be added with mouse directed place on chart.
    • Guest
    • 10 years ago
    Please see my updated answer. Does it work for you?
  • You must to post comments
Showing 2 results
Your Answer

Please first to submit.