Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

How to add annotations to scattergraph?

Solved!
Go to solution

It seems to be simple Smiley Happy(sur it will be), but i spent 2 hour trying to add an annotation to a scattergraph.

 

It's working perfectly in design mode, but i want to do it by code, something like this:

 

 Dim ann As New XYAnnotationCollection

ScatterGraph1.Annotations.Add(ann)

 

But this is not working, ann is a XYAnnotationCollection not a XYAnnotation. And when i declare it as XYAnnotation, it wont work too, (mustinherit class)!!!

 

Using VB 2005

 

Thank's in advance.

0 Kudos
Message 1 of 3
(4,220 Views)

A quick tip is you can always see the code that is made during Design mode in your code by just unhiding the "Required by the Windows Form Designer" code at the beginning of your program. Here if we make an annotation we can see how VS codes it and copy their syntax.

 

Me.XyPointAnnotation1 = New NationalInstruments.UI.XYPointAnnotation

Me.ScatterGraph1.Annotations.AddRange(New NationalInstruments.UI.XYAnnotation() {Me.XyPointAnnotation1})

Me.XyPointAnnotation1.Caption = "XyPointAnnotation1"
Me.XyPointAnnotation1.CaptionAlignment = New NationalInstruments.UI.AnnotationCaptionAlignment(NationalInstruments.UI.BoundsAlignment.None, 0.0!, 25.0!)
Me.XyPointAnnotation1.XAxis = Me.XAxis1
Me.XyPointAnnotation1.XPosition = 1
Me.XyPointAnnotation1.YAxis = Me.YAxis1
Me.XyPointAnnotation1.YPosition = 9

 

It sounds like you may not be initalizing thethe annotation correctly.

 

Regards,

 

Steven Zittrower

Applications Engineer

National Instruments

http://www.ni.com/support

0 Kudos
Message 2 of 3
(4,201 Views)
Solution
Accepted by topic author ELBOB

Thanks For The Tip. Really helpfull.

 

If it can help someone else, I got it work by using a clone of the first annotation -wich was made by design and invisible-

 

 

Dim ann As XYPointAnnotation

For i = 0 To Nmax

ann = frmsuivi_tendance.XyPointAnnotation1.Clone()

ann.Visible = True

next i

 

0 Kudos
Message 3 of 3
(4,182 Views)