forked from Eserkin/webFinal
-
Notifications
You must be signed in to change notification settings - Fork 0
/
graficoTortasDos.php
53 lines (41 loc) · 1.42 KB
/
graficoTortasDos.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
<?php
// agregamos la bibliotecas necesarias
require_once ('jpgraph/src/jpgraph.php');
require_once ('jpgraph/src/jpgraph_pie.php');
require_once ('jpgraph/src/jpgraph_pie3d.php');
//coneccion con base de datos
$conexion=mysqli_connect("localhost","root","","basesergio");
if (mysqli_connect_errno()) {
echo "Falló la conexión con MySQL: " . mysqli_connect_error();
}
$resultadoUno = mysqli_query($conexion,"select count(*) cantidad1 from disparo where factor=1");
while($row = mysqli_fetch_array($resultadoUno)) {
$dato1 = $row["cantidad1"];
}
$resultadoDos = mysqli_query($conexion,"select count(*) cantidad2 from disparo where factor=0");
while($row = mysqli_fetch_array($resultadoDos)) {
$dato2 = $row["cantidad2"];
}
mysqli_close($conexion);
$data=array($dato1,$dato2);
$a=array('reales','falsas');
$ancho = 600; $alto = 250;
//crear la instancia del objeto graph
$graph = new PieGraph($ancho,$alto, 'auto' );
$graph->img->SetAntiAliasing();
// $graph->SetMarginColor('gray');
$graph->title->Set("Alarmas disparadas reales/falsas");
$graph->title->SetFont(FF_ARIAL, FS_BOLD, 14);
$p1 = new PiePlot3D($data);
$p1->SetLegends($a);
$p1->SetSize(0.45);
$p1->SetCenter(0.5);
$p1->SetLabelType(PIE_VALUE_ADJPERCENTAGE);
$graph->legend->SetAbsPos(220,220,50,10);
$graph->title->SetMargin(20,50,50,100);
$p1->value->SetFont(FF_FONT1,FS_BOLD);
$p1->value->SetColor("black");
$p1->SetLabelPos(0.5);
$graph->Add($p1);
$graph->Stroke();
?>