$bplot->SetShadow(); $bplot->value->SetFormat("%.1f%%"); $bplot->value->Show(); $day0 = strtotime(date("Y") . "-06-01"); $day1 = strtotime(date("Y") . "-09-15"); $day2 = strtotime(date("Y-m-d")); $blue_start = ($day2 - $day0) / (60 * 60 * 24); $blue_end = ($day2 - $day1) / (60 * 60 * 24); if ($blue_start >= 0 xor $blue_end < 0) { //黄色 $graph->SetBackgroundImage('/home/kouji/public_html/html/AutoTweet/image/denryoku_bg_new_y.png', BGIMG_FILLFRAME); } else { //水色 $graph->SetBackgroundImage('/home/kouji/public_html/html/AutoTweet/image/denryoku_bg_new_b.png', BGIMG_FILLFRAME); } $graph->SetBackgroundImageMix(100); $graph->title->SetFont(FF_PGOTHIC, FS_NORMAL, 20); $graph->title->Set("\n《大手電力会社 電力使用率》"); $z = date("H") % 3; if ($z == 2) { $omimai = " 熊本地震の被災地の皆様に、心よりお見舞い申し上げます。\n"; } elseif ($z == 1) { $omimai = "東日本大震災の被災地の皆様に、心よりお見舞い申し上げます。\n"; } elseif ($z == 0) { $omimai = "鳥取県中部地震の被災地の皆様に、心よりお見舞い申し上げます。\n"; } $omimai .= " 一日も早く、復興が出来ますように、お祈り申し上げます。\n"; $omimai .= " " . $data_time . "更新"; $graph->xaxis->title->Set($omimai); $graph->xaxis->title->SetFont(FF_GOTHIC, FS_NORMAL, 10); $graph->xaxis->title->SetMargin(-585);
foreach ($humidity as $value) { $bucket_pos = floor($value / $range_interval); if ($bucket_pos >= $INTERVAL_COUNT) { $bucket_pos = $INTERVAL_COUNT - 1; } $bucket[$bucket_pos]++; //error_log("item=".$value."||bucket_pos=".$bucket_pos."||count=".$bucket[$bucket_pos]); } $humidity_plot = new BarPlot($bucket); $humidity_plot->SetColor('dodgerblue'); $humidity_plot->SetWeight(2); $humidity_plot->SetFillColor('dodgerblue'); $graph = new Graph($width, $height); $graph->SetFrame(false); $graph->SetBackgroundImage('background_v_40_60.png', BGIMG_FILLPLOT); $graph->SetBackgroundImageMix(35); $graph->SetMargin(60, 60, 40, 50); $graph->SetMarginColor('white'); $graph->SetScale('textlin'); $graph->Add($humidity_plot); $graph->ygrid->SetColor("azure3"); $graph->xaxis->SetLabelAngle(90); $graph->xaxis->SetWeight(2); $graph->xaxis->SetFont(FF_ARIAL, FS_NORMAL, $font_size - 3); $graph->xaxis->SetTickLabels($tick_labels); $graph->yaxis->SetWeight(2); $graph->yaxis->SetColor('dodgerblue'); $graph->yaxis->SetFont(FF_ARIAL, FS_NORMAL, $font_size - 3); $graph->yaxis->title->SetColor('dodgerblue'); $graph->yaxis->title->Set('Number of occurrences'); $graph->yaxis->title->SetFont(FF_ARIAL, FS_BOLD, $font_size);
/** * Un tableau contenant les moyennes des eleves pour chaque sequences * * @param type $moyennes = array() */ function genererCourbe($moyennes, $rang, $codeperiode = "S") { try { # Donnees de la courbe $ydata = $moyennes; $ydata2 = $moyennes; /* for ($i = 1; $i <= 6; $i++) { $r = rand(0, 20); $ydata[] = $r; $ydata2[] = $r; } */ /** Definition des label de l'axe x */ if ($codeperiode === "T") { $datax = array("TRIM1", "TRIM2", "TRIM3"); } else { $datax = array("seq 1", "seq 2", "seq 3", "seq 4", "seq 5", "seq 6"); } # Creation du graph $graph = new Graph(350, 250, 'auto'); $graph->SetMarginColor('white'); # Definir le max et le min des valeur X $graph->SetScale('textlin', 0, 20); #$graph->xaxis->title->Set("Séquences"); $graph->yaxis->title->SetFont(FF_ARIAL, FS_BOLD, 12); $graph->yaxis->title->Set("Moyennes"); $graph->xaxis->SetTickLabels($datax); $graph->xaxis->title->SetFont(FF_ARIAL, FS_BOLD, 12); if ($codeperiode === "T") { $graph->xaxis->SetTitle("Trimestres", "middle"); } else { $graph->xaxis->SetTitle("Séquences", "middle"); } $graph->SetBackgroundGradient('white', 'lightblue', GRAD_HOR, BGRAD_PLOT); # Adjuster les margins (left, right, top, bottom) $graph->SetMargin(40, 5, 21, 45); # Box autour du plotarea $graph->SetBox(); # Un cadre ou frame autour de l'image $graph->SetFrame(false); # Definir le titre tabulaire $graph->tabtitle->SetFont(FF_ARIAL, FS_BOLD, 8); $graph->tabtitle->Set($_SESSION['anneeacademique']); # Definir le titre du graphe $graph->title->SetFont(FF_VERDANA, FS_BOLD, 8); $graph->title->SetAlign("right"); if (count($ydata) > 1) { $prev = $ydata[count($ydata) - 2]; if ($prev < $ydata[count($ydata) - 1]) { $graph->title->Set("Performance en hausse"); } elseif ($prev == $ydata[count($ydata) - 1]) { $graph->title->Set("Performance constante"); } else { $graph->title->Set("Performance en baisse"); } } # Definir les grid X et Y $graph->ygrid->SetFill(true, '#BBBBBB@0.9', '#FFFFFF@0.9'); //$graph->ygrid->SetLineStyle('dashed'); //$graph->ygrid->SetColor('gray'); //$graph->xgrid->SetLineStyle('dashed'); $graph->xgrid->SetColor('gray'); $graph->xgrid->Show(); //$graph->ygrid->Show(); #$graph->SetBackgroundGradient('blue','navy:0.5',GRAD_HOR,BGRAD_MARGIN); $graph->xaxis->SetFont(FF_ARIAL, FS_NORMAL, 8); $graph->xaxis->SetLabelAngle(0); # Creation d'une bar pot $bplot = new BarPlot($ydata); $bplot->SetWidth(0.9); $fcol = '#440000'; $tcol = '#FF9090'; $bplot->SetFillGradient($fcol, $tcol, GRAD_LEFT_REFLECTION); # Set line weigth to 0 so that there are no border around each bar $bplot->SetWeight(0); # Create filled line plot $lplot = new LinePlot($ydata2); $lplot->SetFillColor('skyblue@0.5'); $lplot->SetStyle(1); $lplot->SetColor('navy@0.7'); $lplot->SetBarCenter(); $lplot->mark->SetType(MARK_SQUARE); $lplot->mark->SetColor('blue@0.5'); $lplot->mark->SetFillColor('lightblue'); $lplot->mark->SetSize(5); # Afficher les moyenne au dessus des barres $accbarplot = new AccBarPlot(array($bplot)); $accbarplot->value->SetFormat("%.2f"); $accbarplot->value->Show(); $graph->Add($accbarplot); $graph->SetBackgroundImageMix(50); # Definir un fond d'ecran pour l'image $background = SITE_ROOT . "public/photos/eleves/" . $rang['PHOTOEL']; if (!empty($rang['PHOTOEL']) && file_exists(ROOT . DS . "public" . DS . "photos" . DS . "eleves" . DS . $rang['PHOTOEL'])) { $graph->SetBackgroundImage($background, BGIMG_FILLPLOT); # $icon = new IconPlot($background, 25, 25, 0.8, 50); } else { //$graph->SetBackgroundImage(SITE_ROOT . "public/img/". LOGO, BGIMG_FILLPLOT); # $icon = new IconPlot(SITE_ROOT . "public/img/ipw.png", 25, 25, 0.8, 50); } # $icon->SetAnchor('right', 'bottom'); $graph->Add($lplot); // Display the graph $filename = ROOT . DS . "public" . DS . "tmp" . DS . $rang['IDELEVE'] . ".png"; if (file_exists($filename)) { unlink($filename); } $graph->Stroke($filename); //echo "<img src='" . SITE_ROOT . "public/tmp/emp.png' />"; } catch (Exception $e) { var_dump($e); } }