line-dot.php 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. <?php
  2. /**
  3. * PHP Integration of Open Flash Chart
  4. * Copyright (C) 2008 John Glazebrook <open-flash-chart@teethgrinder.co.uk>
  5. *
  6. * This library is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU Lesser General Public
  8. * License as published by the Free Software Foundation; either
  9. * version 2.1 of the License, or (at your option) any later version.
  10. *
  11. * This library is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. * Lesser General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU Lesser General Public
  17. * License along with this library; if not, write to the Free Software
  18. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  19. */
  20. require_once('OFC/OFC_Chart.php');
  21. $data_1 = array();
  22. $data_2 = array();
  23. $data_3 = array();
  24. for( $i=0; $i<6.2; $i+=0.2 )
  25. {
  26. $data_1[] = (sin($i) * 1.9) + 7;
  27. $data_2[] = (sin($i) * 1.9) + 10;
  28. $data_3[] = (sin($i) * 1.9) + 4;
  29. // just show to two decimal places
  30. // in our labels:
  31. //$labels[] = number_format($tmp,2);
  32. }
  33. $title = new OFC_Elements_Title( date("D M d Y") );
  34. $line_1 = new OFC_Charts_Line_Dot();
  35. $line_1->set_values( $data_1 );
  36. $line_1->set_halo_size( 0 );
  37. $line_1->set_width( 2 );
  38. $line_1->set_dot_size( 4 );
  39. $line_2 = new OFC_Charts_Line_Dot();
  40. $line_2->set_values( $data_2 );
  41. $line_2->set_halo_size( 1 );
  42. $line_2->set_width( 1 );
  43. $line_2->set_dot_size( 4 );
  44. $line_3 = new OFC_Charts_Line_Dot();
  45. $line_3->set_values( $data_3 );
  46. $line_3->set_halo_size( 1 );
  47. $line_3->set_width( 6 );
  48. $line_3->set_dot_size( 4 );
  49. $y = new OFC_Elements_Axis_Y();
  50. $y->set_range( 0, 15, 5 );
  51. $chart = new OFC_Chart();
  52. $chart->set_title( $title );
  53. $chart->add_element( $line_1 );
  54. $chart->add_element( $line_2 );
  55. $chart->add_element( $line_3 );
  56. $chart->set_y_axis( $y );
  57. echo $chart->toPrettyString();