그래프 만들기-gd 안쓰고

· 15년 전 · 2915

<?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,976
15년 전 조회 1,929
15년 전 조회 3,218
15년 전 조회 3,098
15년 전 조회 6,103
15년 전 조회 2,054
15년 전 조회 4,820
15년 전 조회 1,935
15년 전 조회 2,214
15년 전 조회 2,199
15년 전 조회 2,199
15년 전 조회 1,674
15년 전 조회 1,928
15년 전 조회 2,055
15년 전 조회 2,006
15년 전 조회 2,702
15년 전 조회 1,846
15년 전 조회 1,954
15년 전 조회 1,450
15년 전 조회 1,552
15년 전 조회 1,545
15년 전 조회 1,484
15년 전 조회 1,444
15년 전 조회 1,482
15년 전 조회 1,634
15년 전 조회 1,664
15년 전 조회 3,172
15년 전 조회 1,493
15년 전 조회 2,147
15년 전 조회 2,003
15년 전 조회 2,165
15년 전 조회 1,869
15년 전 조회 2,373
15년 전 조회 1,175
15년 전 조회 1,647
15년 전 조회 1,623
15년 전 조회 3,422
15년 전 조회 3,758
15년 전 조회 2,456
15년 전 조회 1,900
15년 전 조회 2,541
15년 전 조회 2,022
15년 전 조회 1,640
15년 전 조회 4,329
15년 전 조회 1,981
15년 전 조회 2,072
15년 전 조회 3,321
15년 전 조회 2,032
15년 전 조회 4,724
15년 전 조회 2,916
15년 전 조회 3,716
15년 전 조회 2,329
15년 전 조회 2,569
15년 전 조회 1,858
15년 전 조회 4,922
16년 전 조회 4,536
16년 전 조회 4,330
16년 전 조회 5,749
16년 전 조회 3,978
16년 전 조회 2,331
16년 전 조회 2,314
16년 전 조회 2,445
16년 전 조회 2,138
16년 전 조회 4,574
16년 전 조회 3,482
16년 전 조회 2,636
16년 전 조회 2,242
16년 전 조회 2,424
16년 전 조회 2,932
16년 전 조회 2,030
16년 전 조회 2,954
16년 전 조회 2,272
16년 전 조회 2,403
16년 전 조회 2,021
16년 전 조회 2,732
16년 전 조회 2,061
16년 전 조회 2,479
16년 전 조회 2,660
16년 전 조회 1,731
16년 전 조회 1,794
16년 전 조회 2,460
16년 전 조회 5,873
16년 전 조회 2,187
16년 전 조회 2,719
16년 전 조회 2,897
16년 전 조회 2,049
16년 전 조회 1,835
16년 전 조회 2,760
16년 전 조회 5,474
16년 전 조회 2,751
16년 전 조회 3,411
16년 전 조회 2,267
16년 전 조회 4,167
16년 전 조회 4,960
16년 전 조회 3,604
16년 전 조회 2,854
16년 전 조회 2,970
16년 전 조회 3,180
16년 전 조회 2,704
16년 전 조회 6,055