function showGraph($searchInfo = '')
 {
     $conditions = empty($searchInfo['keywordId']) ? "" : " and s.keyword_id=" . intval($searchInfo['keywordId']);
     $conditions .= empty($searchInfo['seId']) ? "" : " and s.searchengine_id=" . intval($searchInfo['seId']);
     $sql = "select s.*,se.domain \r\n\t\t\t\t\tfrom searchresults s,searchengines se  \r\n\t\t\t\t\twhere s.searchengine_id=se.id \r\n\t\t\t\t\tand time>= " . intval($searchInfo['fromTime']) . " and time<" . intval($searchInfo['toTime']) . " {$conditions}  \r\n\t\t\t\t\torder by s.time";
     $repList = $this->db->select($sql);
     $reportList = array();
     $seList = array();
     foreach ($repList as $repInfo) {
         $var = $repInfo['searchengine_id'] . $repInfo['keyword_id'] . $repInfo['time'];
         if (empty($reportList[$var])) {
             $reportList[$var] = $repInfo;
         } else {
             if ($repInfo['rank'] < $reportList[$var]['rank']) {
                 $reportList[$var] = $repInfo;
             }
         }
         if (empty($seList[$repInfo['searchengine_id']])) {
             $seList[$repInfo['searchengine_id']] = $repInfo['domain'];
         }
     }
     asort($seList);
     $dataList = array();
     $maxValue = 0;
     foreach ($reportList as $repInfo) {
         $seId = $repInfo['searchengine_id'];
         $dataList[$repInfo['time']][$seId] = $repInfo['rank'];
         $maxValue = $repInfo['rank'] > $maxValue ? $repInfo['rank'] : $maxValue;
     }
     // check whether the records are available for drawing graph
     if (empty($dataList) || empty($maxValue)) {
         $kpText = $_SESSION['lang_code'] == 'ja' ? $_SESSION['text']['common']['No Records Found'] . "!" : "No Records Found!";
         $this->showMessageAsImage($kpText);
     }
     # Dataset definition
     $dataSet = new pData();
     foreach ($dataList as $dataInfo) {
         $i = 1;
         foreach ($seList as $seId => $seVal) {
             $val = empty($dataInfo[$seId]) ? 0 : $dataInfo[$seId];
             $dataSet->AddPoint($val, "Serie" . $i++);
         }
     }
     $i = 1;
     foreach ($seList as $seDomain) {
         $dataSet->AddSerie("Serie{$i}");
         $dataSet->SetSerieName($seDomain, "Serie{$i}");
         $i++;
     }
     $serieCount = count($seList) + 1;
     $dataSet->AddPoint(array_keys($dataList), "Serie{$serieCount}");
     $dataSet->SetAbsciseLabelSerie("Serie{$serieCount}");
     # if language is japanese
     if ($_SESSION['lang_code'] == 'ja') {
         $fontFile = "fonts/M+1P+IPAG.ttf";
         $dataSet->SetXAxisName($_SESSION['text']['common']["Date"]);
         $dataSet->SetYAxisName($_SESSION['text']['common']["Rank"]);
     } else {
         $fontFile = "fonts/tahoma.ttf";
         $dataSet->SetXAxisName("Date");
         $dataSet->SetYAxisName("Rank");
     }
     $dataSet->SetXAxisFormat("date");
     # Initialise the graph
     $chart = new pChart(720, 520);
     $chart->setFixedScale($maxValue, 1);
     $chart->setFontProperties($fontFile, 8);
     $chart->setGraphArea(85, 30, 670, 425);
     $chart->drawFilledRoundedRectangle(7, 7, 713, 513, 5, 240, 240, 240);
     $chart->drawRoundedRectangle(5, 5, 715, 515, 5, 230, 230, 230);
     $chart->drawGraphArea(255, 255, 255, TRUE);
     $chart->drawScale($dataSet->GetData(), $dataSet->GetDataDescription(), SCALE_NORMAL, 150, 150, 150, TRUE, 90, 2);
     $chart->drawGrid(4, TRUE, 230, 230, 230, 50);
     # Draw the 0 line
     $chart->setFontProperties($fontFile, 6);
     $chart->drawTreshold(0, 143, 55, 72, TRUE, TRUE);
     # Draw the line graph
     $chart->drawLineGraph($dataSet->GetData(), $dataSet->GetDataDescription());
     $chart->drawPlotGraph($dataSet->GetData(), $dataSet->GetDataDescription(), 3, 2, 255, 255, 255);
     $j = 1;
     $chart->setFontProperties($fontFile, 10);
     foreach ($seList as $seDomain) {
         $chart->writeValues($dataSet->GetData(), $dataSet->GetDataDescription(), "Serie" . $j++);
     }
     # Finish the graph
     $chart->setFontProperties("fonts/tahoma.ttf", 8);
     $chart->drawLegend(90, 35, $dataSet->GetDataDescription(), 255, 255, 255);
     $chart->setFontProperties($fontFile, 10);
     $kpText = $_SESSION['lang_code'] == 'ja' ? $this->spTextKeyword["Keyword Position Report"] : "Keyword Position Report";
     $chart->drawTitle(60, 22, $kpText, 50, 50, 50, 585);
     $chart->stroke();
 }
