03-03-2021 02:14 PM
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]
Solved! Go to Solution.
03-04-2021 09:48 AM
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.)
03-15-2021 01:05 PM
That works! Thanks.