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

Message ListMessage List     Post MessagePost Message

  Set min/max axis values across charts
Posted by Steve on Sep-07-2021 08:28
Hi. I am producing several dual yAxis charts, and I want the min/max of the scales to be comparable across them.  I have looked at the yAxis object, which has getMinValue and getMaxValue but no setMinValue or setMaxValue.

Can you please point me to an example of how to set the mix/max on a yAxis?

  Re: Set min/max axis values across charts
Posted by Peter Kwan on Sep-07-2021 12:50
Hi Steve,

If your code does not specify the axis scale, ChartDirector will automatically determine the axis scale based on your data. So it is possible different charts has different axis scales.

You can specify the axis scale using Axis.setLinearScale,  Axis.setLinearScale2, Axis.setLogScale, Axis.setLogScale2, ..... See:

https://www.advsofteng.com/doc/cdperl.htm#Axis.setLinearScale.htm
https://www.advsofteng.com/doc/cdperl.htm#Axis.setLinearScale2.htm
https://www.advsofteng.com/doc/cdperl.htm#Axis.htm

For example (in Perl):

# Scale from 0 to 100, with a label every 20 units
$c->yAxis()->setLinearScale(0, 100, 20);

Sometimes it may be desirable to have ChartDirector automatically determine the axis scale but somehow keep the scale of all charts the same. One method to do this is to add all the data for all the charts into the first chart as a transparent line layer. The line would not be visible but ChartDirector will determine the y-axis scale based on all the data, so that the y-axis scale can include all the data range. The y-axis of other charts can then be synchronized with that of the first chart using Axis.syncAxis (or you can add all the data to the other charts too as a transparent layer.)

Regards
Peter Kwan

  Re: Set min/max axis values across charts
Posted by Steve on Sep-10-2021 02:32
Your last suggestion sounds like it would be the best option for me.  Can you point to an example of doing this?  I have five series.   Do you mean just push all the values onto a $data_all list?  Then not quite sure how to add that to an invisible layer.

  Re: Set min/max axis values across charts
Posted by Peter Kwan on Sep-11-2021 02:59
Hi Steve,

You can try:

$c->addLineLayer($myData0, $perlchartdir::Transparent);
$c->addLineLayer($myData1, $perlchartdir::Transparent);
$c->addLineLayer($myData2, 0xff0000);
$c->addLineLayer($myData3, $perlchartdir::Transparent);
$c->addLineLayer($myData4, $perlchartdir::Transparent);

There are 5 line layers, but only one of them is visible (the $myData2). The y-axis scale will be determined based on all 5 series. If all your charts are coded in the same way, with the same 5 layers, but only one line visible, then they can display different lines yet have the same y-axis scale.

Regards
Peter Kwan