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

Message ListMessage List     Post MessagePost Message

  Must Axis::setLinearScale be called before addScatterLayer?
Posted by Michael Stache on Feb-03-2025 22:20

Hello Support,

as the subject already states: I saw that my left Y axis only draws the right way, if I call Axis::setLinearScale before all calls to addScatterLayer. Is there a way that I can reverse this order: call addScatterLayer first and then do the Y axis scaling? Because my algorithm is much easier then.

Thanks for advice.
Michael

  Re: Must Axis::setLinearScale be called before addScatterLayer?
Posted by Peter Kwan on Feb-03-2025 22:53
Hi Michael,

Yes, you can call addScatterLayer first or setLinearScale first. It does not matter.

What you cannot do is to call setLinearScale after the axis scale has already been "finalized". For example, consider the following sequence:

1. call addScatterLayer

2. call c->layoutAxes() or c->layout() or c->makeChart(), so that you can use XYChart::getYCoor to obtain the y-pixel coordinates given the y-data value. This implies the y-axis scale must have been finalized. In this case, calling setLinearScale may have no effect.

As a test, you can start with the Scatter Chart sample code:

https://www.advsofteng.com/doc/cdcpp.htm#scatter.htm

You can add a line like c->yAxis()->setLinearScale(0, 300, 50); either before or after the addScatterLayer line, and in either case the y-axis scale will change to 0 - 300 with a tick every 50 units.

Best Regards
Peter Kwan