[php]
view plaincopyprint?
- <?php
- include ("src/jpgraph.php");
- include ("src/jpgraph_line.php");
-
- $data1 = array(19,23,34,38,45,67,71,78,85,87,90,96); //第一條曲線的數組
- $data2 = array(523,634,371,278,685,587,490,256,398,545,367,577); //第二條曲線的數組
-
- $graph = new Graph(400,300); //建立新的Graph對象
- $graph->SetScale("textlin");
- $graph->SetY2Scale("lin");
- $graph->SetShadow(); //設定映像的陰影樣式
-
- $graph->img->SetMargin(40,50,20,70); //設定映像邊距
- $graph->title->Set("年度收支表"); //設定映像標題
-
- $lineplot1=new LinePlot($data1); //建立設定兩條曲線對象
- $lineplot2=new LinePlot($data2);
-
- $graph->Add($lineplot1); //將曲線放置到映像上
- $graph->AddY2($lineplot2);
-
- $graph->xaxis->title->Set("月份"); //設定座標軸名稱
- $graph->yaxis->title->Set("兆美元");
- $graph->y2axis->title->Set("兆美元");
-
- $graph->title->SetFont(FF_SIMSUN,FS_BOLD); //設定字型
- $graph->yaxis->title->SetFont(FF_SIMSUN,FS_BOLD);
- $graph->y2axis->title->SetFont(FF_SIMSUN,FS_BOLD);
- $graph->xaxis->title->SetFont(FF_SIMSUN,FS_BOLD);
-
- $lineplot1->SetColor("red"); //設定顏色
- $lineplot2->SetColor("blue");
-
- $lineplot1->SetLegend("Cost Amount"); //設定圖例名稱
- $lineplot2->SetLegend("Revenue Amount");
-
- $graph->legend->SetLayout(LEGEND_HOR); //設定圖例樣式和位置
- $graph->legend->Pos(0.4,0.95,"center","bottom");
-
- $graph->Stroke(); //輸出映像
- ?>
<?php<br />include ("src/jpgraph.php");<br />include ("src/jpgraph_line.php");</p><p>$data1 = array(19,23,34,38,45,67,71,78,85,87,90,96);//第一條曲線的數組<br />$data2 = array(523,634,371,278,685,587,490,256,398,545,367,577);//第二條曲線的數組</p><p>$graph = new Graph(400,300);//建立新的Graph對象<br />$graph->SetScale("textlin");<br />$graph->SetY2Scale("lin");<br />$graph->SetShadow();//設定映像的陰影樣式</p><p>$graph->img->SetMargin(40,50,20,70);//設定映像邊距<br />$graph->title->Set("年度收支表");//設定映像標題</p><p>$lineplot1=new LinePlot($data1);//建立設定兩條曲線對象<br />$lineplot2=new LinePlot($data2);</p><p>$graph->Add($lineplot1);//將曲線放置到映像上<br />$graph->AddY2($lineplot2);</p><p>$graph->xaxis->title->Set("月份");//設定座標軸名稱<br />$graph->yaxis->title->Set("兆美元");<br />$graph->y2axis->title->Set("兆美元");</p><p>$graph->title->SetFont(FF_SIMSUN,FS_BOLD);//設定字型<br />$graph->yaxis->title->SetFont(FF_SIMSUN,FS_BOLD);<br />$graph->y2axis->title->SetFont(FF_SIMSUN,FS_BOLD);<br />$graph->xaxis->title->SetFont(FF_SIMSUN,FS_BOLD);</p><p>$lineplot1->SetColor("red");//設定顏色<br />$lineplot2->SetColor("blue");</p><p>$lineplot1->SetLegend("Cost Amount");//設定圖例名稱<br />$lineplot2->SetLegend("Revenue Amount");</p><p>$graph->legend->SetLayout(LEGEND_HOR);//設定圖例樣式和位置<br />$graph->legend->Pos(0.4,0.95,"center","bottom");</p><p>$graph->Stroke();//輸出映像<br />?><br />