확

그래프 만들기-gd 안쓰고

· 2010-04-28 (수) 18:06:20 · 3914

<?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에서 이동 됨]
댓글을 작성하시려면 로그인이 필요합니다.

프로그램

8,187건
+
제목 글쓴이 날짜 조회
10-12-01 조회 2,150
10-12-01 조회 2,097
10-12-01 조회 2,280
10-12-01 조회 1,999
10-12-01 조회 2,129
10-12-01 조회 2,134
10-11-30 조회 2,552
10-11-30 조회 2,016
10-11-30 조회 2,215
10-11-30 조회 2,220
10-11-30 조회 2,731
10-11-30 조회 2,141
10-11-30 조회 2,356
10-11-29 조회 2,956
10-11-29 조회 2,195
10-11-29 조회 2,091
10-11-29 조회 1,891
10-11-29 조회 2,023
10-11-29 조회 1,981
10-11-29 조회 3,403
10-11-29 조회 2,227
10-11-28 조회 2,371
10-11-28 조회 2,164
10-11-28 조회 2,858
10-11-28 조회 2,695
10-11-28 조회 2,330
10-11-27 조회 2,103
10-11-27 조회 2,516
10-11-27 조회 1,967
10-11-27 조회 2,094
10-11-27 조회 2,129
10-11-27 조회 2,071
10-11-27 조회 2,054
10-11-27 조회 2,350
10-11-26 조회 2,147
10-11-26 조회 2,152
10-11-26 조회 2,181
10-11-26 조회 2,265
10-11-26 조회 3,961
10-11-26 조회 2,217
10-11-26 조회 2,084
10-11-26 조회 2,106
10-11-26 조회 2,065
10-11-25 조회 2,286
10-11-25 조회 2,056
10-11-25 조회 2,389
10-11-25 조회 2,113
10-11-25 조회 2,169
10-11-25 조회 2,590
10-11-25 조회 2,043
10-11-25 조회 2,112
10-11-25 조회 2,037
10-11-25 조회 2,265
10-11-25 조회 1,973
10-11-25 조회 2,618
10-11-25 조회 2,215
10-11-24 조회 2,126
10-11-24 조회 2,464
10-11-24 조회 2,109
10-11-24 조회 2,129
10-11-24 조회 2,081
10-11-24 조회 2,192
10-11-24 조회 2,080
10-11-23 조회 2,247
10-11-23 조회 2,161
10-11-23 조회 2,503
10-11-23 조회 2,055
10-11-23 조회 2,166
10-11-23 조회 2,221
10-11-23 조회 2,487
10-11-23 조회 2,993
10-11-23 조회 2,179
10-11-23 조회 2,293
10-11-23 조회 2,300
10-11-23 조회 2,403
10-11-23 조회 2,240
10-11-22 조회 2,468
10-11-22 조회 2,204
10-11-22 조회 2,367
10-11-22 조회 2,196
10-11-22 조회 5,327
10-11-22 조회 8,223
10-11-22 조회 2,319
10-11-22 조회 2,082
10-11-21 조회 2,615
10-11-21 조회 2,317
10-11-20 조회 2,409
10-11-20 조회 2,175
10-11-20 조회 2,086
10-11-19 조회 2,551
10-11-19 조회 2,169
10-11-19 조회 2,897
10-11-18 조회 2,614
10-11-18 조회 2,249
10-11-18 조회 2,221
10-11-18 조회 2,068
10-11-18 조회 2,478
10-11-17 조회 2,198
10-11-17 조회 4,331
10-11-17 조회 2,569