include "../../pChart/pChart/pData.class"; include "../../pChart/pChart/pChart.class"; $array_to_display = $_SESSION['histo_downtime_array']; //$array_to_display = round($array_to_display); $name_to_display = $_SESSION['histo_downtime_nom']; $machine_to_display = $_SESSION['machine_nom']; // Dataset definition $DataSet = new pData(); $DataSet->AddPoint($array_to_display, "Serie1"); $DataSet->AddPoint(array("Jan", "Fev", "Mars", "Avril", "Mai", "Juin", "Juillet", "Aout", "Sept.", "Oct.", "Nov.", "Dec."), "Serie2"); $DataSet->AddAllSeries(); $DataSet->SetAbsciseLabelSerie("Serie2"); $DataSet->SetSerieName("{$machine_to_display}", "Serie1"); $DataSet->SetXAxisName("Mois"); $DataSet->SetYAxisName("Downtime"); $DataSet->SetYAxisUnit(" h"); // Initialise the graph $Test = new pChart(500, 250); $Test->setFontProperties("../../pChart/Fonts/tahoma.ttf", 10); $Test->setGraphArea(70, 30, 480, 200); $Test->drawFilledRoundedRectangle(7, 7, 493, 243, 5, 240, 240, 240); $Test->drawRoundedRectangle(5, 5, 495, 225, 5, 230, 230, 230); $Test->drawGraphArea(255, 255, 255, TRUE); $Test->drawScale($DataSet->GetData(), $DataSet->GetDataDescription(), SCALE_NORMAL, 150, 150, 150, TRUE, 0, 2); $Test->drawGrid(4, TRUE, 230, 230, 230, 50); // Draw the 0 line $Test->setFontProperties("../../pChart/Fonts/tahoma.ttf", 10); $Test->drawTreshold(0, 143, 55, 72, TRUE, TRUE); // Draw the line graph $Test->drawLineGraph($DataSet->GetData(), $DataSet->GetDataDescription()); $Test->drawPlotGraph($DataSet->GetData(), $DataSet->GetDataDescription(), 3, 2, 255, 255, 255);
include "../../pChart/pChart/pData.class"; include "../../pChart/pChart/pChart.class"; $array_to_display = $_SESSION['histo_tps_pannes_array']; //$array_to_display = round($array_to_display); $name_to_display = $_SESSION['histo_tps_pannes_nom']; $machine_to_display = $_SESSION['machine_nom']; // Dataset definition $DataSet = new pData(); $DataSet->AddPoint($array_to_display, "Serie1"); $DataSet->AddPoint(array("Jan", "Fev", "Mars", "Avril", "Mai", "Juin", "Juillet", "Aout", "Sept.", "Oct.", "Nov.", "Dec."), "Serie2"); $DataSet->AddAllSeries(); $DataSet->SetAbsciseLabelSerie("Serie2"); $DataSet->SetSerieName("{$machine_to_display}", "Serie1"); $DataSet->SetXAxisName("Mois"); $DataSet->SetYAxisName("temps par panne"); $DataSet->SetYAxisUnit(" min"); // Initialise the graph $Test = new pChart(500, 250); $Test->setFontProperties("../../pChart/Fonts/tahoma.ttf", 10); $Test->setGraphArea(85, 30, 480, 200); $Test->drawFilledRoundedRectangle(7, 7, 493, 243, 5, 240, 240, 240); $Test->drawRoundedRectangle(5, 5, 495, 225, 5, 230, 230, 230); $Test->drawGraphArea(255, 255, 255, TRUE); $Test->drawScale($DataSet->GetData(), $DataSet->GetDataDescription(), SCALE_NORMAL, 150, 150, 150, TRUE, 0, 2); $Test->drawGrid(4, TRUE, 230, 230, 230, 50); // Draw the 0 line $Test->setFontProperties("../../pChart/Fonts/tahoma.ttf", 10); $Test->drawTreshold(0, 143, 55, 72, TRUE, TRUE); // Draw the line graph $Test->drawLineGraph($DataSet->GetData(), $DataSet->GetDataDescription()); $Test->drawPlotGraph($DataSet->GetData(), $DataSet->GetDataDescription(), 3, 2, 255, 255, 255);
/** * Generates an histogram * * @param array list of exercise names * @param array my results 0 to 100 * @param array average scores 0-100 */ static function generate_session_exercise_graph($names, $my_results, $average) { require_once api_get_path(LIBRARY_PATH).'pchart/pData.class.php'; require_once api_get_path(LIBRARY_PATH).'pchart/pChart.class.php'; require_once api_get_path(LIBRARY_PATH).'pchart/pCache.class.php'; $cache = new pCache(); // Dataset definition $data_set = new pData(); // Dataset definition $data_set->AddPoint($average, "Serie1"); $data_set->AddPoint($my_results, "Serie2"); $data_set->AddPoint($names, "Serie3"); $data_set->AddAllSeries(); $data_set->SetAbsciseLabelSerie('Serie3'); $data_set->SetSerieName(get_lang('AverageScore'),"Serie1"); $data_set->SetSerieName(get_lang('MyResults'), "Serie2"); //$data_set->SetYAxisName(get_lang("Percentage")); $data_set->SetYAxisUnit("%"); // Initialise the graph $main_width = 860; $main_height = 500; $y_label_angle = 50; $data_set->RemoveSerie("Serie3"); $graph = new pChart($main_width, $main_height); //See 3.2 BT#2797 $graph->setFixedScale(0,100); $graph->setFontProperties(api_get_path(LIBRARY_PATH).'pchart/fonts/tahoma.ttf',8); $graph->setGraphArea(65,50,$main_width-20, $main_height-140); $graph->drawFilledRoundedRectangle(7,7,$main_width-7,$main_height-7,5,240,240,240); $graph->drawRoundedRectangle(5,5,$main_width-5,$main_height -5,5,230,230,230); $graph->drawGraphArea(255,255,255,TRUE); //SCALE_NORMAL, SCALE_START0, SCALE_ADDALLSTART0, SCALE_ADDALL $graph->drawScale($data_set->GetData(),$data_set->GetDataDescription(),SCALE_NORMAL ,150,150,150,TRUE,$y_label_angle,1, TRUE); $graph->drawGrid(4,TRUE,230,230,230,70); // Draw the 0 line $graph->setFontProperties(api_get_path(LIBRARY_PATH).'pchart/fonts/tahoma.ttf',6); $graph->drawTreshold(0,143,55,72,TRUE,TRUE); // Draw the cubic curve graph $graph->drawLineGraph($data_set->GetData(),$data_set->GetDataDescription()); $graph->drawPlotGraph($data_set->GetData(),$data_set->GetDataDescription(),1,1,230,255,255); // Finish the graph $graph->setFontProperties(api_get_path(LIBRARY_PATH).'pchart/fonts/tahoma.ttf',10); $graph->drawLegend($main_width - 150,70,$data_set->GetDataDescription(),255,255,255); $graph->setFontProperties(api_get_path(LIBRARY_PATH).'pchart/fonts/tahoma.ttf',11); $graph->drawTitle(50, 30, get_lang('ExercisesInTimeProgressChart'), 50,50,50,$main_width-110, true); // $main_graph = new pChart($main_width,$main_height); $courseCode = isset($_GET['course']) ? Security::remove_XSS($_GET['course']) : null; $graph_id = 'generate_session_exercise_graph'.$courseCode.'-'.intval($_GET['session_id']).'-'.api_get_user_id(); if ($cache->IsInCache($graph_id, $data_set->GetData())) { //if (0) { //if we already created the img //echo 'in cache'; $img_file = $cache->GetHash($graph_id,$data_set->GetData()); } else { $cache->WriteToCache($graph_id, $data_set->GetData(), $graph); ob_start(); $graph->Stroke(); ob_end_clean(); $img_file = $cache->GetHash($graph_id, $data_set->GetData()); } $html = '<img src="'.api_get_path(WEB_ARCHIVE_PATH).$img_file.'">'; return $html; }
/* Example1 : A simple line chart */ // Standard inclusions include "src/pData.php"; include "src/pChart.php"; // Dataset definition $DataSet = new pData(); $DataSet->ImportFromCSV("Sample/bulkdata.csv", ",", array(1, 2, 3), FALSE, 0); $DataSet->AddAllSeries(); $DataSet->SetAbsciseLabelSerie(); $DataSet->SetSerieName("January", "Serie1"); $DataSet->SetSerieName("February", "Serie2"); $DataSet->SetSerieName("March", "Serie3"); $DataSet->SetYAxisName("Average age"); $DataSet->SetYAxisUnit("µs"); // Initialise the graph $Test = new pChart(700, 230); $Test->setFontProperties("Fonts/tahoma.ttf", 8); $Test->setGraphArea(70, 30, 680, 200); $Test->drawFilledRoundedRectangle(7, 7, 693, 223, 5, 240, 240, 240); $Test->drawRoundedRectangle(5, 5, 695, 225, 5, 230, 230, 230); $Test->drawGraphArea(255, 255, 255, TRUE); $Test->drawScale($DataSet->GetData(), $DataSet->GetDataDescription(), SCALE_NORMAL, 150, 150, 150, TRUE, 0, 2); $Test->drawGrid(4, TRUE, 230, 230, 230, 50); // Draw the 0 line $Test->setFontProperties("Fonts/tahoma.ttf", 6); $Test->drawTreshold(0, 143, 55, 72, TRUE, TRUE); // Draw the line graph $Test->drawLineGraph($DataSet->GetData(), $DataSet->GetDataDescription()); $Test->drawPlotGraph($DataSet->GetData(), $DataSet->GetDataDescription(), 3, 2, 255, 255, 255);
*/ // Standard inclusions include "src/pData.php"; include "src/pChart.php"; // Dataset definition $DataSet = new pData(); $DataSet->AddPoint(array(9, 9, 9, 10, 10, 11, 12, 14, 16, 17, 18, 18, 19, 19, 18, 15, 12, 10, 9), "Serie1"); $DataSet->AddPoint(array(10, 11, 11, 12, 12, 13, 14, 15, 17, 19, 22, 24, 23, 23, 22, 20, 18, 16, 14), "Serie2"); $DataSet->AddPoint(array(4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22), "Serie3"); $DataSet->AddAllSeries(); $DataSet->RemoveSerie("Serie3"); $DataSet->SetAbsciseLabelSerie("Serie3"); $DataSet->SetSerieName("January", "Serie1"); $DataSet->SetSerieName("February", "Serie2"); $DataSet->SetYAxisName("Temperature"); $DataSet->SetYAxisUnit("∞C"); $DataSet->SetXAxisUnit("h"); // Initialise the graph $Test = new pChart(700, 230); $Test->drawGraphAreaGradient(132, 153, 172, 50, TARGET_BACKGROUND); // Graph area setup $Test->setFontProperties("Fonts/tahoma.ttf", 8); $Test->setGraphArea(60, 20, 585, 180); $Test->drawGraphArea(213, 217, 221, FALSE); $Test->drawScale($DataSet->GetData(), $DataSet->GetDataDescription(), SCALE_NORMAL, 213, 217, 221, TRUE, 0, 2); $Test->drawGraphAreaGradient(162, 183, 202, 50); $Test->drawGrid(4, TRUE, 230, 230, 230, 20); // Draw the line chart $Test->setShadowProperties(3, 3, 0, 0, 0, 30, 4); $Test->drawLineGraph($DataSet->GetData(), $DataSet->GetDataDescription()); $Test->clearShadow();
include "src/pChart.php"; // Dataset definition $DataSet = new pData(); $DataSet->AddPoint(array(1, 2, 5), "Serie1"); $DataSet->AddPoint(array(3, 2, 2), "Serie2"); $DataSet->AddPoint(array(3, 4, 1), "Serie3"); $DataSet->AddPoint(array("A#~1", "A#~2", "A#~3"), "Labels"); $DataSet->AddAllSeries(); $DataSet->RemoveSerie("Labels"); $DataSet->SetAbsciseLabelSerie("Labels"); $DataSet->SetSerieName("Alpha", "Serie1"); $DataSet->SetSerieName("Beta", "Serie2"); $DataSet->SetSerieName("Gama", "Serie3"); $DataSet->SetXAxisName("Samples IDs"); $DataSet->SetYAxisName("Test Marker"); $DataSet->SetYAxisUnit("µm"); // Initialise the graph $Test = new pChart(380, 400); $Test->drawGraphAreaGradient(90, 90, 90, 90, TARGET_BACKGROUND); // Graph area setup $Test->setFontProperties("Fonts/pf_arma_five.ttf", 6); $Test->setGraphArea(110, 180, 350, 360); $Test->drawGraphArea(213, 217, 221, FALSE); $Test->drawScale($DataSet->GetData(), $DataSet->GetDataDescription(), SCALE_ADDALLSTART0, 213, 217, 221, TRUE, 0, 2, TRUE); $Test->drawGraphAreaGradient(40, 40, 40, -50); $Test->drawGrid(4, TRUE, 230, 230, 230, 5); // Draw the title $Test->setFontProperties("Fonts/tahoma.ttf", 10); $Title = " Average growth size for selected\r\n DNA samples "; $Test->setLineStyle(2); $Test->drawLine(51, -2, 51, 402, 0, 0, 0);
//Close the connection fclose($handle); // Include Global Config include "../conf/graph_conf.php"; // Standard inclusions include "{$pChart_path}/pData.class"; include "{$pChart_path}/pChart.class"; // Dataset definition $DataSet = new pData(); $DataSet->AddPoint($ydata, "Serie1"); $DataSet->AddPoint($xdata, "Serie3"); $DataSet->AddSerie("Serie1"); $DataSet->SetAbsciseLabelSerie("Serie3"); $DataSet->SetYAxisName("Usage"); $DataSet->SetXAxisName("Hour"); $DataSet->SetYAxisUnit("%"); #$DataSet->SetXAxisFormat("date"); // Initialise the graph $Test = new pChart(900, 225); $Test->setColorPalette(0, 126, 185, 245); $Test->setFontProperties("{$font}", 8); $Test->setGraphArea(75, 35, 890, 190); #$Test->drawFilledRoundedRectangle(7,7,450,223,5,240,240,240); #$Test->drawRoundedRectangle(5,5,450,225,5,230,230,230); $Test->drawGraphArea(255, 255, 255, FALSE); $Test->drawScale($DataSet->GetData(), $DataSet->GetDataDescription(), SCALE_NORMAL, 75, 75, 75, TRUE, 0, 2); $Test->drawGrid(1, TRUE, 240, 240, 240); #$Test->drawGrid(4,TRUE); // Draw the 0 line $Test->setFontProperties("{$font}", 6); $Test->drawTreshold(0, 143, 55, 72, TRUE, TRUE);
function main() { $ThisArea = array('1' => 'Orizaba', '2' => 'Guadalajara', '3' => 'Ramos Arizpe', '4' => 'Tijuana'); if (!$this->args) { $this->help(); $this->err(__('Usage report <id_area> <id_fraccion> <year> <month> <all_areas> ', true)); $this->_stop(); } $KeyArea = $this->args[0]; $Fraccion = $this->args[1]; $CurrentYear = $this->args[2]; $CurrentMonth = $this->args[3]; $all = $this->args[4]; $args = $this->args; $this->out(pr($args)); $NumDays = date('t', mktime('0', '0', '0', $CurrentMonth, '01', $CurrentYear)); if (empty($all) && !empty($KeyArea) && !empty($CurrentMonth)) { // CurrentMonth Area $TonelajeConditions['TonelajeCurrent.fecha_guia LIKE'] = "%" . $CurrentYear . "-" . $CurrentMonth . "%"; $TonelajeConditions['TonelajeCurrent.id_area'] = $KeyArea; $TonelajeConditions['TonelajeCurrent.id_fraccion'] = $Fraccion; } if ($all == true && $KeyArea == false && $CurrentMonth == false) { // AllYear $TonelajeConditions['TonelajeCurrent.fecha_guia LIKE'] = "%" . $CurrentYear . "%"; $TonelajeConditions['TonelajeCurrent.id_fraccion'] = $Fraccion; } if ($all == true && $KeyArea > 0 && $CurrentMonth == false) { // AllYearArea $TonelajeConditions['TonelajeCurrent.fecha_guia LIKE'] = "%" . $CurrentYear . "%"; $TonelajeConditions['TonelajeCurrent.id_area'] = $KeyArea; $TonelajeConditions['TonelajeCurrent.id_fraccion'] = $Fraccion; } // $this->out(pr($TonelajeConditions));exit(); // $TonelajeConditions['TonelajeCurrent.fecha_guia LIKE'] = "%".$CurrentYear."-".$CurrentMonth."%"; // $TonelajeConditions['TonelajeCurrent.id_area'] = $KeyArea; // $TonelajeConditions['TonelajeCurrent.id_fraccion'] = $Fraccion; // $this->out(pr($TonelajeConditions));exit(); $report = $this->TonelajeCurrent->find('all', array('conditions' => $TonelajeConditions)); $toneladas = null; $report_day = array(); $report_year = array(); // $this->out(pr($report));exit(); foreach ($report as $key => $data) { if ($data['TonelajeCurrent']['status_guia'] == ' B') { $canceladas[] = $data; } $MyMonth = date('M', mktime('0', '0', '0', $CurrentMonth, '01', $CurrentYear)); // $this->out(pr($data)); // $report_day['00'] = '0'; if ($data['TonelajeCurrent']['status_guia'] !== ' B') { $toneladas += $data['TonelajeCurrent']['peso']; $counter[] = $data['TonelajeCurrent']['peso']; $day = substr($data['TonelajeCurrent']['fecha_guia'], 8, 2); $report_day[$day] += $data['TonelajeCurrent']['peso']; } } // End foreach $report /** ALERT Save the result for Display in the view */ // $this->out(pr($report_day));exit(); // $this->out($NumDays); // $this->out($MyMonth); // exit(); // $this->out(count($counter));exit(); //2 $this->autoRender = false; //3 App::import('Vendor', 'pData', array('file' => 'pchart' . DS . 'pData.class')); App::import('Vendor', 'pChart', array('file' => 'pchart' . DS . 'pChart.class')); //4 $fontFolder = APP . 'vendors' . DS . 'pchart' . DS . 'Fonts'; $fontFolder = '..' . DS . '..' . DS . 'vendors' . DS . 'pchart' . DS . 'Fonts'; // $SchemaFolder = APP.'vendors'.DS.'pchart'.DS.'schema'; //5 // Dataset definition $DataSet = new pData(); $MaxTons = max($report_day); $MaxTons = $MaxTons + 100; foreach ($report_day as $key => $value) { $MyDay[] = (int) $key; } // $this->out(pr($MyDay)); $DataSet->AddPoint($report_day, "Serie1"); // $DataSet->AddPoint('4',"Serie2"); // $DataSet->AddPoint('20',"Serie3"); // $DataSet->AddPoint($MyDay,"Name"); // exit(); // $this->out(pr($DataSet->GetData())); // $idx=0; // foreach($MyDay as $key => $value){ // $DataSet->AddPoint($value,"Serie1"); // $DataSet->AddPoint((int)$key,"Name"); // } // $this->out(pr($MyDay)); // $DataSet->GetData()['0']['Name']=; // $DataSet->GetData()['0']['Name']=1; $this->out(pr($DataSet->GetData())); $DataSet->AddAllSeries(); $DataSet->SetAbsciseLabelSerie(); $key = $value = null; $DataSet->SetSerieName("Toneladas", "Serie1"); $DataSet->SetSerieName("Dia", "Serie2"); $DataSet->SetYAxisName("Toneladas Dias"); $DataSet->SetYAxisUnit("Ton"); $DataSet->SetXAxisName("Dias"); $DataSet->SetXAxisFormat("number"); // Initialise the graph // pr($SchemaFolder); $Test = new pChart(820, 260); $Test->setFixedScale(1, $MaxTons, 5, 0, $NumDays, 5); $Test->setDateFormat("H:m"); $Test->setFontProperties($fontFolder . DS . "tahoma.ttf", 10); $Test->setColorPalette(0, 115, 173, 207); $Test->setColorPalette(1, 144, 196, 226); $Test->setColorPalette(2, 174, 216, 240); $Test->setColorPalette(3, 64, 140, 195); $Test->setColorPalette(4, 104, 188, 209); $Test->setColorPalette(5, 99, 200, 226); $Test->setColorPalette(6, 82, 124, 148); $Test->setColorPalette(7, 97, 152, 183); $Test->setColorPalette(8, 105, 210, 231); $Test->setColorPalette(9, 167, 219, 216); $Test->setColorPalette(10, 224, 228, 204); $Test->setColorPalette(11, 243, 134, 48); // $Test->loadColorPalette("/tmp/schema/blue.txt",","); $Test->setGraphArea(100, 30, 790, 200); // $Test->drawFilledRoundedRectangle(7,7,693,223,5,240,240,240); $Test->drawRoundedRectangle(5, 5, 810, 225, 5, 230, 230, 230); $Test->drawGraphArea(255, 255, 255, TRUE); // dibujar la grafica $Test->drawScale($DataSet->GetData(), $DataSet->GetDataDescription(), SCALE_NORMAL, 150, 150, 150, TRUE, 0, 2, TRUE); $Test->drawGrid(4, TRUE, 230, 230, 230, 50); // Draw the line graph // Draw the 0 line $Test->setFontProperties($fontFolder . DS . "tahoma.ttf", 10); $Test->drawTreshold(0, 143, 55, 72, TRUE, TRUE); // Draw the bar graph $Test->drawBarGraph($DataSet->GetData(), $DataSet->GetDataDescription(), TRUE, 80); // $Test->drawPlotGraph($DataSet->GetData(),$DataSet->GetDataDescription()); // $Test->drawXYPlotGraph($DataSet->GetData(),$DataSet->GetDataDescription(),"Serie1","Serie2"); // $Test->drawXYPlotGraph($DataSet->GetData(),$DataSet->GetDataDescription(),"Serie1","Serie3"); // $Test->drawXYGraph($DataSet->GetData(),$DataSet->GetDataDescription(),"Serie1","Serie2"); // Finish the graph $today = date('Y-m-d'); // $Test->setFontProperties($fontFolder.DS."tahoma.ttf",8); // $Test->drawLegend(820,150,$DataSet->GetDataDescription(),255,255,255); $Test->setFontProperties($fontFolder . DS . "tahoma.ttf", 10); if (empty($all) && !empty($KeyArea) && !empty($CurrentMonth)) { // CurrentMonth Area $Test->drawTitle(220, 22, "Toneladas {$ThisArea[$KeyArea]} {$MyMonth} {$CurrentYear}", 50, 50, 50, 585); $Test->Render("../../app/webroot/img/thumbs/graph_" . $today . "_" . $KeyArea . "_" . $Fraccion . ".png"); } if ($all == true && $KeyArea == false && $CurrentMonth == false) { // AllYear $Test->drawTitle(220, 22, "Toneladas {$CurrentYear}", 50, 50, 50, 585); $Test->Render("../../app/webroot/img/thumbs/graph_" . $CurrentYear . "_" . $KeyArea . ".png"); } if ($all == true && $KeyArea > 0 && $CurrentMonth == false) { // AllYearArea $Test->drawTitle(220, 22, "Toneladas {$ThisArea[$KeyArea]} {$CurrentYear}", 50, 50, 50, 585); $Test->Render("../../app/webroot/img/thumbs/graph_" . $CurrentYear . "_" . $KeyArea . ".png"); } // $Test->drawTitle(220,22,"Toneladas $MyMonth $CurrentYear",50,50,50,585); // $Test->Render("../../app/webroot/img/thumbs/graph_".$today."_".$KeyArea."_".$Fraccion.".png"); }
} if ($p6 != '') { $DataSet->SetSerieName($n6, "Serie6"); } if ($p7 != '') { $DataSet->SetSerieName($n7, "Serie7"); } if ($p8 != '') { $DataSet->SetSerieName($n8, "Serie8"); } if ($p9 != '') { $DataSet->SetSerieName($n9, "Serie9"); } //---------------------------- Set X & Y axis units if ($unit) { $DataSet->SetYAxisUnit($unit); } else { $DataSet->SetYAxisUnit(""); } $DataSet->SetXAxisUnit(""); //---------------------------- Create Object of pChart $Test = new pChart($w, $h); //---------------------------- Set generic colors for one (first) channel if ($_GET['gcolor'] == 'red') { $Test->setColorPalette(0, 220, 50, 50); } elseif ($_GET['gcolor'] == 'brown') { $Test->setColorPalette(0, 220, 140, 100); } elseif ($_GET['gcolor'] == 'blue') { $Test->setColorPalette(0, 100, 140, 220); } elseif ($_GET['gcolor'] == 'green') { $Test->setColorPalette(0, 100, 200, 100);
$Chart->drawGraphAreaGradient(40, 40, 40, -50); if (count($date) < 2) { $Chart->setFontProperties(IMAGE_PATH . '/sig/font/DejaVuSans.ttf', 11); $Chart->drawTextBox(100, 90, 180, 110, "Not Enough Session Data", 0, 0, 0, 0, ALIGN_LEFT, FALSE, 255, 255, 255, 0); } else { $DataSet = new pData(); $DataSet->AddPoint($skill, 'SerieSkill'); $DataSet->AddPoint($skill_change, 'SerieSession'); $DataSet->AddPoint($date, 'SerieDate'); $DataSet->AddSerie('SerieSkill'); $DataSet->SetAbsciseLabelSerie('SerieDate'); $DataSet->SetSerieName('Skill', 'SerieSkill'); $DataSet->SetSerieName('Session', 'SerieSession'); $Chart->setFontProperties(IMAGE_PATH . '/sig/font/DejaVuSans.ttf', 7); $DataSet->SetYAxisName('Skill'); $DataSet->SetYAxisUnit('K'); $Chart->setColorPalette(0, 255, 255, 0); $Chart->drawRightScale($DataSet->GetData(), $DataSet->GetDataDescription(), SCALE_NORMAL, $color['red'], $color['green'], $color['blue'], TRUE, 0, 0); $Chart->drawGrid(1, FALSE, 55, 55, 55, 100); $Chart->setShadowProperties(3, 3, 0, 0, 0, 30, 4); $Chart->drawCubicCurve($DataSet->GetData(), $DataSet->GetDataDescription()); $Chart->clearShadow(); $Chart->drawFilledCubicCurve($DataSet->GetData(), $DataSet->GetDataDescription(), 0.1, 30); $Chart->drawPlotGraph($DataSet->GetData(), $DataSet->GetDataDescription(), 1, 1, 255, 255, 255); $Chart->clearScale(); $DataSet->RemoveSerie('SerieSkill'); $DataSet->AddSerie('SerieSession'); $DataSet->SetYAxisName('Session'); $DataSet->SetYAxisUnit(''); $Chart->setColorPalette(1, 255, 0, 0); $Chart->setColorPalette(2, 0, 0, 255);
include "pChart/pData.class"; include "pChart/pChart.class"; // Dataset definition $DataSet = new pData(); $DataSet->AddPoint(1, "Serie1"); $DataSet->AddPoint(3, "Serie2"); $DataSet->AddPoint(3, "Serie3"); $DataSet->AddPoint("A#~1", "Labels"); $DataSet->AddAllSeries(); $DataSet->RemoveSerie("Labels"); $DataSet->SetAbsciseLabelSerie("Labels"); $DataSet->SetSerieName("Alpha", "Serie1"); $DataSet->SetSerieName("Beta", "Serie2"); $DataSet->SetSerieName("Gama", "Serie3"); $DataSet->SetYAxisName("Test Marker"); $DataSet->SetYAxisUnit("�m"); // Initialise the graph $Test = new pChart(210, 230); $Test->setFontProperties("Fonts/tahoma.ttf", 8); $Test->setGraphArea(65, 30, 125, 200); $Test->drawFilledRoundedRectangle(7, 7, 203, 223, 5, 240, 240, 240); $Test->drawRoundedRectangle(5, 5, 205, 225, 5, 230, 230, 230); $Test->drawGraphArea(255, 255, 255, TRUE); $Test->drawScale($DataSet->GetData(), $DataSet->GetDataDescription(), SCALE_ADDALLSTART0, 150, 150, 150, TRUE, 0, 2, TRUE); $Test->drawGrid(4, TRUE, 230, 230, 230, 50); // Draw the 0 line $Test->setFontProperties("Fonts/tahoma.ttf", 6); $Test->drawTreshold(0, 143, 55, 72, TRUE, TRUE); // Draw the bar graph $Test->drawStackedBarGraph($DataSet->GetData(), $DataSet->GetDataDescription(), 50); // Finish the graph
function main() { $ThisArea = array('1' => 'Orizaba', '2' => 'Guadalajara', '3' => 'Ramos Arizpe', '4' => 'Tijuana'); if (!$this->args) { $this->help(); $this->err(__('Usage report <year> <area> <month> <fraction> <all_areas> ', true)); $this->_stop(); } $KmsConditions = null; if (isset($this->args[0]) && !isset($this->args[3])) { $CurrentYear = $this->args[0]; $KmsConditions['KmsCurrent.fecha_guia LIKE'] = "%" . $CurrentYear . "%"; } if (isset($this->args[1])) { $KeyArea = $this->args[1]; $KmsConditions['KmsCurrent.id_area'] = $KeyArea; } else { $KeyArea = null; } if (isset($this->args[2])) { $CurrentMonth = $this->args[2]; $CurrentYear = $this->args[0]; $KmsConditions['KmsCurrent.fecha_guia LIKE'] = "%" . $CurrentYear . "-" . $CurrentMonth . "%"; } else { $CurrentMonth = null; } if (isset($this->args[3])) { $Fraccion = $this->args[3]; $KmsConditions['KmsCurrent.id_fraccion'] = $Fraccion; } else { $Fraccion = null; } if (isset($this->args[4])) { $all = $this->args[4]; } else { $all = null; } $args = $this->args; /** ALERT Like in the ancient times Define the vars firts **/ // $KmsConditions = null; // $this->out(pr($KmsConditions)); // $this->out(pr($args));exit(); $NumDays = date('t', mktime('0', '0', '0', $CurrentMonth, '01', $CurrentYear)); /** TODO => Firts we need all areas => all fractions => CurrentYear ** => Second Detail By Four Areas => CurrentYear ** => Third Graphics by Area => Month => Fraction => CurrentYear **/ $kms_full = $full = $kms_all = null; $kms_search = $this->KmsCurrent->find('all', array('conditions' => $KmsConditions)); // $this->out(pr($KmsConditions)); // $this->out(pr($kms_search)); // exit(); if (!empty($kms_search)) { foreach ($kms_search as $key => $value) { if ($value['KmsCurrent']['id_configuracionviaje'] == '3') { $kms_full[$value['KmsCurrent']['no_viaje']][] = $value['KmsCurrent']['kms_viaje']; $kms_full[$value['KmsCurrent']['no_viaje']]['day'] = substr($value['KmsCurrent']['fecha_guia'], 8, 2); } elseif ($value['KmsCurrent']['id_configuracionviaje'] == '2' or $value['KmsCurrent']['id_configuracionviaje'] == '1') { $kms_all += $value['KmsCurrent']['kms_viaje']; $kms_senc[substr($value['KmsCurrent']['fecha_guia'], 8, 2)] = $value['KmsCurrent']['kms_viaje']; } } foreach ($kms_full as $k => $data) { $full += $data['0']; $full_days[$data['day']] += $data['0']; } $AreaCorp['kms_all'] = ($kms_all + $full) * 2; $all_days = ($kms_all + array_sum($full_days)) * 2; } else { $AreaCorp['kms_all'] = null; } // $this->out(pr($full)); $this->out(pr($full_days)); // $this->out(array_sum($full_days)); $this->out(pr($kms_senc)); $this->out(pr($AreaCorp)); $this->out(pr($all_days)); // exit(); $report_day = $kms_senc; $report_year = array(); /** ALERT Save the result for Display in the view */ //2 $this->autoRender = false; //3 App::import('Vendor', 'pData', array('file' => 'pchart' . DS . 'pData.class')); App::import('Vendor', 'pChart', array('file' => 'pchart' . DS . 'pChart.class')); //4 $fontFolder = APP . 'vendors' . DS . 'pchart' . DS . 'Fonts'; $fontFolder = '..' . DS . '..' . DS . 'vendors' . DS . 'pchart' . DS . 'Fonts'; //5 // Dataset definition $DataSet = new pData(); $MaxKms = max($report_day); $MaxKms = $MaxKms + 100; foreach ($report_day as $key => $value) { $MyDay[] = (int) $key; } // $this->out(pr($MyDay)); $DataSet->AddPoint($report_day, "Serie1"); // $DataSet->AddPoint('4',"Serie2"); // $DataSet->AddPoint('20',"Serie3"); // $DataSet->AddPoint($MyDay,"Name"); // exit(); // $this->out(pr($DataSet->GetData())); // $idx=0; // foreach($MyDay as $key => $value){ // $DataSet->AddPoint($value,"Serie1"); // $DataSet->AddPoint((int)$key,"Name"); // } // $this->out(pr($MyDay)); // $DataSet->GetData()['0']['Name']=; // $DataSet->GetData()['0']['Name']=1; $this->out(pr($DataSet->GetData())); $DataSet->AddAllSeries(); $DataSet->SetAbsciseLabelSerie(); $key = $value = null; $DataSet->SetSerieName("Kilometros", "Serie1"); $DataSet->SetSerieName("Dia", "Serie2"); $DataSet->SetYAxisName("Kilometros Dias"); $DataSet->SetYAxisUnit("Kms"); $DataSet->SetXAxisName("Dias"); $DataSet->SetXAxisFormat("number"); // Initialise the graph // pr($SchemaFolder); $Test = new pChart(820, 260); $Test->setFixedScale(1, $MaxKms, 5, 0, $NumDays, 5); $Test->setDateFormat("H:m"); $Test->setFontProperties($fontFolder . DS . "tahoma.ttf", 10); // $Test->setColorPalette(0,115,173,207); // $Test->setColorPalette(1,144,196,226); $Test->setColorPalette(2, 174, 216, 240); $Test->setColorPalette(3, 64, 140, 195); $Test->setColorPalette(4, 104, 188, 209); $Test->setColorPalette(5, 99, 200, 226); $Test->setColorPalette(6, 82, 124, 148); $Test->setColorPalette(7, 97, 152, 183); $Test->setColorPalette(8, 105, 210, 231); $Test->setColorPalette(9, 167, 219, 216); $Test->setColorPalette(10, 224, 228, 204); $Test->setColorPalette(11, 243, 134, 48); // $Test->loadColorPalette("/tmp/schema/blue.txt",","); $Test->setGraphArea(100, 30, 790, 200); // $Test->drawFilledRoundedRectangle(7,7,693,223,5,240,240,240); $Test->drawRoundedRectangle(5, 5, 810, 225, 5, 230, 230, 230); $Test->drawGraphArea(255, 255, 255, TRUE); // dibujar la grafica $Test->drawScale($DataSet->GetData(), $DataSet->GetDataDescription(), SCALE_NORMAL, 150, 150, 150, TRUE, 0, 2, TRUE); $Test->drawGrid(4, TRUE, 230, 230, 230, 50); // Draw the line graph // Draw the 0 line $Test->setFontProperties($fontFolder . DS . "tahoma.ttf", 10); $Test->drawTreshold(0, 143, 55, 72, TRUE, TRUE); // Draw the bar graph $Test->drawBarGraph($DataSet->GetData(), $DataSet->GetDataDescription(), TRUE, 80); // $Test->drawPlotGraph($DataSet->GetData(),$DataSet->GetDataDescription()); // $Test->drawXYPlotGraph($DataSet->GetData(),$DataSet->GetDataDescription(),"Serie1","Serie2"); // $Test->drawXYPlotGraph($DataSet->GetData(),$DataSet->GetDataDescription(),"Serie1","Serie3"); // $Test->drawXYGraph($DataSet->GetData(),$DataSet->GetDataDescription(),"Serie1","Serie2"); // Finish the graph $today = date('Y-m-d'); // $Test->setFontProperties($fontFolder.DS."tahoma.ttf",8); // $Test->drawLegend(820,150,$DataSet->GetDataDescription(),255,255,255); $Test->setFontProperties($fontFolder . DS . "tahoma.ttf", 10); // $_today = if (isset($KeyArea)) { $area = "_" . $KeyArea; } else { $area = "_0"; } if (isset($Fraccion)) { $fraction = "_" . $Fraccion; } else { $fraction = "_0"; } $Test->drawTitle(220, 22, "Kilometros {$ThisArea[$KeyArea]} {$MyMonth} {$CurrentYear}", 50, 50, 50, 585); $Test->Render("../../app/webroot/img/thumbs/graph_kms_" . $today . $area . $fraction . ".png"); }
public function build() { require_once PCHART_BASE_DIR . DIRECTORY_SEPARATOR . 'pData.php'; require_once PCHART_BASE_DIR . DIRECTORY_SEPARATOR . 'pChart.php'; $dataSet = new pData(); foreach ($this->lines as $name => $ordinateValues) { if (count($ordinateValues) != count($this->absciseValues)) { throw new Exception('Count of line "' . $name . '" ordinate points "' . count($ordinateValues) . '" mismatch to abscise points "' . count($this->absciseValues) . '"'); } $dataSet->AddPoint($ordinateValues, $name); } $dataSet->AddPoint($this->absciseValues, 'Abscise'); $dataSet->AddAllSeries(); $dataSet->RemoveSerie('Abscise'); $dataSet->SetAbsciseLabelSerie('Abscise'); foreach ($this->lines as $name => $ordinateValues) { $dataSet->SetSerieName($name, $name); } $dataSet->SetYAxisUnit($this->ordinateStepTitle); $dataSet->SetXAxisUnit($this->absciseStepTitle); $chart = new pChart($this->maxWidth, $this->maxHeight); $chart->drawGraphAreaGradient(132, 153, 172, 50, TARGET_BACKGROUND); // Graph area setup $chart->setFontProperties(PCHART_FONTS_DIR . DIRECTORY_SEPARATOR . 'tahoma.ttf', 10); $chart->setGraphArea($this->graphMargins[0], $this->graphMargins[1], $this->maxWidth - $this->graphMargins[2], $this->maxHeight - $this->graphMargins[3]); $chart->drawGraphArea(213, 217, 221, FALSE); $ordinateScaleMargin = ($this->getMaxOrdinateValue() - $this->getMinOrdinateValue()) / $this->ordinateDevisions; $chart->setFixedScale($this->getMinOrdinateValue() - $ordinateScaleMargin, $this->getMaxOrdinateValue() + $ordinateScaleMargin, $this->ordinateDevisions); $chart->drawScale($dataSet->GetData(), $dataSet->GetDataDescription(), SCALE_NORMAL, 213, 217, 221, TRUE, 0, 2); $chart->drawGraphAreaGradient(162, 183, 202, 50); $chart->drawGrid(4, TRUE, 230, 230, 230, 20); // Draw the line chart // $chart->setShadowProperties(1, 1, 0, 0, 0, 30, 4); $chart->drawLineGraph($dataSet->GetData(), $dataSet->GetDataDescription()); $chart->clearShadow(); $chart->drawPlotGraph($dataSet->GetData(), $dataSet->GetDataDescription(), 5, 3, -1, -1, -1, TRUE); // Draw the legend $chart->drawLegend($this->maxWidth - $this->graphMargins[2] + 10, $this->graphMargins[1], $dataSet->GetDataDescription(), 236, 238, 240, 52, 58, 82); // Draw chart title if ($this->chartTitle) { $chart->drawTextBox(0, $this->maxHeight - 20, $this->maxWidth, $this->maxHeight, $this->chartTitle, 0, 255, 255, 255, ALIGN_RIGHT, TRUE, 0, 0, 0, 30); } // Render the picture $chart->addBorder(2); $chart->Render($this->outputFilepath); }
*/ // Standard inclusions include "pChart/pData.class"; include "pChart/pChart.class"; // Dataset definition $DataSet = new pData(); $DataSet->AddPoint(array(60, 70, 90, 110, 100, 90), "Serie1"); $DataSet->AddPoint(array(40, 50, 60, 80, 70, 60), "Serie2"); $DataSet->AddPoint(array("Jan", "Feb", "Mar", "Apr", "May", "Jun"), "Serie3"); $DataSet->AddSerie("Serie1"); $DataSet->AddSerie("Serie2"); $DataSet->SetAbsciseLabelSerie("Serie3"); $DataSet->SetSerieName("Company A", "Serie1"); $DataSet->SetSerieName("Company B", "Serie2"); $DataSet->SetYAxisName("Product sales"); $DataSet->SetYAxisUnit("k"); $DataSet->SetSerieSymbol("Serie1", "Sample/Point_Asterisk.gif"); $DataSet->SetSerieSymbol("Serie2", "Sample/Point_Cd.gif"); // Initialise the graph $Test = new pChart(700, 230); $Test->setFontProperties("Fonts/tahoma.ttf", 8); $Test->setGraphArea(65, 30, 650, 200); $Test->drawFilledRoundedRectangle(7, 7, 693, 223, 5, 240, 240, 240); $Test->drawRoundedRectangle(5, 5, 695, 225, 5, 230, 230, 230); $Test->drawGraphArea(255, 255, 255, TRUE); $Test->drawScale($DataSet->GetData(), $DataSet->GetDataDescription(), SCALE_NORMAL, 150, 150, 150, TRUE, 0, 2, TRUE); $Test->drawGrid(4, TRUE, 230, 230, 230, 50); // Draw the title $Test->setFontProperties("Fonts/pf_arma_five.ttf", 6); $Title = "Comparative product sales for company A & B "; $Test->drawTextBox(65, 30, 650, 45, $Title, 0, 255, 255, 255, ALIGN_RIGHT, TRUE, 0, 0, 0, 30);
<?php // Standard inclusions include "pChart/pData.class"; include "pChart/pChart.class"; // Dataset definition $DataSet = new pData(); $DataSet->AddPoint(array(1079, 1151, 1185, 1226, 1121, 738, 710), "Visitor"); $DataSet->AddPoint(array("1 พ.ย.", "2 พ.ย.", "3 พ.ย.", "4 พ.ย.", "5 พ.ย.", "6 พ.ย.", "7 พ.ย."), "Day"); $DataSet->AddSerie("Visitor"); $DataSet->SetAbsciseLabelSerie("Day"); $DataSet->SetYAxisName("Visitors"); $DataSet->SetYAxisUnit("ip"); // Initialise the graph $Graph = new pChart(700, 230); $Graph->setFontProperties("Fonts/tahoma.ttf", 8); $Graph->setGraphArea(70, 30, 680, 200); $Graph->drawFilledRoundedRectangle(7, 7, 693, 223, 5, 240, 240, 240); $Graph->drawRoundedRectangle(5, 5, 695, 225, 5, 230, 230, 230); $Graph->drawGraphArea(255, 255, 255, TRUE); $Graph->drawScale($DataSet->GetData(), $DataSet->GetDataDescription(), SCALE_NORMAL, 150, 150, 150, TRUE, 0, 2); $Graph->drawGrid(4, TRUE, 230, 230, 230, 50); // Draw the 0 line $Graph->setFontProperties("Fonts/tahoma.ttf", 6); $Graph->drawTreshold(0, 143, 55, 72, TRUE, TRUE); // Draw the line graph $Graph->drawLineGraph($DataSet->GetData(), $DataSet->GetDataDescription()); $Graph->drawPlotGraph($DataSet->GetData(), $DataSet->GetDataDescription(), 3, 2, 255, 255, 255); // Finish the graph $Graph->setFontProperties("Fonts/tahoma.ttf", 8); $Graph->drawLegend(75, 35, $DataSet->GetDataDescription(), 255, 255, 255);
*/ // Standard inclusions include "../lib/pData.php"; include "../lib/pChart.php"; // Dataset definition $DataSet = new pData(); $DataSet->AddPoint(array(9, 9, 9, 10, 10, 11, 12, 14, 16, 17, 18, 18, 19, 19, 18, 15, 12, 10, 9), "Serie1"); $DataSet->AddPoint(array(10, 11, 11, 12, 12, 13, 14, 15, 17, 19, 22, 24, 23, 23, 22, 20, 18, 16, 14), "Serie2"); $DataSet->AddPoint(array(4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22), "Serie3"); $DataSet->AddAllSeries(); $DataSet->RemoveSerie("Serie3"); $DataSet->SetAbsciseLabelSerie("Serie3"); $DataSet->SetSerieName("January", "Serie1"); $DataSet->SetSerieName("February", "Serie2"); $DataSet->SetYAxisName("Temperature"); $DataSet->SetYAxisUnit("°C"); $DataSet->SetXAxisUnit("h"); // Initialise the graph $Test = new pChart(700, 230); $Test->drawGraphAreaGradient(132, 173, 131, 50, TARGET_BACKGROUND); $Test->setFontProperties("../Fonts/tahoma.ttf", 8); $Test->setGraphArea(120, 20, 675, 190); $Test->drawGraphArea(213, 217, 221, FALSE); $Test->drawScale($DataSet->GetData(), $DataSet->GetDataDescription(), SCALE_ADDALL, 213, 217, 221, TRUE, 0, 2, TRUE); $Test->drawGraphAreaGradient(163, 203, 167, 50); $Test->drawGrid(4, TRUE, 230, 230, 230, 20); // Draw the bar chart $Test->drawStackedBarGraph($DataSet->GetData(), $DataSet->GetDataDescription(), 70); // Draw the title $Title = " Average Temperatures during\r\n the first months of 2008 "; $Test->drawTextBox(0, 0, 50, 230, $Title, 90, 255, 255, 255, ALIGN_BOTTOM_CENTER, TRUE, 0, 0, 0, 30);
function cartesianChart($type, $x, $y, $w, $h, $imgname = '', $config = array()) { $w -= 4; $h -= 4; $settings = array('FontName' => 'tahoma.ttf', 'FontSize' => 8, 'LegendFontSize' => 8, 'LegendFontName' => 'tahoma.ttf', 'Logo' => '', 'LogoTransparency' => 20, 'XAxisFormat' => 'number', 'XAxisUnit' => '', 'YAxisFormat' => 'number', 'YAxisUnit' => '', 'XLogo' => 0, 'YLogo' => 0, 'Xlabel' => 'x label', 'XAngle' => 0, 'Ylabel' => 'y label', 'Legend' => '', 'Textbox' => '', 'TextboxFontSize' => 8, 'TextboxFontName' => 'tahoma.ttf', 'ImgR' => 132, 'ImgG' => 173, 'ImgB' => 131, 'Decay' => 80, 'BGR' => 163, 'BGG' => 203, 'BGB' => 167, 'Decay2' => 80, 'Filled' => '', 'DataR' => 191, 'DataG' => 120, 'DataB' => 71, 'LBR' => 226, 'LBG' => 228, 'LBB' => 230, 'LR' => 0, 'LG' => 0, 'LB' => 0); // Get the custom settings if (is_array($config)) { foreach ($config as $key => $val) { $settings[$key] = $val; } } $DataSet = new pData(); $DataSet->AddPoint($y, "Serie1"); $DataSet->AddPoint($x, "Serie2"); $DataSet->AddAllSeries(); $DataSet->RemoveSerie("Serie2"); $DataSet->SetAbsciseLabelSerie("Serie2"); $DataSet->SetSerieName($settings['Legend'], "Serie1"); $DataSet->SetYAxisName($settings['Ylabel']); $DataSet->SetXAxisName($settings['Xlabel']); $DataSet->SetXAxisFormat($settings['XAxisFormat']); if (strlen($settings['XAxisUnit'])) { $DataSet->SetXAxisUnit($settings['XAxisUnit']); } if (strlen($settings['YAxisUnit'])) { $DataSet->SetYAxisUnit($settings['YAxisUnit']); } $DataSet->SetYAxisFormat($settings['YAxisFormat']); // Initialise the graph $Test = new pChart($w, $h); $Test->drawGraphAreaGradient($settings['ImgR'], $settings['ImgG'], $settings['ImgB'], $settings['Decay'], TARGET_BACKGROUND); $FontSize = $settings['FontSize']; $FontName = $this->_ext_path . "/fonts/" . $settings['FontName']; $Test->setFontProperties($FontName, $FontSize); //Calc Textbox Height if (strlen($settings['Textbox'])) { $TextboxFontSize = $settings['TextboxFontSize']; $TextboxFontName = $this->_ext_path . "/fonts/" . $settings['TextboxFontName']; $Position = imageftbbox($TextboxFontSize, 0, $TextboxFontName, $settings['Textbox']); $TextboxHeight = $Position[1] - $Position[7] + 8; } else { $TextboxHeight = 0; } // Maximize The graph area //on Y axis if ($settings['XAxisFormat'] == 'time') { $xdata = "99:99:99"; $Position = imageftbbox($FontSize, 0, $FontName, $xdata); $WXmax = $Position[2] - $Position[0]; $TextHeightX = $Position[1] - $Position[7]; } elseif ($settings['XAxisFormat'] == 'date') { $xdata = "99/99/9999"; $Position = imageftbbox($FontSize, 0, $FontName, $xdata); $WXmax = $Position[2] - $Position[0]; $TextHeightX = $Position[1] - $Position[7]; } else { $WXmax = 0; foreach ($x as $xdata) { $xdata .= $settings['XAxisUnit']; $Position = imageftbbox($FontSize, 0, $FontName, $xdata); $TextWidth = $Position[2] - $Position[0]; $TextHeightX = $Position[1] - $Position[7]; $WXmax = $TextWidth > $WXmax ? $TextWidth : $WXmax; } } if ($settings['XAngle'] > 0) { $sin = abs(sin(deg2rad($settings['XAngle']))); $cos = abs(cos(deg2rad($settings['XAngle']))); $HXmax = $WXmax * $sin + $TextHeightX * $cos; } else { $HXmax = $TextHeightX; } //on Y axis... if ($settings['YAxisFormat'] == 'time') { $ydata = "99:99:99"; $Position = imageftbbox($FontSize, 0, $FontName, $ydata); $WYmax = $Position[2] - $Position[0]; $TextHeightY = $Position[1] - $Position[7]; } elseif ($settings['YAxisFormat'] == 'date') { $ydata = "99/99/9999"; $Position = imageftbbox($FontSize, 0, $FontName, $ydata); $WYmax = $Position[2] - $Position[0]; $TextHeightY = $Position[1] - $Position[7]; } else { $WYmax = 0; foreach ($y as $ydata) { $ydata .= $settings['YAxisUnit']; //echo $ydata."<br>"; $Position = imageftbbox($FontSize, 0, $FontName, $ydata); $TextWidth = $Position[2] - $Position[0]; $TextHeightY = $Position[1] - $Position[7]; $WYmax = $TextWidth > $WYmax ? $TextWidth : $WYmax; } } $Test->setGraphArea($WYmax + $TextHeightY + 35, 20, $w - 25, $h - $HXmax - $TextHeightX - $TextboxHeight - 20); //$Test->setGraphArea(60,20,$w-25,($settings['XAngle']==0)?$h-70:$h-100); $Test->drawScale($DataSet->GetData(), $DataSet->GetDataDescription(), SCALE_ADDALL, 213, 217, 221, TRUE, $settings['XAngle'], 0, TRUE); $Test->drawGraphAreaGradient($settings['BGR'], $settings['BGG'], $settings['BGB'], $settings['Decay2']); $Test->drawGrid(4, TRUE, 230, 230, 230, 20); // This will put the picture "logo.png" with transparency if (strlen($settings['Logo'])) { $XLogo = $WYmax + $TextHeightY + 35 + $settings['XLogo']; $YLogo = 20 + $settings['XLogo']; $logo = $settings['Logo']; //Fing extension of logo : png,gif or jpg if ($this->_findexts($logo) == "png") { echo "png!"; $Test->drawFromPNG($logo, $XLogo, $YLogo, $settings['LogoTransparency']); } elseif ($this->_findexts($logo) == "gif") { echo "gif!"; $Test->drawFromGIF($logo, $XLogo, $YLogo, $settings['LogoTransparency']); } elseif ($this->_findexts($logo) == "jpg") { echo "jpg"; $Test->drawFromJPG($logo, $XLogo, $YLogo, $settings['LogoTransparency']); } } $Test->setColorPalette(0, $settings['DataR'], $settings['DataG'], $settings['DataB']); if ($type == "bar") { // Draw the bar chart $Test->drawStackedBarGraph($DataSet->GetData(), $DataSet->GetDataDescription(), 70); } elseif ($type == "line") { $Test->drawLineGraph($DataSet->GetData(), $DataSet->GetDataDescription()); $Test->drawPlotGraph($DataSet->GetData(), $DataSet->GetDataDescription(), 3, 0, -1, -1, -1, TRUE); } elseif ($type == "cubic") { $Test->setShadowProperties(3, 3, 0, 0, 0, 30, 4); $Test->drawCubicCurve($DataSet->GetData(), $DataSet->GetDataDescription()); $Test->clearShadow(); if ($settings['Filled'] == 'yes') { $Test->drawFilledCubicCurve($DataSet->GetData(), $DataSet->GetDataDescription(), 0.1, 30); } $Test->drawPlotGraph($DataSet->GetData(), $DataSet->GetDataDescription(), 3, 0, -1, -1, -1, TRUE); } // Draw the textbox if (strlen($settings['Textbox'])) { $Test->setFontProperties($TextboxFontName, $TextboxFontSize); $Test->drawTextBox(0, $h - $TextboxHeight, $w, $h, $settings['Textbox'], 0, 255, 255, 255, ALIGN_CENTER, TRUE, 0, 0, 0, 30); } // Draw the legend if (strlen($settings['Legend'])) { $LegendFontSize = $settings['LegendFontSize']; $LegendFontName = $this->_ext_path . "/fonts/" . $settings['LegendFontName']; $Position = imageftbbox($LegendFontSize, 0, $LegendFontName, $settings['Legend']); $LegendW = $Position[2] - $Position[0] + 40; $Test->setFontProperties($LegendFontName, $LegendFontSize); $Test->drawLegend($w - $LegendW, 10, $DataSet->GetDataDescription(), $settings['LBR'], $settings['LBG'], $settings['LBB'], 52, 58, 82, $settings['LR'], $settings['LG'], $settings['LB'], TRUE); } // Render the picture $Test->addBorder(2); if (strlen($imgname)) { //custom image name $imgname = $this->_img_path . "/" . $imgname; } else { $this->obj->load->helper('string'); $imgname = $this->_img_path . "/{$type}-" . random_string('alnum', 16) . ".png"; } $Test->Render($imgname); return array("name" => '/' . $imgname, "w" => $w + 4, "h" => $h + 4); }