<?php /* * バープロットとラインプロットを同時に表示する複合プロットの例 */ // JpGraphのインクルード include_once ("../src/jpgraph.php"); include_once ("../src/jpgraph_bar.php"); include_once ("../src/jpgraph_line.php"); include_once ("../src/jpgraph_scatter.php"); include_once ("../src/jpgraph_regstat.php"); include_once ("../src/jpgraph_log.php"); // 月 $month=array("1月","2月","3月","4月","5月","6月","7月","8月","9月","10月","11月","12月"); // a軸 $a_data1 = array(27, 0,40,20,60,53,19,69,87, 0,20,19); $a_data2 = array(12,25,13,23,30,48,76,57,43,61,12,0); $a_data3 = array(55,23,10,55,30,51,39,69,21,49,27,0); // b軸 $b_data1 = array(55,25,35,59,54,77,76,105,90,61,12,2); // 線j $j_datay = array(2000,5000,4000,8000,7000,6000,14800,12000,11000,5000,1000,500); // グラフサイズ $DISP_SIZE_X = 330; $DISP_SIZE_Y = 200; // 背景色 $BACK_COLOR = "#FEFEEE"; $TITLE = " プログラム言語のマーケットシェア(仮) "; $graph = new Graph($DISP_SIZE_X,$DISP_SIZE_Y,"auto"); // キャンバスに影 $graph->SetShadow(); $graph->SetScale("textlin"); $graph->SetY2Scale("lin"); $graph->img->SetMargin(35,45,5,35); $graph->title->Set($TITLE); $graph->title->SetFont(FF_PGOTHIC); $graph->title->SetColor('darkred'); $graph->xaxis->SetFont(FF_PGOTHIC,FS_NORMAL,7); $graph->yaxis->SetFont(FF_PGOTHIC,FS_NORMAL,8); // X軸の月を傾ける $graph->xaxis->SetTickLabels($month); $graph->xaxis->SetFont(FF_PGOTHIC,FS_NORMAL,7); $graph->xaxis->SetLabelAngle(40); // 背景 $graph->yaxis->HideZeroLabel(); $graph->ygrid->SetFill(true,'#EFEFEF@0.5','#BBCCFF@0.5'); // 棒インスタンス $a_1plot = new BarPlot($a_data1); $a_2plot = new BarPlot($a_data2); $a_3plot = new BarPlot($a_data3); // 線のインスタンス $li1 = new LinePlot($j_datay); $li1->SetFillColor("red@0.8"); $li1->mark->SetType(MARK_FILLEDCIRCLE); $li1->mark->SetFillColor("red"); $li1->mark->SetWidth(2); // 棒の種類設定 $a_1plot->SetFillGradient("navy","lightsteelblue",GRAD_WIDE_MIDVER); $a_2plot->SetFillGradient("blue","lightsteelblue",GRAD_MIDHOR); $a_3plot->SetFillGradient("royalblue","lightsteelblue",GRAD_CENTER); $b_1plot = new BarPlot($b_data1); $b_1plot->SetFillColor("skyblue"); // 棒積み上げ $a_plot = new AccBarPlot(array($a_1plot,$a_2plot,$a_3plot)); // 棒をグループ化 $gplot = new GroupBarPlot(array($a_plot,$b_1plot)); // 棒幅 $gplot->SetWidth(0.7); // 線グラフを手前に表示させる $graph->SetY2orderback(false); // グラフに追加 $graph->Add($gplot); $graph->AddY2($li1); // 描画 $graph->Stroke(); ?>