Example #1
0
 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;
 }
 public static function linerMoreShow($data, $x_num, $legend, $data_x, $max_y, $graph_title = "", $x_title = "", $y_title = "")
 {
     $graph = new Graph(LENHSIZE, HEISIZE, "auto");
     //创建画布
     $graph->img->SetMargin(LEFT, 60, UP, DOWN);
     //设置统计图所在画布的位置,左边距50、右边距40、上边距30、下边距40,单位为像素
     $graph->img->SetAntiAliasing();
     //设置折线的平滑状态
     $graph->SetScale("textlin", 0, 1);
     //设置刻度样式
     $graph->SetShadow();
     //创建画布阴影
     $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->xaxis->SetTickLabels($data_x);
     //设置X轴
     $graph->xaxis->SetFont(FF_SIMSUN);
     //设置X坐标轴的字体
     $graph->yscale->SetGrace(20);
     foreach ($data as $key => $value) {
         $p1 = new LinePlot($value);
         //创建折线图对象
         $graph->Add($p1);
         //在统计图上绘制折线
         $p1->mark->SetType(MARK_FILLEDCIRCLE);
         $p1->mark->SetFillColor(Statistics::$color[$key]);
         //设置填充的颜色
         $p1->mark->SetWidth(3);
         //设置圆形标记的直径为4像素
         $p1->SetLegend($legend[$key]);
         $p1->SetColor(Statistics::$color[$key]);
         //设置折形颜色为蓝色
         $p1->SetCenter();
     }
     $graph->xaxis->setFont(FF_SIMSUN, FS_BOLD, X_FONT);
     //设置字体
     $graph->xgrid->Show();
     if ($x_num > 10) {
         $graph->xaxis->SetLabelAngle(45);
     }
     $graph->InitializeFrameAndMargin();
     $graph->legend->SetFrameWeight(1);
     $graph->legend->SetColor('#4E4E4E', '#00A78A');
     $graph->legend->SetMarkAbsSize(8);
     $graph->legend->setFont(FF_SIMSUN, FS_BOLD, GRAGHSIZE - 6);
     $num = rand(0, RAND);
     $name = "Histogrm" . $num . ".png";
     session_start();
     $_SESSION["name"] = $name;
     $graph->Stroke($name);
     return $name;
 }