public function actionBar($id = -1) { include 'jpgraph/jpgraph.php'; include 'jpgraph/jpgraph_bar.php'; $data = $this->analyse($id); $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("textint"); $graph->setMargin(100, 100, 100, 100); $graph->xaxis->SetTickLabels($xdata); $barplot = new BarPlot($ydata); // $barplot->setFillColor(array('red','blue','green')); $barplot->setcolor("orange"); $graph->Add($barplot); $barplot->value->Show(); $graph->Stroke(); }