|
Highlight the ending point on Y axis |
Posted by techsoft on Jun-17-2015 19:32 |
|
Hi Peter,
1.How to highlight the last ending point of moving averages and last trading point on Y-
axis with a thin rectangle box or with a light background color.?
2.How to make a little gap between graph and chart box end line?, because users might be
not able to see the last point.
please find the below image.
Thanks,
Techsoft
|
Re: Highlight the ending point on Y axis |
Posted by Peter Kwan on Jun-18-2015 03:31 |
|
Hi techsoft,
1. You can put marks at the y-axis at any values you like. For example,
#This is your main price chart. We save the returned XYChart object to $m so that
#we can add mark boxes to it
$m = $c->addMainChart(240);
#The value of the mark box = last close price
$lastPrice = $closeData[count($closeData) - 1];
#The mark box
$mark = $m->yAxis()->addMark($lastPrice, -1, $lastPrice, "arial.ttf", 8);
$mark->setMarkColor(Transparent, 0x000000, Transparent);
$mark->setBackground(0xffff99, 0x000000);
You can add more marks at other values, such as the last moving average value. For
example:
#This is the moving average line. We save the returned Layer object to $layer so that
#we can retrieve the data value
$layer = $c->addSimpleMovingAvg(20, 0x9900ff);
#The value closest to the right side of the chart
$lastValue = $layer->getDataSet(0)->getValue($layer->getNearestXValue($c-
>getWidth()));
#Add mark as usual
$mark = $m->yAxis()->addMark($lastValue, -1, $lastValue, "arial.ttf", 8);
$mark->setMarkColor(Transparent, 0x000000, Transparent);
$mark->setBackground(0xff99ff, 0x000000);
2. To create a gap, you may add an extra valid timestamp with no OHLC and volume
data. For example:
#Add an extra timeStamp equal to the last timeStamp. This will create a gap.
$timeStamp[] = $timeStamp[count($timeStamp) - 1];
Hope this can help.
Regards
Peter Kwan |
Re: Highlight the ending point on Y axis |
Posted by techsoft on Jun-19-2015 18:37 |
|
Hi Peter,
Thanks for your reply, now it is highlighting the last close price on the axis in a label but
it cuts off the last decimal value. I have tried some solutions from the previous posts but
not working . And i want to show the values behind the highlighted label, now its hidden.
Also how to mark last candlestick with yellow background.
Thanks,
Techsoft
|
Re: Highlight the ending point on Y axis |
Posted by Peter Kwan on Jun-20-2015 06:29 |
|
Hi techsoft,
The last decimal value falls outside of the chart. To display longer labels, you may
increase the right margin using FinanceChart.setMargins.
http://www.advsofteng.com/doc/cdphp.htm#FinanceChart.setMargins.htm
For example:
$myFinanceChart->setMargins(40, 30, 60, 35);
The axis mark will cause labels overlapping with it to be removed. If you still want the
labels, you may try to add a textbox at the axis position instead of a mark. For example:
..... create chart as usual .....
#After configuring the entire chart, auto-scale the axis, so that we can determine
#the axis scale
$myFinanceChart->layout();
$mark = $m->addText($m->getPlotArea()->getRightX(), $m->getYCoor($lastPrice),
$lastPrice, "arial.ttf", 8, 0x000000, Left);
$mark->setBackground(0xffff99, 0x000000);
To add a yellow rectangle, you may use add a layer that uses rectangular symbols, such
as a box-whisker layer. For example, the following code adds a box-whisker layer with
only one box at the last position, with the box top and bottom being the highData and
lowData:
$boxTop = array_pad(array($highData[count($highData) - 1]), -count($highData),
NoValue);
$boxBottom = array_pad(array($lowData[count($lowData) - 1]), -count($lowData),
NoValue);
$layer = $m->addBoxLayer($boxBottom, $boxTop, 0xffff00);
$layer->setDataGap(0);
Hope this can help.
Regards
Peter Kwan |
|