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

Message ListMessage List     Post MessagePost Message

  Adding an extra axis on the left side with percentage against min value
Posted by daniel on Nov-07-2019 17:42
Attachments:
Hi all,

I am trying to achieve something simple with no success. I certainly miss something simple since I have been able to work out much more complex stuff with the great CD API!

The issue - have an extra percentage axis on an XY plot - on the right side of the plot with tick marks that would be the typical nicely rounded values (100%,120%... or 100%,150%,...) depending on Y values, font size and plot height that CD typically provides.

What I currently do - see pseudo code below - is add an extra Y axis and sync the values of both axes. It works but I cannot get the extra axis to work as expected, tick on rounded percentage values:

oCompareAxis = oChartObject.addAxis(6,0)
oCompareAxis.syncAxis(oChartObject.YAxis())
oCompareAxis.SetLabelFormat("{={value}100/25000|0}%") && 25000 is the min value!

The axes remains in full sync:-(

I expect I may possibly achieve the result if I add some hidden layer to the XY chartobject feed the layer with the percentage values and then set the extra axis accordingly. Am I right? Is there a smarter alternative?

Daniel
unsync_axes.png

  Re: Adding an extra axis on the left side with percentage against min value
Posted by Peter Kwan on Nov-08-2019 12:53
Hi Daniel,

According to your code, the left and right y-axis are at the same scale (they are synchronized), but the labels are formatted to make them look different.

My understanding of your case is that the right y-axis is not used to plot anything in the chart. It is used for human reading only. You want the right y-axis scale to be related to the left y-axis scale, but not the same. It is like one side shows the weight in pounds, and the other side shows the same weight in kg.

For this type of usage, you can use syncAxis to set the scale. For example:

' The right y-axis scale is equal to the left y-axis scale multiplied by 100.0/25000
oCompareAxis.syncAxis(oChartObject.yAxis(), 100.0/25000)

By default, the right y-axis labels will be at the grid line positions. This means that the y-axis label may not be "nice numbers", depending on the scale factor. If you want the right y-axis labels to be "nice numbers", then the ticks between the two y-axes would not align. If this is what is needed, you can use:

oCompareAxis.setRounding(False, False)

Hope this can help.

Regards
Peter Kwan

  Re: Adding an extra axis on the left side with percentage against min value
Posted by daniel on Nov-08-2019 17:09
Hi Peter,

>oCompareAxis.setRounding(False, False)
>Hope this can help.

It did! Thanks for the fast and helpful answer.

Daniel

  Re: Adding an extra axis on the left side with percentage against min value
Posted by Daniel on Nov-11-2019 19:48
Attachments:
Just better with a telling image:-)

Daniel
sync_axes.png