Mi problema es el siguiente, tengo un codigo que me realiza una grafica segun los resultados de una base de datos,la grafica es con php y utilizando Jplot, hasta hay todo funciona a la maravilla, ahora mi profesor me dijo que cuando le de click a un boton el me grafique, ahora eso pues se hace con Jquery y Ajax, ahora mi problema es que no se muy bien como hacer eso ya que esos dos temas no son mi fuerte, este es el codigo:
<html>
<html>
<head>
<meta charset="UTF-8">
<title>Graficas con Jplot</title>
<script src="jquery-1.11.1.js"></script>
<script src="jplot/excanvas.js"></script>
<script src="jplot/jquery.min.js"></script>
<script src="jplot/jquery.jqplot.min.js"></script>
<link rel="stylesheet" href="jplot/jquery.jqplot.min.css">
<script src="jplot/plugins/jqplot.barRenderer.min.js"></script>
<script src="jplot/plugins/jqplot.categoryAxisRenderer.min.js"></script>
<script src="jplot/plugins/jqplot.pointLabels.min.js"></script>
<script src="jplot/plugins/jqplot.canvasTextRenderer.min.js"></script>
<script src="jplot/plugins/jqplot.canvasAxisLabelRenderer.min.js"></script>
</head>
<body>
<input type='button' value='buscar' id='btnbuscar' onclick="jplot()">
<script type="text/javascript">
var datos= $.ajax({
url: 'http://localhost/Jajax/prueba.php',
type: 'POST',
dataType: 'json',
}).responseText;
function jplot(){
$.jqplot('torta',
[<?php
echo "[";
foreach ($datos as $hob) {
echo $hob['cantidad'].',';
}
echo "]";
?>], {
series: [
{
renderer: $.jqplot.BarRenderer,
label: 'Consultar'
},
],
seriesColors: ["#000080"],
seriesDefaults: {
pointLabels: {
show: true
},
rendererOptions: {
barPadding: 0,
barMargin: 0,
barDirection: 'vertical',
barWidth: 20,
shadowOffset: 5,
shadowDepth: 3,
shadowAlpha: 0.2,
}
},
axes: {
xaxis: {
label: 'Acciones',
renderer: $.jqplot.CategoryAxisRenderer,
ticks: <?php
echo "[";
foreach ($datos as $hob) {
echo "'" . $hob['accion']."',";
}
echo "]";
?>
},
yaxis: {
labelRenderer: $.jqplot.CanvasAxisLabelRenderer,
label: 'Cantidad'
}
},
title: 'Tabla Consultar',
legend: {
show: true,
location: 'e', // compass direction, nw, n, ne, e, se, s, sw, w.
placement: 'outsideGrid'
}
});
});
}
</script>
</body>
</html>
el archivo prueba.php que nombro hay es el que tiene la conexion que es el siguiente:
<?php
$conexion = mysql_connect("localhost", "root", "");
if (!$conexion) {
die(mysql_error());
}
mysql_select_db("jplot", $conexion);
$sql = mysql_query ('SELECT B.accion, B.tabla, count(B.accion) as cantidad
FROM usuario A, bitacora B
WHERE A.id = B.usuario_id
AND B.tabla = \'tab_consultar\'
GROUP BY B.tabla, B.accion
ORDER BY B.tabla, B.accion');
$datos= array();
while ($hob= mysql_fetch_assoc($sql))
{
$datos[] = $hob;
}
?>
LE AGRADEZCO DE ANTEMANO QUIEN ME PUEDA AYUDAR..
![lloron](http://static.forosdelweb.com/fdwtheme/images/smilies/chillando.png)
![lloron](http://static.forosdelweb.com/fdwtheme/images/smilies/chillando.png)
![lloron](http://static.forosdelweb.com/fdwtheme/images/smilies/chillando.png)
![lloron](http://static.forosdelweb.com/fdwtheme/images/smilies/chillando.png)
![lloron](http://static.forosdelweb.com/fdwtheme/images/smilies/chillando.png)
![lloron](http://static.forosdelweb.com/fdwtheme/images/smilies/chillando.png)