|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| ||||||||||||||||||||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
I have been pouring through the examples at pear.veggerby.dk and PHPBuilder.com and others but still don't quite understand how to get my dataset built for my graph. Can anyone help?
I want to create a multiple bar graph with y-axis in $ and x-axis in months. I want to have multiple bars at each month showing the production amounts for multiple years; similar to the example at pear.veggerby.dk for plot_bar_multiple . My code so far looks like: // create the graph $Graph =& Image_Graph::factory('graph', array(600, 300)); // add a TrueType font $Font =& $Graph->addNew('ttf_font', 'arial'); // set the font size to 11 pixels $Font->setSize(8); $Graph->setFont($Font); $Graph->add( Image_Graph::vertical( Image_Graph::factory('title', array('Monthly Production', 12)), Image_Graph::vertical( $Plotarea = Image_Graph::factory('plotarea'), $Legend = Image_Graph::factory('legend'), 90 ), 5 ) ); $Legend->setPlotarea($Plotarea); $histres = $db->query('SELECT practice_id, year, month, prod FROM month_history WHERE practice_id = '. $practice_id.' ORDER BY year, month'); if (PEAR::isError($histres)) { $message .= "History: ".$histres->getMessage(); Var_Dump::display($message); exit(); } $doOnce = true; $currentyear = 0; $Dataset[] =& Image_Graph::factory('dataset'); while ($row = $histres->fetchRow()) { if ($doOnce) { $currentyear = $row['year']; $doOnce = false; } if ($currentyear != $row['year']) { $Dataset[] =& Image_Graph::factory('dataset'); $currentyear = $row['year']; } $Dataset->addPoint($month_abrev[$row['month']], $row['m_prod']); } // create the 1st plot as smoothed area chart using the 1st dataset $Plot =& $Plotarea->addNew('bar', array($Dataset)); // output the Graph $Graph->done(); When I run this, I get: Fatal error: Call to a member function addPoint() on a non-object in /home/practicemonitor/test.php on line 126 line 126 is the addPoint call inside the while loop. Any help out there? Please? -Roxanne |
![]() |
| Viewing: Codewalkers Forums > PHP Related > PEAR Packages > Creating dataset for Image_Graph |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|