Ver Mensaje Individual
  #1 (permalink)  
Antiguo 19/04/2013, 06:49
Avatar de mager3
mager3
 
Fecha de Ingreso: junio-2012
Ubicación: Medellin
Mensajes: 318
Antigüedad: 11 años, 10 meses
Puntos: 4
Información duda con posicion de leyenda en Gráfico

Cordial Saludo,

He usado por primera vez la libreria jpgraph, todo me ha salido muy bien, a exepcion de la posicion de una leyenda Y ya que me sale muy pegada a los datos de la grafica y quyeda montado los numeros de la grafica y la leyenda por lo que no se entiende los datos.... . ¿ como puedo correr la leyenda un poco mas a la izquierda?



Codigo:

Código PHP:
Ver original
  1. <?php
  2. include ("conexion.php");
  3. require_once ('../jpgraph/src/jpgraph.php');
  4. require_once ('../jpgraph/src/jpgraph_bar.php');
  5. // $Id: barscalecallbackex1.php,v 1.2 2002/07/11 23:27:28 aditus Exp $
  6.  
  7. $ano=$_GET['ano'];
  8. $mes=$_GET['mes'];
  9. $mesi=$mes;
  10.  
  11. //$ano=2012;
  12.  
  13.                 SELECT day(HoraTiquete),count(IdPeticion)
  14.             FROM tblpeticiones
  15. WHERE year(HoraTiquete)=$ano && month(HoraTiquete)=$mes
  16.             GROUP BY 1
  17. ");
  18. $datay = array();
  19.  
  20. while($bus = mysql_fetch_array($sql))
  21. {
  22. array_push($datay,$bus[1]);
  23. }
  24.  
  25.  
  26.  
  27. $sql=mysql_query("SELECT day(HoraTiquete),count(IdPeticion)
  28.             FROM tblpeticiones
  29. WHERE year(HoraTiquete)=$ano && month(HoraTiquete)=$mes
  30.             GROUP BY 1
  31.                                    
  32. ");
  33. $mes = array();
  34.  
  35. while($bus = mysql_fetch_array($sql))
  36. {
  37. array_push($mes,$bus[0]);
  38. }
  39.  
  40. // Callback function for Y-scale
  41. function yScaleCallback($aVal) {
  42.     return number_format($aVal);
  43. }
  44.  
  45. // Some data
  46. //$datay=array(120567,134013,192000,87000);
  47.  
  48. // Create the graph and setup the basic parameters
  49. $graph = new Graph(460,200,'auto');
  50. $graph->img->SetMargin(80,30,30,40);
  51. $graph->SetScale("textint");
  52. $graph->SetShadow();
  53. $graph->SetFrame(false); // No border around the graph
  54.  
  55. // Add some grace to the top so that the scale doesn't
  56. // end exactly at the max value.
  57. // Since we are using integer scale the gace gets intervalled
  58. // to adding integer values.
  59. // For example grace 10 to 100 will add 1 to max, 101-200 adds 2
  60. // and so on...
  61. $graph->yaxis->scale->SetGrace(30);
  62. $graph->yaxis->SetLabelFormatCallback('yScaleCallback');
  63. $graph->yaxis->SetTitle("Fichos Atendidas","middle");
  64.  
  65. // Setup X-axis labels
  66. //$a = $gDateLocale->GetShortMonth();
  67. $graph->xaxis->SetTickLabels($mes);
  68. $graph->xaxis->SetFont(FF_FONT1);
  69. $graph->xaxis->SetTitle("Dias de atencion","middle");
  70.  
  71. // Setup graph title ands fonts
  72. $graph->title->Set("Operaciones acumuladas por dia durante el $ano y mes $mesi ");
  73. $graph->title->SetFont(FF_FONT1);
  74. //$graph->xaxis->title->Set("Year 2002");
  75. $graph->xaxis->title->SetFont(FF_FONT1);
  76.                              
  77. // Create a bar pot
  78. $bplot = new BarPlot($datay);
  79. //$bplot->SetFillColor("blue");
  80. $bplot->SetWidth(0.5);
  81. $bplot->SetShadow();
  82.  
  83. // Setup the values that are displayed on top of each bar
  84. $bplot->value->Show();
  85. // Must use TTF fonts if we want text at an arbitrary angle
  86. $bplot->value->SetFont(FF_FONT1);
  87. $bplot->value->SetAngle(90);
  88. $bplot->value->SetFormat(' %0.0f');
  89. // Black color for positive values and darkred for negative values
  90. $bplot->value->SetColor("black","darkred");
  91. $graph->Add($bplot);
  92.  
  93. // Finally stroke the graph
  94. $graph->Stroke();
  95. ?>