[42] | 1 | <?php // content="text/plain; charset=utf-8"
|
---|
| 2 | require_once ('jpgraph/jpgraph.php');
|
---|
| 3 | require_once ('jpgraph/jpgraph_scatter.php');
|
---|
| 4 |
|
---|
| 5 | $numpoints=50;
|
---|
| 6 | $k=0.05;
|
---|
| 7 |
|
---|
| 8 | // Create some data points
|
---|
| 9 | for($i=0; $i<$numpoints; ++$i) {
|
---|
| 10 | $datay[$i]=exp(-$k*$i)*cos(2*M_PI/10*$i);
|
---|
| 11 | }
|
---|
| 12 |
|
---|
| 13 | // A format callbakc function
|
---|
| 14 | function mycallback($l) {
|
---|
| 15 | return sprintf("%02.2f",$l);
|
---|
| 16 | }
|
---|
| 17 |
|
---|
| 18 | // Setup the basic parameters for the graph
|
---|
| 19 | $graph = new Graph(400,200);
|
---|
| 20 | $graph->SetScale("intlin");
|
---|
| 21 | $graph->SetShadow();
|
---|
| 22 | $graph->SetBox();
|
---|
| 23 |
|
---|
| 24 | $graph->title->Set("Impuls Example 3");
|
---|
| 25 | $graph->title->SetFont(FF_FONT1,FS_BOLD);
|
---|
| 26 |
|
---|
| 27 | // Set format callback for labels
|
---|
| 28 | $graph->yaxis->SetLabelFormatCallback("mycallback");
|
---|
| 29 |
|
---|
| 30 | // Set X-axis at the minimum value of Y-axis (default will be at 0)
|
---|
| 31 | $graph->xaxis->SetPos("min"); // "min" will position the x-axis at the minimum value of the Y-axis
|
---|
| 32 |
|
---|
| 33 | // Extend the margin for the labels on the Y-axis and reverse the direction
|
---|
| 34 | // of the ticks on the Y-axis
|
---|
| 35 | $graph->yaxis->SetLabelMargin(12);
|
---|
| 36 | $graph->xaxis->SetLabelMargin(6);
|
---|
| 37 | $graph->yaxis->SetTickSide(SIDE_LEFT);
|
---|
| 38 | $graph->xaxis->SetTickSide(SIDE_DOWN);
|
---|
| 39 |
|
---|
| 40 | // Create a new impuls type scatter plot
|
---|
| 41 | $sp1 = new ScatterPlot($datay);
|
---|
| 42 | $sp1->mark->SetType(MARK_SQUARE);
|
---|
| 43 | $sp1->mark->SetFillColor("red");
|
---|
| 44 | $sp1->SetImpuls();
|
---|
| 45 | $sp1->SetColor("blue");
|
---|
| 46 | $sp1->SetWeight(1);
|
---|
| 47 | $sp1->mark->SetWidth(3);
|
---|
| 48 |
|
---|
| 49 | $graph->Add($sp1);
|
---|
| 50 |
|
---|
| 51 | $graph->Stroke();
|
---|
| 52 |
|
---|
| 53 | ?>
|
---|