ASE Home Page Products Download Purchase Support About ASE
ChartDirector General
Forum HomeForum Home   SearchSearch

Message ListMessage List     Post MessagePost Message

  How to keep a same scale between x-axis and y-axis?
Posted by JSF on Nov-07-2016 17:33
Attachments:
Firstly, thank you very much for your help before.

Based on your suggestion, I rewrote the code.    Now the extracted demo can simulate the realtime trajectory data of vehicles. Zooming in and out by mouse wheel is also ok.

But the scale between the x-axis and y-axis still can't keep the same, even though i add code shown by your sample in the OnViewPortChanged method.

I think this problem may be related to the syncLinearAxisWithViewPort method, which is added in the drawchart function at line 544 in ScrGraphic_TestDlg.cpp.

When I commented syncLinearAxisWithViewPort method, it seems that zooming and moving chart is not available.

The attached file is about the demo. Can you please help me to optimize the code and identify the bugs?

By the way, the attachment is up to 250K. so I compress the project and the chartdir60.dll should be add on the ScuGraphic_TestScuGraphic_Test or dubug in order to start the program.


Thanks again.
ScuGraphic_Test.rar
ScuGraphic_Test.rar

233.84 Kb

  Re: How to keep a same scale between x-axis and y-axis?
Posted by Peter Kwan on Nov-08-2016 03:43
Hi JSF,

In my testing of your code, I found that the axis data range are the same for the x-axis and y-axis. For example, if the x-axis zoomed to 60 units long (such as from -20 to 40), the y-axis is also 60 units long.

However, the aspect ratio of the x and y units are not 1:1. It is because your code sets the full x-axis and y-axis scale to be the same -50 to 50. However, the width and height of the plot area is not the same. (The plot area can be rectangular.) So the chart is initialized with the aspect ratio not 1:1, and it will keep the same ratio so that the line will be zoomed by the same factor in both x and y directions.

If you want the aspect ratio to be 1:1 as well, please use a rectangular plot area, or you can modify the x and y full range so that they are proportional to the plot area width and height. For example, if the x range is -50 to 50, and the plot area width:height = 2:1, then the y-axis full range can be set to -25 to 25.

In summary, the aspect ratio of the chart will be the aspect ratio that you initially configured.

Hope this can help.

Regards
Peter Kwan