그래프 만들기-gd 안쓰고

· 15년 전 · 2489

<?php
/* ================================================================
 * filename  :  gra.php
 * Creator  :  이창열, 2009. 02. 22

 * Comment :  그래프 그리기
 ==================================================================*/
 
# 그래프 출력을 위한 데이터의 최대값및 최소값 세팅
$maxVal = 50;  // 최대값 5백만
$step = 5;   // 단위 5십만


$arrVal = array(25,18, 34, 46, 10, 29, 17, 38, 26, 25, 27, 39, 44, 22, 16, 43, 39, 22, 44, 18, 14, 22, 32, 45);

function showStickGraph($maxVal, $minVal, $step, $arrVal)
{
 $bottomCommentHeight= 30;    // 하단 설명공간 높이 픽셀값
 $cntY = round($maxVal / $step);  // y축 눈금개수
 $unitHight = 30;        // 단위 높이 픽셀값
 $minVal = 0;         // 최소값
 $k= 10;
 
?>
 <table cellpadding=0 cellspacing=0 border="1" >
  <tr>
   
   <!-- y축-->
   <td >
     <table cellpadding=0 cellspacing=0 border="1" >
      
      <? for ($a= $maxVal; $a >= $minVal; $a -= $step){ ?>
      <tr>
       <td height="<?=$unitHight?>" valign="bottom" align="right">
        <font size="2"><?=$a?></font>
       </td>
      </tr>
      <?}?>
      
      <tr>
       <td height="<?=$bottomCommentHeight?>">
        <font size="2">매출<br>(단위:10만)</font></td>
      </tr>
      
     </table>
 
    </td>
   
   <!--x축-->
   <td valign="bottom"> 
    <table cellpadding=0 cellspacing=0 border="0" >
     <tr>
      <? for ($i= 0; $i < 24; $i++){ ?>
      <td align="center" valign="bottom">
          <table cellpadding=0 cellspacing=0 border="1" >
           <tr>
         <td width="20" height="<?=($arrVal[$i])/$step * $unitHight ?>" bgcolor="green" valign="top" align="center">
          <font size="2" color="white"><b><?=$arrVal[$i]?></b></font></td>
        </tr>
        
        <tr>
         <td height="<?=$bottomCommentHeight?>" valigh="top"><font size="2"><?=($i<10)?"0$i":$i?></font></td>
        </tr>
       </table>
        </td>
        <?}?>
      </tr>
     
     </table>

    </td>
  
  </tr>
 </table>
<?
}
showStickGraph($maxVal, $minVal, $step, $arrVal);
?>

[이 게시물은 관리자님에 의해 2011-10-31 16:55:28 jQuery에서 이동 됨]
|
댓글을 작성하시려면 로그인이 필요합니다.

프로그램

+
제목 글쓴이 날짜 조회
15년 전 조회 1,525
15년 전 조회 1,492
15년 전 조회 2,772
15년 전 조회 2,691
15년 전 조회 5,664
15년 전 조회 1,588
15년 전 조회 4,395
15년 전 조회 1,487
15년 전 조회 1,776
15년 전 조회 1,750
15년 전 조회 1,752
15년 전 조회 1,248
15년 전 조회 1,494
15년 전 조회 1,641
15년 전 조회 1,542
15년 전 조회 2,260
15년 전 조회 1,410
15년 전 조회 1,503
15년 전 조회 1,020
15년 전 조회 1,114
15년 전 조회 1,102
15년 전 조회 1,054
15년 전 조회 988
15년 전 조회 1,064
15년 전 조회 1,201
15년 전 조회 1,219
15년 전 조회 2,748
15년 전 조회 1,054
15년 전 조회 1,717
15년 전 조회 1,585
15년 전 조회 1,719
15년 전 조회 1,418
15년 전 조회 1,911
15년 전 조회 731
15년 전 조회 1,209
15년 전 조회 1,189
15년 전 조회 2,974
15년 전 조회 3,320
15년 전 조회 1,986
15년 전 조회 1,468
15년 전 조회 2,085
15년 전 조회 1,590
15년 전 조회 1,204
15년 전 조회 3,891
15년 전 조회 1,527
15년 전 조회 1,623
15년 전 조회 2,880
15년 전 조회 1,575
15년 전 조회 4,287
15년 전 조회 2,490
15년 전 조회 3,260
15년 전 조회 1,894
15년 전 조회 2,128
15년 전 조회 1,412
15년 전 조회 4,490
15년 전 조회 4,107
15년 전 조회 3,916
15년 전 조회 5,314
15년 전 조회 3,547
15년 전 조회 1,919
15년 전 조회 1,863
15년 전 조회 2,005
15년 전 조회 1,714
15년 전 조회 4,119
15년 전 조회 3,031
15년 전 조회 2,198
16년 전 조회 1,793
16년 전 조회 2,003
16년 전 조회 2,496
16년 전 조회 1,577
16년 전 조회 2,515
16년 전 조회 1,841
16년 전 조회 1,948
16년 전 조회 1,601
16년 전 조회 2,296
16년 전 조회 1,619
16년 전 조회 2,039
16년 전 조회 2,228
16년 전 조회 1,304
16년 전 조회 1,368
16년 전 조회 2,018
16년 전 조회 5,449
16년 전 조회 1,742
16년 전 조회 2,264
16년 전 조회 2,457
16년 전 조회 1,615
16년 전 조회 1,404
16년 전 조회 2,332
16년 전 조회 5,047
16년 전 조회 2,311
16년 전 조회 2,978
16년 전 조회 1,850
16년 전 조회 3,707
16년 전 조회 4,552
16년 전 조회 3,194
16년 전 조회 2,460
16년 전 조회 2,549
16년 전 조회 2,779
16년 전 조회 2,283
16년 전 조회 5,646