Measurement Studio for VB6

cancel
Showing results for 
Search instead for 
Did you mean: 

How to get Graph's PlotArea Position & Size

With Measurement Studio V6.0 it is possible to put annotation on Graph, in PlotArea coordinates.
But to use these annotations correctly, I need to know the Graph's PlotArea position (relative to ClientRectangle) and the size.
Hot to do that?
Regards
0 Kudos
Message 1 of 5
(3,720 Views)
If you change the annotation's CoordinateType property to cwPlotAreaCoordinates, the coordinates you set should be in plot area coordinates with no further calculations required. For example, this example creates a new annotation and sets the annotation to coordinates (25, 25) in the plot area:

Dim annotation As CWAnnotation
Set annotation = CWGraph1.Annotations.Add

annotation.CoordinateType = cwPlotAreaCoordinates
annotation.Caption.Text = "Hello"
annotation.Caption.SetCoordinates 25, 25

Please post a reply with more information if this does not do what you want.

- Elton
0 Kudos
Message 2 of 5
(3,720 Views)
Well....
Imagine you want to put an annotation in each corner of the PlotArea, to do that, you need to know the SIZE of the PlotArea. So my question is how to get the PlotArea size. Thanks anyway.
Regards
Stephane
0 Kudos
Message 3 of 5
(3,720 Views)
I see ... sorry about the confusion. There's not an easy way to do this. Probably the best way to position the annotations would be to use axes coordinates.

- Elton
0 Kudos
Message 4 of 5
(3,720 Views)
Here is a function that calculate X position relative to the graph control's parent window, from any X-axis value in the plot.

int CDlgWithGraph::GetXForPlotPoint( double dbPlotXValue )
{
CNiAnnotation annotation = m_ctrlGraph.Annotations.Item(1);
annotation.SetCoordinateType( CNiAnnotation::AxesCoordinates );
annotation.GetCaption().SetXCoordinate( dbPlotXValue );
annotation.SetCoordinateType( CNiAnnotation::ScreenCoordinates );
CPoint pt( annotation.GetCaption().GetXCoordinate(), 0 );
m_ctrlGraph.ClientToScreen( &pt ); // pt in screen
ScreenToClient( &pt );
return pt.x;
}

To get the SIZE of the plot area, pass min_x and max_x to width; pass min_y and max_y to get height. ( x,y values passed in are in pl
ot axes ).
Message 5 of 5
(3,720 Views)