Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

aspect ratio of graph

When I resize the control its aspect ratio changes. IF say I have circle drawn will turn into oval or a square into recatngle. Please guide me in maintaining the aspect ratio of the drawn points.

thank you,
Shivu
0 Kudos
Message 1 of 11
(4,777 Views)
Hi Shivu,

You can use the button size property of the control to read the current width and height of the control, calculate the aspect ratio, calculate the new height based on the width and aspect ratio and programmatically change the button size.

Regards,
Ankita A.
Applications Engineer
National Instruments
0 Kudos
Message 2 of 11
(4,782 Views)
The points of a plot are specified in data coordinates, and how those points are drawn on screen are specified by the axes. If the axes become wider or taller, that changes the screen coordinates of the axis scale, hence changes how the data points are mapped on screen.

There may still be a way to do what you want. Could you please provide a little more information about what you're trying to do? For example, do you want the circle to always be in the same position in the plot area, regardless of the axis ranges? Or do you need the position of the circle to be specified in data coordinates? If you provide more information about what you're trying to do, I'll post an example that demonstrates how to do it if it's possible. Thanks.

- Elton
0 Kudos
Message 3 of 11
(4,782 Views)
Elton,

I am displaying the circle to be displayed always in the same position relative to the axis of the plot. When I rezise I want to keep the aspect ratio same so that the circle will retain the shape, I am not worried about the axis range (may be a change of upto +20% of the original axis range is ok).

thank you,
Shivu
0 Kudos
Message 4 of 11
(4,782 Views)
I'm still not 100% clear on what you're trying to do. What is the position relative to the axis that the circle is drawn? Ideally, are you wanting the circle to not resize at all, or do you want it to resize, but for it to always be a perfect circle and for it not to become an oval? If the latter, how should resizing the control influence the size of the circle? Should the size of the circle be a ratio of the size of the control, but still be a perfect circle? What does this circle represent? Thanks.

- Elton
0 Kudos
Message 5 of 11
(4,782 Views)
What is the position relative to the axis that the circle is drawn?

Answer>> A circle with radius one and centered at axis (0,0) on the scatteredgraph.

Ideally, are you wanting the circle to not resize at all, or do you want it to resize, but for it to always be a perfect circle and for it not to become an oval?

Answer>> I dont mind if it gets resized, but should not loose its shape (keeping the constant aspect ratio.) not to become oval. I have attached the project file

If the latter, how should resizing the control influence the size of the circle?
Answer>> when I resize the form the graph should will resize (takes the clinetsize of the form, in appln I have attached). the data doesnt, so the relative position of
data on the graph changes and the it looses it circle shape.



Should the size of the circle be a ratio of the size of the control, but still be a perfect circle?
Answer>> The circle should maintain the circle shape , I dont mind if the axis bounds are changed.


What does this circle represent?
Answer>> represented by drawing the points connected by solid line in a UI.scatterplot object.

try to resize the form in the appln that I have attached, it looses it shape. I would like maintain the shape and keeping the same data. If the axis bounds are automatic i dont mind it if it varies from +/- 1 to +/- 1.2 .

Hope I am clear this time, thank u.
shiva
0 Kudos
Message 6 of 11
(4,782 Views)
I could able to do it with the plaotarea and range of x/y axis.
0 Kudos
Message 7 of 11
(4,782 Views)
Sorry for the delayed response on this. I read your answers and looked at your example, but I still wasn't quite sure what you wanted. It would be possible to have a circle in the graph and keep it a circle as the control were resized, but then the circle would no longer map to same data coordinates as specified by the axes. You mentioned that you were able to do it with the plot area and the range of the x/y axes. Just out of curiosity, could you please elaborate on this solution? Thanks.

- Elton
0 Kudos
Message 8 of 11
(4,782 Views)
when the control is resized, by calculating the range of x or y (by keeping the either one fixed to say range 1) for the existing plotAreaBounds.
below is the code:

//////////////////////////////////////////
Range fix = new Range((double) -1.0, (double) 1.0);

if (graph.PlotAreaBounds.Height > graph.PlotAreaBounds.Width)
{
xAxis.Range = fix;
dMax = (double)graph.PlotAreaBounds.Height/
(double)graph.PlotAreaBounds.Width;
dMin = (-1) * dMax;
{
yAxis.Range = new Range(dMin, dMax);
}
}
////////////////////////////////
0 Kudos
Message 9 of 11
(4,782 Views)
Hi Elton,
is this feature added in version 7.1?
Please let me know.
thank u
Shiva
0 Kudos
Message 10 of 11
(4,782 Views)