Ver post
  #34 (permalink)  
Old 15-oct-2007, 20:07
emerson emerson está offline
 
Registrado: abril-2007
Posts: 50
emerson va por buen camino
Predeterminado problema con grafico de torta

hola a todos
tengo un problema para realizar un grafico tipo torta o pie como lo quieran llamar pues necesito generarlo dinamicamente. lo que pasa es que al generar el codigo que extrae los datos de la base de datos al primer valor me le antepone un 0, los otros valores si estan saliendo bien, el otro problema es que lo que entiendo del archivo de ejemplo es que los graficos de torta tienen dos array uno con los nombres de las areas a graficar y otro con los valores y en el que yo estoy manejando es una adaptacion del de barras y la verdad no entiendo que pueda estar fallando.


este es el codigo que estoy usando
Código PHP:
<?php
//include charts.php to access the InsertChart function
include "charts.php";
//start the PHP multi-dimensional array and create the region titles
$chart 'chart_data' ][ ][ ] = "";
$chart 'chart_data' ][ ][ ] = "DERECHO_PETICION";
$chart 'chart_data' ][ ][ ] = "INFORMACION";
$chart 'chart_data' ][ ][ ] = "QUEJA";
//connect to the database
mysql_connect "localhost""root""" );
mysql_select_db "strencas_str" );
//get all the data in the Growth table
$result mysql_query ("SELECT pqr, Count(pqr) AS total
FROM pqr
group by pqr  "
);
for (
$i 1$i <= 1$i++) {
    for (
$j 1$j <= 1$j++) {
        
$chart['chart_data'][$i][$j] = 0;       
    }
}  
 
//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"pqr" ) ) {
      case 
"DERECHO_PETICION":
      
$row 1;
      break;
      case 
"INFORMACION":
      
$row 2;
      break;
      case 
"QUEJA":
      
$row 3;
      break;
 
   }
   
//determine which column in the PHP array the current data belongs to
   //$col = mysql_result ( $result, $i, "MES") - $MinMES + 1;
     //populate the PHP array with the revenue data
   
