[ Index ]
 

Code source de jpGraph 2.2

Accédez au Source d'autres logiciels libres

title

Body

[fermer]

/src/Examples/ -> balloonex1.php (source)

   1  <?php
   2  // $Id: balloonex1.php,v 1.5 2002/12/15 16:08:51 aditus Exp $
   3  include  ("../jpgraph.php");
   4  include  ("../jpgraph_scatter.php");
   5  
   6  // Some data
   7  $datax = array(1,2,3,4,5,6,7,8);
   8  $datay = array(12,23,95,18,65,28,86,44);
   9  // Callback for markers
  10  // Must return array(width,color,fill_color)
  11  // If any of the returned values are "" then the
  12  // default value for that parameter will be used.
  13  function FCallback($aVal) {
  14      // This callback will adjust the fill color and size of
  15      // the datapoint according to the data value according to
  16      if( $aVal < 30 ) $c = "blue";
  17      elseif( $aVal < 70 ) $c = "green";
  18      else $c="red";
  19      return array(floor($aVal/3),"",$c);
  20  }
  21  
  22  // Setup a basic graph
  23  $graph = new Graph(400,300,'auto');
  24  $graph->SetScale("linlin");
  25  $graph->img->SetMargin(40,100,40,40);        
  26  $graph->SetShadow();
  27  $graph->title->Set("Example of ballon scatter plot");
  28  // Use a lot of grace to get large scales
  29  $graph->yaxis->scale->SetGrace(50,10);
  30  
  31  // Make sure X-axis as at the bottom of the graph
  32  $graph->xaxis->SetPos('min');
  33  
  34  // Create the scatter plot
  35  $sp1 = new ScatterPlot($datay,$datax);
  36  $sp1->mark->SetType(MARK_FILLEDCIRCLE);
  37  
  38  // Uncomment the following two lines to display the values
  39  $sp1->value->Show();
  40  $sp1->value->SetFont(FF_FONT1,FS_BOLD);
  41  
  42  // Specify the callback
  43  $sp1->mark->SetCallback("FCallback");
  44  
  45  // Setup the legend for plot
  46  $sp1->SetLegend('Year 2002');
  47  
  48  // Add the scatter plot to the graph
  49  $graph->Add($sp1);
  50  
  51  // ... and send to browser
  52  $graph->Stroke();
  53  
  54  ?>
  55  
  56  


Généré le : Sat Nov 24 09:27:55 2007 par Balluche grâce à PHPXref 0.7
  Clicky Web Analytics