PEAR Forum :: PHP Extension and Application Repository

PEAR Forum Forum Index
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
Image_graph_dot or scatter

 
Post new topic   Reply to topic    PEAR Forum Forum Index -> Images
View previous topic :: View next topic  
Author Message
beach_defender



Joined: 23 Jul 2007
Posts: 3

PostPosted: Mon Jul 23, 2007 9:26 am    Post subject: Image_graph_dot or scatter Reply with quote

Hi,
I'm trying to build a scattergram showing gross_margin against sales.

I can get the graph displaying with no trouble, but I cant get any links display.

As a trial I have the following style of code:

Code:

$result = $db->query($QueryString,true,"Error in scattergram query");
if ($result)
{
   $data = $db->getFieldsArray($result);
   $i = 0;
   while ($row = $db->fetch_array($result))
   {
      $GraphData[] = $row;
      $tag['id'] = $row['crmid'];
      $tag['alt'] = $row['crmid'];
      $tag['url'] = $site_URL;
      $PlotResult->addPoint($row['salescount'],$row['totalgm'],$tag);
//      $PlotResult->addPoint($row['salescount'],$row['averagegm'],array('url'=>'http://www.hpfm.com.au', 'alt'=> $row['crmid']));
//      
   }
}

//$DataSet1 = Image_Graph::factory('Image_Graph_Plot_Dot',array($ResultSet));
//Var_Dump::display($GraphData);
//Var_Dump::display($PlotResult);
//exit;
/**
 * Start preparing the graph.
 */


// create the graph
$Graph =& Image_Graph::factory('graph', array(600, 400));
// add a TrueType font
$Font =& $Graph->addNew('font', 'Verdana');
// set the font size to 11 pixels
$Font->setSize(8);

$Graph->setFont($Font);
$GraphTitle = Image_Graph::factory('title', array('Gross Margin Scatergram', 12));
$Plotarea = Image_Graph::factory('plotarea');
$Legend = Image_Graph::factory('legend');
$Legend->setPlotarea($Plotarea);       
$GraphSetup = Image_Graph::vertical($Plotarea,$Legend,90);

$Graph->add($GraphSetup);

// create the dataset
//$Dataset1 =& Image_Graph::factory('random', array(10, 2, 9, false));

// create the 1st plot as smoothed area chart using the 1st dataset
$Plot1 =& $Plotarea->addNew('scatter', $PlotResult);
$Marker1 =& Image_Graph::factory('Image_Graph_Marker_Diamond');
$Marker1->setFillColor('blue');
$Marker1->setLineColor('black');
// set a line color
$Plot1->setMarker($Marker1);
$Plot1->setTitle('Gross Margin vs Number of Sales');

// create the dataset
//$Dataset2 =& Image_Graph::factory('random', array(10, 10, 15, false));
// create the 1st plot as smoothed area chart using the 1st dataset
//$Plot2 =& $Plotarea->addNew('Image_Graph_Plot_Dot', array(&$Dataset2));
//$Marker2 =& Image_Graph::factory('Image_Graph_Marker_Plus');
//$Marker2->setFillColor('green');
//$Marker2->setLineColor('black');
//// set a line color
////$Plot2->setMarker($Marker2);
//$Plot2->setTitle('Extrovert');
//Var_Dump::display($Graph);
//ob_flush;
// output the Graph
$Graph->done();
?>


So essentially I want a link at each point.

As you can see I have used the sample code from http://pear.veggerby.dk/

but butchered it a bit.

I have a few questions:
1. Is it possible (I can see how without editing the PEAR package code at pesent)
2, If yes, abovem what incredibly silly thing must I have done?

3. If no, where can I make it happen?

Thanks for your help,

Barry
Back to top
View user's profile Send private message MSN Messenger
beach_defender



Joined: 23 Jul 2007
Posts: 3

PostPosted: Thu Jul 26, 2007 8:58 am    Post subject: Reply with quote

Oh, I had hoped someone had an idea by now.

I will update this if I resolve it.

If anyone has thoughts, please let me know.

Thanks
Barry
Back to top
View user's profile Send private message MSN Messenger
beach_defender



Joined: 23 Jul 2007
Posts: 3

PostPosted: Sat Jul 28, 2007 8:11 am    Post subject: Reply with quote

I have links working now with Image_Marker_Cross

I made the following changes to ..pear/Image/Graph/Marker/Cross.php

Replaced
Code:


$this->_canvas->polygon(array('connect' => true));



with

Code:

$this->_canvas->polygon(array('connect' => true, 'map_vertices' => true));




and moved it to before the calls to addVertex()

and then for each vertex,replaced

Code:


$this->_canvas->addVertex(array('x' => $x - $d1 - $d2, 'y' => $y - $d1 + $d2);


with

Code:

$this->_canvas->addVertex(array('x' => $x - $d1 - $d2, 'y' => $y - $d1 + $d2,
                                 'url'=>  $values['data']['url'],
                                 'id' => $values['data']['id'],
                                 'alt' => $values['data']['alt']));



I made changes to the setup as well I used 'dataset' not 'scatter'

I setup the graph as follows:

Code:

// create the graph
$canvas =& Image_Canvas::factory('png', array('width' => 600, 'height' => 400, 'usemap' => true));
$imagemap = $canvas->getImageMap();
$Graph =& Image_Graph::factory('graph', $canvas);
// add a TrueType font
$Font =& $Graph->addNew('font', 'Verdana');
// set the font size to 11 pixels
$Font->setSize(8);

$Graph->setFont($Font);
$GraphTitle = Image_Graph::factory('title', array('Gross Margin Scatergram', 12));
$Plotarea = Image_Graph::factory('plotarea');
$Legend = Image_Graph::factory('legend');
$Legend->setPlotarea($Plotarea);
$GraphSetup = Image_Graph::vertical($Plotarea,$Legend,90);

$Graph->add($GraphSetup);



I will try to update more later.

Barry
Back to top
View user's profile Send private message MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic    PEAR Forum Forum Index -> Images All times are GMT + 2 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum



PEAR Forum topic RSS feed 
Powered by phpBB © 2001, 2005 phpBB Group

Provided by Ministry of Web developement