$chart 'chart_data' ][ $row ][ $col ] = mysql_result $result$i"total");
}
$chart'chart_grid_h' ] = array ( 'thickness'=>);
$chart'chart_pref' ] = array ( 'rotation_x'=>60 ); 
$chart'chart_rect' ] = array ( 'x'=>50'y'=>50'width'=>300'height'=>200'positive_alpha'=>);
$chart'chart_transition' ] = array ( 'type'=>"spin"'delay'=>.5'duration'=>.75'order'=>"category" );
$chart'chart_type' ] = "3d pie";
$chart'chart_value' ] = array ( 'color'=>"000000"'alpha'=>65'font'=>"arial"'bold'=>true'size'=>10'position'=>"inside"'prefix'=>""'suffix'=>""'decimals'=>0'separator'=>""'as_percentage'=>true );
$chart'draw' ] = array ( array ( 'type'=>"text"'color'=>"000000"'alpha'=>4'size'=>20'x'=>-50'y'=>260'width'=>500'height'=>50'text'=>"PORCENTAJE DE PETICIONES Y QUEJAS"'h_align'=>"center"'v_align'=>"middle" )) ;
$chart'legend_label' ] = array ( 'layout'=>"horizontal"'bullet'=>"circle"'font'=>"arial"'bold'=>true'size'=>12'color'=>"ffffff"'alpha'=>85 ); 
$chart'legend_rect' ] = array ( 'x'=>0'y'=>45'width'=>50'height'=>210'margin'=>10'fill_color'=>"ffffff"'fill_alpha'=>10'line_color'=>"000000"'line_alpha'=>0'line_thickness'=>);  
$chart'legend_transition' ] = array ( 'type'=>"dissolve"'delay'=>0'duration'=>);
$chart'series_color' ] = array ( "00ff88""ffaa00","44aaff""aa00ff" ); 
$chart'series_explode' ] = array ( 25750);
SendChartData $chart );
?>
la tabla de datos es la siguiente
Codigo:
-- phpMyAdmin SQL Dump
-- version 2.10.0.2
-- phpMyAdmin | MySQL Database Administration Tool | www.phpmyadmin.net
-- 
-- Servidor: localhost
-- Tiempo de generación: 15-10-2007 a las 21:05:24
-- Versión del servidor: 4.1.22
-- Versión de PHP: 4.4.4
SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";
-- 
-- Base de datos: `strencas_str`
-- 
-- --------------------------------------------------------
-- 
-- Estructura de tabla para la tabla `pqr`
-- 
CREATE TABLE IF NOT EXISTS `pqr` (
  `id_pqr` int(10) unsigned NOT NULL auto_increment,
  `us` text collate latin1_spanish_ci,
  `seg_ing` datetime default '0000-00-00 00:00:00',
  `paciente` text collate latin1_spanish_ci,
  `formato` text collate latin1_spanish_ci,
  `pqr` text collate latin1_spanish_ci,
  `caso` longtext collate latin1_spanish_ci,
  `obser` longtext collate latin1_spanish_ci,
  `accion` longtext collate latin1_spanish_ci,
  `estado` tinyint(1) default '0',
  `fech_sol` date default '0000-00-00',
  PRIMARY KEY  (`id_pqr`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 COLLATE=latin1_spanish_ci AUTO_INCREMENT=16 ;
-- 
-- Volcar la base de datos para la tabla `pqr`
-- 
INSERT INTO `pqr` VALUES (3, NULL, '2007-10-13 13:28:30', NULL, 'CARTA', 'INFORMACION', 'CONCENTRADOR', 'eee', NULL, 0, '0000-00-00');
INSERT INTO `pqr` VALUES (4, 'USUARIO', '2007-10-13 13:30:10', NULL, 'CARTA', 'DERECHO_PETICION', 'CONCENTRADOR', 'rrrr', NULL, 0, '0000-00-00');
INSERT INTO `pqr` VALUES (5, 'USUARIO', '2007-10-13 13:30:10', NULL, 'CARTA', 'DERECHO_PETICION', 'CONCENTRADOR', 'rrrr', NULL, 0, '0000-00-00');
INSERT INTO `pqr` VALUES (6, 'USUARIO', '2007-10-13 13:30:10', NULL, 'CARTA', 'DERECHO_PETICION', 'CONCENTRADOR', 'rrrr', NULL, 0, '0000-00-00');
INSERT INTO `pqr` VALUES (7, 'USUARIO', '2007-10-13 13:30:10', NULL, 'CARTA', 'DERECHO_PETICION', 'CONCENTRADOR', 'rrrr', NULL, 0, '0000-00-00');
INSERT INTO `pqr` VALUES (8, 'USUARIO', '2007-10-13 13:30:10', NULL, 'CARTA', 'DERECHO_PETICION', 'CONCENTRADOR', 'rrrr', NULL, 0, '0000-00-00');
INSERT INTO `pqr` VALUES (9, 'USUARIO', '2007-10-13 13:30:10', NULL, 'CARTA', 'DERECHO_PETICION', 'CONCENTRADOR', 'rrrr', NULL, 0, '0000-00-00');
INSERT INTO `pqr` VALUES (10, 'USUARIO', '2007-10-13 22:42:33', '46670463', 'CARTA DE EPS', 'INFORMACION', 'FALLECIO', 'OOOOOOO', 'yeyeyeyey', 1, '2007-10-15');
INSERT INTO `pqr` VALUES (11, 'USUARIO', '2007-10-13 22:42:33', '46670463', 'CARTA DE EPS', 'INFORMACION', 'FALLECIO', 'OOOOOOO', 'GAGAGAG', 1, '2007-10-18');
INSERT INTO `pqr` VALUES (12, 'USUARIO', '2007-10-13 22:42:33', '46670463', 'CARTA DE EPS', 'INFORMACION', 'FALLECIO', 'OOOOOOO', 'hshshshsh', 1, '2007-10-16');
INSERT INTO `pqr` VALUES (13, 'USUARIO', '2007-10-13 22:46:41', '46670463', 'TELEFONICA', 'DERECHO_PETICION', 'CONCENTRADOR', 'pppp', NULL, 0, '0000-00-00');
INSERT INTO `pqr` VALUES (14, 'USUARIO', '2007-10-13 22:46:41', '46670463', 'TELEFONICA', 'DERECHO_PETICION', 'CONCENTRADOR', 'pppp', NULL, 0, '0000-00-00');
INSERT INTO `pqr` VALUES (15, 'USUARIO', '2007-10-13 22:50:09', '46670463', 'PERSONAL', 'QUEJA', 'DESECHOS', 'gggggg', NULL, 0, '0000-00-00');
agradezco su ayuda
Citar y responder