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

Message ListMessage List     Post MessagePost Message

  Determine min. and max. values for auto-scaled y-axis before base.layout
Posted by Frank on Apr-22-2005 17:41
Hi Peter,

I am wondering if there is way in ChartDirector to solve my problem, I hope you understand my explanation:

I have datapoints that are outside the visible range of a chart I am drawing. This is not optimal for the user as he is not able to retrieve datapoint tool tip information for such datapoints. My idea therefore was to draw datapoints outside the visible range right on the max. or min. edge of chart and visualize this with a special icon. This works perfect for charts that use a y-axis that is calculated by myself, knowing the exact range of the y-axis.

I also need to draw charts with an auto-scaled y-Axis. I use setLinearScale for this.  I know in order to obtain the max. and min. axis value I need to call base.layout(). The problem is, that at this time the chart is already created, too late for me to correct the y-position of out-of-range datapoints. I use an internal calculation that gets me very close max. and min. y values with the result that such datapoints are positioned very close to the edge, but not precise enough.

I cannot draw the chart twice as this takes too long. Is there another idea you have in mind to solve my problem?

Thanks, Frank

  Re: Determine min. and max. values for auto-scaled y-axis before base.layout
Posted by Peter Kwan on Apr-22-2005 20:12
Hi Frank,

There are many methods to solve this problem. I think the key problem is that you seems to use a "semi-automatic" auto-scaling, that is, you use setLinearScale to suggest a max/min value without suggesting the tick spacing, and let ChartDirector auto-scaling to determine the tick spacing and "round" the axis to the tick position.

If you use full auto-scaling, then the problem will not exist because it is impossible to have data points outside the axis range. ChartDirector will always scale the axis to include all data points.

If you use full manual scaling (that is, provide 3 parameters to setLinearScale), the problem also will not occur, because ChartDirector will use your scale exactly as it is without adjustment, so the max/min values will be whatever you provide to ChartDirector.

There are several methods I can think of. You may disable "axis rounding", so that the axis end points will be at exactly the min/max value you provide, even under auto-scaling. The draw back is if the axis is not guarantee to start or end at a tick position. The code is (in VBScript):

Call c.yAxis().setRounding(0, 0)

The other method is to draw the "symbol" after layout. I am not sure what is the "symbol" you mention. If it is an image symbol on a file, you can draw it easily after layout with:

'Assume the code is on a web server, and the image is relative to the current URL
Call c.setSearchPath(Server.MapPath("."))
Call c.addText(xPixelCoor, yPixelCoor, "<*IMG=mySymbol.png*>")

The yCoor above is trivial. It is just the pixel coordinate of the plot area top edge (you don't need to know the axis scale). If you need to get the xPixelCoor given an x-value, you may use Layer.getXCoor.

Regards
Peter Kwan

  Re: Determine min. and max. values for auto-scaled y-axis before base.layout
Posted by Frank on Apr-22-2005 20:41
Hi Peter,

you are such a Wiz! Setting rounding to false solved my problem. Thanks a lot for your quick and helpful assistance.

Regards, Frank