|
Gettting axis label coodinates |
Posted by Seppo Laaksonen on May-02-2012 17:34 |
|
Hi,
is there a way to get axis label's shape and coodinates similar to pie chart's getLabelCoor?
Do know that one can use getAxisImageMap and parse the coordinates from returned
string, but was looking for method that would get coordinate for a given label. Something
along the lines of $c->xAxis->getLabelCoor( 1 );
--
Seppo Laaksonen
mydbr.com |
Re: Gettting axis label coodinates |
Posted by Peter Kwan on May-03-2012 02:25 |
|
Hi Seppo,
You may get the coordinate of a given point on the axis. It is like:
$xCoor = $c->getXCoor(1);
#assume the x-axis is at the bottom of the plot area
$plotArea = $c->getPlotArea();
$yCoor = $plotArea->getTopY() + $plotArea->getHeight();
However, the above does not get the exact shape of the axis label. In fact, previous versions of ChartDirector only "estimate" the shape (eg. it assumes the label hot spot is a rectangle centered at the tick position, and of width equal to the distance between two ticks, and the height equal to the line height). Recent versions of ChartDirector tend to be more accurate in determining the shape when generating the image map.
If you do not need the exact shape (eg. you are just trying to respond to mouse interactions, such does not require the exact shape), you may just estimate the shape like what earlier versions of ChartDirector did.
If you need a more accurate shape, and the label is either horizontal or vertical, you may compute the shape by obtaining the width and height of the label. First, use Axis.getLabel to get the label text. Then put it in a dummy TextBox (using addText and put the TextBox outside the chart), and use Box.getHeight and Box.getWidth to get the text size.
Hope this can help.
Regards
Peter Kwan |
Re: Gettting axis label coodinates |
Posted by Seppo Laaksonen on May-03-2012 02:45 |
|
OK,
thanks for the reply. Looks like it is easiest just to use getAxisImageMap and parse the
needed information from there.
--
Seppo Laaksonen
mydbr.com |
|