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

Message ListMessage List     Post MessagePost Message

  Fixed X axis / Y axis ratio
Posted by achar on Jun-23-2022 22:22
Hello,

I cannot find a similar question in the forum, so I will ask. Is there a way to "lock" the X and Y axis ratio? In particular, I want to draw a cross section consisting of multiple (x,y) points. Both axes will display the same unit of length (e.g., m), so I do not want the image to be "distorted". The step in X direction must be the same as in the Y direction. Can ChartDirector do that?

Thank you in advance,

  Re: Fixed X axis / Y axis ratio
Posted by Peter Kwan on Jun-24-2022 04:30
Hi achar,

For "cross section", are you referring to the cross section like in the "Contour Chart Cross Section" sample code:

https://www.advsofteng.com/doc/cdnet.htm#contourcrosssection.htm

Or are you just referring to a general chart with an x-axis and a y-axis?

For a general XY Chart, if you can use Axis.setLinearScale to specify the axis scale (instead of letting ChartDirector automatically determine the axis scale), then you can always specify any scale you like and you can certainly lock the x/y axis ratio with your code. For example:

// Setting both the x-axis and y-axis to 0 to 10.
c.xAxis().setLinearScale(0, 10, 1);
c.yAxis().setLInearScale(0, 10, 1);

If you let ChartDirector auto-scale both the x-axis and y-axis, then ChartDirector will determine the axis scale to best fit your data points, but it cannot ensure the one x-axis unit and one y-axis unit are of the same length in pixels.

You can let ChartDirector auto-scale one axis, and configure the second axis to synchronize with the first axis using Axis.syncScale. The two axes scale will then be locked into a fixed ratio (such as 1). Note that in this case the second axis scale may not be best fit for your data. In particular, depending on your application, it may be possible some data points will fall outside the axis.

Regards
Peter Kwan