hitherescotty Posted June 26, 2008 Share Posted June 26, 2008 hi! I am trying to build a grouped bar graph with JPGraph and it's giving me the standard "The image “http://localhost/testgraphs.php” cannot be displayed, because it contains errors." and I don't know why. Anyone? I've included all code except the $_SESSION variables. The important ones are explained in the weird comments I've made. <?php session_start(); include ("jpgraph/jpgraph.php"); include ("jpgraph/jpgraph_bar.php"); include ("jpgraph/jpgraph_line.php"); include ("jpgraph/jpgraph_iconplot.php"); require_once("jpgraph/jpgraph_date.php"); $graphWidth = $_SESSION['graphWidth']; $graphHeight = $_SESSION['graphHeight']; function TimeCallback($aVal) { return Date('',strtotime($aVal)); } $account = $_SESSION['account']; $monthData = $_SESSION['arr_temps_by_month']; //print_r($monthData); foreach($monthData as $aValue){ //print_r($aValue); $year = $aValue['startingYear']; $month = intval(date('m',strtotime($aValue['startingYearMonth']))); $ydata[$year][$month] = $aValue['monthUsage']; //echo "<br>"; }unset($aValue); //$ydata: this is the best format ive got yet! its a 2d array with $ydata[$year][$month] = monthusage BEST 4:45 PM 6-25 foreach ($ydata as $data) { if (!$data['1']) { $data['1'] = 0; } if (!$data['2']) { $data['2'] = 0; } if (!$data['3']) { $data['3'] = 0; } if (!$data['4']) { $data['4'] = 0; } if (!$data['5']) { $data['5'] = 0; } if (!$data['6']) { $data['6'] = 0; } if (!$data['7']) { $data['7'] = 0; } if (!$data['8']) { $data['8'] = 0; } if (!$data['9']) { $data['9'] = 0; } if (!$data['10']) { $data['10'] = 0; } if (!$data['11']) { $data['11'] = 0; } if (!$data['12']) { $data['12'] = 0; } ksort($data); //print_r($data); $ydataClean[]=$data; //this is now $ydataClean[0][01]=monthusage etc. it removes starting year. BESTTTTT 5:09 pm 6-25 //echo "<br>"; }unset($data); //print_r($ydataClean); for($num=0;$num<count($ydataClean);$num++) { $bplot[$num] = new BarPlot($ydataClean[$num]); //$bplot[$num]->SetFillColor([$i]); //$bplot[$num]->SetLegend($groupU[$i]); }unset($num); $gbarplot = new GroupBarPlot($bplot); $months=$gDateLocale->GetShortMonth(); // Create the graph. $graph = new Graph($graphWidth,$graphHeight); $graph->SetScale("textlin",0,100); // Add the plots to the graph $graph->Add($gbarplot); $graph->title->Set("Total Monthly Use"); $graph->title->Align("center"); $graph->xaxis->SetTitle("","center"); $graph->yaxis->title->Set(""); $gbarplot->SetWidth(0.; $graph->legend->SetFont(FF_ARIAL,FS_NORMAL,; $graph->title->SetFont(FF_ARIAL,FS_BOLD,15); $graph->yaxis->title->SetFont(FF_ARIAL,FS_BOLD,12); $graph->xaxis->title->SetFont(FF_ARIAL,FS_BOLD,12); $graph->yaxis->SetFont(FF_FONT1,FS_NORMAL,; $graph->xaxis->SetFont(FF_FONT1,FS_NORMAL,; $icon = new IconPlot('logo_med.gif',$graphWidth/2,$graphHeight/2.2,$graphHeight/400,40); $icon->SetAnchor('center','center'); $graph->Add($icon); $graph->Stroke(); //$fileName = "downloads/testgraphs_".$account.".png"; //$graph->img->Stream($fileName); //$graph->img->Headers(); //$graph->img->Stream(); ?> Quote Link to comment Share on other sites More sharing options...
hitherescotty Posted June 26, 2008 Author Share Posted June 26, 2008 bump Quote Link to comment Share on other sites More sharing options...
hitherescotty Posted June 27, 2008 Author Share Posted June 27, 2008 pleez pleez bump Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.