$sql = "Select * from closingprices where cid=" . $_GET['cid'] . " and inserttimestamp>date(now()- interval '" . $_GET['months'] . " months')"; $pgdata = pg_query($shareconn, $sql); #echo $sql; // Some data for ($i = 0; $i < pg_numrows($pgdata); $i++) { $xdata[] = pg_fetch_result($pgdata, $i, "inserttimestamp"); $ydata[] = pg_fetch_result($pgdata, $i, "ruling_price"); } #print count($ydata); #$ydata = array(11,3, 8,12,5 ,1,9, 13,5,7 ); // Create the graph. These two calls are always required $graph = new Graph(600, 250, "auto"); $graph->SetScale("textlin"); $graph->SetMargin(30, 140, 40, 70); $graph->title->Set('Share price for ' . pg_fetch_result($pgdata, 0, 'alpha_code')); $graph->xaxis->SetTickLabels($xdata); $graph->xaxis->SetTextLabelInterval(30); $graph->xaxis->SetLabelAngle(90); $bplot = new linePlot($ydata); #$bplot ->SetFillColor ("blue"); $bplot->SetLegend("Logins"); $graph->legend->Pos(0.05, 0.5, "right", "center"); #$gbplot = new GroupBarPlot (array($bplot ,$bplot2,$bplot3,$bplot4,$bplot5,$bplot6,$bplot7)); $graph->Add($bplot); // Display the graph $graph->Stroke(); dbclose(); agdbclose(); ?>
public function actionLine($id = -1) { $data = $this->analyse($id); include 'jpgraph/jpgraph.php'; include 'jpgraph/jpgraph_line.php'; $ydata = array(); $xdata = array(); foreach ($data as $key => $value) { array_push($xdata, $key); array_push($ydata, $value); } if (count($data) == 0) { echo '近一个习惯起没有相应的反馈级记录'; die; } $graph = new Graph(500, 500, 'auto'); $graph->SetScale('textlin'); $linePlot = new linePlot($ydata); $linePlot->SetColor("blue:0.5"); $linePlot->value->Show(); $linePlot->SetWeight(1); $graph->Add($linePlot); $graph->xaxis->SetTickLabels($xdata); // $graph -> xaxis -> SetTextLabelInterval(2); $graph->yaxis->SetColor("black"); $graph->yaxis->SetWeight(2); $graph->SetShadow(); $graph->Stroke(); }
public function actionLine($id) { $cate_name = Category::model()->findByPk($id)->cname; $data = $this->analyse($id); include 'jpgraph/jpgraph.php'; include 'jpgraph/jpgraph_line.php'; $ydata = array(); $xdata = array(); foreach ($data as $key => $value) { array_push($xdata, $key); array_push($ydata, $value); } if (count($data) == 0) { echo '近一个习惯起没有相应的反馈级记录'; die; } $graph = new Graph(500, 500, 'auto'); $graph->SetScale('textlin'); $graph->title->Set('近一个星期关于' . $cate_name . '的反馈情况'); $linePlot = new linePlot($ydata); $linePlot->SetColor("blue:0.5"); $linePlot->SetWeight(2); $graph->Add($linePlot); $graph->xaxis->SetTickLabels($xdata); $graph->xaxis->SetTextLabelInterval(2); $graph->yaxis->SetColor("black"); $graph->yaxis->SetWeight(2); $graph->SetShadow(); $graph->Stroke(); }