[42] | 1 | <?php // content="text/plain; charset=utf-8"
|
---|
| 2 | require_once ('jpgraph/jpgraph.php');
|
---|
| 3 | require_once ('jpgraph/jpgraph_line.php');
|
---|
| 4 | require_once ('jpgraph/jpgraph_date.php');
|
---|
| 5 | require_once ('jpgraph/jpgraph_utils.inc.php');
|
---|
| 6 |
|
---|
| 7 | // Get a dataset stored in $xdata and $ydata
|
---|
| 8 | require_once ('dataset01.inc.php');
|
---|
| 9 |
|
---|
| 10 | $dateUtils = new DateScaleUtils();
|
---|
| 11 |
|
---|
| 12 | // Setup a basic graph
|
---|
| 13 | $width=500; $height=300;
|
---|
| 14 | $graph = new Graph($width, $height);
|
---|
| 15 | $graph->SetScale('datlin');
|
---|
| 16 | $graph->SetMargin(60,20,40,60);
|
---|
| 17 |
|
---|
| 18 | // Setup the titles
|
---|
| 19 | $graph->title->SetFont(FF_ARIAL,FS_BOLD,12);
|
---|
| 20 | $graph->title->Set('Development since 1984');
|
---|
| 21 | $graph->subtitle->SetFont(FF_ARIAL,FS_ITALIC,10);
|
---|
| 22 | $graph->subtitle->Set('(Example using the builtin date scale)');
|
---|
| 23 |
|
---|
| 24 | // Setup the labels to be correctly format on the X-axis
|
---|
| 25 | $graph->xaxis->SetFont(FF_ARIAL,FS_NORMAL,8);
|
---|
| 26 | $graph->xaxis->SetLabelAngle(30);
|
---|
| 27 |
|
---|
| 28 | // The second paramter set to 'true' will make the library interpret the
|
---|
| 29 | // format string as a date format. We use a Month + Year format
|
---|
| 30 | // $graph->xaxis->SetLabelFormatString('M, Y',true);
|
---|
| 31 |
|
---|
| 32 | // First add an area plot
|
---|
| 33 | $lp1 = new LinePlot($ydata,$xdata);
|
---|
| 34 | $lp1->SetWeight(0);
|
---|
| 35 | $lp1->SetFillColor('orange@0.85');
|
---|
| 36 | $graph->Add($lp1);
|
---|
| 37 |
|
---|
| 38 | // And then add line. We use two plots in order to get a
|
---|
| 39 | // more distinct border on the graph
|
---|
| 40 | $lp2 = new LinePlot($ydata,$xdata);
|
---|
| 41 | $lp2->SetColor('orange');
|
---|
| 42 | $graph->Add($lp2);
|
---|
| 43 |
|
---|
| 44 | // And send back to the client
|
---|
| 45 | $graph->Stroke();
|
---|
| 46 |
|
---|
| 47 | ?>
|
---|