Aspect Ratio of Chart

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Post Reply
jenb
Newbie
Newbie
Posts: 50
Joined: Thu Jun 21, 2007 12:00 am

Aspect Ratio of Chart

Post by jenb » Wed Mar 18, 2009 10:30 am

I am using a surface series chart. Even when I have 100 x, and 100 z points the chart appears as a rectangle, not a square. How can I fix the aspect ratio of the chart so that it appears as a square.

Thanks in advance for any help.

Yeray
Site Admin
Site Admin
Posts: 9613
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Post by Yeray » Wed Mar 18, 2009 11:18 am

Hi jenb,

If your chart axes are longer for X values than in Y values (or reverse), the axis is auto-scaled to fit you series values. I you want the axis "proportional", you could do something similar than the demo at Welcome !\Axes\Isometric axes
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

jenb
Newbie
Newbie
Posts: 50
Joined: Thu Jun 21, 2007 12:00 am

Post by jenb » Fri Mar 20, 2009 9:12 am

Dear Yeray

Your suggested solution does work for initial display of the chart, but how do I deal with the OnRotate event?

It would be nice if there were some options in the chart that could scale the two axis according to their min and max values.

Regards

jenb

Yeray
Site Admin
Site Admin
Posts: 9613
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Post by Yeray » Fri Mar 20, 2009 10:15 am

Hi jenb,

Some time ago I've made an example for a customer that asked for something similar, if I understand well. Here it is the topic. Note that this was made for VB6 and TeeChart ActiveX. If you find problems translating it, feel free to ask here and we'll try to help you.
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

jenb
Newbie
Newbie
Posts: 50
Joined: Thu Jun 21, 2007 12:00 am

Post by jenb » Thu Apr 02, 2009 1:33 pm

Yeray

I looked at your example, but I can't use the code from it, quoted below, as HandleDC is no longer supported.
XYScreen = (GetDeviceCaps(.Canvas.HandleDC, HORZSIZE) / Screen.Width) / (GetDeviceCaps(.Canvas.HandleDC, VERTSIZE) / Screen.Height)
I am using the following code
Screen screen = Screen.FromControl(this);
Graphics g = Graphics.FromHwnd(this.Handle);
IntPtr hptr = g.GetHdc();

double xyscreen = GetDeviceCaps(hptr, HORZSIZE) * screen.Bounds.Height;
xyscreen /= (double)GetDeviceCaps(hptr, VERTSIZE) * screen.Bounds.Width;
Which is from your example in the features gallery. I am using a 3D surface chart but I only require the bottom and depth axis (x and z to be the same length). Actually they have the same min and max values, maybe I just need to set the axes to Automatic?

Regards

jenb

Yeray
Site Admin
Site Admin
Posts: 9613
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Post by Yeray » Mon Apr 06, 2009 10:52 am

Hi jenb,

1. Yes, you have to calculate xyscreen relation as you are doing. That's one of the differences in the process in VB6 and VS.

2. So, if I understand well, you would like to see the bottom and the depth axis with the same length in pixels. But it's necessary they have the same angle with the horizontal or not?
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

jenb
Newbie
Newbie
Posts: 50
Joined: Thu Jun 21, 2007 12:00 am

Post by jenb » Mon Apr 06, 2009 12:51 pm

Hi Yeray

I managed to get both axis equal by multiplying xyscreen by constant 1.7 (see below)
double xyscreen = GetDeviceCaps(hptr, HORZSIZE) * screen.Bounds.Height*1.7;
xyscreen /= (double)GetDeviceCaps(hptr, VERTSIZE) * screen.Bounds.Width;
I want both axis to look the same regardless of the rotation. I call the function in the OnMouseUp event and it works ok, but I have the problem of the chart "shrinking" as mentioned by the user in the example below.

http://www.teechart.net/support/viewtopic.php?t=7885

I posted an example screen shot "Sn 552 Peak Energy Only.jpg" on your upload site. Does the drawThebox function in your solution in the above URL get over the "shrinking" problem. I found it quite hard to translate this function and I haven't included it so far in my code.

Regards

jenb

Yeray
Site Admin
Site Admin
Posts: 9613
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Post by Yeray » Tue Apr 07, 2009 7:46 am

Hi jenb,

Ok. Having a chart with an elevation like in the picture, I think I understand the meaning of rotating the chart. I'll try to make an example that will consider the elevation and the rotation in order to calculate and draw the isometric axis.

Regarding the shrinking problem, I think that this was due to rounding calculations but it was skipped by forcing the chart to be repainted one or maybe two times more.

The drawTheBox method was very particular for this customer. He had 3D points in a box... The last code I posted there resulted in this:

Image
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

Post Reply