| Line | |
|---|
| 1 | <?php // content="text/plain; charset=utf-8"
|
|---|
| 2 | // Example of a stock chart
|
|---|
| 3 | require_once ('jpgraph/jpgraph.php');
|
|---|
| 4 | require_once ('jpgraph/jpgraph_stock.php');
|
|---|
| 5 |
|
|---|
| 6 | // Data must be in the format : open,close,min,max,median
|
|---|
| 7 | $datay = array(
|
|---|
| 8 | 34,42,27,45,36,
|
|---|
| 9 | 55,25,14,59,40,
|
|---|
| 10 | 15,40,12,47,23,
|
|---|
| 11 | 62,38,25,65,57,
|
|---|
| 12 | 38,49,32,64,45);
|
|---|
| 13 |
|
|---|
| 14 | // Setup a simple graph
|
|---|
| 15 | $graph = new Graph(300,200);
|
|---|
| 16 | $graph->SetScale("textlin");
|
|---|
| 17 | $graph->SetMarginColor('lightblue');
|
|---|
| 18 | $graph->title->Set('Box Stock chart example');
|
|---|
| 19 | $graph->subtitle->Set('(Indented X-axis)');
|
|---|
| 20 |
|
|---|
| 21 | // Create a new stock plot
|
|---|
| 22 | $p1 = new BoxPlot($datay);
|
|---|
| 23 |
|
|---|
| 24 | // Width of the bars (in pixels)
|
|---|
| 25 | $p1->SetWidth(9);
|
|---|
| 26 |
|
|---|
| 27 | // Indent bars so they dont start and end at the edge of the
|
|---|
| 28 | // plot area
|
|---|
| 29 | $p1->SetCenter();
|
|---|
| 30 |
|
|---|
| 31 | // Uncomment the following line to hide the horizontal end lines
|
|---|
| 32 | //$p1->HideEndLines();
|
|---|
| 33 |
|
|---|
| 34 | // Add the plot to the graph and send it back to the browser
|
|---|
| 35 | $graph->Add($p1);
|
|---|
| 36 | $graph->Stroke();
|
|---|
| 37 |
|
|---|
| 38 | ?>
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.