Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

How to programmatically add colored diamonds markers into WPF WritableGraph Control

Solved!
Go to solution

Hello! I'm interested to know how to programmatically add colored diamond markers inside my WPF Writable Graph Control's plot1.

 

I thought about using "NI Cursors" at various points on plot1, and then I thought twice about it... so I better ask the NI Board what the best approach should be! Maybe cursors aren't the way to go? Is there something easier? 

 

These children need to be bound to plot1 and move if I pan around, stationary to the plot1. Say for instance I have 4 interesting points on my plot1 and I want to mark them with 4 different colored diamonds programmatically because I may have more or less than 4. How do I do that?

 

Attached is my WPF Control, it has 2 plots, and 1 Cursor and 2 axis [please excuse the .cs extension - the Board wouldn't let me attach a xaml extension type file]

 

 

 

0 Kudos
Message 1 of 3
(1,184 Views)
Solution
Accepted by topic author MrEman

From your description, it sounds like PointAnnotation best fits your goals. Here is an example of how to create a point annotation in code, positioned on a point using the same axes as a plot:

Plot plot = plot1;
double horizontalPosition = ...;
double verticalPosition = ...;

var annotation = new PointAnnotation {
    TargetShape = PointShape.Diamond,
    Fill = Brushes.Aqua,
    Label = "Point of interest",
    HorizontalAxis = plot.HorizontalScale,
    VerticalAxis = plot.VerticalScale,
    HorizontalPosition = horizontalPosition,
    VerticalPosition = verticalPosition
};
graph.Children.Add( annotation );

 

(This example includes a label, but this can be left out and the label arrow hidden by setting the appropriate visibility properties.)

~ Paul H
Message 2 of 3
(1,145 Views)

That works! Thanks.

0 Kudos
Message 3 of 3
(1,114 Views)