$graph->SetShadow(); $graph->title->SetFont(FF_ARIAL, FS_BOLD, 15); $graph->title->Set("Cash flow "); $graph->subtitle->Set("(Department X)"); // Show both X and Y grid $graph->xgrid->Show(true, false); // Add 10% grace ("space") at top and botton of Y-scale. $graph->yscale->SetGrace(10, 10); // Turn the tick mark out from the plot area $graph->xaxis->SetTickSide(SIDE_DOWN); $graph->yaxis->SetTickSide(SIDE_LEFT); // Create a bar pot $bplot = new BarPlot($datay); $bplot->SetFillColor("orange"); $bplot->SetShadow(); // Show the actual value for each bar on top/bottom $bplot->value->Show(); $bplot->value->SetFormat("%02d kr"); // Position the X-axis at the bottom of the plotare $graph->xaxis->SetPos("min"); // .. and add the plot to the graph $graph->Add($bplot); // Add mark graph with static lines $graph->AddLine(new PlotLine(HORIZONTAL, 0, "black", 2)); $graph->AddLine(new PlotLine(VERTICAL, 3, "black", 2)); //$graph->title->Set("Test of bar gradient fill"); $graph->xaxis->title->Set("X-title"); $graph->yaxis->title->Set("Y-title"); $graph->yaxis->title->SetFont(FF_ARIAL, FS_BOLD, 11); $graph->xaxis->title->SetFont(FF_ARIAL, FS_BOLD, 11); $graph->Stroke();
// .. and add the plot to the graph $graph->Add($bplot); // Add upper and lower band and use no frames $band[0] = new PlotBand(HORIZONTAL, BAND_RDIAG, 10, 20, "green"); $band[0]->ShowFrame(false); $band[1] = new PlotBand(HORIZONTAL, BAND_LDIAG, -20, -10, "red"); $band[1]->ShowFrame(false); $band[1]->SetDensity(20); $band[2] = new PlotBand(HORIZONTAL, BAND_DIAGCROSS, "min", -20, "red"); $band[2]->ShowFrame(false); $band[2]->SetDensity(40); $band[3] = new PlotBand(VERTICAL, BAND_HLINE, 0, 1, "darkgray"); $band[3]->ShowFrame(false); $band[3]->SetOrder(DEPTH_FRONT); $band[4] = new PlotBand(VERTICAL, BAND_HVCROSS, 5, "max", "darkgray"); $band[4]->ShowFrame(false); $band[4]->SetOrder(DEPTH_FRONT); $band[5] = new PlotBand(HORIZONTAL, BAND_SOLID, 20, "max", "lightgreen"); $band[6] = new PlotBand(HORIZONTAL, BAND_3DPLANE, -10, 0, "blue"); $band[6]->SetDensity(70); $graph->Add($band); $graph->AddLine(new PlotLine(HORIZONTAL, 0, "black", 2)); //$graph->title->Set("Test of bar gradient fill"); $graph->xaxis->title->Set("X-title"); $graph->yaxis->title->Set("Y-title"); $graph->yaxis->title->SetFont(FF_ARIAL, FS_BOLD, 11); $graph->xaxis->title->SetFont(FF_ARIAL, FS_BOLD, 11); $graph->Stroke(); ?>
public static function liner3Show($data_x, $data_y, $x_title, $y_title, $graph_title) { // echo var_dump($data_x); // echo var_dump($data_y); $graph = new Graph(LENHSIZE, HEISIZE); //创建画布 $graph->img->SetMargin(LEFT, 80, UP, DOWN); //设置统计图所在画布的位置,左边距50、右边距40、上边距30、下边距40,单位为像素 // $graph->yscale->ticks->Set($max_y/2,1); $graph->img->SetAntiAliasing(); //设置折线的平滑状态 $graph->SetScale("textlin", 210, 230); //设置刻度样式 $graph->SetShadow(); //创建画布阴影 $graph->xgrid->Show(); $line = new PlotLine(HORIZONTAL, 220, "red", 2); //设置红色警戒线 $line->SetLegend("警戒线"); $graph->legend->setFont(FF_SIMSUN, FS_BOLD, GRAGHSIZE - 5); $graph->AddLine($line, false); $graph->title->Set($graph_title); //设置标题 $graph->title->SetFont(FF_SIMSUN, FS_BOLD, GRAGHSIZE); //设置标题字体 $graph->SetMarginColor("lightblue"); //设置画布的背景颜色为淡蓝色 $graph->yaxis->title->SetFont(FF_SIMSUN, FS_BOLD); //设置Y轴标题的字体 $graph->xaxis->SetPos("min"); // $graph->yaxis->HideZeroLabel(); // $graph->ygrid->SetFill(true,'#EFEFEF@0.5','#BBCCFF@0.5'); // $a=array("1月","2月","3月","4月","5月","6月","7月","8月","9月","10月","11月","12月"); //X轴 $graph->xaxis->SetTickLabels($data_x); //设置X轴 $graph->xaxis->SetFont(FF_SIMSUN); //设置X坐标轴的字体 // $graph->yscale->SetGrace(20); $p1 = new LinePlot($data_y); //创建折线图对象 $p1->mark->SetType(MARK_FILLEDCIRCLE); //设置数据坐标点为圆形标记 $p1->mark->SetFillColor("black"); //设置填充的颜色 $p1->mark->SetWidth(3); //设置圆形标记的直径为3像素 $p1->SetColor("blue"); // $p1->SetYMin(0); $graph->Add($p1); $graph->InitializeFrameAndMargin(); $num = rand(0, RAND); // echo var_dump($num); $name = "Histogrm" . $num . ".png"; session_start(); $_SESSION["name"] = $name; // echo var_dump($name); $graph->Stroke($name); return $name; }
// $i++; // } // // // echo '</pre>'; $lineplot->SetColor('blue'); $lineplot->SetFillColor("blue@0.8"); if ($starttime > strtotime('-13 months', $endtime)) { $lineplot->SetStepStyle(true); } $orangeline = new PlotLine(HORIZONTAL, $aantalbedden * 0.8, 'orange', 1); $redline = new PlotLine(HORIZONTAL, $aantalbedden * 0.9, 'red', 1); $maxline = new PlotLine(HORIZONTAL, $aantalbedden, 'black', 1); // Add the plot to the graph $graph->Add($lineplot); $graph->AddLine($orangeline); $graph->AddLine($redline); $graph->AddLine($maxline); if ($starttime < strtotime('-6 months', $endtime)) { // Trend $prec = floor(count($ydata) / 10); //echo $prec . '<br />'; $avg = array(); for ($i = 0; $i < count($ydata); $i++) { $tmp = 0; for ($j = 1; $j < $prec; $j++) { $tmp += $ydata[$i - $j]; $tmp += $ydata[$i + $j]; } $tmp += $ydata[$i]; //echo $tmp . '<br />';
$graph->SetMarginColor("khaki"); // Set legend box specification $graph->legend->SetFillColor("white"); $graph->legend->SetLineWeight(2); // Set X-axis at the minimum value of Y-axis (default will be at 0) $graph->xaxis->SetPos("min"); // "min" will position the x-axis at the minimum value of the Y-axis // Extend the margin for the labels on the Y-axis and reverse the direction // of the ticks on the Y-axis $graph->yaxis->SetLabelMargin(12); $graph->xaxis->SetLabelMargin(6); $graph->yaxis->SetTickSide(SIDE_LEFT); $graph->xaxis->SetTickSide(SIDE_DOWN); // Add mark graph with static lines $line = new PlotLine(HORIZONTAL, 0, "black", 2); $graph->AddLine($line); // Create a new impuls type scatter plot $sp1 = new ScatterPlot($datay, $datax); $sp1->mark->SetType(MARK_SQUARE); $sp1->mark->SetFillColor("red"); $sp1->mark->SetWidth(3); $sp1->SetImpuls(); $sp1->SetColor("blue"); $sp1->SetWeight(1); $sp1->SetLegend("Non-causal signal"); $graph->Add($sp1); // Create the envelope plot $ep1 = new LinePlot($datayenv, $datax); $ep1->SetStyle("dotted"); $ep1->SetLegend("Positive envelope"); $graph->Add($ep1);
$graph->xaxis->SetFont(FF_FONT1, FS_BOLD); $graph->yaxis->SetTitleMargin(30); $graph->xaxis->SetPos("min"); //$graph->xaxis->SetTitle("Day of Month"); //$graph->xaxis->SetTickLabels($xlabels); $graph->xaxis->SetLabelFormatString("M d", true); $graph->xaxis->SetLabelAngle(90); $graph->yaxis->SetTitle("Precipitation (in)"); $graph->title->Set($cities[$station]["name"] . " [{$station}] Precipitation for " . $year); $graph->subtitle->Set("Climate Site: " . $cities[$climate_site]["name"] . "[" . $climate_site . "]"); $graph->legend->SetLayout(LEGEND_HOR); $graph->legend->Pos(0.05, 0.1, "right", "top"); reset($times); while (list($k, $v) = each($times)) { if (date("d", $v) == 1) { $graph->AddLine(new PlotLine(VERTICAL, $v, "tan", 1)); } } // Create the linear plot $lp0 = new LinePlot($cdiff, $times); $lp0->SetColor("green"); $lp0->SetLegend("Accum Difference"); $b2plot = new BarPlot($obs, $atimes); $b2plot->SetFillColor("blue"); $b2plot->SetLegend("Obs Rain"); // Create the linear plot $lp1 = new LinePlot($aobs, $atimes); $lp1->SetLegend("Actual Accum"); $lp1->SetColor("blue"); $lp1->SetWeight(3); $lp2 = new LinePlot($aclimate, $times);
// Create the linear plot $lineplot3 = new LinePlot($s2_hi); $lineplot3->SetLegend($cities[$station2]["name"] . " Avg High"); $lineplot3->SetColor("blue"); // Create the linear plot $lineplot4 = new LinePlot($s2_lo); $lineplot4->SetLegend("Low"); $lineplot4->SetColor("blue"); // Create the linear plot $lineplot5 = new LinePlot($s2_av); $lineplot5->SetLegend("Avg"); $lineplot5->SetColor("blue"); // Create the linear plot $lineplot6 = new LinePlot($s1_av); $lineplot6->SetLegend("Avg"); $lineplot6->SetColor("red"); // Add the plot to the graph $graph->Add($lineplot); $graph->Add($lineplot6); $graph->Add($lineplot2); $graph->Add($lineplot3); $graph->Add($lineplot5); $graph->Add($lineplot4); for ($i = 0; $i < 11; $i++) { $graph->AddLine(new PlotLine(VERTICAL, 7 + $i * 10, "tan", 1)); } // Display the graph $graph->Stroke(); ?>
// Create the linear plot $lineplot = new LinePlot($ydata); $graph->Add($lineplot); $lineplot->SetLegend("Max " . $var . " (F)"); $lineplot->SetColor("red"); // Create the linear plot $lineplot2 = new LinePlot($ydata2); $graph->Add($lineplot2); $lineplot2->SetLegend("Min " . $var . " (F)"); $lineplot2->SetColor("blue"); // Create the linear plot $lineplot3 = new LinePlot($ydata3); $graph->Add($lineplot3); $lineplot3->SetLegend("Average (F)"); $lineplot3->SetColor("brown"); $graph->AddLine(new PlotLine(VERTICAL, 31, "tan", 1)); $graph->AddLine(new PlotLine(VERTICAL, 60, "tan", 1)); $graph->AddLine(new PlotLine(VERTICAL, 91, "black", 1)); $graph->AddLine(new PlotLine(VERTICAL, 121, "tan", 1)); $graph->AddLine(new PlotLine(VERTICAL, 152, "tan", 1)); $graph->AddLine(new PlotLine(VERTICAL, 182, "black", 1)); $graph->AddLine(new PlotLine(VERTICAL, 213, "tan", 1)); $graph->AddLine(new PlotLine(VERTICAL, 244, "tan", 1)); $graph->AddLine(new PlotLine(VERTICAL, 274, "black", 1)); $graph->AddLine(new PlotLine(VERTICAL, 305, "tan", 1)); $graph->AddLine(new PlotLine(VERTICAL, 335, "tan", 1)); $graph->AddLine(new PlotLine(HORIZONTAL, 32, "blue", 2)); // Add the plot to the graph // Display the graph $graph->Stroke(); ?>
$graph->yaxis->title->SetFont(FF_FONT1, FS_BOLD, 12); $graph->xaxis->SetTitle("Year"); $graph->xaxis->SetTitleMargin(35); $graph->xaxis->title->SetFont(FF_FONT1, FS_BOLD, 12); $graph->xaxis->SetPos("min"); $graph->legend->Pos(0.01, 0.07000000000000001); $graph->legend->SetLayout(LEGEND_HOR); // Create the linear plot $lineplot = new LinePlot($ydata); $lineplot->SetLegend("Avg High (F)"); $lineplot->SetColor("red"); // Create the linear plot $lineplot2 = new LinePlot($ydata2); $lineplot2->SetLegend("Avg Temp (F)"); $lineplot2->SetColor("green"); // Create the linear plot $lineplot3 = new LinePlot($ydata3); $lineplot3->SetLegend("Avg Low (F)"); $lineplot3->SetColor("blue"); // Add the plot to the graph $graph->Add($lineplot); $graph->Add($lineplot2); $graph->Add($lineplot3); for ($i = 0; $i < $decades; $i++) { $graph->AddLine(new PlotLine(VERTICAL, $offset + $i * 10, "tan", 1)); } // Display the graph $graph->Stroke(); ?>