Gráficos con PHP y Google Charts
Google Charts es un API de Google que permite crear gráficos estadísticos de manera sencilla, estos gráficos se pueden crear accediendo a un URL con los parámetros adecuados. Entre los gráficos disponibles se encuentran: Line chart, Sparkline, Bar chart, Pie chart, Venn diagram, Scatter plot, Radar chart, Map, Google-o-meter, QR codes.
Para facilitarnos el proceso de crear estos gráficos existe la clase googchart escrita en PHP 5, el cual brinda una serie de métodos para generar gráficos estadísticos complejos con lineas de código sencillas.
Para utilizar esta clase primero descargamos la librería y copiamos el archivo GoogChart.class.php el cual contiene la clase que necesitamos, luego incluimos este archivo al inicio de nuestros scripts.
<?php
require('GoogChart.class.php');
$chart = new GoogChart();
?>
A continuación creamos un array con los datos que deseamos graficar, el siguiente paso es crear el array con los colores a utilizar y finalmente utilizamos el método setChartAttrs donde pasamos como parámetros el tipo de gráfico, el titulo, un array con los datos a graficar, las dimensiones del gráfico y finalmente un array con los colores a utilizar en el gráfico.
<?php $data = array( 'IE7' => 22, 'IE6' => 30.7, 'IE5' => 1.7, 'Firefox' => 36.5, 'Mozilla' => 1.1, 'Safari' => 2, 'Opera' => 1.4, ); $color = array( '#99C754', '#54C7C5', '#999999', ); $chart->setChartAttrs( array( 'type' => 'pie', 'title' => 'Browser market 2008', 'data' => $data, 'size' => array( 400, 300 ), 'color' => $color )); ?>
Autor
Escrito por Jose Aguilar - Director ejecutivo y tecnológico en JA Modules. Experto programador PrestaShop y Experto programador WordPress.
Y SI LA INFORMACION ES DE LA BD Y LOS CAMPOS SON 3 CON CODIGO PHP
Hola,
Seria posible, tan solo deberías rellenar los arrays con la información registrada en la base de datos.
Si no sabes como hacerlo, puedes solicitar ayuda en nuestro centro de soporte técnico -> https://www.jamodules.com/es/soporte
Saludos
Que tal Jose:
Muchas gracias por tus aportes a la comunidad, realmente eres un profesional en todo el sentido de la palabra. Por favor recibe mis agradecimientos por todo lo que haces por nosotros. Muchas felicidades.
Que tengas buen día.
Juan
hey I your magnanimous, weblog 🙂
I conceive you have remarked some very interesting points , appreciate it for the post.
First off I want to say fantastic blog! I had a quick question that I’d like to ask if you don’t mind. I was interested to find out how you center yourself and clear your thoughts before writing. I’ve had difficulty clearing my mind in getting my ideas out there. I truly do enjoy writing however it just seems like the first 10 to 15 minutes are generally lost just trying to figure out how to begin. Any ideas or tips? Many thanks!
Hi! I’m at work surfing around your blog from my new iphone 4! Just wanted to say I love reading through your blog and look forward to all your posts! Keep up the superb work!
This is really interesting, You’re an overly professional blogger. I’ve joined your rss feed and look ahead to seeking extra of your great post. Additionally, I have shared your web site in my social networks!
I am impressed with this site, really I am a fan .