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

Message ListMessage List     Post MessagePost Message

  3-D Scatter chart autoscaling
Posted by Michael on Mar-14-2019 20:46
When I draw a 3-D scatter chart, I want its Z axis to always start at zero.  Instead its Z axis is autoscaled to the data on the first draw even though I have
Chart3D.zAxis().setLinearScale(0, ZMax);
After the first draw (in other words if I redraw during pan/zoom or something like that), the Z axis properly starts at zero.  How can I force autoscaling off?  Axis.setAutoScale() is not available for 3D charts.
Thank you-

  Re: 3-D Scatter chart autoscaling
Posted by Peter Kwan on Mar-15-2019 14:55
Hi Michael,

The code Chart3D.zAxis().setLinearScale(0, ZMax); should ensure the z-axis starts at 0, unless zMax is 0. If zMax is 0, then it is an invalid scale, and ChartDirector will ignore it.

Anyway, another method to ensure the z-axis starts at 0 is to use:

Chart3D.zAxis().setAutoScale(0, 0, 1);

The third parameter is the "zero affinity parameter". If set to 1, it tells ChartDirector to always include zero when auto-scaling the axis. See:

https://www.advsofteng.com/doc/cdnet.htm#Axis.setAutoScale.htm

Note that the setLinearScale or setAutoScale must occur before the chart is displayed. It has no effect if the chart has already been displayed.

Regards
Peter Kwan

  Re: 3-D Scatter chart autoscaling
Posted by Michael on Mar-19-2019 00:41
Dear POeter,
Thank you for the suggestion.  The part that actually did the trick was, "Note that the setLinearScale or setAutoScale must occur before the chart is displayed. It has no effect if the chart has already been displayed."  It's not clear to me when the chart is actually "displayed"  (I thought it was sometime after  viewer.Chart = c; but evidently it is sooner.  I moved my setLinearScale() earlier in the sequence and suddenly it worked.
Thanks!

  Re: 3-D Scatter chart autoscaling
Posted by Peter Kwan on Mar-19-2019 03:17
Hi Michael,

Sorry for the confusion. ChartDirector will only compute the axis scale once, after which the setLinearScale has no effect. The axis scale is computed when it is needed in order to generate the output, which can include generating the chart image or the image map. The axis scale is also computed when "BaseChart.layout" or "BaseChart.makeChart" is called, because ChartDirector cannot determine the position of chart objects unless the axis scale is fixed.

Regards
Peter Kwan