|
hiding chart labels. |
Posted by Stephen on Sep-13-2011 20:05 |
|
Hi
I am attempting to hide all the labels in the chart draw by financeChart
ive seen a couple of forum messages, like...
$c.getLegend().setPos(-9999, -9999);
ive tried this and it doesn't seem to work.
ive also tried...
$c->getLegend().setPos(-9999, -9999);
with no lick there either.
how do i get rid of the labels in one hit?
im using the php version of chartDirector.
thanks
Stephen |
Re: hiding chart labels. |
Posted by Stephen on Sep-14-2011 19:04 |
|
Cool
yes that works .
I?ve also worked out (using this example) that to ?void? an indicator label the following is the same syntax?.
This is what I have at the moment in my addIndicator function that creates the rsi indicator with labels..
return $m->addRSI($height, $args[0], 0x800080, 20, 0xff6666, 0x6666ff);
using your example from the thread? this works fine in removing the labels (which seems messy to me )?.
$b = $m->addRSI($height, $args[0], 0x800080, 20, 0xff6666, 0x6666ff);
$b->getLegend()->setPos(-9999, -9999);
return $m;
But if I write what I think should work, and seems ?a nicer way? of switching the labels off, it doesn?t actually work (the label still appears):
$m->addRSI($height, $args[0], 0x800080, 20, 0xff6666, 0x6666ff);
$m->getLegend()->setPos(-9999, -9999);
return $m;
The $b var is local only to the function, and is destroyed when $m is returned
$b appears to be an ?alias? of $m and not a cloned object of $m (ie $b = $m; )
Is this really just the standard php/OOP way of doing things?
I would of thought you could directly set the $m object?s properties?
Also? here is a good question: is there a way of putting the ?messy version ie: $b? in a single line?
Or will this just be to cryptic and have a performance overhead?
thanks in advance?
s |
Re: hiding chart labels. |
Posted by Peter Kwan on Sep-15-2011 01:01 |
|
Hi Stephen,
The $b is not an alias to $m or a clone of the object $m. It is the returned value of the addRSI method call, which is a reference to the XYChart object representing the RSI chart created.
You would need to use $b->getLegend(..) if you would like to manipulate the legend box of the RSI chart, because the legend box of the RSI chart is the property of the RSI chart.
$m is the FinanceChart container, which can contain the main price chart, RSI chart, and other indicator charts, each of which has its own legend box. If you use $m->getLegend, it is not sure which legend box you are referring to. (In fact, if you use $m->getLegend, you are referring to the legend box of the FinanceChart container itself, which is not used in FinanceChart.)
In PHP, a variable is always the reference of the object, just like most other modern OOP languages (Java, C#, VB, ...). The variable is not the object. It does not matter if your code destroys the variable. As long as there still exist a reference to the object somewhere, the object will be there. If there is no reference, the PHP system will reclaim the object.
To put the code in a single line, you can use:
$m->addRSI($height, $args[0], 0x800080, 20, 0xff6666, 0x6666ff)->getLegend()->setPos(-9999, -9999);
There is no practical performance overhead whether you use a single line or two lines.
Hope this can help.
Regards
Peter Kwan |
|