Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 8th, 2012  |  syntax: None  |  size: 1.58 KB  |  hits: 9  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. <?php if (! defined('BASEPATH')) exit('No direct script access');
  2. /**
  3.  *
  4.  * @author Yorick Peterse
  5.  * @package Codeigniter Open Flash Chart
  6.  * @category Controllers
  7.  */
  8. class Example extends Controller
  9. {
  10.         /**
  11.          * Called whenever the class is initialized.
  12.          *
  13.          * @access public
  14.          * @return void
  15.          */
  16.         public function __construct()
  17.         {
  18.                 parent::__construct();
  19.                 $this->load->library('openflashchart');
  20.                 $this->load->helper('url');
  21.         }
  22.  
  23.         // -----------------------------------------------
  24.  
  25.         /**
  26.          * Show a graph
  27.          *
  28.          * @access public
  29.          * @return void
  30.          */
  31.         public function index()
  32.         {
  33.                 echo $this->openflashchart->generate_flash(site_url('example/get_json'), 'ofc_object', 900, 700);
  34.         }
  35.        
  36.         // -----------------------------------------------
  37.        
  38.         /**
  39.          * Generate some JSON for the chart
  40.          *
  41.          * @access public
  42.          * @return void
  43.          */
  44.         public function get_json()
  45.         {
  46.                 header('Content-type: application/json');
  47.                  
  48.                 $this->openflashchart->set_y_axis(NULL, array('max' => 50));
  49.                 $this->openflashchart->set_y_legend('Number of students', '{color: #000000; font-size: 14px;}');       
  50.                
  51.                 // Create the chart data
  52.                 $this->openflashchart->new_chart('line', array(12, 14, 25), array('text' => 'Female', 'colour' => '#FF0000'));
  53.                 $this->openflashchart->new_chart('line', array(10,30,20), array('text' => 'Male', 'colour' => '#000000') );
  54.                 $this->openflashchart->new_chart('line ', array(0,1,42), array('text' => 'Unsure'));
  55.  
  56.                 echo $this->openflashchart->generate_chart('Students');
  57.         }
  58. }
  59. /* End of file example.php */
  60. /* Location: ./application/controllers/example.php */