data-lines-2.php 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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. // generate some random data
  22. srand((double)microtime()*1000000);
  23. $data_1 = array();
  24. $data_2 = array();
  25. $data_3 = array();
  26. for( $i=0; $i<9; $i++ )
  27. {
  28. $data_1[] = rand(1,6);
  29. $data_2[] = rand(7,13);
  30. $data_3[] = rand(14,19);
  31. }
  32. $line_dot = new OFC_Charts_Line_Dot();
  33. $line_dot->set_width( 4 );
  34. $line_dot->set_colour( '#DFC329' );
  35. $line_dot->set_dot_size( 5 );
  36. $line_dot->set_values( $data_1 );
  37. $line_hollow = new OFC_Charts_Line_Hollow();
  38. $line_hollow->set_width( 1 );
  39. $line_hollow->set_colour( '#6363AC' );
  40. $line_hollow->set_dot_size( 5 );
  41. $line_hollow->set_values( $data_2 );
  42. $line = new OFC_Charts_Line();
  43. $line->set_width( 1 );
  44. $line->set_colour( '#5E4725' );
  45. $line->set_dot_size( 5 );
  46. $line->set_values( $data_3 );
  47. $y = new OFC_Elements_Axis_Y();
  48. $y->set_range( 0, 20, 5 );
  49. $chart = new OFC_Chart();
  50. $chart->set_title( new OFC_Elements_Title( 'Three lines example' ) );
  51. $chart->set_y_axis( $y );
  52. //
  53. // here we add our data sets to the chart:
  54. //
  55. $chart->add_element( $line_dot );
  56. $chart->add_element( $line_hollow );
  57. $chart->add_element( $line );
  58. echo $chart->toPrettyString();