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

Message ListMessage List     Post MessagePost Message

  Match zero-line of two y-Axis
Posted by Andreas on Sep-26-2017 16:29
Attachments:
Hello Peter,

in the attachment i have a chart with two y-axis, the left one shows the values, the right one the accumulated values.

I understand that chartdirector distributes the values and accumulated values on the corresponding axes but for our customer it is confusing, that there are two "zero-lines".

1) Is it possible to match the two zero-lines, i.e. make the accumulated values not start at the bottom but on the zero-line of the values?

2) Why does the value-Axis start at -60000? The minimum value is -31124,80 and I wonder why it doesn't start at -40000...

Thank you again for your help!
BR
Andreas
Welding.PNG

  Re: Match zero-line of two y-Axis
Posted by Michael P on Sep-26-2017 19:10
1. Use sync axis:
void syncAxis(const Axis *axis, double slope = 1, double intercept = 0);

2. You can always set your own LinearScale(...)

  Re: Match zero-line of two y-Axis
Posted by Peter Kwan on Sep-27-2017 01:21
Hi Andreas,

(1) Unluckily, ChartDirector auto-scaling cannot automatically match the zero lines. You would need to at least define the scale of one of the axis with your own code. As mentioned by "Michael P" in an earlier post, using syncAxis is a possible method.

For your case, if the one of the axis are for raw data and the other axis for the "accumulated data", you may let ChartDirector auto-scale the raw data axis, and provide a multiplier for the accumulated axis. For the chart in your post, a multiplier can be 10, which means the accumulated axis will be from -600000 to 1000000. The code is like:

c.syncAxis(multiplier);

The key code you need to write is to compute the multiplier. One method is like:

(a) Determine the ratio of the maximum position values of the raw data and accumulated data.

(b) Determine the ratio of the most negative values of the raw data and accumulated data.

(c) Choose the maximum of (a) and (b) as the starting point of the multiplier

(d) Round up the multiplier to some "nice number" (such as 2, 5, 10, 20, 50, 100, ...).


(2) The minimum scale is -60000 instead of -40000 because by default, ChartDirector auto-scaling will ensure there is a 10% "scale margin" to avoid the data representation (the line for line charts) from being too close to the axis. It happens after adding the margin, the lower limit falls below -40000, so ChartDirector has to choose the next label position -60000. The Axis.setAutoScale can be used to change the scale margin. For example:

// set the scale margin to 0 with no zero affinity
c.yAxis().setAutoScale(0, 0, 0);

See:

http://www.advsofteng.com/doc/cdcoldfusion.htm#Axis.setAutoScale.htm

Regards
Peter Kwan