Hi I have a pChart 2 bar chart which contains a variable number of bars and as well as the actual value for each bar I wish to display 2 additional values to the right hand side of each bar. Please consider the image below where the values in the rectangle are an example of the figures I need to add to the chart.
Obviously I want to make them look a bit neater than this but really at the moment I am just wondering
What would be the correct way to do this in pChart?
Is there a built in way to perform this kind of decoration?
If not, how should I best align my additional output with each bar in the chart, considering that these bars are variable in pixel size and data size (i.e. this has to be calculated not approximated for a single scenario).
Just for clarity the extra figures are simply the same scores from previous years and would be decorated in a colour border or similar and included in a legend.
Thanks.
In the drawBarChart() method of the file pDraw.class.php there is the following conditional at the end of that method:
if ($DisplayPos == LABEL_POS_INSIDE && abs($TxtWidth) < abs($BarWidth)){
...
else{
At the end of that else block is a $this->drawText() method, this outputs the value on the end of the bar and will be called for each bar in the series. You can also at this point write additional values to the end of the chart (in this case the right margin) using the following:
$itemGap = 45; //the space between items
$items = array(1,2,3); //the value to draw
$colStart = $this->GraphAreaX2 + $itemGap;
foreach($itemGap as $item)
{
$this->drawText($colStart, $Y + $YOffset + $YSize / 2, $item, array("R" => $DisplayR, "G" => $DisplayG, "B" => $DisplayB, "Align" => $Align, "FontSize" => $DisplaySize));
$colStart += $itemGap;
}
I hope that is helpful to someone.