ASE Home Page Products Download Purchase Support About ASE
ChartDirector Support
Forum HomeForum Home   SearchSearch

Message ListMessage List     Post MessagePost Message

  problem adding Extra field in image map
Posted by kirsten on Jun-01-2011 16:03
Hi,

I have a chart with multiple lines and I want the image map to have a link on each data-point with a different querystring depending on the line. I add the lines as follows

$layer = $c->addLineLayer();
$layer->setLineWidth(2);

for ($l=1; $l <= $aGraphInfo['NumLines']; $l++)
{
   $dataSetObj = $layer->addDataSet($aGraphInfo[$l]['Data'], $aGraphInfo[$l]['Color'], $aGraphInfo[$l]['Legend']);
   $dataSetObj->setDataSymbol($aGraphInfo[$l]['DataSymbol'], $aGraphInfo[$l]['DataSymbolSize']);

   $dataSetObj->addExtraField($aGraphInfo[$l]['Offset']);
}

$sChart = htmlspecialchars($c->makeSession("chart1"));

$sImageMap = $c->getHTMLImageMap('', '', 'href="'.$aGraphInfo['ImageLink'].'?do={dsdiField0}&h={xLabel}" title="{value} {dataSetName} for '.$sXaxixLabel.' {xLabel}" alt=""');


But all I get in the link on the image map is {dsdiField0}
eg http://www.mysite.com/detailspage.php?do= {dsdiField0}&h=4

What am I doing wrong?

  Re: problem adding Extra field in image map
Posted by Peter Kwan on Jun-02-2011 01:09
Hi kirsten,

I think your code should not run at all. The $dataSetObj->addExtraField should be $layer->addExtraField.

Hope this can help.

Regards
Peter Kwan

  Re: problem adding Extra field in image map
Posted by kirsten on Jun-13-2011 18:44
Thanks.  I can see where I went wrong there.

Problem with Extra Fields in Bar Chart
****************************
I am now trying to add an image map with links to a bar chart but cannot get it to work.  The link & tool-tip on the first bar is correct but the second bar does not substitute the link value and the tool-tip shows the link value rather than tool-tip value.  The rest does not substitute the extra field values at all.

Below is the code I am using to test it.

<?php
    require_once('phpchartdir.php');

    $myData = array(423, 935, 332, 181, 896);
    $labels = array("UK", "USA", "Spain", "Norway", "Germany");

    $anArrayOfSpecialTooltipsForMyData = array("TT 0-0", "TT 0-1", "TT 0-2", "TT 0-3", "TT 0-4" );
    $anArrayOfURLsForMyData = array("URL_0_0", "URL_0_1", "URL_0_2", "URL_0_3", "URL_0_4" );

    $c = new XYChart(600, 375);
    $c->setPlotArea(50, 55, 500, 280, $c->linearGradientColor(0, 55, 0, 335, 0xf9fcff, 0xaaccff), -1, Transparent, 0xffffff);


    $c->swapXY(true);
    $c->xAxis->setReverse();

    $c->xAxis->setLabels($labels);

    $barLayerObj = $c->addBarLayer3($myData);
    $c->addExtraField($anArrayOfSpecialTooltipsForMyData);
    $c->addExtraField($anArrayOfURLsForMyData);


    $chart1URL = $c->makeSession("chart1");
    $imageMap = $c->getHTMLImageMap("{noescape_url}{dsdiField1}", "", "title='{dsdiField0}'");

?>
<html>
<body style="margin:5px 0px 0px 5px">
<div style="font-size:18pt; font-family:verdana; font-weight:bold">
    Simple Clickable Bar Chart
</div>
<hr style="border:solid 1px #000080" />
<div style="font-size:10pt; font-family:verdana; margin-bottom:20">
    Clickable Graph
</div>
<img src="/common/chart/getchart.php?<?php echo $chart1URL?>" border="0" usemap="#map1">
<map name="map1">
<?php echo $imageMap?>
</map>
</body>
</html>

  Re: problem adding Extra field in image map
Posted by kirsten on Jun-13-2011 19:15
I can see what the problem is now.
For a Bar Graph I need to use dsField rather than dsdiField as the extra field is only indexed by the dataset number