|
Scatter layer Image Map problem |
Posted by Marko on Aug-22-2013 17:37 |
|
Hi
Can you please tell me what am I doing wrong when swapping XY. Can't get the image map area to swap... see attachment. The minimal example code is:
<?php
require_once("phpchartdir.php");
session_start();
if(isset($_GET['img'])) {
header("Content-type: image/png");
print $_SESSION[$_GET["img"]];
exit;
}
$dataX0 = array(60);
$dataY0 = array(10);
$dataZX0 = array(70);
$dataZY0 = array(10);
$c = new XYChart(450, 420);
$c->swapXY();
$c->setPlotArea(55, 65, 350, 300, -1, -1, 0xc0c0c0, 0xc0c0c0, -1);
$scatterLayerObj = $c->addScatterLayer($dataX0, $dataY0, "", SquareSymbol, 9, 0x00ff3333, 0x00ff3333);
$scatterLayerObj->setSymbolScale($dataZX0, XAxisScale, $dataZY0, YAxisScale);
$url = $c->makeSession('theid');
$im = $c->getHTMLImageMap('scatter.php','','');
?>
<html>
<head></head>
<body>
<image id="idImgTasks" src="scatter.php?<?php echo $url;?>" usemap="#map1"/>
<map id="idMapTasks" name="map1">
<?php echo $im;?>
</map>
<script src="http://code.jquery.com/jquery-1.10.1.min.js"></script>
<script type="text/javascript" src="http://davidlynch.org/projects/maphilight/jquery.maphilight.min.js"></script>
<script type="text/javascript">$(function() {
$('#idImgTasks').maphilight();
});
</script>
</body>
</html>
|
Re: Scatter layer Image Map problem |
Posted by Peter Kwan on Aug-22-2013 23:56 |
|
Hi Marko,
I confirm that this is in fact due to a bug in ChartDirector. ChartDirector does not compute
the image map correctly for a scatter chart with swapXY and with symbols of which the
bounding box is rectangular (non-square). In particular, it does not swap the width and
height of the scatter symbol when computing the image map.
To work around, one method is not to use swapXY, but to swap the x and y coordinates
before passing them to ChartDirector.
For example, instead of using:
$c->swapXY();
$scatterLayerObj = $c->addScatterLayer($dataX0, $dataY0, ...);
$scatterLayerObj->setSymbolScale($dataZX0, XAxisScale, $dataZY0, YAxisScale);
one may use:
$scatterLayerObj = $c->addScatterLayer($dataY0, $dataX0, ...);
$scatterLayerObj->setSymbolScale($dataZY0, XAxisScale, $dataZX0, YAxisScale);
If the above method is not suitable for your case (eg. because you have other layers that
must use swapXY), please let me know which operating system edition of ChartDirector you
are using. We would need to create a patch for you to fix the problem.
Regards
Peter Kwan |
Re: Scatter layer Image Map problem |
Posted by Marko on Aug-23-2013 14:16 |
|
Thank you for you help, Peter.
I use ChartDirector on various OS distributions, Windows and Linux. PHP ranges from 5.2.5 to 5.4.14 My testing environment runs on Win XP, PHP Version 5.4.8 and CD 5 (83951617).
I hit this problem after adding ImageMap to the chart described here:
http://www.chartdir.com/forum/download_thread.php?site=chartdir&bn=chartdir_support&thread=1376398633 Then I've made a minimal test case to eliminate potential bad parameterization.
I'm not sure if some unpainfull workaround is possible here... |
Re: Scatter layer Image Map problem |
Posted by Peter Kwan on Aug-24-2013 00:59 |
|
Hi Marko,
For your particular case, one work around is to compute the image map with your own code
(instead of using getHTMLImageMap). It should be like:
.... after calling $c->makeSession .....
for ($i = 0; $i < count($startDate); ++$i)
{
$topCoor = $c->getXCoor($taskNo[$i] + 0.5 - $height[$i]);
$bottomCoor = $c->getXCoor($taskNo[$i] + 0.5);
$leftCoor = $c->getYCoor($startDate[$i]);
$rightCoor = $c->getYCoor($endDate[$i]);
$areaTags[] = "<area shape='rect' coords='$leftCoor,$topCoor,$rightCoor,$bottomCoor'
title='Entry $i'>";
}
$imageMap = join("\\n", $areaTags);
Hope this can help.
Regards
Peter Kwan |
|