<?php
require 'phplot.php';
mysql_connect("localhost", "root", "ito477") or
die("Could not connect: " . mysql_error());
mysql_select_db("despesas");
$plot = new PHPlot();
//Set plot and data type
$plot -> SetPlotType ( 'lines' );
$plot -> SetDataType ( 'text-data' );
//Select testdb and assign data to variable $data
$r = mysql_query("SELECT id, valor FROM despesa WHERE id>20");
if (! $r ) exit();
$data = array();
$n_rows = mysql_num_rows ( $r );
for ( $i = 0 ; $i < $n_rows ; $i ++) $data [] = mysql_fetch_row ( $r );
$plot -> SetDataValues ( $data );
$plot -> SetXDataLabelPos ( 'none' );
$plot -> SetLineWidths ( 3 );
$plot -> SetDrawXGrid ( True );
//Draw the graph
$plot -> DrawGraph ();
?>
obs: for ( $i = 0 ; $i < $n_rows ; $i ++) $data [] = mysql_fetch_row ( $r , $i ); ////////// retirei $i no final, pois, estava duplicando o gráfico.
também é preciso instalar o phplot