The Measurement Studio 7.0 graphs (WaveformGraph and ScatterGraph) expose events that allow you to custom draw areas of the control. Most of these events appear as pairs of BeforeDraw____ and AfterDraw___. The BeforeDraw events are raised before the drawing begins and AfterDraw events are raised after the drawing has completed.
In your case, you can attach an event handler to the AfterDrawPlotArea event of the ScatterGraph since you want to draw on top of everything that is drawn in the plot area. In the event handler:
// Assuming e is the name of the AfterDrawEventArgs parameter.
// Find the minimum y-value on the first plot in the Plots
// collection of the graph.
double[] xData = scatterGraph1.Plots[0].GetXData();
double[] yData = scatterGraph1.Plots[0].GetYData();
if (yData.Length > 0)
{
double x = xData[0];
double yMin = yData[0];
for (int i = 1; i < yData.Length; ++i)
{
if (yData[i] < yMin)
{
x = xData[i];
yMin = yData[i];
}
}
// Map the data point to a point in device coordinates.
PointF minPoint = scatterGraph1.Plots[0].MapPoint(e.Bounds, x, yMin);
// Calculate the starting point for the line of the
// arrow.
PointF startingPoint = new PointF(minPoint.X + 1, minPoint.Y - 1);
PointF endingPoint = new PointF(minPoint.X + 10, startingPoint.Y - 9);
// Draw a vertical line representing the stick of the
// arrow from the point.
e.Graphics.DrawLine(Pens.White, startingPoint, endingPoint);
PointF leftArrowEnd = new PointF(startingPoint.X, startingPoint.Y - 3);
PointF rightArrowEnd = new PointF(startingPoint.X + 3, startingPoint.Y);
// Draw the arrows.
e.Graphics.DrawLine(Pens.White, startingPoint, leftArrowEnd);
e.Graphics.DrawLine(Pens.White, startingPoint, rightArrowEnd);
// Calculate the location of the text by centering it
// about the arrow.
SizeF textSize = e.Graphics.MeasureString("MIN", scatterGraph1.Font);
PointF textLocation = new PointF(endingPoint.X + 1, endingPoint.Y - (textSize.Height / 2));
// Draw the "MIN" string
e.Graphics.DrawString("MIN", scatterGraph1.Font, Brushes.White, textLocation);
}
Hope this helps.
Abhishek Ghuwalewala
Measurement Studio
National Instruments