<?php

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of graphically_draw_data
 *
 * @author zmq163
 */
class Graphicallydrawdata extends CI_Controller {
    //put your code here
    public function __construct() {
        parent::__construct();
        include APPPATH . 'third_party/libchart/classes/libchart.php';
        $this->load->model('Graphically_draw_data_model');
    }
    /**
     * 
     * 
     * 
     * 
     */
    public function test(){
        $chart = new PieChart(360, 200);
        $palette = new Palette();
        $palette->setBackgroundColor(array(new Color(110, 120, 130)));
	$dataSet = new XYDataSet();
	$dataSet->addPoint(new Point("Vaccine Done (80)", 80));
	$dataSet->addPoint(new Point("Missed Vaccine (10)", 10));
	
	$chart->setDataSet($dataSet);

	$chart->setTitle("Child Immunization");
	$chart->render('graph/piechart/1.png');
        
        
        
        
        //$data=  $this->Graphically_draw_data_model->testModel();
        
        //$chart = new VerticalBarChart(500, 250);
        //$chart = new PieChart(150, 90);
        //$chart = new LineChart(500, 300);
        //$chart = new HorizontalBarChart(500, 300);
        //$palette = new Palette();
        //$palette->setBackgroundColor(array(new Color(110, 120, 130)));
//        $dataSet = new XYDataSet();
//        foreach ($data as $key => $value) {
//            $dataSet->addPoint(new Point($value['ratings'].$value['name'], $value['ratings']));
//        }
//        $chart->setDataSet($dataSet);
//        $chart->setTitle("Top Programming Languages for June 2012");
//        $chart->render("graph/horizentalchart/1.png");
//        //new pie chart instance
//       // $chart = new PieChart(500, 300);
//        
//        $chart = new LineChart(500, 250);
//
//	$serie1 = new XYDataSet();
//	$serie1->addPoint(new Point("06-01", 273));
//	$serie1->addPoint(new Point("06-02", 421));
//	$serie1->addPoint(new Point("06-03", 642));
//	$serie1->addPoint(new Point("06-04", 799));
//	$serie1->addPoint(new Point("06-05", 1009));
//	$serie1->addPoint(new Point("06-06", 1106));
////
//	$serie2 = new XYDataSet();
//	$serie2->addPoint(new Point("06-01", 280));
//	$serie2->addPoint(new Point("06-02", 300));
//	$serie2->addPoint(new Point("06-03", 212));
//	$serie2->addPoint(new Point("06-04", 542));
//	$serie2->addPoint(new Point("06-05", 600));
//	$serie2->addPoint(new Point("06-06", 850));
////        
//        $dataSet = new XYSeriesDataSet();
//	$dataSet->addSerie("Product 1", $serie1);
//	$dataSet->addSerie("Product 2", $serie2);
//	$chart->setDataSet($dataSet);
////                
//      $chart->setTitle("Sales for 2006");
//      $chart->render("graph/linechart/1.png");

        //data set instance
//        $dataSet = new XYDataSet();
//
//        //actual data
//        //get data from the database
//        //include database connection
//        $this->db->select('*');
//        $this->db->from('programming_languages');
//        $query=$this->db->get();
//        if($query->num_rows()>0){
//            
//        }


//        $dataSet = new XYDataSet();
//        $dataSet->addPoint(new Point("Jan 2005", 273));
//        $dataSet->addPoint(new Point("Feb 2005", 321));
//        $dataSet->addPoint(new Point("March 2005", 442));
//        $dataSet->addPoint(new Point("April 2005", 711));
//        $chart->setDataSet($dataSet);
//
//        //set chart title
//        $chart->setTitle("Tiobe Top Programming Languages for June 2012");
//
//        //render as an image and store under "generated" folder
//        $chart->render("genrated/2.png");
        //include 'db_connect.php';
        //query all records from the database
        //$query = "select * from programming_languages";
        //execute the query
        //$result = $mysqli->query($query);

        //get number of rows returned
        //$num_results = $result->num_rows;

//        if ($num_results > 0) {
//
//            while ($row = $result->fetch_assoc()) {
//                extract($row);
//                $dataSet->addPoint(new Point("{$name} {$ratings}", $ratings));
//            }
//
//            //finalize dataset
//            $chart->setDataSet($dataSet);
//
//            //set chart title
//            $chart->setTitle("Tiobe Top Programming Languages for June 2012");
//
//            //render as an image and store under "generated" folder
//            $chart->render("generated/1.png");
//        }
        
    }
}
