Image Graph - Printing?

images php coding issues or problems here.

Moderators: macek, egami, gesf

rararipe
New php-forum User
New php-forum User
Posts: 4
Joined: Wed Oct 22, 2003 3:19 am
Contact:

Image Graph - Printing?

Postby rararipe » Wed Oct 22, 2003 4:10 am

Hi

I'm trying print an image graph generated by PHPlot from the little tool bar showed when the mouse over it. As a result, no image is printed and the only thing that is printed is the html code of the window where the image graph was created.

Anybody can help me?

sigix
php-forum Active User
php-forum Active User
Posts: 364
Joined: Mon Jul 14, 2003 9:39 pm
Location: /Earth/Xion

Postby sigix » Wed Oct 22, 2003 4:13 am

can you post the code here for reference

and also use JPGraphs they are really good...

rararipe
New php-forum User
New php-forum User
Posts: 4
Joined: Wed Oct 22, 2003 3:19 am
Contact:

Postby rararipe » Wed Oct 22, 2003 4:44 am

The code is...

include($DOCUMENT_ROOT.'/system/classes/cria_grafico.php');

$arr=unserialize(stripslashes($var_contador));
$arr_legenda=$arr[0];
$arr_contador[0]=$arr[1];

$grafico = new cria_grafico();
$grafico->SetTitulo('Ranking');
$grafico->SetTipo($tipo);
$grafico->SetTipoFigura('bmp');
$grafico->SetData($arr_contador);
$grafico->SetLegenda($arr_legenda);
$grafico->SetXLabel('Conceitos');
if ($tipo != "pie") {
$grafico->SetYLabel('Percentuais');
}
$grafico->criar();

The cria_grafico.php file is...

include ($DOCUMENT_ROOT.'/system/phplot/phplot.php');
class cria_grafico
{
var $graph;
var $tipo;
var $data;
var $legenda;
var $titulo;
var $tipo_figura;

function cria_grafico()
{
$this->graph = new PHPlot(700,500);
}

function SetTipoFigura($tipo_figura)
{
$this->tipo_figura=$tipo_figura;
}

function SetTipo($tipo)
{
$this->tipo=$tipo;
}

function SetData($data)
{
$tam = count($data[0]);
for ($i = 0; $i < $tam; $i++) {
if ($data[0][$i]==0)
{
$newdata[0][$i] = '0,05';
}
else
{
$newdata[0][$i] = $data[0][$i];
}
}
$this->data=$newdata;
}

function SetLegenda($legenda)
{
$this->legenda=$legenda;
}

function SetTitulo($titulo)
{
$this->titulo=$titulo;
}
function SetXLabel($xlabel)
{
$this->xlabel=$xlabel;
}
function SetYLabel($ylabel)
{
$this->ylabel=$ylabel;
}
function SetYLabel($ylabel)
{
$this->ylabel=$ylabel;
}
function criar()
{
if (isset($this->tipo))
{
//tipo de grafico
$this->graph->SetPlotType($this->tipo);
}
else
{
echo "Erro de parametro. SetTipo.";
exit();
}
if (isset($this->data))
{
if($this->tipo=="bars")
{
//seta os valores para o grafico
$this->graph->SetDataValues($this->data);
}
else
{
//seta os valores para o grafico
$this->data[1]=$this->data[0];
$this->graph->SetDataValues($this->data);
}
}
else
{
echo "Erro de parametro. SetData.";
exit();
}
//posicao da legenda
$this->graph->SetLegendPixels(597,0.1,0,0);
//titulo para o grafico
if (isset($this->titulo))
$this->graph->SetTitle($this->titulo);
if (isset($this->xlabel))
$this->graph->SetXLabel($this->xlabel);
if (isset($this->ylabel))
$this->graph->SetYLabel($this->ylabel);
$this->graph->SetLabelScalePosition(1.18);
if (isset($this->legenda))
$this->graph->SetLegend($this->legenda);
$this->graph->SetBackgroundColor('white');
$this->graph->SetPlotBgColor('pink');
$this->graph->DrawGraph();
}
}

Thanks for your help
:)


Return to “PHP coding => Images”

Who is online

Users browsing this forum: No registered users and 1 guest