. .

 

 

.
.

03 / 09 / 2010

Usuarios conectados: 7

Cargando documento...

Buscar:

.

Este Sitio:

Principal

Dreamweaver

Fireworks

JavaScript

CSS

Sonido

Artículos

Links

E-ufemismos

Descargas

Historial

 

Mailing List:

Suscríbete a la lista de correo, No practico spamming y ofrece algunas ventajas.

Pulsa aquí para saber más y suscribirte.

 

Recomendados:

Tecnorama >Dreamweaver Extensions

 

PHP Pie Chart

Versión para imprimir | Translate this page

PHP Pie Chart: Just for DMX and php_mysql Server Model: This extension will let you create pie charts (using percentages) from a Recordset.

The extension won't create the Recordset: It just draws the chart according to the results. The recordset must return, at least, a field with numeric data and the extension will calculate the percentage for each value and it will put it in the pie chart. Let's see an example:
We've got the tables "companies" and "sales":

COMPAPNIES

  

SALES

id_company

company_name

id_sale

id_company

amount

1

Microsoft

1

2

2

2

Adobe

2

3

150

3

Macromedia

3

1

55


You can see that there's a relationship between them (the field "id_company") and we want to guess the sales percentage for each company. Our Recordset could be:
SELECT SUM(amount),company_name
FROM sales, companies
WHERE sales.id_company=companies.id_company
GROUP BY companies.id_comapny


this Recordset will display:

company_name

amount

Microsoft

55

Macromedia

150

Adobe

2


With this recordset, we can use the extension:

Recordset: Select the name of your Recordset.

Display: You can uncheck it if you only want to show the percentages in the pie chart without legend.

Label Field: This field should show the label attached to every percentage (the company name, in our example).

Data Field: Select which field stores the numeric data ("amount" in our example).

Font Size: Select a font size for your label.

minPercent: You must indicate the smallest percentage the pie chart should display. All values smaller than this will be grouped as "Other". remember that 0.01 equals 1% and 1.00 equals 100%. In the picture, you can see that all values smaller than 22% (0.22) will be grouped as "Other".

Width / Height: with and height for the pie chart image.

BgColor: Background color.

Linecolor: Color for the lines that separate every piece of the chart.

Color1...color8: colores for each piece. If the chart displays more than 8 results, color 1 will be used again and so on.

See a Demo



Limitations:


To use this extension, your PHP must have support for GD 1.6 or above.

Remember that, when using this extension, You can't add anything else to your document. Don't use it embedded into a normal document: If you want to embed the resulting chart in a document, you must link to it as if it were a common image. How can you do it? It's easy:

For example. You have saved the php file with the code to "draw" the chart as "chart.php" and you want to show it in another document, called "companies.php". Open this file in DWMX, Select "insert Image" and select the file "chart.php":

<img src="images/chart.php">

If your recordset need some parameters, you can add it to the path:

<img src="images/chart.php?yourparam=44">

And the pie chart will be shown as an image in your document.

Download it here


Acknowledgements: This extension has been made with code written byJames Heinrich, from silisoftware. In his site you'll find more useful PHP scripts.Thanks, James.

Comments? 16, so far. Displaying 1 ->5

1.- I can't show the chart into another document. Doesn't I have to change the extension .php into .png or something?

2.- Lo siento, se ve muy bien y todo... pero cómo la aplico?!?!?!?!

3.- in which page these are inserting

4.- i cant find that tool on my dreamweaver...

5.- This script is not working for me. Can it handle more than 3 rows of data?

Tecnorama says: Yes, it can. Check the following url:
http://www.tecnorama.org/descargas

« Previous | 1 - 5 | 6 - 10 | 11 - 15 | 16 - 16 | Next »

Add your Comments



Escribe el código de la imagen superior:

:

TECNORAMA es simplemente una página personal. No sirve ni de promoción del autor ni cosas por el estilo.
Todos los códigos, textos y tutoriales son de libre uso mientras se mencione al autor (no es mucho pedir)
Este sitio es compatible con IE6/NS6/Mozilla1.0
Para contactar, puedes enviarme un e-mail a tecnorama@hotmail.com