Ver post
  #3 (permalink)  
Old 18-abr-2007, 08:43
emerson emerson está offline
 
Registrado: abril-2007
Posts: 51
emerson va por buen camino
Predeterminado

hola pablasso
muchisimas gracias por tu ayuda. gracias a ella ya pude generar los graficos estaticos de mi proyecto... pero ..... con los graficos dinamicos tengo un problema, ya que tome el ejemplo del tutorial pero la grafica no me muestra los datos reales de la base de datos, comparando los datos de los archivos estaticos con el dinamico, los datos no estan en orde me aperecen de esta manera:
LINE 2001 2002 2003 2004 2005 REGION A REGION B REGION C 56 21 5 90 100

y pues obviamente lo que me grafica es la linea 56

el escript que estoy usando es el siguiente:

<?php
//include charts.php to access the InsertChart function
include "charts.php";
//change the chart to a bar chart
$chart [ 'chart_type' ] = "LINE";
//start the PHP multi-dimensional array and create the region titles
$chart [ 'chart_data' ][ 0 ][ 0 ] = "";
$chart [ 'chart_data' ][ 1 ][ 0 ] = "REGION A";
$chart [ 'chart_data' ][ 2 ][ 0 ] = "REGION B";
$chart [ 'chart_data' ][ 3 ][ 0 ] = "REGION C";
//connect to the database
mysql_connect ( "localhost", "root", "" );
mysql_select_db ( "Accounting" );
//get the smallest year to determine which year to start the chart with
$result = mysql_query ( "SELECT MIN(Year) AS MinYear FROM Growth" );
$MinYear = mysql_result ( $result, 0, "MinYear" );
//get all the data in the Growth table
$result = mysql_query ("SELECT * FROM Growth");
//extract the data from the query result one row at a time
for ( $i=0; $i < mysql_num_rows($result); $i++ ) {
//determine which row in the PHP array the current data belongs to
switch ( mysql_result ( $result, $i, "region" ) ) {
case "Region A":
$row = 1;
break;
case "Region B":
$row = 2;
break;
case "Region C":
$row = 3;
break;
}
//determine which column in the PHP array the current data belongs to
$col = mysql_result ( $result, $i, "year") - $MinYear + 1;
//populate the PHP array with the Year title
$chart [ 'chart_data' ][ 0 ][ $col ] = mysql_result ( $result, $i, "year");
//populate the PHP array with the revenue data
$chart [ 'chart_data' ][ $row ][ $col ] = mysql_result ( $result, $i, "revenue");
}
//send the new data to charts.swf
SendChartData ( $chart );
?>

muchisimas gracias por tu ayuda
emerson
Citar y responder