[ Index ]
 

Code source de jpGraph 2.2

Accédez au Source d'autres logiciels libres

title

Body

[fermer]

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

   1  <?php
   2  include  ('../jpgraph.php');
   3  include  ('../jpgraph_line.php');
   4  include  ('../jpgraph_scatter.php');
   5  include  ('../jpgraph_regstat.php');
   6  
   7  // Original data points
   8  $xdata = array(1,3,12,15);
   9  $ydata = array(5,15,2,19);
  10  
  11  // Get the interpolated values by creating
  12  // a new Spline object.
  13  $bez = new Bezier($xdata,$ydata);
  14  
  15  // For the new data set we want 40 points to
  16  // get a smooth curve.
  17  list($newx,$newy) = $bez->Get(50);
  18  
  19  // Create the graph
  20  $g = new Graph(300,200);
  21  $g->SetMargin(30,20,40,30);
  22  $g->title->Set("Bezier interpolation");
  23  $g->title->SetFont(FF_ARIAL,FS_NORMAL,12);
  24  $g->subtitle->Set('(Control points shown in red)');
  25  $g->subtitle->SetColor('darkred');
  26  $g->SetMarginColor('lightblue');
  27  
  28  //$g->img->SetAntiAliasing();
  29  
  30  // We need a linlin scale since we provide both
  31  // x and y coordinates for the data points.
  32  $g->SetScale('linlin');
  33  
  34  // We want 1 decimal for the X-label
  35  $g->xaxis->SetLabelFormat('%1.1f');
  36  
  37  // We use a scatterplot to illustrate the original
  38  // contro points.
  39  $bplot = new ScatterPlot($ydata,$xdata);
  40  $bplot->mark->SetFillColor('red@0.3');
  41  $bplot->mark->SetColor('red@0.5');
  42  
  43  // And a line plot to stroke the smooth curve we got
  44  // from the original control points
  45  $lplot = new LinePlot($newy,$newx);
  46  $lplot->SetColor('navy');
  47  
  48  // Add the plots to the graph and stroke
  49  $g->Add($lplot);
  50  $g->Add($bplot);
  51  $g->Stroke();
  52  
  53  ?>
  54  


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