|
Controling chart axis origins and relative symmetry |
Posted by DC Kelley on Jun-14-2011 07:14 |
|
The XYChart.setAxisAtOrigin() call has a couple of constants whose proper use is not clear to me.
Are the values :
XYAxisSymmetric 16
XYAxisSymmetricIfNeeded 32
Intended to simply replace having to combine the X and Y constants (XAxisSymmetric and YAxisSymmetric) of is there more to this? Do they (when given a "square" plot area to work in) produce a square gird in the resultnig axis layout? In other words is this a way to insure that the layout will be Symmetric such that --both-- X and Y axis will have the same relative units? If would seem to me if there were simply a shortcut, the value would be a sum of the others, so perhaps there is more here then I an able to figure out.
I am trying to layout some spatial X-Y data and suddenly controlling this is needed to avoid skewing the data in the eye of the viewer.
As always, many thanks DC Kelley |
Re: Controling chart axis origins and relative symmetry |
Posted by Peter Kwan on Jun-15-2011 01:13 |
|
Hi DC Kelley,
The XAxisSymmetric ensures the magnitude of the positive and negative parts of the x-axis are of the same. The YAxisSymmetric is the same but applies to the y-axis. These two constants do not ensure the x-axis scale is the same as the y-axis scale.
The XYAxisSymmetric means that the positive and negative parts of the x-axis and y-axis are all the same. So it ensures the x-axis scale is the same as the y-axis scale.
Note that XYAxisSymmetric may not be what you need, because it always cause the original (0, 0) to be at the center of the chart. Also, it does not ensure the two axes are using the same pixels per data unit. For example, suppose the x-axis and y-axis scale are the same and are -100 to 100. If the plot area is 2000 x 200 pixels, for the x-axis, the -100 to 100 scale will be spread to 2000 pixels, which means 10 pixels per x-unit. For the y-axis, it would just be 1 pixel per y=unit.
For geographic charts, I think the best method is to simply specify the scale with your own code (eg. using Axis.setLinearScale). In this way, you can control the scale to ensure the two axes haing the same pixels per data unit.
Hope this can help.
Regards
Peter Kwan |
Re: Controling chart axis origins and relative symmetry |
Posted by DC Kelley on Jun-16-2011 00:23 |
|
I think I understand what you are saying now. Even when the X & Y scale is the same (and the image plot area is more or less 'square') the auto units and graph ticks and were not the same and that confused me. |
Re: Controling chart axis origins and relative symmetry |
Posted by Peter Kwan on Jun-16-2011 00:39 |
|
Hi DC Kelley,
The ticks are not the same because normally, we should use different label density for the x-axis and the y-axis. By default, if the labels are to be generated by ChartDirector, ChartDirector will use a minimum label spacing of 20 pixels for the y-axis, and 50 pixels for the x-axis.
The label spacings for x-axis and y-axis are different because text flows horizontally by default. So a label like "10000" will take a lot of space horizontally (the width for 5 characters), but only talk little space vertically (the height for one line). Therefore, naturally, we can put more labels on the y-axis, and less labels on the x-axis.
For your case, you can set the tick density for the x and y axes to be equal (eg. using Axis.setTickDensity to set the minimum tick spacing to 50). In this case, if the axes also have the same range and same length, then they will have the same labels.
Hope this can help.
Regards
Peter Kwan |
|