public function mybar_new_chart($yearsales, $chainsales, $totalsales, $provinces, $title) { require_once 'Examples/jpgraph/jpgraph.php'; require_once 'Examples/jpgraph/jpgraph_bar.php'; //$data2y = array(41, 2, 3, 4, 5, 6, 17, 8, 19, 10, 11, 12, 13, 14, 25, 16, 17, 48, 1, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33); //$data1y = $ydata; // Create the graph. These two calls are always required $graph = new Graph(1024, 468); $graph->SetScale("textlin"); $graph->SetMargin(30, 1, 20, 90); // Box around plotarea $graph->SetBox(); // No frame around the image $graph->SetFrame(false); $graph->title->Set($title); $graph->title->SetFont(FF_SIMSUN, FS_BOLD); $graph->yaxis->title->SetFont(FF_SIMSUN, FS_BOLD); $graph->xaxis->title->SetFont(FF_SIMSUN, FS_BOLD); // Setup month as labels on the X-axis $graph->xaxis->SetTickLabels($provinces); $graph->xaxis->SetFont(FF_SIMSUN, FS_NORMAL, 8); $graph->xaxis->SetLabelAngle(35); $graph->legend->SetFont(FF_SIMSUN, FS_NORMAL); // Create the bar plots $b1plot = new BarPlot($yearsales); $b1plot->SetFillColor("orange"); $b1plot->SetLegend("去年同期"); $b1plot->value->Show(); $b1plot->value->SetFont(FF_ARIAL, FS_NORMAL, 8); $b1plot->value->SetFormat('%d'); /* $b2plot = new BarPlot($chainsales); $b2plot->SetFillColor("blue"); $b2plot->SetLegend("环比"); $b2plot->value->Show(); $b2plot->value->SetFont(FF_ARIAL,FS_NORMAL,8); $b2plot->value->SetFormat('%d');*/ $b3plot = new BarPlot($totalsales); $b3plot->SetFillColor("yellow"); $b3plot->SetLegend("销量"); $b3plot->SetYBase(100); $b3plot->value->Show(); $b3plot->value->SetFont(FF_ARIAL, FS_NORMAL, 8); $b3plot->value->SetFormat('%d'); $graph->legend->SetPos(0.05, 0.5, 'right', 'center'); // Create the grouped bar plot $gbplot = new GroupBarPlot(array($b2plot,$b1plot,$b3plot)); $gbplot = new GroupBarPlot(array($b3plot)); // ...and add it to the graPH $graph->Add($gbplot); // Display the graph $graph->Stroke(); }