| Line | |
|---|
| 1 | <?php
|
|---|
| 2 |
|
|---|
| 3 |
|
|---|
| 4 | $data = array();
|
|---|
| 5 |
|
|---|
| 6 | for( $i=0; $i<6.2; $i+=0.2 )
|
|---|
| 7 | {
|
|---|
| 8 | $tmp = sin($i) * 1.9;
|
|---|
| 9 | $data[] = $tmp;
|
|---|
| 10 | }
|
|---|
| 11 |
|
|---|
| 12 | require_once('OFC/OFC_Chart.php');
|
|---|
| 13 |
|
|---|
| 14 | $chart = new OFC_Chart();
|
|---|
| 15 | $chart->set_title( new OFC_Elements_Title( 'Area Chart' ) );
|
|---|
| 16 |
|
|---|
| 17 | //
|
|---|
| 18 | // Make our area chart:
|
|---|
| 19 | //
|
|---|
| 20 | $area = new OFC_Charts_Area_Hollow();
|
|---|
| 21 | // set the circle line width:
|
|---|
| 22 | $area->set_width( 1 );
|
|---|
| 23 | $area->set_values( $data );
|
|---|
| 24 | // add the area object to the chart:
|
|---|
| 25 | $chart->add_element( $area );
|
|---|
| 26 |
|
|---|
| 27 | $y_axis = new OFC_Elements_Axis_Y();
|
|---|
| 28 | $y_axis->set_range( -2, 2, 2 );
|
|---|
| 29 | $y_axis->labels = null;
|
|---|
| 30 | $y_axis->set_offset( false );
|
|---|
| 31 |
|
|---|
| 32 | $x_axis = new OFC_Elements_Axis_X();
|
|---|
| 33 | $x_axis->labels = $data;
|
|---|
| 34 | $x_axis->set_steps( 2 );
|
|---|
| 35 |
|
|---|
| 36 | $x_labels = new OFC_Elements_Axis_X_Label_Set();
|
|---|
| 37 | $x_labels->set_steps( 4 );
|
|---|
| 38 | $x_labels->set_vertical();
|
|---|
| 39 | // Add the X Axis Labels to the X Axis
|
|---|
| 40 | $x_axis->set_labels( $x_labels );
|
|---|
| 41 |
|
|---|
| 42 |
|
|---|
| 43 |
|
|---|
| 44 | $chart->add_y_axis( $y_axis );
|
|---|
| 45 | $chart->x_axis = $x_axis;
|
|---|
| 46 |
|
|---|
| 47 | echo $chart->toPrettyString();
|
|---|
| 48 |
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.