|
Background image on a data point |
Posted by Andrew Schmidt on Nov-25-2010 02:42 |
|
Hi,
I'm trying to put a background image on a custom data point (specifically, the final point on a line layer).
I've kinda hacked something together that does this: I put an image on the data point and have a negative offset for the following text so that it moves the text over the image. However, this ends up pushing the image over to the left away from the actual data point. I assume it does this because it takes the whole width before adjustments / offsets when calculating it's total width.
Here's my code:
$txt = "<*img=bubble.gif*><*xoffset=-43,yoffset=17,color=0xffffff,size=12*>{value|1}";
$layer->addCustomDataLabel(0, count($this->xdata)-1, $txt);
The TextBox object that addCustomDataLabel returns has no ability to set a background image. Is there an easier / more proper way to do this?
Thanks,
Andrew |
Re: Background image on a data point |
Posted by Andrew Schmidt on Nov-25-2010 03:12 |
|
So I found a better solution so that the image isn't pushed over to the left.
By wrapping the image & text in a block tag first with the exact height/width of the image.
$txt = "<*block,maxwidth=90,height=40*><*img=bubble.gif*><*xoffset=10,yoffset=34,color=0xffffff,size=12,font=arialbd.ttf*>{value|1}<*/*>";
And although this will work, I'm still curious if there's an easier/simpler way.
Andrew |
Re: Background image on a data point |
Posted by Peter Kwan on Nov-25-2010 14:39 |
|
Hi Andrew,
I may use a scatter layer with just the last point. The scatter layer can be configured to use any image as the data point. For example (using PHP 5 syntax):
$lastPoint = $c->addScatterLayer(array($myXCoor[count($myXCoor) - 1]), array($myYCoor[count($myYCoor) - 1]));
$lastPoint->getDataSet(0)->setDataSymbol2("img=buffer.gif");
#Put a white label at the center of the data point, use:
$layerPoint->setDataLabelFormat("{value|1}");
$layerPoint->setDataLabelStyle("arialbd.ttf", 8, 0xffffff)->setAlignment(Center);
If you do not use x-coordinates (no setXData) for your data points, please replace "array($myXCoor[count($myXCoor) - 1])" with "array(count($myYCoor) - 1)".
Hope this can help.
Regards
Peter Kwan |
|