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

Message ListMessage List     Post MessagePost Message

  Problem scaling Yaxis
Posted by niroshan on Jun-09-2008 16:35
Attachments:
Hi Peter,

I`m using PHP version of financial charting, and I have a problem in scaling the Yaxis.  As for the initial chart it does the yaxis scaling perfectly according to the data array I passed but the problem only comes when i try to add Fibonacci Retracement or any other custom lines.
The problem is if any of the custom lines has higher or min values which not  represent in the original chart, the lines draws outside the chart.(see attached image)

How do i rescale Yaxis values every time I add a custom lines which has greater or lower  Yaxis value then the original chart so all the custom lines will draw inside the chart?

Thanks in advance,

Best regards,
Niroshan
scalling.jpg

  Re: Problem scaling Yaxis
Posted by Peter Kwan on Jun-10-2008 01:25
Hi niroshan,

You may consider to add a Transparent scatter layer using the highest and lowest mark values as the data. This will cause the y-axis to include those values in its scale. For example:


$m = $c->addMainChart(.......);

$dummyData = array_pad(array(), count($timeStamps), NoValue);
$dummyData[count($timeStamps) - 1] = $highestMark;
$dummyData[count($timeStamps) - 2] = $lowestMark;
$m->addScatterLayer(null, $dummyData, "", SquareSymbol, 1, Transparent, Transparent);

Hope this can help.

Regards
Peter Kwan

  Re: Problem scaling Yaxis
Posted by niroshan on Jun-12-2008 16:18
Attachments:
Hi Peter,
Thank you very much for your reply. According to your guide lines i have managed to solve the problem 50%. :)

This problem occurred for me only when i try to add custom lines. In my chart I allow users to add support and resistance. How I add S&R lines are by creating custom lines.
This is what i did to solve the problem ,

step 1
------
Got the maximum and minimum values of the custom lines.

Step 2
-------
get the maximum and minimum  values of the chart using close, open, high and low arrays.(I did it using PHP min() and max() functions instead of using axis getMinValue() or getMaxValue() methods)

Step 3
-------
Compare both min and max values of custom lines with close, open, high and low arrays min and max values and set the most highest and lowest as the min and max values of the ScatterLayer and draw the layer.

This works very well and now all the custom lines will be drawn inside the chart. (refer image one)


but the problem comes when i try to add moving averages which will go beyond the higher values of close, open, high and low arrays. (refer image two)

Now I explain why i said i cannot use getMinValue() or getMaxValue() functions on step 1. that is because as for manual says we need to use layout() explicitly before we call those functions.

But the problem is if i call layout function in the middle of the chart drawing process that will effect the rest of the code like i wont be able to add addScatterLayer after calling the layout(). But as for my situation i need to add addScatterLayer after drawing the SMA because after drawing the SMA only i will be able to get the max of yaxis.

can we call layout() any where in the code and call necessary functions (ex: getMinValue() or getMaxValue() ) to get values and then switch off explicit auto-scaling and allow the auto-scaling facility back to chart director?

Is there anyway i can get max and min value of the yAxis after drawing the SMA or any other indicators, so i can make it as the max value of the chart to redraw the chart?

Thanks you,

Best regards,
Niroshan
before_SMA.jpg
after_SMA.jpg

  Re: Problem scaling Yaxis
Posted by Peter Kwan on Jun-13-2008 02:01
Hi niroshan,

In your case, you should not need to use the getMaxValue and getMinValue.

In fact, you just need to perform the followings:

(1) Got the maximum and minimum values of the custom lines. Use them to add a scatter layer.

There is no need to worry about the high/low/open/close or moving average or any other technical indicator or price bands. ChartDirector auto-scaling will automatically consider them when determining the axis scale.

Hope this can help.

Regards
Peter Kwan

  Re: Problem scaling Yaxis
Posted by niroshan on Jun-14-2008 20:04
Hi Peter,
Thank you very much. Its working perfectly now.

Thanks,
Best Regards,
niroshan