|
How to add multiple close lines on PHP finance chart |
Posted by Wajid Khilji on Apr-11-2012 20:51 |
|
Please can you tell me ho can I add multiple close lines in PHP finance chart
Thanks and regards
Wajid Ali |
Re: How to add multiple close lines on PHP finance chart |
Posted by Peter Kwan on Apr-12-2012 03:05 |
|
Hi Wajid,
You can use something like:
$m = $c->addMainChart(240);
$c->addCloseLine(0x008800);
#add another close line for a different stock
$c->addLineIndicator2($m, $myOtherCloseData, 0xcc0000, "xxx");
If your intention is to add two close lines for comparison purpose, you may consider to use FinanceChart.addComparison. This method will adjust the second close line so that it starts at the same point as the first close line to facilitate comparison.
Hope this can help.
Regards
Peter Kwan |
Re: How to add multiple close lines on PHP finance chart |
Posted by Wajid Ali on Apr-12-2012 14:22 |
|
Thanks
Actually I forgot to mention I need to add custom labels on a finance chart as well along
with multiple close lines. I have done this previously in C# with your support now I want to
do the same in PHP.
Thanks and regards
Wajid Ali |
Re: How to add multiple close lines on PHP finance chart |
Posted by Peter Kwan on Apr-13-2012 00:07 |
|
Hi Wajid,
You can use the same method as in your C# code to add the custom labels. If you can inform me the C# code you are using, I can translate it to PHP for you.
For example, if you would like to add a custom label in some points on a line, you may use Layer.addCustomDataLabel, like:
$layer = $c->addLineIndicator2($m, $myOtherCloseData, 0xcc0000, "xxx");
$layer->addCustomDataLabel(............);
If you would like to add a custom label on the axis, you may use Axis.addMark, like:
$m->yAxis->addMark(..........);
Hope this can help.
Regards
Peter Kwan |
Re: How to add multiple close lines on PHP finance chart |
Posted by Wajid Ali on Apr-13-2012 15:39 |
|
Thans peter,
When ever I do something on experimental basis, debug always lead me to this code
garbageCollector() {
global $cd_garbage;
reset($cd_garbage);
while (list(, $obj) = each($cd_garbage))
$obj->__del__();
$cd_garbage = array();
}
and then all stops.
I have tried the code but it also leads me here.
Well Sir as you have asked the C# code is written below.
///m is a finance chart
XYChart mainChart = m.addMainChart(mainHeight);
mainChart.setBackground(Chart.Transparent);
mainChart.addLineLayer(closeData1, 0x99ff66);
mainChart.xAxis().setLabels(labels);
Thanks and regards
Wajid Ali |
Re: How to add multiple close lines on PHP finance chart |
Posted by Peter Kwan on Apr-14-2012 01:14 |
|
Hi Wajid,
The garbageCollector function is registered as a shutdown function. Right after the garbageCollector code, you should see the following line which registers garbageCollector as a shutdown function.
register_shutdown_function("garbageCollector");
So when PHP is about the shutdown (eg. because it has already finished the script), it will call this garbageCollector. Therefore, it is normal that you always end at garbageCollector and then the script terminates.
For the C# code, the equivalent code in PHP is:
###m is a finance chart
$mainChart = $m->addMainChart($mainHeight);
$mainChart->setBackground(Transparent);
$mainChart->addLineLayer($closeData1, 0x99ff66);
$mainChart->xAxis->setLabels($labels);
The above assumes you have the equivalent variables in your PHP code (the variables $m, $mainHeight, $closeData1 and $labels).
Hope this can help.
Regards
Peter Kwan |
Re: How to add multiple close lines on PHP finance chart |
Posted by Wajid Ali on Apr-14-2012 16:34 |
|
Thank You very much peter. It works
But it is some how I not showing the labels expectedly. might be an error in code or
anything. Can you tell me where could I be wrong in this. The chart is attached
Thanks and Regards
Wajid Ali
|
Re: How to add multiple close lines on PHP finance chart |
Posted by Peter Kwan on Apr-17-2012 00:38 |
|
Hi Wajid,
For "no labels are showing", are you referring to the x-axis labels?
As I have not seen your code, I am not sure what is the cause of the problem. My guess is that $labels contain only 1 label, so only 1 label is shown.
For testing, you may try to use your $closeData as labels.
$mainChart->addLineLayer($closeData1, 0x99ff66);
$mainChart->xAxis->setLabels($closeData1);
Another testing method is to display the labels somewhere else on the chart. For example:
$m->addTitle("count = " . count($labels) . " * " . count($closeData1) . " * " . $labels[count($labels) - 1]);
The above should show the number of labels, number of data points, and the last label in your array. This may help to diagnose the problem (eg. to check if the number of labels is the same as the number of data points).
If you need further help, would you mind to inform me of the charting part of your code, and also the result of the chart with the above "addTitle" code?
Regards
Peter Kwan |
Re: How to add multiple close lines on PHP finance chart |
Posted by Wajid Ali on Apr-17-2012 15:22 |
|
Found it, Thanks peter |
Re: How to add multiple close lines on PHP finance chart |
Posted by ravi akasapu on Jul-30-2013 21:46 |
|
Hi,
Instead of using Add Comparison, is there any other way we can add multiple close lines for
Finance Charts.
I am using below code, This code is allowing me to create two close lines in single chart.
But I need to seperate the Y-axis for both close lines.
$c->setData($timeStamps, $highData, $lowData, $openData, $closeData, $volData,
$extraDays);
$c->setLegendStyle("normal", 8, Transparent, Transparent);
$c->addMainChart(200);
$c->addCloseLine(0x00ff00);
$c->setData($timeStamps, $highData, $lowData, $openData, $closeData1, $volData,
$extraDays);
$c->addCloseLine(0x000099);
Please let me know.
thanks
Ravi |
Re: How to add multiple close lines on PHP finance chart |
Posted by Peter Kwan on Jul-31-2013 02:08 |
|
Hi ravi,
You may add a line to an XYChart (eg. the main price chart) in a FinanceChart just like adding a line to a normal XYChart. For example:
$c->setData($timeStamps, $highData, $lowData, $openData, $closeData, $volData,
$extraDays);
$c->setLegendStyle("normal", 8, Transparent, Transparent);
$myXYChart = $c->addMainChart(200);
$c->addCloseLine(0x00ff00);
$myLineLayer = $myXYChart->addLineLayer($closeData1, 0xff0000, "My Line");
$myLineLayer->setUseYAxis2(); #bind to another y-axis
Hope this can help.
Regards
Peter Kwan |
|