PCHomepage
Programmer
I have a simple, basic function for creating a Table graph in JPGraph, which is doing so by way of feeding it a query and it is working well. However, the number of rows and overall size of the data varies so is there some way to "measure" it to dynamically supply height and width parameters?
Code:
function TableGraph($Query, $Titles, $JPGraphPath, $FullURL, $ProcessType, $CanvasWidth='742', $CanvasHeight='150', $mysqli) {
require_once ($JPGraphPath."/jpgraph.php");
require_once ($JPGraphPath."/jpgraph_canvas.php");
require_once ($JPGraphPath."/jpgraph_table.php");
if ($result = $mysqli->query("$Query")):
$data[] = $Titles;
while ($row = $result->fetch_array()):
$data[] = $row;
endwhile;
endif;
$ImageName = rand();
$graph = new CanvasGraph($CanvasWidth,$CanvasHeight);
//$graph->SetImgFormat('png',60);
$table = new GTextTable();
$table->Set($data);
$graph->Add($table);
// Produce an image, display the graph
$fileName = $JPGraphPath."/Temp/".$ImageName.".png";
$graph->Stroke($fileName); // Creates image file
$OutputImage = "<div class=\"ImageGraph\">\n";
$OutputImage .= "<img src=\"$FullURL/jpgraph/Temp/".$ImageName.".png\">\n";
$OutputImage .= "</div>\n\n";
echo $OutputImage;
}