Is possible to make a jpgraph table as report code?

Is possible to make a jpgraph table as report code?

Postby Ralcala » Fri Nov 22, 2013 10:14 pm

Hi again NB Team

iam stuck trying to make a table on Detail Block and then I use a sample table graph code from jpgraph but it's possible to use it with report code or adding this to graph code to obtain 2 graphs on the same page?

here is the code…

<?php
require_once ('jpgraph/jpgraph.php');
require_once ('jpgraph/jpgraph_canvas.php');
require_once ('jpgraph/jpgraph_table.php');

// Setup graph context
$graph = new CanvasGraph(430,430);

// 1. Enter Database details
$dbhost = "127.0.0.1";
$dbuser = "user";
$dbpass = "secret";
$dbname = "1304391_ur";

// 2. Create a database connection
$connection = mysql_connect($dbhost,$dbuser,$dbpass);
if (!$connection) {
die("Database connection failed: " . mysql_error());
}

// 3. Select a database to use
$db_select = mysql_select_db($dbname,$connection);
if (!$db_select) {
die("Database selection failed: " . mysql_error());
}

$query = mysql_query("SELECT * FROM an_anticipos" );


// fetch the result / convert resulte in to array

while ($rows = mysql_fetch_array($query)) {

$res = array($rows['fecha_an'],$rows['par_progr_an'],$rows['par_avance_an'],$rows['avance_prog_an'],$rows['avance_avance_an'],$rows['desv_prog_an'],$rows['desv_avance_an']);

}

// Setup the basic table
$data = array($res);

// Setup the basic table and font
$table = new GTextTable();
$table->Set($data);
$table->SetFont(FF_ARIAL,FS_NORMAL,14);

// Turn on/off border
$table->SetBorder(1);

// Turn on/off grid
$table->setGrid(1);

// Setup font for rows
$table->SetRowFont(0,FF_ARIAL,FS_BOLD,14);

// Setup color
$table->SetFillColor(0,0,0,6,'black@0.7');

// Set default table alignment
$table->SetAlign('center');

// Add table to graph
$graph->Add($table);

// and send it back to the client
$graph->Stroke();

?>

Thanks again and sorry for the insistence….
Ralcala
 
Posts: 11
Joined: Fri Aug 16, 2013 11:44 pm

Return to Report Writer