php Jpgraph繪製複雜的X-Y座標圖

來源:互聯網
上載者:User
[php]
view plaincopyprint?
  1. <?php  
  2. include ("src/jpgraph.php");  
  3. include ("src/jpgraph_line.php");  
  4.   
  5. $data1 = array(19,23,34,38,45,67,71,78,85,87,90,96);                    //第一條曲線的數組
      
  6. $data2 = array(523,634,371,278,685,587,490,256,398,545,367,577);        //第二條曲線的數組
      
  7.   
  8. $graph = new Graph(400,300);                                        //建立新的Graph對象
      
  9. $graph->SetScale("textlin");  
  10. $graph->SetY2Scale("lin");  
  11. $graph->SetShadow();                                         //設定映像的陰影樣式
      
  12.   
  13. $graph->img->SetMargin(40,50,20,70);                              //設定映像邊距
      
  14. $graph->title->Set("年度收支表");                      //設定映像標題
      
  15.   
  16. $lineplot1=new LinePlot($data1);                                    //建立設定兩條曲線對象
      
  17. $lineplot2=new LinePlot($data2);  
  18.   
  19. $graph->Add($lineplot1);                                         //將曲線放置到映像上
      
  20. $graph->AddY2($lineplot2);  
  21.   
  22. $graph->xaxis->title->Set("月份");                                   //設定座標軸名稱
      
  23. $graph->yaxis->title->Set("兆美元");  
  24. $graph->y2axis->title->Set("兆美元");  
  25.   
  26. $graph->title->SetFont(FF_SIMSUN,FS_BOLD);                            //設定字型
      
  27. $graph->yaxis->title->SetFont(FF_SIMSUN,FS_BOLD);  
  28. $graph->y2axis->title->SetFont(FF_SIMSUN,FS_BOLD);  
  29. $graph->xaxis->title->SetFont(FF_SIMSUN,FS_BOLD);  
  30.   
  31. $lineplot1->SetColor("red");                                     //設定顏色
      
  32. $lineplot2->SetColor("blue");  
  33.   
  34. $lineplot1->SetLegend("Cost Amount");                                //設定圖例名稱
      
  35. $lineplot2->SetLegend("Revenue Amount");  
  36.   
  37. $graph->legend->SetLayout(LEGEND_HOR);                            //設定圖例樣式和位置
      
  38. $graph->legend->Pos(0.4,0.95,"center","bottom");  
  39.   
  40. $graph->Stroke();                                                //輸出映像
      
  41. ?>  

<?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 />

 

 

 

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.