$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);
$Test->writeValues($DataSet->GetData(), $DataSet->GetDataDescription(), "Serie1");
// Finish the graph
$Test->setFontProperties("../../pChart/Fonts/tahoma.ttf", 8);
//$Test->drawLegend(75,35,$DataSet->GetDataDescription(),255,255,255);
$Test->setFontProperties("../../pChart/Fonts/tahoma.ttf", 10);
$Test->drawTitle(60, 22, "Temps moyen par panne par mois", 50, 50, 50, 585);
//$Test->Render("example1.png");
$Test->stroke();
 function showGraph($searchInfo = '')
 {
     $conditions = empty($searchInfo['keywordId']) ? "" : " and s.keyword_id=" . $searchInfo['keywordId'];
     $conditions .= empty($searchInfo['seId']) ? "" : " and s.searchengine_id=" . $searchInfo['seId'];
     $sql = "select s.*,se.domain \r\n\t\t\t\t\tfrom searchresults s,searchengines se  \r\n\t\t\t\t\twhere s.searchengine_id=se.id \r\n\t\t\t\t\tand time>= {$searchInfo['fromTime']} and time<{$searchInfo['toTime']} {$conditions}  \r\n\t\t\t\t\torder by s.time";
     $repList = $this->db->select($sql);
     $reportList = array();
     $seList = array();
     foreach ($repList as $repInfo) {
         $var = $repInfo['searchengine_id'] . $repInfo['keyword_id'] . $repInfo['time'];
         if (empty($reportList[$var])) {
             $reportList[$var] = $repInfo;
         } else {
             if ($repInfo['rank'] < $reportList[$var]['rank']) {
                 $reportList[$var] = $repInfo;
             }
         }
         if (empty($seList[$repInfo['searchengine_id']])) {
             $seList[$repInfo['searchengine_id']] = $repInfo['domain'];
         }
     }
     asort($seList);
     $dataList = array();
     foreach ($reportList as $repInfo) {
         $seId = $repInfo['searchengine_id'];
         $dataList[$repInfo['time']][$seId] = $repInfo['rank'];
     }
     # Dataset definition
     $dataSet = new pData();
     foreach ($dataList as $dataInfo) {
         $i = 1;
         foreach ($seList as $seId => $seVal) {
             $val = empty($dataInfo[$seId]) ? 0 : $dataInfo[$seId];
             $dataSet->AddPoint($val, "Serie" . $i++);
         }
     }
     $i = 1;
     foreach ($seList as $seDomain) {
         $dataSet->AddSerie("Serie{$i}");
         $dataSet->SetSerieName($seDomain, "Serie{$i}");
         $i++;
     }
     $serieCount = count($seList) + 1;
     $dataSet->AddPoint(array_keys($dataList), "Serie{$serieCount}");
     $dataSet->SetAbsciseLabelSerie("Serie{$serieCount}");
     $dataSet->SetXAxisName("Date");
     $dataSet->SetYAxisName("Rank");
     $dataSet->SetXAxisFormat("date");
     # Initialise the graph
     $chart = new pChart(720, 520);
     $chart->setFontProperties("fonts/tahoma.ttf", 8);
     $chart->setGraphArea(85, 30, 670, 425);
     $chart->drawFilledRoundedRectangle(7, 7, 713, 513, 5, 240, 240, 240);
     $chart->drawRoundedRectangle(5, 5, 715, 515, 5, 230, 230, 230);
     $chart->drawGraphArea(255, 255, 255, TRUE);
     $chart->drawScale($dataSet->GetData(), $dataSet->GetDataDescription(), SCALE_NORMAL, 150, 150, 150, TRUE, 90, 2);
     $chart->drawGrid(4, TRUE, 230, 230, 230, 50);
     # Draw the 0 line
     $chart->setFontProperties("fonts/tahoma.ttf", 6);
     $chart->drawTreshold(0, 143, 55, 72, TRUE, TRUE);
     # Draw the line graph
     $chart->drawLineGraph($dataSet->GetData(), $dataSet->GetDataDescription());
     $chart->drawPlotGraph($dataSet->GetData(), $dataSet->GetDataDescription(), 3, 2, 255, 255, 255);
     $j = 1;
     $chart->setFontProperties("fonts/tahoma.ttf", 10);
     foreach ($seList as $seDomain) {
         $chart->writeValues($dataSet->GetData(), $dataSet->GetDataDescription(), "Serie" . $j++);
     }
     # Finish the graph
     $chart->setFontProperties("fonts/tahoma.ttf", 8);
     $chart->drawLegend(90, 35, $dataSet->GetDataDescription(), 255, 255, 255);
     $chart->setFontProperties("fonts/tahoma.ttf", 10);
     $chart->drawTitle(60, 22, "Keyword Position Report", 50, 50, 50, 585);
     $chart->stroke();
 }