area-hollow.php 924 B

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