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

Message ListMessage List     Post MessagePost Message

  Multiple scales on one y axis
Posted by David on Mar-15-2013 23:40
In order to save space, is there an option to combine multiple y axes on to one displayed axis?  The displayed axis would show one set of ticks with the corresponding axes values labeled at each tick mark.  I realize this could be done manually, but I was wondering if there was a built-in mechanism for this that handles the spacing computations.

Thanks.

  Re: Multiple scales on one y axis
Posted by Peter Kwan on Mar-18-2013 23:12
Hi David,

As you probably are already aware, ChartDirector supports multiple y-axes, and an example is in the "Multiple Axes" sample code. In that sample code, the axes are placed 50 pixels apart, but you can certainly place the axes 0 pixel apart, so they overlap.

However, if the axes overlap, it is possible the axis labels will overlap too. If you overlap many y-axis, the labels may become hard to read.

The followings are some ideas you may consider to manage the labels:

(a) If the labels are specified by your code, your code can always choose the labels so that they do not overlap.

(b) If you are using auto-scaling, and the labels are automatically generated by ChartDirector, you may try to increase the label distance (using Axis.setTickDensity). In this way, you can reduce the number of labels on an axis, so that there is less chance of overlapping.

(c) You can configure the labels to have a non-transparent (or semi-transparent) backgrouind (using Box.setBackground on the TextBox object returned from Axis.setLabelStyle). In this way, if the labels overlap, the labels in front will block the labels in the back, and you can still see the labels in front clearly.

(d) You can move some of the labels away from the axis (using Axis.setLabelGap). For example, the labels for the first axis may stay at the default position, while the labels for the second axis may be moved further to the left side (assumed the y-axis is vertical and on the left side of the plot area). It is like have two columns of labels for the two axis scales. However, this method will increase the space used.

Regards
Peter Kwan

  Re: Multiple scales on one y axis
Posted by David on Mar-19-2013 07:51
Thanks for the tips.  We'll certainly try those out and see if we can make it work.  The sample charts we've seen that use this method allow the multiple axes to share tick points.  On each tick, all axes values are displayed with line breaks.  Looks something like this:

1000
100    -
10

500
50      -
5

100
10      -
1

I believe the default behavior is to have a primary axis that sets the ticks, and the other axes values are filled in for that particular tick location regardless of whether the value is a logical tick point.

I do realize this can be done manually - just wanted to make sure I wasn't overlooking a feature that's already present.

  Re: Multiple scales on one y axis
Posted by Peter Kwan on Mar-19-2013 23:24
Hi David,

If the labels are related, you can just use one y-axis, and configure its labels to show 3 lines, like:

c.yAxis().setLabelFormat("{={value}*100}\\n{={value}*10}\\n{value}");

You can even use CDML to configure the three lines to have different colors or font style (see http://www.advsofteng.com/doc/cdnet.htm#cdml.htm).

If your axis scale is automatically determined by ChartDirector, you may want to use "c.yAxis().setTickDensity(60);" to make sure ChartDirector reserve sufficient space between labels (because your labels are taller than usual). On the other hand, if you code fully specifies the scale and the ticks, then there is no need to use setTickDensity.

Hope this can help.

Regards
Peter Kwan

  Re: Multiple scales on one y axis
Posted by David on Mar-20-2013 02:16
Great - thanks Peter.  That sounds like what I'm looking for.

  Re: Multiple scales on one y axis
Posted by Chris on Jan-31-2014 02:04
I am evaluating ChartDirector for our software. How can we have Multiple scales on one y
axis using MFC?

Thanks

  Re: Multiple scales on one y axis
Posted by Peter Kwan on Jan-31-2014 05:15
Hi Chris,

Yes. You can have multiple scales on one y-axis. The exact details depend on the
relationship between the scales.

If the scales are independent (eg. one scale is the temperature, and the other scale is the
rainfall), you can add two y-axes to the chart. (See the "Multiple Axes" sample code.) You
can put the two y-axes in the same position, so it looks like a single axis. However, if the
scales are automatically determined by ChartDirector based on your data, as the scales are
independent, there is no guarantee that their labels would not overlap.

If the scales are dependent (eg. one scale is temperature in Celcius, the other scale is
temperature in Fahrenheit), you can just use a multi-line label to display the two scales like
what is mentioned previously in this thread. In general, the multi-line label method works if
you know how the two scale are related. For example, if the two scales are temperature
and rainfall, and for some reason, you want the rainfall label to be equal to 10 times the
temperature label, then the multi-line method would also apply.

Hope this can help.

Regards
Peter Kwan