Example #1
0
 function generategraph($report_id, $result_report)
 {
     //to generate the chart
     $this->load->plugin('jpgraph');
     $graph = loadgraph($report_id);
     switch ($report_id) {
         case 0:
             break;
         case 1:
             $data = array();
             $factorarray = array();
             $i = 1;
             foreach ($result_report->result_array() as $row) {
                 $data[] = $row['deficient_count'];
                 $factorarray[] = $i;
                 $i = $i + 1;
             }
             $graph = new PieGraph(520, 320);
             $graph->SetShadow();
             $graph->title->Set("Factor Deficiency Graph");
             $p1 = new PiePlot3D($data);
             $graph->Add($p1);
             $p1->ExplodeAll(10);
             $p1->SetAngle(70);
             $p1->SetLegends($factorarray);
             $graph_temp_directory = $this->config->item('absolute_path') . 'graphimage';
             $graph_file_name = $this->session->userdata('chapter') . '_deficientgraph.png';
             $graph_file_location = $graph_temp_directory . '/' . $graph_file_name;
             if (file_exists($graph_file_location)) {
                 unlink($graph_file_location);
             }
             $graph->Stroke($graph_file_location);
             $returnvalue = $this->config->item('base_url') . 'graphimage/' . $this->session->userdata('chapter') . '_deficientgraph.png';
             break;
         case 2:
             $data = array(1, 2, 3);
             $defarray = array();
             $i = 1;
             $row = $result_report->result_array();
             $defarray[] = $row[0]['severe'];
             $defarray[] = $row[0]['modrate'];
             $defarray[] = $row[0]['mild'];
             $graph = new PieGraph(520, 320);
             $graph->SetShadow();
             $graph->title->Set("Severity Graph");
             $p1 = new PiePlot3D($defarray);
             $graph->Add($p1);
             $p1->ExplodeAll(10);
             $p1->SetAngle(70);
             $p1->SetLegends($data);
             $graph_temp_directory = $this->config->item('absolute_path') . 'graphimage';
             $graph_file_name = $this->session->userdata('chapter') . '_severitygraph.png';
             $graph_file_location = $graph_temp_directory . '/' . $graph_file_name;
             if (file_exists($graph_file_location)) {
                 unlink($graph_file_location);
             }
             $graph->Stroke($graph_file_location);
             $returnvalue = $this->config->item('base_url') . 'graphimage/' . $this->session->userdata('chapter') . '_severitygraph.png';
             break;
     }
     return $returnvalue;
 }
Example #2
0
 function generategraph($report_id, $result_report)
 {
     //to generate the chart
     $this->load->plugin('jpgraph');
     $graph = loadgraph($report_id);
     switch ($report_id) {
         case 0:
             // We need some data
             //build Data Value
             $datay = array();
             foreach ($result_report->result_array() as $row) {
                 $datay[] = $row['pat_count'];
             }
             // Setup the graph.
             $graph = new Graph(520, 350);
             $graph->SetScale("textlin");
             // Add a drop shadow
             $graph->SetShadow();
             // Adjust the margin a bit to make more room for titles
             $graph->SetMargin(40, 30, 20, 40);
             // Setup the titles
             $graph->title->Set('NHR Registry');
             $graph->xaxis->title->Set('Chapters');
             $graph->yaxis->title->Set('Number PWHs');
             // Create the bar pot
             $bplot = new BarPlot($datay);
             // Adjust fill color
             $bplot->SetFillColor('orange');
             $graph->Add($bplot);
             $graph->title->SetFont(FF_FONT1, FS_BOLD);
             $graph->yaxis->title->SetFont(FF_FONT1, FS_BOLD);
             $graph->xaxis->title->SetFont(FF_FONT1, FS_BOLD);
             $graph_temp_directory = $this->config->item('absolute_path') . 'graphimage';
             $graph_file_name = 'adminchaptergraph.png';
             $graph_file_location = $graph_temp_directory . '/' . $graph_file_name;
             if (file_exists($graph_file_location)) {
                 unlink($graph_file_location);
             }
             // Finally send the graph to the browser
             $graph->Stroke($graph_file_location);
             $returnvalue = $this->config->item('base_url') . 'graphimage/adminchaptergraph.png';
             break;
         case 1:
             $data = array();
             $factorarray = array();
             $i = 1;
             foreach ($result_report->result_array() as $row) {
                 $data[] = $row['deficient_count'];
                 $factorarray[] = $i;
                 $i = $i + 1;
             }
             $graph = new PieGraph(520, 320);
             $graph->SetShadow();
             $graph->title->Set("Factor Deficiency Graph");
             $p1 = new PiePlot3D($data);
             $graph->Add($p1);
             $p1->ExplodeAll(10);
             $p1->SetAngle(70);
             $p1->SetLegends($factorarray);
             $graph_temp_directory = $this->config->item('absolute_path') . 'graphimage';
             $graph_file_name = 'admindeficientgraph.png';
             $graph_file_location = $graph_temp_directory . '/' . $graph_file_name;
             if (file_exists($graph_file_location)) {
                 unlink($graph_file_location);
             }
             $graph->Stroke($graph_file_location);
             $returnvalue = $this->config->item('base_url') . 'graphimage/admindeficientgraph.png';
             break;
         case 2:
             $data = array(1, 2, 3);
             $defarray = array();
             $i = 1;
             $row = $result_report->result_array();
             $defarray[] = $row[0]['severe'];
             $defarray[] = $row[0]['modrate'];
             $defarray[] = $row[0]['mild'];
             $graph = new PieGraph(520, 320);
             $graph->SetShadow();
             $graph->title->Set("Severity Graph");
             $p1 = new PiePlot3D($defarray);
             $graph->Add($p1);
             $p1->ExplodeAll(10);
             $p1->SetAngle(70);
             $p1->SetLegends($data);
             $graph_temp_directory = $this->config->item('absolute_path') . 'graphimage';
             $graph_file_name = 'adminseveritygraph.png';
             $graph_file_location = $graph_temp_directory . '/' . $graph_file_name;
             if (file_exists($graph_file_location)) {
                 unlink($graph_file_location);
             }
             $graph->Stroke($graph_file_location);
             $returnvalue = $this->config->item('base_url') . 'graphimage/adminseveritygraph.png';
             break;
     }
     return $returnvalue;
 }